Ejemplo n.º 1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     comboBox1.SelectedIndex = comboBox2.SelectedIndex = 0;
     Functions.Precalc();
     _tWhite = TypeOfGamer.Human;
     _tBlack = TypeOfGamer.Human;
     _curPlayer = Player.White;
     _game = new Game(_mainBoard);
     _ai = new AI();
     _lastStep = null;
     pictureBox1.Invalidate();
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
               var board = new Board();
            //Создаем пешек
            //for (int i = 0; i < 8; i++)
            //{
            //    new Pawn(Player.White, 1, i);
            //    new Pawn(Player.Black, 6, i);
            //}
            //new Rook(Player.White, 0, 0);
            //new Rook(Player.Black, 7, 0);
            //new Knight(Player.White, 0, 1);
            //new Knight(Player.Black, 7, 1);
            //new Bishop(Player.White, 0, 2);
            //new Bishop(Player.Black, 7, 2);
            //new Queen(Player.White, 0, 3);
            //new Queen(Player.Black, 7, 3);
            //new King(Player.White, 0, 4);
            //new King(Player.Black, 7, 4);
            //new Bishop(Player.White, 0, 5);
            //new Bishop(Player.Black, 7, 5);
            //new Knight(Player.White, 0, 6);
            //new Knight(Player.Black, 7, 6);
            //new Rook(Player.White, 0, 7);
            //new Rook(Player.Black, 7, 7);

            var g = new Game(board);
            var ai = new AI();
            var s = State.Calm;

            while (s != State.Checkmate)
            {
                PrintBoard(board.Figures);
                Console.WriteLine();

                Console.Write("Введите ваш ход({0}): ", g.Player);
                Step st;
                if (g.Player == Player.White)
                {
                    var step = Console.ReadLine();
                    st = Step.StringToStep(step);
                }
                else
                {
                    var tim = new Stopwatch();
                    tim.Start();
                    st = ai.SelectMove(g.Player, 6, board);
                    tim.Stop();
                    Console.WriteLine(tim.ElapsedMilliseconds);
                    Console.WriteLine();
                }
                try
                {
                        g.doMove(st);
                    s = g.calcState();
                }
                catch (ErrorStepExveption)
                {
                    Console.WriteLine("Не коректный ход");
                }
            }
        }
Ejemplo n.º 3
0
        public void time2()
        {
            var board = new Board(true);
            Queen.PrecalcStep();
            Bishop.PrecalcStep();
            Rook.PrecalcStep();
            King.preaCalc();
            Knight.preaCalc();
            //Создаем пешек
            //Создаем пешек
            for (var i = 0; i < 8; i++)
            {
                new Pawn(Player.White, board, 1, i);
                new Pawn(Player.Black, board, 6, i);
            }
            new Rook(Player.White, board, 0, 0);
            new Rook(Player.Black, board, 7, 0);
            new Knight(Player.White, board, 0, 1);
            new Knight(Player.Black, board, 7, 1);
            new Bishop(Player.White, board, 0, 2);
            new Bishop(Player.Black, board, 7, 2);
            new Queen(Player.White, board, 0, 3);
            new Queen(Player.Black, board, 7, 3);
            new King(Player.White, board, 0, 4);
            new King(Player.Black, board, 7, 4);
            new Bishop(Player.White, board, 0, 5);
            new Bishop(Player.Black, board, 7, 5);
            new Knight(Player.White, board, 0, 6);
            new Knight(Player.Black, board, 7, 6);
            new Rook(Player.White, board, 0, 7);
            new Rook(Player.Black, board, 7, 7);

            var ai = new AI();

            var g = new Game(board);
            var timer = new Stopwatch();
            timer.Start();

            var x = ai.SelectMove(Player.White, 8, board);
            timer.Stop();
             //   Assert.AreEqual(1000, timer.ElapsedMilliseconds);
            Assert.AreEqual(10000, ai.Count);
        }