Class: Engine
- Inherits:
-
Object
- Object
- Engine
- Includes:
- AlgebraicConversion, Display, HumanInputValidation
- Defined in:
- lib/sapphire-chess/engine.rb
Constant Summary
Constants included from AlgebraicConversion
AlgebraicConversion::ALGEBRAIC_NOTATION_FORMAT, AlgebraicConversion::CASTLING_INPUT_FORMAT, AlgebraicConversion::LETTER_RESET_VALUE
Instance Method Summary collapse
-
#initialize ⇒ Engine
constructor
A new instance of Engine.
- #play ⇒ Object
Methods included from HumanInputValidation
#convert_player_input, #double_input?, #prompt_color, #prompt_difficulty, #prompt_game_mode, #prompt_move, #prompt_target_square, #single_input?, #valid_castling?, #valid_color?, #valid_difficulty?, #valid_piece_selection?, #valid_player_input?, #valid_target_square?
Methods included from Display
#clear_screen, #display_check, #display_checkmate, #display_difficulty_settings, #display_game_modes, #display_graphic_score, #display_last_moves, #display_material_score, #display_move, #display_move_message, #display_player_turn, #display_turn_number, #display_welcome, #display_winner, #new_line, #piece_score, #piece_symbol
Constructor Details
#initialize ⇒ Engine
Returns a new instance of Engine.
18 19 20 21 22 |
# File 'lib/sapphire-chess/engine.rb', line 18 def initialize @board = Board.initialize_board @renderer = BoardRenderer.new(board) @turn_number = 1 end |
Instance Method Details
#play ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sapphire-chess/engine.rb', line 24 def play display_welcome define_players @current_player = white_player board.add_players!(white_player, black_player) if computer_plays? set_difficulty board.set_game_difficulty end main_game_loop end_game end |