Class: CpuPlayer
Overview
require ‘player’
Instance Attribute Summary collapse
-
#ai ⇒ Object
Returns the value of attribute ai.
Attributes inherited from Player
Instance Method Summary collapse
-
#initialize(token, ai) ⇒ CpuPlayer
constructor
A new instance of CpuPlayer.
- #perform_move(game_state, move_param = nil) ⇒ Object
Constructor Details
#initialize(token, ai) ⇒ CpuPlayer
Returns a new instance of CpuPlayer.
6 7 8 9 |
# File 'lib/cpu_player.rb', line 6 def initialize(token, ai) @token = token @ai = ai end |
Instance Attribute Details
#ai ⇒ Object
Returns the value of attribute ai.
4 5 6 |
# File 'lib/cpu_player.rb', line 4 def ai @ai end |
Instance Method Details
#perform_move(game_state, move_param = nil) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/cpu_player.rb', line 11 def perform_move(game_state, move_param = nil) move = @ai.calculate_move(game_state.board, self) # board.add_piece(@token, move) game_state.update(move) end |