Пример #1
0
        /// <summary>
        /// GetWalks - Получить прогулки
        /// Get availables walks
        /// Получить доступные прогулки
        /// </summary>
        /// <param name="moves">
        /// Walk moves will be added to the collection
        /// Ходовые ходы будут добавлены в коллекцию
        /// </param>
        /// <param name="board">
        /// the board state
        /// состояние правления
        /// </param>
        /// <param name="player">
        /// the player
        /// игрок
        /// </param>
        private static void GetWalks(ICollection <Move> moves, IBoard board, Player player)
        {
            for (int pos = 1; pos <= BoardConstants.LightSquareCount; pos++)
            {
                Piece    piece    = board[pos];
                Location location = Location.FromPosition(pos);
                int      row      = location.Row;
                int      col      = location.Col;

                if (BoardUtilities.IsOwner(player, piece))
                {
                    int forwardDirection  = (BoardUtilities.IsBlack(piece)) ? 1 : -1;
                    int backwardDirection = (!BoardUtilities.IsKing(piece)) ? 0 : (BoardUtilities.IsBlack(piece)) ? -1 : 1;

                    GetWalks(moves, board, row, col, forwardDirection, -1);
                    GetWalks(moves, board, row, col, forwardDirection, 1);

                    if (backwardDirection != 0)
                    {
                        GetWalks(moves, board, row, col, backwardDirection, -1);
                        GetWalks(moves, board, row, col, backwardDirection, 1);
                    }
                }
            }
        }
Пример #2
0
 public static void GetCaptures(ICollection <Move> moves, IBoard board, Player player)
 {
     // Get captures
     for (int pos = 1; pos <= BoardConstants.LightSquareCount; pos++)
     {
         if (BoardUtilities.IsOwner(player, board[pos]))
         {
             Location location = Location.FromPosition(pos);
             GetCaptures(moves, board.Copy(), location.Row, location.Col);
         }
     }
 }