class JustShogi::OuBase
Ou Base ¶ ↑
The piece that moves 1 space away.
Public Instance Methods
base_destinations(square, game_state)
click to toggle source
All the squares that the king could move to normally.
@param [Square] square
the origin square.
@param [GameState] game_state
the current game state.
@return [SquareSet]
# File lib/just_shogi/pieces/ou_base.rb, line 32 def base_destinations(square, game_state) game_state.squares.at_range(square, 1).unoccupied_or_occupied_by_opponent(player_number) end
checked_squares(square, game_state)
click to toggle source
All the squares that the king could not move to because of check.
@param [Square] square
the origin square.
@param [GameState] game_state
the current game state.
@return [SquareSet]
# File lib/just_shogi/pieces/ou_base.rb, line 45 def checked_squares(square, game_state) dup = game_state.clone # set the piece to nil to handle case where a piece threatens squares behind this piece. dup.squares.find_ou_for_player(player_number).piece = nil dup.squares.threatened_by(opponent, dup) end
destinations(square, game_state)
click to toggle source
All the squares that the piece can move to and/or capture.
@param [Square] square
the origin square.
@param [GameState] game_state
the current game state.
@return [SquareSet]
# File lib/just_shogi/pieces/ou_base.rb, line 19 def destinations(square, game_state) base_destinations(square, game_state) # - checked_squares(square, game_state) - shared_king_squares(game_state) end