Class: XO::AI::Player
- Inherits:
-
Object
- Object
- XO::AI::Player
- Defined in:
- lib/xo/ai/player.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #best_score(next_grids_scores) ⇒ Object
-
#initialize(token) ⇒ Player
constructor
A new instance of Player.
- #loser_value ⇒ Object
- #non_terminal_score(next_grids, scores) ⇒ Object
- #squashed_value ⇒ Object
- #terminal_score(outcome) ⇒ Object
- #winner_value ⇒ Object
Constructor Details
#initialize(token) ⇒ Player
Returns a new instance of Player.
9 10 11 |
# File 'lib/xo/ai/player.rb', line 9 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/xo/ai/player.rb', line 7 def token @token end |
Instance Method Details
#best_score(next_grids_scores) ⇒ Object
21 22 23 |
# File 'lib/xo/ai/player.rb', line 21 def best_score(next_grids_scores) raise NotImplementedError end |
#loser_value ⇒ Object
29 30 31 |
# File 'lib/xo/ai/player.rb', line 29 def loser_value raise NotImplementedError end |
#non_terminal_score(next_grids, scores) ⇒ Object
17 18 19 |
# File 'lib/xo/ai/player.rb', line 17 def non_terminal_score(next_grids, scores) best_score(compute_next_grids_scores(next_grids, scores)) end |
#squashed_value ⇒ Object
33 34 35 |
# File 'lib/xo/ai/player.rb', line 33 def squashed_value 0 end |
#terminal_score(outcome) ⇒ Object
13 14 15 |
# File 'lib/xo/ai/player.rb', line 13 def terminal_score(outcome) send("#{outcome}_value") end |
#winner_value ⇒ Object
25 26 27 |
# File 'lib/xo/ai/player.rb', line 25 def winner_value raise NotImplementedError end |