Class: CpuPlayer

Inherits:
Player show all
Defined in:
lib/cpu_player.rb

Overview

require ‘player’

Instance Attribute Summary collapse

Attributes inherited from Player

#token

Instance Method Summary collapse

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

#aiObject

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