public void TestBishopOnE7Moves() { var uciStream = new UciStream(); var board = uciStream.Board; board.SetPosition("rnbq1bnr/ppppkppp/4p3/8/8/BP6/P1PPPPPP/RN1QKBNR b KQ - 0 3"); var unoccupiedMovesMask = Board.BishopMoveMasks[Square.e7]; var expectedUnoccupiedMovesMask = 0ul; Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.d8); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.f8); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.d6); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.f6); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.c5); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.g5); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.b4); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.h4); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.a3); var relevantMoveDestinations = unoccupiedMovesMask & PrecalculatedMoves.GetRelevantOccupancy(Square.e7, false); uciStream.WriteMessageLine("Relevant move destinations = "); uciStream.WriteMessageLine(Position.ToString(relevantMoveDestinations)); uciStream.WriteMessageLine(); ulong expectedRelevantMoveDestinations = 0; Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.d6); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.f6); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.c5); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.g5); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.b4); uciStream.WriteMessageLine("Expected relevant move destinations = "); uciStream.WriteMessageLine(Position.ToString(relevantMoveDestinations)); uciStream.WriteMessageLine(); Assert.That(relevantMoveDestinations, Is.EqualTo(expectedRelevantMoveDestinations)); Direction[] bishopDirections = { Direction.NorthEast, Direction.SouthEast, Direction.SouthWest, Direction.NorthWest }; var bishopDestinations = Board.CreateMoveDestinationsMask(Square.e7, board.CurrentPosition.Occupancy, bishopDirections); uciStream.WriteMessageLine("Bishop destinations = "); uciStream.WriteMessageLine(Position.ToString(bishopDestinations)); uciStream.WriteMessageLine(); var expectedBishopDestinations = 0ul; Bitwise.SetBit(ref expectedBishopDestinations, Square.d8); Bitwise.SetBit(ref expectedBishopDestinations, Square.f8); Bitwise.SetBit(ref expectedBishopDestinations, Square.d6); Bitwise.SetBit(ref expectedBishopDestinations, Square.f6); Bitwise.SetBit(ref expectedBishopDestinations, Square.c5); Bitwise.SetBit(ref expectedBishopDestinations, Square.g5); Bitwise.SetBit(ref expectedBishopDestinations, Square.b4); Bitwise.SetBit(ref expectedBishopDestinations, Square.h4); Bitwise.SetBit(ref expectedBishopDestinations, Square.a3); uciStream.WriteMessageLine("Expected bishop destinations = "); uciStream.WriteMessageLine(Position.ToString(expectedBishopDestinations)); uciStream.WriteMessageLine(); Assert.That(bishopDestinations, Is.EqualTo(expectedBishopDestinations)); var precalculatedBishopDestinations = Board.PrecalculatedMoves.GetBishopMovesMask(Square.e7, board.CurrentPosition.Occupancy); uciStream.WriteMessageLine("Precalculated bishop destinations = "); uciStream.WriteMessageLine(Position.ToString(precalculatedBishopDestinations)); uciStream.WriteMessageLine(); Assert.That(precalculatedBishopDestinations, Is.EqualTo(expectedBishopDestinations)); }
public void TestBishopOnE7Moves() { var board = new Board(WriteMessageLine, long.MaxValue); board.SetPosition("rnbq1bnr/ppppkppp/4p3/8/8/BP6/P1PPPPPP/RN1QKBNR b KQ - 0 3"); var unoccupiedMovesMask = Board.BishopMoveMasks[(int)Square.E7]; var expectedUnoccupiedMovesMask = 0ul; Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.D8); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.F8); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.D6); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.F6); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.C5); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.G5); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.B4); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.H4); Bitwise.SetBit(ref expectedUnoccupiedMovesMask, Square.A3); var relevantMoveDestinations = unoccupiedMovesMask & PrecalculatedMoves.GetRelevantOccupancy(Square.E7, false); WriteMessageLine("Relevant move destinations = "); WriteMessageLine(Position.ToString(relevantMoveDestinations)); WriteMessageLine(); ulong expectedRelevantMoveDestinations = 0; Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.D6); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.F6); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.C5); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.G5); Bitwise.SetBit(ref expectedRelevantMoveDestinations, Square.B4); WriteMessageLine("Expected relevant move destinations = "); WriteMessageLine(Position.ToString(relevantMoveDestinations)); WriteMessageLine(); Assert.That(relevantMoveDestinations, Is.EqualTo(expectedRelevantMoveDestinations)); Direction[] bishopDirections = { Direction.NorthEast, Direction.SouthEast, Direction.SouthWest, Direction.NorthWest }; var bishopDestinations = Board.CreateMoveDestinationsMask(Square.E7, board.CurrentPosition.Occupancy, bishopDirections); WriteMessageLine("Bishop destinations = "); WriteMessageLine(Position.ToString(bishopDestinations)); WriteMessageLine(); var expectedBishopDestinations = 0ul; Bitwise.SetBit(ref expectedBishopDestinations, Square.D8); Bitwise.SetBit(ref expectedBishopDestinations, Square.F8); Bitwise.SetBit(ref expectedBishopDestinations, Square.D6); Bitwise.SetBit(ref expectedBishopDestinations, Square.F6); Bitwise.SetBit(ref expectedBishopDestinations, Square.C5); Bitwise.SetBit(ref expectedBishopDestinations, Square.G5); Bitwise.SetBit(ref expectedBishopDestinations, Square.B4); Bitwise.SetBit(ref expectedBishopDestinations, Square.H4); Bitwise.SetBit(ref expectedBishopDestinations, Square.A3); WriteMessageLine("Expected bishop destinations = "); WriteMessageLine(Position.ToString(expectedBishopDestinations)); WriteMessageLine(); Assert.That(bishopDestinations, Is.EqualTo(expectedBishopDestinations)); var precalculatedBishopDestinations = Board.PrecalculatedMoves.GetBishopMovesMask(Square.E7, board.CurrentPosition.Occupancy); WriteMessageLine("Precalculated bishop destinations = "); WriteMessageLine(Position.ToString(precalculatedBishopDestinations)); WriteMessageLine(); Assert.That(precalculatedBishopDestinations, Is.EqualTo(expectedBishopDestinations)); }