Exemple #1
0
        public void CalculateOpeningMove()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2();

            chessEngine2.New();

            Move move = chessEngine2.CalculateMove();

            Assert.IsNotNull(move);
        }
Exemple #2
0
        public void CalculateOpeningMoveBlack()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2();

            chessEngine2.New();

            chessEngine2.ExecuteMove(new Move("E2", "E4", chessEngine2["E2"], MoveType.PawnDoubleStep));
            Move move = chessEngine2.CalculateMove();

            Assert.IsNotNull(move);
        }
Exemple #3
0
        public void CalculateOneMoveMate1()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2
            {
                ["G6"] = new King(Color.White, MoveType.Normal),
                ["H8"] = new King(Color.Black, MoveType.Normal),
                ["A1"] = new Rook(Color.White)
            };

            Move move = chessEngine2.CalculateMove();

            Assert.IsTrue(move.End.AreEqual(new Position("A8")));
        }
Exemple #4
0
        public void CalculatePawnBeat()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2
            {
                ["H1"] = new King(Color.White, MoveType.Normal),
                ["E4"] = new Pawn(Color.White),
                ["G8"] = new King(Color.Black, MoveType.Normal),
                ["D5"] = new Pawn(Color.Black)
            };


            Move move = chessEngine2.CalculateMove();

            Assert.IsTrue(move.End.AreEqual(new Position("D5")));
        }
Exemple #5
0
        public void CheckStaleMate()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2
            {
                ["H3"] = new King(Color.White, MoveType.Normal),
                ["H2"] = new Pawn(Color.White),
                ["H4"] = new Pawn(Color.White),
                ["H5"] = new Pawn(Color.Black),
                ["H8"] = new King(Color.Black, MoveType.Normal),
                ["G8"] = new Rook(Color.Black)
            };


            Move move = chessEngine2.CalculateMove();

            Assert.IsTrue(move.Rating.Evaluation == Evaluation.WhiteStaleMate);
        }
Exemple #6
0
        public void CheckEnpassant()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2
            {
                ["G6"] = new King(Color.White, MoveType.Normal),
                ["C2"] = new Pawn(Color.White),
                ["H8"] = new King(Color.Black, MoveType.Normal),
                ["B4"] = new Pawn(Color.Black)
            };

            chessEngine2.ExecuteMove(new Move("C2", "C4", chessEngine2["C2"], MoveType.PawnDoubleStep));
            Move move = chessEngine2.CalculateMove();

            chessEngine2.ExecuteMove(move);

            Assert.IsTrue(move.Type == MoveType.EnpassantBlackLeft);
        }
Exemple #7
0
        public void CalculateTwoMoveMate()
        {
            ChessEngine2 chessEngine2 = new ChessEngine2
            {
                ["G6"] = new King(Color.White, MoveType.Normal),
                ["C4"] = new Pawn(Color.White),
                ["H8"] = new King(Color.Black, MoveType.Normal),
                ["B5"] = new Pawn(Color.Black),
                ["G5"] = new Rook(Color.White)
            };

            Move move = chessEngine2.CalculateMove();

            Assert.IsTrue(move.Rating.Evaluation == Evaluation.BlackCheckMate);
            Assert.IsTrue(move.Rating.Situation == Situation.WhiteVictory);
            Assert.IsTrue(move.Piece is Rook);
        }