class Checkers::AI::Engine::Base
Attributes
tree_depth[R]
Public Class Methods
new(tree_depth = 3)
click to toggle source
# File lib/checkers/ai/engine/base.rb, line 9 def initialize(tree_depth = 3) @tree_depth = tree_depth end
Public Instance Methods
next_board(board) { |decision_tree_root, tree_depth| ... }
click to toggle source
# File lib/checkers/ai/engine/base.rb, line 13 def next_board(board) if board.jumped Board.generate_boards(board, :ai).first else decision_tree_root = Tree.build(board, tree_depth).root yield(decision_tree_root, tree_depth) decision_tree_root.children.max_by(&:score).board end end
Protected Instance Methods
max(a, b)
click to toggle source
# File lib/checkers/ai/engine/base.rb, line 27 def max(a, b) a > b ? a : b end
min(a, b)
click to toggle source
# File lib/checkers/ai/engine/base.rb, line 31 def min(a, b) a < b ? a : b end