Class: Tictactoe::Players::Computer

Inherits:
Object
  • Object
show all
Defined in:
lib/tictactoe/players/computer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mark, intelligence, chooser) ⇒ Computer



6
7
8
9
10
# File 'lib/tictactoe/players/computer.rb', line 6

def initialize(mark, intelligence, chooser)
  @intelligence = intelligence
  @chooser = chooser
  @mark = mark
end

Instance Attribute Details

#markObject (readonly)

Returns the value of attribute mark.



4
5
6
# File 'lib/tictactoe/players/computer.rb', line 4

def mark
  @mark
end

Instance Method Details

#get_move(state) ⇒ Object



12
13
14
15
# File 'lib/tictactoe/players/computer.rb', line 12

def get_move(state)
  moves = intelligence.desired_moves(state, mark)
  chooser.choose_one(moves)
end

#ready_to_move?Boolean



17
18
19
# File 'lib/tictactoe/players/computer.rb', line 17

def ready_to_move?
  true
end