Class: Tictactoe::Ai::ABNegamax
- Inherits:
-
Object
- Object
- Tictactoe::Ai::ABNegamax
- Defined in:
- lib/tictactoe/ai/ab_negamax.rb
Constant Summary collapse
- COLOR_SELF =
1- COLOR_OPPONENT =
-1
Instance Attribute Summary collapse
-
#depth_limit ⇒ Object
readonly
Returns the value of attribute depth_limit.
-
#depth_reached_score ⇒ Object
readonly
Returns the value of attribute depth_reached_score.
Instance Method Summary collapse
- #best_nodes(tree) ⇒ Object
-
#initialize(depth_limit, depth_reached_score) ⇒ ABNegamax
constructor
A new instance of ABNegamax.
- #score(tree) ⇒ Object
Constructor Details
#initialize(depth_limit, depth_reached_score) ⇒ ABNegamax
7 8 9 10 |
# File 'lib/tictactoe/ai/ab_negamax.rb', line 7 def initialize(depth_limit, depth_reached_score) @depth_limit = depth_limit @depth_reached_score = depth_reached_score end |
Instance Attribute Details
#depth_limit ⇒ Object (readonly)
Returns the value of attribute depth_limit.
12 13 14 |
# File 'lib/tictactoe/ai/ab_negamax.rb', line 12 def depth_limit @depth_limit end |
#depth_reached_score ⇒ Object (readonly)
Returns the value of attribute depth_reached_score.
12 13 14 |
# File 'lib/tictactoe/ai/ab_negamax.rb', line 12 def depth_reached_score @depth_reached_score end |
Instance Method Details
#best_nodes(tree) ⇒ Object
18 19 20 |
# File 'lib/tictactoe/ai/ab_negamax.rb', line 18 def best_nodes(tree) negamax(tree)[:nodes] end |
#score(tree) ⇒ Object
14 15 16 |
# File 'lib/tictactoe/ai/ab_negamax.rb', line 14 def score(tree) negamax(tree)[:score] end |