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



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

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

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



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

def color
  @color
end

Instance Method Details

#make_move(board) ⇒ Object



15
16
17
18
19
# File 'lib/oxo/computer.rb', line 15

def make_move(board)
  sleep @delay

  board.legal_moves.sample
end

#nameObject



11
12
13
# File 'lib/oxo/computer.rb', line 11

def name
  "oxo"
end