Class: OXO::Computer
- Inherits:
-
Object
- Object
- OXO::Computer
- Defined in:
- lib/oxo/computer.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Instance Method Summary collapse
-
#initialize(color, delay: 0) ⇒ Computer
constructor
A new instance of Computer.
- #make_move(board) ⇒ Object
- #name ⇒ Object
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
#color ⇒ Object (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 |
#name ⇒ Object
13 14 15 |
# File 'lib/oxo/computer.rb', line 13 def name "oxo" end |