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
6 7 8 9 |
# File 'lib/oxo/computer.rb', line 6 def initialize(color, delay: 0) @color = color @delay = delay end |
Instance Attribute Details
#color ⇒ Object (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 |
#name ⇒ Object
11 12 13 |
# File 'lib/oxo/computer.rb', line 11 def name "oxo" end |