Class: Tictactoe::Players::Computer
- Inherits:
-
Object
- Object
- Tictactoe::Players::Computer
- Defined in:
- lib/tictactoe/players/computer.rb
Instance Attribute Summary collapse
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
Instance Method Summary collapse
- #get_move(state) ⇒ Object
-
#initialize(mark, intelligence, chooser) ⇒ Computer
constructor
A new instance of Computer.
- #ready_to_move? ⇒ Boolean
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
#mark ⇒ Object (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 |