diff --git a/src/Lynx.Benchmark/MoveGeneratorParallel.cs b/src/Lynx.Benchmark/MoveGeneratorParallel.cs index a0b66e67a..6b92075c4 100644 --- a/src/Lynx.Benchmark/MoveGeneratorParallel.cs +++ b/src/Lynx.Benchmark/MoveGeneratorParallel.cs @@ -293,9 +293,9 @@ internal static IEnumerable GenerateCastlingMoves(Position position, int o if (((position.Castle & (int)CastlingRights.WK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g1) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.e1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.e1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.WhiteShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -304,9 +304,9 @@ internal static IEnumerable GenerateCastlingMoves(Position position, int o && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.d1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b1) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.e1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.e1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.WhiteLongCastleKingSquare, piece, isLongCastle: TRUE); } @@ -316,9 +316,9 @@ internal static IEnumerable GenerateCastlingMoves(Position position, int o if (((position.Castle & (int)CastlingRights.BK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g8) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.e8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.e8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.BlackShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -327,9 +327,9 @@ internal static IEnumerable GenerateCastlingMoves(Position position, int o && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.d8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b8) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.e8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.e8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.BlackLongCastleKingSquare, piece, isLongCastle: TRUE); } diff --git a/src/Lynx.Dev/Program.cs b/src/Lynx.Dev/Program.cs index fa47e8369..834394169 100644 --- a/src/Lynx.Dev/Program.cs +++ b/src/Lynx.Dev/Program.cs @@ -338,7 +338,7 @@ static void _21_IsSquareAttacked() position.PrintAttackedSquares(Side.Black); - Console.WriteLine(Attacks.IsSquaredAttacked((int)BoardSquare.e4, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Console.WriteLine(Attacks.IsSquareAttacked((int)BoardSquare.e4, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); Console.WriteLine("====================================="); diff --git a/src/Lynx/Attacks.cs b/src/Lynx/Attacks.cs index 9c211e3ff..620e1779e 100644 --- a/src/Lynx/Attacks.cs +++ b/src/Lynx/Attacks.cs @@ -123,11 +123,11 @@ public static BitBoard QueenAttacks(BitBoard rookAttacks, BitBoard bishopAttacks } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsSquaredAttackedBySide(int squaredIndex, Position position, Side sideToMove) => - IsSquaredAttacked(squaredIndex, sideToMove, position.PieceBitBoards, position.OccupancyBitBoards); + public static bool IsSquareAttackedBySide(int squaredIndex, Position position, Side sideToMove) => + IsSquareAttacked(squaredIndex, sideToMove, position.PieceBitBoards, position.OccupancyBitBoards); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsSquaredAttacked(int squareIndex, Side sideToMove, BitBoard[] piecePosition, BitBoard[] occupancy) + public static bool IsSquareAttacked(int squareIndex, Side sideToMove, BitBoard[] piecePosition, BitBoard[] occupancy) { Utils.Assert(sideToMove != Side.Both); diff --git a/src/Lynx/Model/Position.cs b/src/Lynx/Model/Position.cs index 52fbb8306..336501655 100644 --- a/src/Lynx/Model/Position.cs +++ b/src/Lynx/Model/Position.cs @@ -460,7 +460,7 @@ internal bool IsValid() var oppositeKingSquare = oppositeKingBitBoard == default ? -1 : oppositeKingBitBoard.GetLS1BIndex(); return kingSquare >= 0 && oppositeKingSquare >= 0 - && !Attacks.IsSquaredAttacked(oppositeKingSquare, Side, PieceBitBoards, OccupancyBitBoards); + && !Attacks.IsSquareAttacked(oppositeKingSquare, Side, PieceBitBoards, OccupancyBitBoards); } /// @@ -475,7 +475,7 @@ public bool WasProduceByAValidMove() { var oppositeKingSquare = PieceBitBoards[(int)Piece.k - Utils.PieceOffset(Side)].GetLS1BIndex(); - return !Attacks.IsSquaredAttacked(oppositeKingSquare, Side, PieceBitBoards, OccupancyBitBoards); + return !Attacks.IsSquareAttacked(oppositeKingSquare, Side, PieceBitBoards, OccupancyBitBoards); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -960,7 +960,7 @@ public void PrintAttackedSquares(Side sideToMove) var squareIndex = BitBoardExtensions.SquareIndex(rank, file); - var pieceRepresentation = Attacks.IsSquaredAttacked(squareIndex, sideToMove, PieceBitBoards, OccupancyBitBoards) + var pieceRepresentation = Attacks.IsSquareAttacked(squareIndex, sideToMove, PieceBitBoards, OccupancyBitBoards) ? '1' : '.'; diff --git a/src/Lynx/MoveGenerator.cs b/src/Lynx/MoveGenerator.cs index 5b8dccb72..ec8284f7a 100644 --- a/src/Lynx/MoveGenerator.cs +++ b/src/Lynx/MoveGenerator.cs @@ -171,13 +171,13 @@ internal static void GenerateCastlingMoves(ref int localIndex, Move[] movePool, { if (position.Side == Side.White) { - bool ise1Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e1, position, oppositeSide); + bool ise1Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e1, position, oppositeSide); if (((position.Castle & (int)CastlingRights.WK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) { movePool[localIndex++] = MoveExtensions.Encode(sourceSquare, Constants.WhiteShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -187,21 +187,21 @@ internal static void GenerateCastlingMoves(ref int localIndex, Move[] movePool, && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) { movePool[localIndex++] = MoveExtensions.Encode(sourceSquare, Constants.WhiteLongCastleKingSquare, piece, isLongCastle: TRUE); } } else { - bool ise8Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e8, position, oppositeSide); + bool ise8Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e8, position, oppositeSide); if (((position.Castle & (int)CastlingRights.BK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) { movePool[localIndex++] = MoveExtensions.Encode(sourceSquare, Constants.BlackShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -211,8 +211,8 @@ internal static void GenerateCastlingMoves(ref int localIndex, Move[] movePool, && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) { movePool[localIndex++] = MoveExtensions.Encode(sourceSquare, Constants.BlackLongCastleKingSquare, piece, isLongCastle: TRUE); } @@ -398,13 +398,13 @@ private static bool IsAnyCastlingMoveValid(Position position, int offset) if (position.Side == Side.White) { - bool ise1Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e1, position, oppositeSide); + bool ise1Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e1, position, oppositeSide); if (((position.Castle & (int)CastlingRights.WK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g1, position, oppositeSide) && IsValidMove(position, MoveExtensions.Encode(sourceSquare, Constants.WhiteShortCastleKingSquare, piece, isShortCastle: TRUE))) { return true; @@ -415,8 +415,8 @@ private static bool IsAnyCastlingMoveValid(Position position, int offset) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c1, position, oppositeSide) && IsValidMove(position, MoveExtensions.Encode(sourceSquare, Constants.WhiteLongCastleKingSquare, piece, isLongCastle: TRUE))) { return true; @@ -424,13 +424,13 @@ private static bool IsAnyCastlingMoveValid(Position position, int offset) } else { - bool ise8Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e8, position, oppositeSide); + bool ise8Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e8, position, oppositeSide); if (((position.Castle & (int)CastlingRights.BK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g8, position, oppositeSide) && IsValidMove(position, MoveExtensions.Encode(sourceSquare, Constants.BlackShortCastleKingSquare, piece, isShortCastle: TRUE))) { return true; @@ -441,8 +441,8 @@ private static bool IsAnyCastlingMoveValid(Position position, int offset) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c8, position, oppositeSide) && IsValidMove(position, MoveExtensions.Encode(sourceSquare, Constants.BlackLongCastleKingSquare, piece, isLongCastle: TRUE))) { return true; @@ -619,13 +619,13 @@ internal static IEnumerable GenerateCastlingMovesForReference(Position pos { if (position.Side == Side.White) { - bool ise1Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e1, position, oppositeSide); + bool ise1Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e1, position, oppositeSide); if (((position.Castle & (int)CastlingRights.WK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g1, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.WhiteShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -635,21 +635,21 @@ internal static IEnumerable GenerateCastlingMovesForReference(Position pos && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c1) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b1) && !ise1Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d1, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d1, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c1, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.WhiteLongCastleKingSquare, piece, isLongCastle: TRUE); } } else { - bool ise8Attacked = Attacks.IsSquaredAttackedBySide((int)BoardSquare.e8, position, oppositeSide); + bool ise8Attacked = Attacks.IsSquareAttackedBySide((int)BoardSquare.e8, position, oppositeSide); if (((position.Castle & (int)CastlingRights.BK) != default) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.f8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.g8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.f8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.f8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.g8, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.BlackShortCastleKingSquare, piece, isShortCastle: TRUE); } @@ -659,8 +659,8 @@ internal static IEnumerable GenerateCastlingMovesForReference(Position pos && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.c8) && !position.OccupancyBitBoards[(int)Side.Both].GetBit(BoardSquare.b8) && !ise8Attacked - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.d8, position, oppositeSide) - && !Attacks.IsSquaredAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.d8, position, oppositeSide) + && !Attacks.IsSquareAttackedBySide((int)BoardSquare.c8, position, oppositeSide)) { yield return MoveExtensions.Encode(sourceSquare, Constants.BlackLongCastleKingSquare, piece, isLongCastle: TRUE); } diff --git a/tests/Lynx.Test/PregeneratedAttacks/IsAttackedSquareTest.cs b/tests/Lynx.Test/PregeneratedAttacks/IsAttackedSquareTest.cs index 2e2bc0009..2436aecfe 100644 --- a/tests/Lynx.Test/PregeneratedAttacks/IsAttackedSquareTest.cs +++ b/tests/Lynx.Test/PregeneratedAttacks/IsAttackedSquareTest.cs @@ -12,12 +12,12 @@ public void IsAttackedByBlackPawn() const int square = (int)BoardSquare.e4; position.PieceBitBoards[(int)Piece.p].SetBit(BoardSquare.d3); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.p].SetBit(BoardSquare.d5); - Assert.True(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.p].Clear(); } @@ -29,12 +29,12 @@ public void IsAttackedByWhitePawn() const int square = (int)BoardSquare.e4; position.PieceBitBoards[(int)Piece.P].SetBit(BoardSquare.d5); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.P].SetBit(BoardSquare.d3); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.P].Clear(); } @@ -46,12 +46,12 @@ public void IsAttackedByBlackKnight() const int square = (int)BoardSquare.e4; position.PieceBitBoards[(int)Piece.n].SetBit(BoardSquare.e7); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.n].SetBit(BoardSquare.f6); - Assert.True(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.n].Clear(); } @@ -63,12 +63,12 @@ public void IsAttackedByWhiteKnight() const int square = (int)BoardSquare.e4; position.PieceBitBoards[(int)Piece.N].SetBit(BoardSquare.d3); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.N].SetBit(BoardSquare.d2); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.N].Clear(); } @@ -80,12 +80,12 @@ public void IsAttackedByBlackBishop() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.b].SetBit(BoardSquare.b7); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.b].SetBit(BoardSquare.b8); - Assert.True(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.b].Clear(); } @@ -97,12 +97,12 @@ public void IsAttackedByWhiteBishop() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.B].SetBit(BoardSquare.a2); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.B].SetBit(BoardSquare.a1); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.B].Clear(); } @@ -114,12 +114,12 @@ public void IsAttackedByBlackRook() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.r].SetBit(BoardSquare.d7); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.r].SetBit(BoardSquare.e8); - Assert.True(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.r].Clear(); } @@ -131,12 +131,12 @@ public void IsAttackedByWhiteRook() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.R].SetBit(BoardSquare.d1); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.R].SetBit(BoardSquare.e1); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.R].Clear(); } @@ -159,16 +159,16 @@ public void IsAttackedByBlackQueen() position.PieceBitBoards[(int)Piece.q].SetBit(BoardSquare.d1); position.PieceBitBoards[(int)Piece.q].SetBit(BoardSquare.c4); position.PieceBitBoards[(int)Piece.q].SetBit(BoardSquare.g4); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.q].SetBit(BoardSquare.e1); - Assert.True(Attacks.IsSquaredAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.q].Clear(); } @@ -191,16 +191,16 @@ public void IsAttackedByWhiteQueen() position.PieceBitBoards[(int)Piece.Q].SetBit(BoardSquare.d1); position.PieceBitBoards[(int)Piece.Q].SetBit(BoardSquare.c4); position.PieceBitBoards[(int)Piece.Q].SetBit(BoardSquare.g4); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.Q].SetBit(BoardSquare.e1); - Assert.True(Attacks.IsSquaredAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square1, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square1, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square2, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square2, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.Q].Clear(); } @@ -212,12 +212,12 @@ public void IsAttackedByBlackKing() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.k].SetBit(BoardSquare.e3); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.k].SetBit(BoardSquare.e4); - Assert.True(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.k].Clear(); } @@ -229,12 +229,12 @@ public void IsAttackedByWhiteKing() const int square = (int)BoardSquare.e5; position.PieceBitBoards[(int)Piece.K].SetBit(BoardSquare.e3); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.False(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.K].SetBit(BoardSquare.e4); - Assert.False(Attacks.IsSquaredAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); - Assert.True(Attacks.IsSquaredAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.False(Attacks.IsSquareAttacked(square, Side.Black, position.PieceBitBoards, position.OccupancyBitBoards)); + Assert.True(Attacks.IsSquareAttacked(square, Side.White, position.PieceBitBoards, position.OccupancyBitBoards)); position.PieceBitBoards[(int)Piece.K].Clear(); }