Пример #1
0
        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));
                }
            }
        }
Пример #2
0
        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));
            }
        }
Пример #3
0
 public void TestIsKingCastling(GameMoveFlags value, bool expectedResult)
 {
     Assert.That(value.IsKingCastling(), Is.EqualTo(expectedResult));
 }
Пример #4
0
 public void TestIsAnyCapture(GameMoveFlags value, bool expectedResult)
 {
     Assert.That(value.IsAnyCapture(), Is.EqualTo(expectedResult));
 }
Пример #5
0
 public void TestIsPawnPromotion(GameMoveFlags value, bool expectedResult)
 {
     Assert.That(value.IsPawnPromotion(), Is.EqualTo(expectedResult));
 }
Пример #6
0
 public void TestIsAnySet(GameMoveFlags value, GameMoveFlags flagsToCheck, bool expectedResult)
 {
     Assert.That(value.IsAnySet(flagsToCheck), Is.EqualTo(expectedResult));
 }
Пример #7
0
 internal GameMoveData2(GameMove2 move, GameMoveFlags moveFlags)
 {
     Move      = move;
     MoveFlags = moveFlags;
 }
Пример #8
0
 internal GameMoveData([NotNull] GameMove move, GameMoveFlags moveFlags)
 {
     Move      = move ?? throw new ArgumentNullException(nameof(move));
     MoveFlags = moveFlags;
 }
Пример #9
0
 public static bool IsQuietMove(GameMoveFlags moveFlags)
 {
     return(!moveFlags.IsAnyCapture() && !moveFlags.IsPawnPromotion());
 }
Пример #10
0
 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);