Beispiel #1
0
        public void CinnamonChess_EnPassantPosition_Metrics_ToDepth5()
        {
            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            // "8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28"
            var gameState = FenHelpers.Parse("8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 28");

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var moves = new List <uint>(20);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 5;

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(5, metrics[depth].Legal);
            Assert.Equal(117, metrics[depth - 1].Legal);
            Assert.Equal(3293, metrics[depth - 2].Legal);
            Assert.Equal(67197, metrics[depth - 3].Legal);
            Assert.Equal(1881089, metrics[depth - 4].Legal);
        }
Beispiel #2
0
        public void CinnamonChess_PromotionsPosition_ToDepth5()
        {
            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            // "8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1"
            var gameState = FenHelpers.Parse("8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1");

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var moves = new List <uint>(20);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 5;

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(18, metrics[depth].Legal);
            Assert.Equal(290, metrics[depth - 1].Legal);
            Assert.Equal(5044, metrics[depth - 2].Legal);
            Assert.Equal(89363, metrics[depth - 3].Legal);
            Assert.Equal(1745545, metrics[depth - 4].Legal);
        }
Beispiel #3
0
        public void Position3()
        {
            // "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -"
            var gameState = FenHelpers.Parse(FenHelpers.Position3);

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 5;

            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(14, metrics[depth].Legal);
            Assert.Equal(1, metrics[depth].Captures);
            Assert.Equal(0, metrics[depth].EnPassantCaptures);
            Assert.Equal(0, metrics[depth].Castles);
            ////Assert.Equal(2, metrics[depth].Checks);

            Assert.Equal(191, metrics[depth - 1].Legal);
            Assert.Equal(14, metrics[depth - 1].Captures);
            Assert.Equal(0, metrics[depth - 1].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 1].Castles);
            ////Assert.Equal(10, metrics[depth - 1].Checks);

            Assert.Equal(2812, metrics[depth - 2].Legal);
            Assert.Equal(209, metrics[depth - 2].Captures);
            Assert.Equal(2, metrics[depth - 2].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 2].Castles);
            ////Assert.Equal(267, metrics[depth - 2].Checks);

            Assert.Equal(43238, metrics[depth - 3].Legal);
            Assert.Equal(3348, metrics[depth - 3].Captures);
            Assert.Equal(123, metrics[depth - 3].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 3].Castles);
            ////Assert.Equal(1680, metrics[depth - 3].Checks);

            Assert.Equal(674624, metrics[depth - 4].Legal);
            Assert.Equal(52051, metrics[depth - 4].Captures);
            Assert.Equal(1165, metrics[depth - 4].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 4].Castles);
            ////Assert.Equal(52950, metrics[depth - 4].Checks);
        }
Beispiel #4
0
        public void Default_Metrics_ToDepth5()
        {
            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            // "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
            var gameState = FenHelpers.Parse(FenHelpers.Default);

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var moves = new List <uint>(20);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 5;

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(20, metrics[depth].Legal);
            Assert.Equal(0, metrics[depth].Captures);
            Assert.Equal(0, metrics[depth].EnPassantCaptures);
            Assert.Equal(0, metrics[depth].Castles);
            ////Assert.Equal(0, metrics[depth].Checks);

            Assert.Equal(400, metrics[depth - 1].Legal);
            Assert.Equal(0, metrics[depth - 1].Captures);
            Assert.Equal(0, metrics[depth - 1].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 1].Castles);
            ////Assert.Equal(0, metrics[depth - 1].Checks);

            Assert.Equal(8902, metrics[depth - 2].Legal);
            Assert.Equal(34, metrics[depth - 2].Captures);
            Assert.Equal(0, metrics[depth - 2].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 2].Castles);
            ////Assert.Equal(12, metrics[depth - 2].Checks);

            Assert.Equal(197281, metrics[depth - 3].Legal);
            Assert.Equal(1576, metrics[depth - 3].Captures);
            Assert.Equal(0, metrics[depth - 3].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 3].Castles);
            ////Assert.Equal(12, metrics[depth - 3].Checks);

            Assert.Equal(4865609, metrics[depth - 4].Legal);
        }
Beispiel #5
0
        public void Position2()
        {
            // "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -"
            var gameState = FenHelpers.Parse(FenHelpers.Position2);

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 3;

            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(48, metrics[depth].Legal);
            Assert.Equal(8, metrics[depth].Captures);
            Assert.Equal(0, metrics[depth].EnPassantCaptures);
            Assert.Equal(2, metrics[depth].Castles);
            ////Assert.Equal(0, metrics[depth].Checks);

            Assert.Equal(2039, metrics[depth - 1].Legal);
            Assert.Equal(351, metrics[depth - 1].Captures);
            Assert.Equal(1, metrics[depth - 1].EnPassantCaptures);
            Assert.Equal(91, metrics[depth - 1].Castles);
            ////Assert.Equal(3, metrics[depth - 1].Checks);

            Assert.Equal(97862, metrics[depth - 2].Legal);
            Assert.Equal(17102, metrics[depth - 2].Captures);
            Assert.Equal(45, metrics[depth - 2].EnPassantCaptures);
            Assert.Equal(3162, metrics[depth - 2].Castles);
            ////Assert.Equal(993, metrics[depth - 2].Checks);
            ////Assert.Equal(1, metrics[depth - 2].Checkmates);
        }
Beispiel #6
0
        public void Position4()
        {
            // "r3k2r/Pppp1ppp/1b3nbN/nP6/BBP1P3/q4N2/Pp1P2PP/R2Q1RK1 w kq - 0 1"
            var gameState = FenHelpers.Parse(FenHelpers.Position4);

            var board          = Board.FromGameState(gameState);
            var boardReference = Board.FromGameState(gameState);

            var metrics = new Dictionary <int, PerftMetrics>();

            var depth = 3;

            var perftRunner = new PerftRunnerMetrics(moveGeneratorFixture.MoveGenerator);

            perftRunner.Go(board, gameState.ToPlay, depth, metrics);

            TestHelpers.AssertEqual(board, boardReference);

            Assert.Equal(6, metrics[depth].Legal);
            Assert.Equal(0, metrics[depth].Captures);
            Assert.Equal(0, metrics[depth].EnPassantCaptures);
            Assert.Equal(0, metrics[depth].Castles);
            ////Assert.Equal(0, metrics[depth].Checks);

            Assert.Equal(264, metrics[depth - 1].Legal);
            Assert.Equal(87, metrics[depth - 1].Captures);
            Assert.Equal(0, metrics[depth - 1].EnPassantCaptures);
            Assert.Equal(6, metrics[depth - 1].Castles);
            ////Assert.Equal(10, metrics[depth - 1].Checks);

            Assert.Equal(9467, metrics[depth - 2].Legal);
            Assert.Equal(1021, metrics[depth - 2].Captures);
            Assert.Equal(4, metrics[depth - 2].EnPassantCaptures);
            Assert.Equal(0, metrics[depth - 2].Castles);
            ////Assert.Equal(38, metrics[depth - 2].Checks);
        }