private static void PopulatePawnMoves( ICollection <GameMoveData2> resultMoves, Bitboard destinationsBitboard, int moveOffset, GameMoveFlags moveFlags) { var isPawnPromotion = (moveFlags & GameMoveFlags.IsPawnPromotion) != 0; while (destinationsBitboard.IsAny) { var targetSquareIndex = Bitboard.PopFirstSquareIndex(ref destinationsBitboard); var move = new GameMove2( new Square(targetSquareIndex - moveOffset), new Square(targetSquareIndex)); if (isPawnPromotion) { var promotionMoves = move.MakeAllPromotions(); foreach (var promotionMove in promotionMoves) { resultMoves.Add(new GameMoveData2(promotionMove, moveFlags)); } } else { resultMoves.Add(new GameMoveData2(move, moveFlags)); } } }
private static void PopulateSimpleMoves( ICollection <GameMoveData2> resultMoves, Square sourceSquare, Bitboard destinationsBitboard, GameMoveFlags moveFlags) { while (destinationsBitboard.IsAny) { var targetSquareIndex = Bitboard.PopFirstSquareIndex(ref destinationsBitboard); var move = new GameMove2(sourceSquare, new Square(targetSquareIndex)); resultMoves.Add(new GameMoveData2(move, moveFlags)); } }
public void TestIsKingCastling(GameMoveFlags value, bool expectedResult) { Assert.That(value.IsKingCastling(), Is.EqualTo(expectedResult)); }
public void TestIsAnyCapture(GameMoveFlags value, bool expectedResult) { Assert.That(value.IsAnyCapture(), Is.EqualTo(expectedResult)); }
public void TestIsPawnPromotion(GameMoveFlags value, bool expectedResult) { Assert.That(value.IsPawnPromotion(), Is.EqualTo(expectedResult)); }
public void TestIsAnySet(GameMoveFlags value, GameMoveFlags flagsToCheck, bool expectedResult) { Assert.That(value.IsAnySet(flagsToCheck), Is.EqualTo(expectedResult)); }
internal GameMoveData2(GameMove2 move, GameMoveFlags moveFlags) { Move = move; MoveFlags = moveFlags; }
internal GameMoveData([NotNull] GameMove move, GameMoveFlags moveFlags) { Move = move ?? throw new ArgumentNullException(nameof(move)); MoveFlags = moveFlags; }
public static bool IsQuietMove(GameMoveFlags moveFlags) { return(!moveFlags.IsAnyCapture() && !moveFlags.IsPawnPromotion()); }
public OrderedMove([NotNull] GameMove move, GameMoveFlags moveFlags) { Move = move ?? throw new ArgumentNullException(nameof(move)); MoveFlags = moveFlags; }
public static bool IsAnySet(this GameMoveFlags value, GameMoveFlags flags) => (value & flags) != 0;
public static bool IsKingCastling(this GameMoveFlags value) => value.IsAnySet(GameMoveFlags.IsKingCastling);
public static bool IsAnyCapture(this GameMoveFlags value) => value.IsAnySet(GameMoveFlags.IsRegularCapture | GameMoveFlags.IsEnPassantCapture);
public static bool IsPawnPromotion(this GameMoveFlags value) => value.IsAnySet(GameMoveFlags.IsPawnPromotion);