using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Threading;
namespace 五子棋
{
public partial class Form1 : Form
{
int index = 0;
private int[,] virtualGobangBoard = new int[15, 15];//虚拟棋盘
private PictureBox[,] gobangPictureBox = new PictureBox[15, 15];//棋子
private Point lastMovePoint = new Point(-1, -1);
private bool blnBegin;
private const int black = -1, white = 1, background = 0;
private int personGobangColor, computerGobangColor;
private int totalGobangCount = 0;
private Stack backStack = new Stack();//用于悔棋的栈
private Stack backTrackStack = new Stack();//用于回溯的栈
const int M = 1;//预测的步数
public Form1()
{
InitializeComponent();
gobangBoardGroupBox.Paint += new PaintEventHandler(gobangBoardGroupBox_Paint);
InitializeGobangBoard();
gobangBoardGroupBox.MouseMove += new MouseEventHandler(gobangBoardGroupBox_MouseMove);
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
gobangBoardGroupBox.MouseClick += new MouseEventHandler(gobangBoardGroupBox_MouseClick);
this.Text = "五子棋";
}
private void InitializeGobangBoard()//初始化棋盘
{
gobangBoardGroupBox.Paint += new PaintEventHandler(gobangBoardGroupBox_Paint);
int x, y;
for (x = 0; x < 15; x++)
for (y = 0; y < 15; y++)
{
gobangPictureBox[x, y] = new PictureBox();
gobangPictureBox[x, y].Location = new Point(10 + x * 40, 10 + y * 40);
gobangPictureBox[x, y].Size = new Size(40, 40);
gobangPictureBox[x, y].BackColor = Color.Transparent;
gobangPictureBox[x, y].SizeMode = PictureBoxSizeMode.CenterImage;
gobangPictureBox[x, y].Visible = false;
gobangBoardGroupBox.Controls.Add(gobangPictureBox[x, y]);
}
}
private void gobangBoardGroupBox_Paint(object sender, PaintEventArgs e)