public void ShouldDecrementThePlys() { var board = new Game.Board(); board.HistoryPly++; board.Ply++; board.History.Add(new History { Move = new Move(new Pawn { Square = 32 }, 42) }); board.TakeMove(); board.HistoryPly.Should().Be(0); board.Ply.Should().Be(0); }
public void ShouldResetThePositionKeyAfterCastling() { const string initialBoardSetupWhiteToMove = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/R3KBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupWhiteToMove); var m = new Move(new King { Square = 25, Color = Color.White }, 23, true); var initialPositon = board.PositionKey; board.MakeMove(m); board.TakeMove(); board.PositionKey.Should().Be(initialPositon); }
public void ShouldGenerateFourHundredMovesAtDepthOneFromInitialPosition() { const string initialBoardSetup = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetup); board.GenerateMoves(); for (int count = 0; count < board.Moves[board.Ply].Count; count++) { if (board.MakeMove(board.Moves[0][count])) { board.GenerateMoves(); board.TakeMove(); } } board.Moves[0].Count.Should().Be(20); board.Moves[1].Count.Should().Be(20); }
public void ShouldResetThePositionKeyPromotion() { const string initialBoardSetupWhiteToMove = "1nbqkbnr/Pppppppp/8/8/8/8/1PPPPPPP/RNBQKBNR w KQk - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 81, Color = Color.White }, 91, new Queen { Square = 91, Color = Color.White }); var initialPositon = board.PositionKey; board.MakeMove(m); board.TakeMove(); board.PositionKey.Should().Be(initialPositon); }
public void ShouldResetThePositionKeyAfterCapture() { const string initialBoardSetupWhiteToMove = "rnbqkbnr/pppppppp/8/8/8/8/1PPPPPPP/RNBQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupWhiteToMove); var m = new Move(new Rook { Square = 21, Color = Color.White }, new Pawn { Square = 81, Color = Color.Black }); var initialPositon = board.PositionKey; board.MakeMove(m); board.TakeMove(); board.PositionKey.Should().Be(initialPositon); }
public void ShouldResetThePositionKeyAfterTakingBackTheOpeningMove() { const string initialBoardSetupWhiteToMove = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; var board = new Game.Board(); board.ParseFen(initialBoardSetupWhiteToMove); var m = new Move(new Pawn { Square = 34, Color = Color.White }, 54) { IsPawnStartMove = true }; var initialPositon = board.PositionKey; board.MakeMove(m); board.TakeMove(); board.PositionKey.Should().Be(initialPositon); }