Class: OXO::Computer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color, delay: 0) ⇒ Computer



8
9
10
11
# File 'lib/oxo/computer.rb', line 8

def initialize(color, delay: 0)
  @color = color
  @delay = delay
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



6
7
8
# File 'lib/oxo/computer.rb', line 6

def color
  @color
end

Instance Method Details

#make_move(board) ⇒ Object



17
18
19
20
21
# File 'lib/oxo/computer.rb', line 17

def make_move(board)
  sleep @delay

  board.legal_moves.sample
end

#nameObject



13
14
15
# File 'lib/oxo/computer.rb', line 13

def name
  "oxo"
end