Sha256: 7670936db48506ed861b184b0e90fabb762e1a9fec6b14cb2ce250d16ef310a4
Contents?: true
Size: 710 Bytes
Versions: 1
Compression:
Stored size: 710 Bytes
Contents
# frozen_string_literal: true module Checkers module AI module Engine class Base attr_reader :tree_depth def initialize(tree_depth = 3) @tree_depth = tree_depth end 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 def max(a, b) a > b ? a : b end def min(a, b) a < b ? a : b end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
checkers-game-0.1.0 | lib/checkers/ai/engine/base.rb |