コード例 #1
0
        private static void PopulatePawnMoves(
            ICollection <GameMoveData> 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 GameMove(
                    new Square(targetSquareIndex - moveOffset),
                    new Square(targetSquareIndex));

                if (isPawnPromotion)
                {
                    var promotionMoves = move.MakeAllPromotions();
                    foreach (var promotionMove in promotionMoves)
                    {
                        resultMoves.Add(new GameMoveData(promotionMove, moveFlags));
                    }
                }
                else
                {
                    resultMoves.Add(new GameMoveData(move, moveFlags));
                }
            }
        }