示例#1
0
        public void testThreatMapDeep_pawnCapture()
        {
            DoktorChessAIBoard ourBoard = new DoktorChessAIBoard(gameType.queenAndPawns, boardSearchConfig.getDebugConfig());
            square ourPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.white, 4, 1);
            square enemyPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.black, 3, 2);

            if (ourBoard.getCoverLevel(new squarePos(3, 2), pieceColour.white) != 1 ||
                ourBoard.getCoverLevel(new squarePos(5, 2), pieceColour.white) != 1)
                throw new AssertFailedException("Threatmap created wrongly");

            if (ourBoard.getCoverLevel(new squarePos(2, 1), pieceColour.white) != -1 ||
                ourBoard.getCoverLevel(new squarePos(4, 1), pieceColour.white) != -1)
                throw new AssertFailedException("Enemy pawn create with no threatened squares");

            if (ourPawn.coveredSquares.Count != 2)
                throw new AssertFailedException("Pawn created not covering two squares");

            if ((!ourPawn.coveredSquares[3, 2]) ||
                (!ourPawn.coveredSquares[5, 2])   )
                throw new AssertFailedException("Pawn created with incorrect .coveredSquares");

            if (((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[3, 2].Count != 1 ||
                ((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[3, 2].Count != 1)
                throw new AssertFailedException("Pawn created with incorrect .piecesWhichThreatenSquare count");

            //if (((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[3, 2][ourPawn.position.flatten()] != ourPawn ||
            //    ((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[5, 2][ourPawn.position.flatten()] != ourPawn)
            //    throw new AssertFailedException("Pawn created with incorrect .piecesWhichThreatenSquare contents");

            move ourMove = new move(ourPawn, ourBoard[3, 2]);
            ourBoard.doMove(ourMove);

            if (ourBoard.getCoverLevel(new squarePos(2, 3), pieceColour.white) != 1 ||
                ourBoard.getCoverLevel(new squarePos(4, 3), pieceColour.white) != 1)
                throw new AssertFailedException("Threatmap did not update cover levels correctly");

            if (ourBoard.getCoverLevel(new squarePos(2, 1), pieceColour.white) != 0 ||
                ourBoard.getCoverLevel(new squarePos(4, 1), pieceColour.white) != 0)
                throw new AssertFailedException("Captured pawn still has threatened squares");

            if (ourPawn.coveredSquares.Count != 2)
                throw new AssertFailedException("Pawn updated not covering two squares");

            if (!ourPawn.coveredSquares[2, 3] ||
                !ourPawn.coveredSquares[4, 3]   )
                throw new AssertFailedException("Pawn updated with incorrect .coveredSquares");

            if (((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[3, 2].Count != 0 ||
                ((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[3, 2].Count != 0)
                throw new AssertFailedException("Pawn's pre-update .piecesWhichThreatenSquare was not changed");

            if (((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[2, 3].Count != 1 ||
                ((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[4, 3].Count != 1)
                throw new AssertFailedException("Pawn updated with incorrect .piecesWhichThreatenSquare count");

            //if (((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[2, 3][ourPawn.position.flatten()] != ourPawn ||
            //    ((threatMap)ourBoard.coverLevel).piecesWhichThreatenSquare[4, 3][ourPawn.position.flatten()] != ourPawn)
            //    throw new AssertFailedException("Pawn updated with incorrect .piecesWhichThreatenSquare contents");
        }
示例#2
0
        public void testThreatMapDeep_discoveredCapture()
        {
            DoktorChessAIBoard ourBoard = new DoktorChessAIBoard(gameType.queenAndPawns, boardSearchConfig.getDebugConfig());

            square ourPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.white, 0, 1);
            square enemyPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.black, 1, 2);
            square ourRook = ourBoard.addPiece(pieceType.rook, pieceColour.white, 0, 0);
            square enemyRook = ourBoard.addPiece(pieceType.rook, pieceColour.black, 0, 7);

            move ourMove = new move(ourPawn, enemyPawn);
            ourBoard.doMove(ourMove);

            // Squares between rooks our pawn should be threatened by both rooks, so should have a threat
            // level of 0, apart from the one at y=3, which is threatened by a pawn.
            for (int x = 1; x < 7; x++)
            {
                if (x == 3)
                {
                    if (ourBoard.getCoverLevel(new squarePos(0, x), pieceColour.black) != -1)
                        throw new AssertFailedException("Threatmap did not update cover levels correctly for discovered spaces");
                }
                else
                {
                    if (ourBoard.getCoverLevel(new squarePos(0, x), pieceColour.black) != 0)
                        throw new AssertFailedException("Threatmap did not update cover levels correctly for discovered spaces");
                }
            }

            // Both rooks should be threatened once, by the other rook.
            if (ourBoard.getCoverLevel(new squarePos(0, 0), pieceColour.black) !=  1 ||
                ourBoard.getCoverLevel(new squarePos(0, 7), pieceColour.white) !=  1   )
                throw new AssertFailedException("Threatmap did not update cover levels correctly for rooks");
        }
示例#3
0
        public void testThreatMapDeep_discoveredPromotion()
        {
            DoktorChessAIBoard ourBoard = new DoktorChessAIBoard(gameType.queenAndPawns, boardSearchConfig.getDebugConfig());
            square ourPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.white, 3, 6);
            square enemyPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.black, 3, 7);
            square ourRook = ourBoard.addPiece(pieceType.rook, pieceColour.white, 0, 7);

            move ourMove = new move(ourPawn, ourBoard[3, 7], pieceType.queen);
            ourBoard.doMove(ourMove);

            // Observe the squares to the right of our pawn - they should not be accessible to the rook
            for (int x = 4; x < 7; x++)
            {
                if (ourBoard.getCoverLevel(new squarePos(x, 7), pieceColour.white) != 1)
                    throw new AssertFailedException("Threatmap did not update cover levels correctly");
            }

            // the pawn itself is protected once.
            if (ourBoard.getCoverLevel(new squarePos(3, 7), pieceColour.white) != 1)
                throw new AssertFailedException("Threatmap did not update cover levels of promoted piece correctly");
        }
示例#4
0
        public void testThreatMapDeep_discovered()
        {
            DoktorChessAIBoard ourBoard = new DoktorChessAIBoard(gameType.queenAndPawns, boardSearchConfig.getDebugConfig()  );
            square ourPawn = ourBoard.addPiece(pieceType.pawn, pieceColour.white, 4, 1);
            square ourRook = ourBoard.addPiece(pieceType.rook, pieceColour.white, 0, 1);

            move ourMove = new move(ourPawn, ourBoard[4, 2]);
            ourBoard.doMove(ourMove);

            // Observe the squares to the right of our pawn - they should now be accessible to the rook

            for (int x = 1; x < 7; x++)
            {
                if (ourBoard.getCoverLevel(new squarePos(x, 1), pieceColour.white) != 1)
                    throw new AssertFailedException("Threatmap did not update cover levels correctly");
            }
        }