public void Fen_Parse_Default_Correct() { var gameState = FenHelpers.Parse(FenHelpers.Default); Assert.Equal(SquareFlagConstants.R2, gameState.WhitePawns); Assert.Equal(SquareFlag.A1 | SquareFlag.H1, gameState.WhiteRooks); Assert.Equal(SquareFlag.B1 | SquareFlag.G1, gameState.WhiteKnights); Assert.Equal(SquareFlag.C1 | SquareFlag.F1, gameState.WhiteBishops); Assert.Equal(SquareFlag.D1, gameState.WhiteQueens); Assert.Equal(SquareFlag.E1, gameState.WhiteKing); Assert.Equal(SquareFlagConstants.R7, gameState.BlackPawns); Assert.Equal(SquareFlag.A8 | SquareFlag.H8, gameState.BlackRooks); Assert.Equal(SquareFlag.B8 | SquareFlag.G8, gameState.BlackKnights); Assert.Equal(SquareFlag.C8 | SquareFlag.F8, gameState.BlackBishops); Assert.Equal(SquareFlag.D8, gameState.BlackQueens); Assert.Equal(SquareFlag.E8, gameState.BlackKing); Assert.Equal(Colour.White, gameState.ToPlay); Assert.True(gameState.WhiteCanCastleKingSide); Assert.True(gameState.WhiteCanCastleQueenSide); Assert.True(gameState.BlackCanCastleKingSide); Assert.True(gameState.BlackCanCastleQueenSide); Assert.Equal((SquareFlag)0, gameState.EnPassant); Assert.Equal(0, gameState.HalfMoveClock); Assert.Equal(1, gameState.FullTurn); }
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); }
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); }
public void White_FourCaptures_OnePush_Correct() { var gameState = FenHelpers.Parse("K6k/8/8/8/8/p1p2p1p/1P4P1/8 w - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var move1 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.B2.ToSquare(), SquareFlag.B3.ToSquare(), PieceType.None, MoveType.Ordinary); var move2 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.G2.ToSquare(), SquareFlag.G3.ToSquare(), PieceType.None, MoveType.Ordinary); var captures = moves.Where(x => x.GetCapturePieceType() != PieceType.None); var capture1 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.B2.ToSquare(), SquareFlag.A3.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture2 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.B2.ToSquare(), SquareFlag.C3.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture3 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.G2.ToSquare(), SquareFlag.F3.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture4 = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.G2.ToSquare(), SquareFlag.H3.ToSquare(), PieceType.Pawn, MoveType.Ordinary); Assert.Contains(move1, moves); Assert.Contains(move2, moves); Assert.Contains(capture1, moves); Assert.Contains(capture2, moves); Assert.Contains(capture3, moves); Assert.Contains(capture4, moves); }
public void E4_16Moves_8Captures_Correct() { var gameState = FenHelpers.Parse("K7/8/2p1p1p1/8/2p1Q1p1/8/2p1p1p1/k7 w - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveCount = moves.Count; var captureViews = GetCaptureMoveViews(moves); var capture1 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.C6.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture2 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.E6.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture3 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.G6.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture4 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.C4.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture5 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.G4.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture6 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.C2.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture7 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.E2.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var capture8 = MoveBuilder.Create(Colour.White, PieceType.Queen, SquareFlag.E4.ToSquare(), SquareFlag.G2.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var captures = captureViews.Select(x => x.Value); Assert.Contains(capture1, captures); Assert.Contains(capture2, captures); Assert.Contains(capture3, captures); Assert.Contains(capture4, captures); Assert.Contains(capture5, captures); Assert.Contains(capture6, captures); Assert.Contains(capture7, captures); Assert.Contains(capture8, captures); }
internal static void Main(string[] args) { Console.WriteLine("ChessSharp Perft"); Console.WriteLine("Initialising data"); var moveGenerator = new MoveGenerator(16); var fenString = FenHelpers.Default; var perftRunner = new PerftRunner(moveGenerator); var gameState = FenHelpers.Parse(fenString); var board = Board.FromGameState(gameState); var boardReference = Board.FromGameState(gameState); Console.WriteLine("Press any key to begin"); Console.ReadKey(); Console.WriteLine($"Starting perft for {fenString} depth 2"); PerftDepth(perftRunner, board, gameState, 2); Console.WriteLine($"Starting perft for {fenString} depth 3"); PerftDepth(perftRunner, board, gameState, 3); Console.WriteLine($"Starting perft for {fenString} depth 4"); PerftDepth(perftRunner, board, gameState, 4); var results = new List <double>(); var iterations = 3; #if DEBUG iterations = 1; #endif for (var i = 0; i < iterations; i++) { Console.WriteLine($"Starting perft for {fenString} depth 5 - iteration {i + 1}"); var result = PerftDepth(perftRunner, board, gameState, 5); results.Add(result); } var averageNps = results.Average(); Console.WriteLine($"Average nps: {Math.Floor(averageNps)}"); Console.WriteLine("Press any key to quit"); Console.ReadKey(); }
public void Fen_Parse_Position5_Correct() { var gameState = FenHelpers.Parse(FenHelpers.Position5); Assert.Equal(Colour.White, gameState.ToPlay); Assert.True(gameState.WhiteCanCastleKingSide); Assert.True(gameState.WhiteCanCastleQueenSide); Assert.False(gameState.BlackCanCastleKingSide); Assert.False(gameState.BlackCanCastleQueenSide); Assert.Equal((SquareFlag)0, gameState.EnPassant); Assert.Equal(1, gameState.HalfMoveClock); Assert.Equal(8, gameState.FullTurn); }
public void Black_FourBlocked_NoMoves_Correct() { var gameState = FenHelpers.Parse("K6k/1p1p1p1p/1P1P1P1P/8/8/8/8/8 b - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetPawnMoveViews(moves); Assert.Empty(moveViews); }
public void PawnPinnedByBishopButCanCapture(string fenString, int expectedMoveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetPawnMoveViews(moves); Assert.Equal(expectedMoveCount, moveViews.Count); }
public void A1_H8_0Capture(string fenString, int moveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var movesViews = GetQueenMoveViews(moves); Assert.Equal(moveCount, movesViews.Count); }
public void KnightNotActuallyPinned(string fenString, int expectedMoveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetKnightMoveViews(moves); Assert.Equal(expectedMoveCount, moveViews.Count); }
public void EvadesCheckByKnight(string fenString, int expectedMovesCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveCount = moves.Count; Assert.Equal(expectedMovesCount, moveCount); }
public void AllDirectionsBlocked(string fenString, int expectedMoveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetRookMoveViews(moves); Assert.Equal(expectedMoveCount, moveViews.Count); }
public void AvoidsMovingIntoNonDiagonalCheck(string fenString, int expectedMovesCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var kingMoves = GetKingMoveViews(moves); Assert.Equal(expectedMovesCount, kingMoves.Count()); }
public void Fen_Parse_Position2_Correct() { var gameState = FenHelpers.Parse(FenHelpers.Position2); Assert.Equal(SquareFlag.E1, gameState.WhiteKing); Assert.Equal(SquareFlag.E8, gameState.BlackKing); Assert.Equal(Colour.White, gameState.ToPlay); Assert.True(gameState.WhiteCanCastleKingSide); Assert.True(gameState.WhiteCanCastleQueenSide); Assert.True(gameState.BlackCanCastleKingSide); Assert.True(gameState.BlackCanCastleQueenSide); Assert.Equal((SquareFlag)0, gameState.EnPassant); }
public void B2_21Moves_0Captures_Correct() { var gameState = FenHelpers.Parse("8/8/8/k7/8/8/1Q6/4K3 w - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var movesViews = GetQueenMoveViews(moves); Assert.Equal(23, movesViews.Count); }
public void Position3_Variants_EnPassantDiscovered(string fenString, int expectedMoveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetPawnMoveViews(moves); Assert.Equal(expectedMoveCount, moveViews.Count); }
public void DiscoverCheckRook2(string fenString) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetPawnMoveViews(moves); Assert.Equal(5, moveViews.Count); }
public void FromCorners(string fenString, int expectedMovesCount) { // This is mainly checking the pawn check magic bitboards as it uses them var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveCount = moves.Count; Assert.Equal(expectedMovesCount, moveCount); }
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); }
public void EvadesDoubleCheck() { var gameState = FenHelpers.Parse("k7/2Q5/8/4p3/3K1P2/2q5/8/8 w - - 0 1"); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveCount = moves.Count; Assert.Equal(3, moveCount); Assert.Equal(2, moves.First().GetNumCheckers()); }
public void MidBoardOnlyOnePush(string fenString, SquareFlag toSquare) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var pawnMoveViews = GetPawnMoveViews(moves); var pawnMoves = pawnMoveViews.Select(x => x.Value); Assert.Collection(pawnMoves, x => Assert.Equal(toSquare, x.GetTo())); }
public void DiscoverCheck(string fenString, SquareFlag fromSquare, SquareFlag toSquare) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(20); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveCount = moves.Count; var illegalMove = MoveBuilder.Create(Colour.White, PieceType.Pawn, fromSquare.ToSquare(), toSquare.ToSquare(), PieceType.None, MoveType.Ordinary); Assert.DoesNotContain(illegalMove, moves); }
public void White_Capture() { var gameState = FenHelpers.Parse("K6k/8/8/8/8/3p4/4P3/8 w - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var capture = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.E2.ToSquare(), SquareFlag.D3.ToSquare(), PieceType.Pawn, MoveType.Ordinary); var movesView = moves.Select(x => new MoveViewer(x)); Assert.Contains(capture, moves); }
public void White_EnPassant_Capture() { var gameState = FenHelpers.Parse("K6k/8/8/3Pp3/8/8/8/8 w - e6"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var enPassantCapture = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.D5.ToSquare(), SquareFlag.E6.ToSquare(), PieceType.Pawn, MoveType.EnPassant); var movesView = moves.Select(x => new MoveViewer(x)); Assert.Contains(enPassantCapture, moves); }
public void White_EnPassant_Capture_DiscoveredCheck() { var gameState = FenHelpers.Parse("8/8/8/q1rPp2K/8/7p/8/8 w - e6"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var enPassantCapture = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.D6.ToSquare(), SquareFlag.E7.ToSquare(), PieceType.Pawn, MoveType.EnPassant); var movesView = moves.Select(x => new MoveViewer(x)); Assert.DoesNotContain(enPassantCapture, moves); }
public void White_DiscoveredCheck() { var gameState = FenHelpers.Parse("8/2b5/3P4/4K3/8/8/8/7k w - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var illegalMove = MoveBuilder.Create(Colour.White, PieceType.Pawn, SquareFlag.D6.ToSquare(), SquareFlag.D7.ToSquare(), PieceType.None, MoveType.Ordinary); var movesView = moves.Select(x => new MoveViewer(x)); Assert.DoesNotContain(illegalMove, moves); }
public void Black_EightPawns_OneAndTwoPushes() { var gameState = FenHelpers.Parse("K6k/pppppppp/8/8/8/8/8/8 b - -"); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); // Purely for debugging var pawnMoves = GetPawnMoveViews(moves); var moveA3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.A7.ToSquare(), SquareFlag.A6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveA4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.A7.ToSquare(), SquareFlag.A5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveB3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.B7.ToSquare(), SquareFlag.B6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveB4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.B7.ToSquare(), SquareFlag.B5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveC3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.C7.ToSquare(), SquareFlag.C6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveC4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.C7.ToSquare(), SquareFlag.C5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveD3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.D7.ToSquare(), SquareFlag.D6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveD4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.D7.ToSquare(), SquareFlag.D5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveE3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.E7.ToSquare(), SquareFlag.E6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveE4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.E7.ToSquare(), SquareFlag.E5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveF3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.F7.ToSquare(), SquareFlag.F6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveF4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.F7.ToSquare(), SquareFlag.F5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveG3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.G7.ToSquare(), SquareFlag.G6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveG4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.G7.ToSquare(), SquareFlag.G5.ToSquare(), PieceType.None, MoveType.Ordinary); var moveH3 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.H7.ToSquare(), SquareFlag.H6.ToSquare(), PieceType.None, MoveType.Ordinary); var moveH4 = MoveBuilder.Create(gameState.ToPlay, PieceType.Pawn, SquareFlag.H7.ToSquare(), SquareFlag.H5.ToSquare(), PieceType.None, MoveType.Ordinary); Assert.Contains(moveA3, moves); Assert.Contains(moveA4, moves); Assert.Contains(moveB3, moves); Assert.Contains(moveB4, moves); Assert.Contains(moveC3, moves); Assert.Contains(moveC4, moves); Assert.Contains(moveD3, moves); Assert.Contains(moveD4, moves); Assert.Contains(moveE3, moves); Assert.Contains(moveE4, moves); Assert.Contains(moveF3, moves); Assert.Contains(moveF4, moves); Assert.Contains(moveG3, moves); Assert.Contains(moveG4, moves); Assert.Contains(moveH3, moves); Assert.Contains(moveH4, moves); }
public void LargeOccupancyOneCapture(string fenString, int expectedMoveCount) { var gameState = FenHelpers.Parse(fenString); var board = CreateBoard(gameState); var moves = new List <uint>(10); MoveGenerator.Generate(board, gameState.ToPlay, moves); var moveViews = GetRookMoveViews(moves); var captureViews = GetCaptureMoveViews(moves); Assert.Equal(expectedMoveCount, moveViews.Count); Assert.Equal(1, captureViews.Count); }
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); }