Sha256: a585235703c1081fc3f1cc9864a31c5bc6b232fb414eafc6770de6867f5239a5

Contents?: true

Size: 492 Bytes

Versions: 1

Compression:

Stored size: 492 Bytes

Contents

# frozen_string_literal: true

module Checkers
  module AI
    class Tree
      attr_reader :root

      def self.build(board, depth)
        Tree.new(Node.new(board, :ai, depth))
      end

      def initialize(node)
        @root = node
      end

      def depth
        current_depth = 0
        children = @root.children

        while children.any?
          current_depth += 1
          children = children.first.children
        end

        current_depth
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
checkers-game-0.1.0 lib/checkers/ai/tree.rb