黑白棋自动博弈程序

想做的东西太多,实在没时间,烂尾了,本来想用蒙特卡洛树搜索的,结果连judge也没完成。在这挂一下,以后一定完成。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Threading;

namespace 黑白棋
{
    public partial class Form1 : Form
    {
        const int nRows = 20;
        const int nCols = 20;
        int heightSize;
        int widthSize;
        Point mouseLocation;
        int nSteps = 1;
        double QCount = 0;
        List listQResult = new List();

        public Form1()
        {
            InitializeComponent();
            heightSize = (this.Height - 50) / nRows;
            widthSize = this.Width / nCols;
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            SolidBrush sb;

            for (int i = 0; i < nRows; i++)
            {
                for (int j = 0; j < nCols; j++)
                {
                    int x = j * widthSize;
                    int y = i * heightSize;

                    Rectangle rect = new Rectangle(x, y, widthSize, heightSize);
                    if ((i + j) % 2 != 0)
                    {
                        sb = new SolidBrush(Color.SkyBlue);

                    }
                    else
                    {
                        sb = new SolidBrush(Color.Pink);
                    }
                    g.FillRectangle(sb, rect);
                }
            }
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            this.mouseLocation = e.Location;
        }

        private void Form1_Click(object sender, EventArgs e)
        {
            int[,] arrayQResult = new int[nRows, nCols];
            Graphics g = this.CreateGraphics();
            int x = this.mouseLocation.X / widthSize;
            int y = this.mouseLocation.Y / heightSize;
            SolidBrush sb;
            if (nSteps % 2 == 1)
            {
                arrayQResult[x, y] = 1;    //黑先  1
                sb = new SolidBrush(Color.Black);
            }
            else
            {
                arrayQResult[x, y] = -1;    //白后  -1
                sb = new SolidBrush(Color.White);
            }
            Rectangle rect = new Rectangle(x * widthSize, y * heightSize, widthSize, heightSize);
            g.FillEllipse(sb, rect);
            nSteps++;
        }


        private void AutoQ()
        {
            int[,] arrayQResult = new int[nRows, nCols];
            Graphics g = this.CreateGraphics();
            ArrayList arrayRnd = new ArrayList();
            for (int i = 0; i < nRows * nCols; i++)
            {
                arrayRnd.Add(i);
            }
            Random rnd = new Random(System.DateTime.Now.Millisecond);
            while (arrayRnd.Count > 0)
            {
                int k = rnd.Next(arrayRnd.Count);
                int x = (int)arrayRnd[k] / nCols;
                int y = (int)arrayRnd[k] % nCols;
                SolidBrush sb;
                if (nSteps % 2 == 1)
                {
                    arrayQResult[x, y] = 1;    //黑先  1
                    sb = new SolidBrush(Color.Black);
                }
                else
                {
                    arrayQResult[x, y] = -1;    //白后  -1
                    sb = new SolidBrush(Color.White);
                }
                Rectangle rect = new Rectangle(x * widthSize, y * heightSize, widthSize, heightSize);
                g.FillEllipse(sb, rect);
                nSteps++;
                arrayRnd.RemoveAt(k);
                -------------------------judge 


            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    AutoQ();
                    QCount++;
                    this.Invoke(new MethodInvoker(() => { this.label1.Text = QCount.ToString(); }));
                }
            })).Start();
        }
    }
}
黑白棋自动博弈程序_第1张图片

你可能感兴趣的:(大数据,神经网络,深度学习,机器学习)