Class: Checkers::AI::Node
- Inherits:
-
Object
- Object
- Checkers::AI::Node
- Defined in:
- lib/checkers/ai/node.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#player ⇒ Object
readonly
Returns the value of attribute player.
-
#score ⇒ Object
Returns the value of attribute score.
Instance Method Summary collapse
- #children_size ⇒ Object
-
#initialize(board, player, depth = 0) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(board, player, depth = 0) ⇒ Node
Returns a new instance of Node.
9 10 11 12 13 14 |
# File 'lib/checkers/ai/node.rb', line 9 def initialize(board, player, depth = 0) @board = board @player = player @score = board.calculate_score(player: player) @children = generate_children(depth) end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
6 7 8 |
# File 'lib/checkers/ai/node.rb', line 6 def board @board end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/checkers/ai/node.rb', line 6 def children @children end |
#player ⇒ Object (readonly)
Returns the value of attribute player.
6 7 8 |
# File 'lib/checkers/ai/node.rb', line 6 def player @player end |
#score ⇒ Object
Returns the value of attribute score.
7 8 9 |
# File 'lib/checkers/ai/node.rb', line 7 def score @score end |
Instance Method Details
#children_size ⇒ Object
16 17 18 |
# File 'lib/checkers/ai/node.rb', line 16 def children_size @children.size end |