class Configuration
Attributes
game_configuration[R]
user_interface[R]
Public Class Methods
new(user_interface)
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 12 def initialize(user_interface) @user_interface = user_interface end
Public Instance Methods
beatable_ai_player(move_signature)
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 35 def beatable_ai_player(move_signature) BeatableAiPlayer.new(move_signature) end
configure_game()
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 16 def configure_game game_configuration = user_interface.get_game_configuration board = Board.new(game_configuration.fetch(:board_side_length)) rules = Rules.new(board) player_1 = player(game_configuration.fetch(:player_1)) player_2 = player(game_configuration.fetch(:player_2)) Runner.new(user_interface, rules, player_1, player_2) end
human_player(move_signature)
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 31 def human_player(move_signature) HumanPlayer.new(move_signature, user_interface) end
player(player)
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 25 def player(player) player_type = player.fetch(:type) move_signature = player.fetch(:move_signature) self.send(player_type, move_signature) end
unbeatable_ai_player(move_signature)
click to toggle source
# File lib/negamax_ttt/configuration.rb, line 39 def unbeatable_ai_player(move_signature) UnbeatableAiPlayer.new(move_signature) end