Class: ComputerPlayer

Inherits:
Player
  • Object
show all
Defined in:
lib/ang_ttt_gem/computer_player.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Player

#mark, #set_mark

Constructor Details

#initialize(mark) ⇒ ComputerPlayer

Returns a new instance of ComputerPlayer.



9
10
11
# File 'lib/ang_ttt_gem/computer_player.rb', line 9

def initialize(mark)
  self.set_mark(mark)
end

Instance Attribute Details

#aiObject

Returns the value of attribute ai.



7
8
9
# File 'lib/ang_ttt_gem/computer_player.rb', line 7

def ai
  @ai
end

Instance Method Details

#get_move(board) ⇒ Object



13
14
15
16
# File 'lib/ang_ttt_gem/computer_player.rb', line 13

def get_move(board)
  ai = Ai.new(self, board)
  cell_number = ai.find_best_move
end