import { Node } from "./node.js"; import { CreateChildNodeFunc, GetMovesFunc } from "./interfaces.js"; /** * Representation of a game tree for any turn based game with any number of players. * @typeParam GS - The object representing the state of the game * @typeParam M - The object representing a move in the game * @typeParam D - Extra data used in evaluation not suitable for storing in the gamestate */ export declare class Tree { /** * Original root when tree was created */ root: Node; /** * Active root used for the creation and searching of tree. * Set to {@link Tree.root} in constructor. */ activeRoot: Node; /** Number of nodes in tree */ nodeCount: number; /** Number of leaf nodes in tree */ leafCount: number; /** Maximum depth of current search */ protected activeDepth: number; /** Callback to get the moves for a gamestate attached to a {@link Node}. */ GetMoves: GetMovesFunc; /** Callback to create a child of a parent node using a move */ CreateChildNode: CreateChildNodeFunc; /** * * @param gamestate The current state of game, placed at root node. Can be any type * @param aim The current players aim at root node */ constructor(root: Node); /** * Generates all children of given node. Does nothing if branches and children already present * @param node Node to create children for * @returns true if nodes created, false if already existed */ protected createChildren(node: Node): boolean; /** * Creates the full game tree recursively starting from given node * @param node Parent node */ protected createTree(node: Node): void; /** * Creates the full game tree starting from {@link Tree.activeRoot}. * * Uses the {@link Tree.GetMoves} and {@link Tree.CreateChildNode} callbacks. * */ createFullTree(): void; /** * Generate all the children of node, starting from those already created * @param node Node to create children for */ protected childGen(node: Node): Generator>; }