Class: PerfectComputer
- Inherits:
-
Object
- Object
- PerfectComputer
- Defined in:
- lib/perfect_computer.rb
Constant Summary collapse
- EARLIEST_CHANCE_TO_WIN =
11- STARTING_DEPTH =
0- MAXIMUM_DEPTH_TO_CHECK =
6- MAXIMUM_SCORE =
1000
Instance Attribute Summary collapse
-
#marker ⇒ Object
readonly
Returns the value of attribute marker.
Instance Method Summary collapse
- #choose_space(board) ⇒ Object
-
#initialize(marker) ⇒ PerfectComputer
constructor
A new instance of PerfectComputer.
Constructor Details
#initialize(marker) ⇒ PerfectComputer
Returns a new instance of PerfectComputer.
12 13 14 |
# File 'lib/perfect_computer.rb', line 12 def initialize(marker) @marker = marker end |
Instance Attribute Details
#marker ⇒ Object (readonly)
Returns the value of attribute marker.
5 6 7 |
# File 'lib/perfect_computer.rb', line 5 def marker @marker end |
Instance Method Details
#choose_space(board) ⇒ Object
16 17 18 19 20 |
# File 'lib/perfect_computer.rb', line 16 def choose_space(board) @best_score = {} negamax(board) @best_score.size > EARLIEST_CHANCE_TO_WIN ? choose_random_space(board) : best_space_to_pick end |