/** * Defines the type of {@link Node}. */ export declare const enum NodeType { /** Node has no parent. Used to initialise {@link Tree} */ ROOT = 0, /** Node has parent and children */ INNER = 1, /** Node has no children. End of game condition. */ LEAF = 2 } /** * Defines the goal at the current gamestate for selecting children. * It is used to select the best of the {@link Node | Nodes} children by their corresponding value, * and therefore to assign a value to the Node. */ export declare const enum NodeAim { /** Current player will select minimum of children values */ MIN = -1, /** * Default value, error if used during normal search. */ NONE = 0, /** Current player will select maximum of children values */ MAX = 1, /** @hidden Node value is based on the mean of all the children (equal probability e.g 1 die)*/ MEAN = 2, /** @hidden Node value is based on the probability of all children (e.g 2 dice)*/ PROB = 3 } /** * Representation of a node in the game {@link Tree}. * * Holds the gamestate, a list of moves and a list of child nodes. * @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 Node { type: NodeType; gamestate: GS; move: M; data: D; aim: NodeAim; moves: Array; /** parent of this node, undefined if node is root */ parent: Node | undefined; /** List of the child nodes that link to this node */ children: Node[]; /** Index of next move to be branched */ moveInd: number; /** Value of the gamestate at this node */ value: number; /** Value used for selection by parent of this node */ inheritedValue: number; /** * Search depth when inherited value was assigned * Use to remove false selections when a-b pruning */ inheritedDepth: number; /** Minimum number of moves required until a leaf node is reached. */ pathLength: number; /** Scores used for multiplayer minimax */ scores: number[]; /** scores inherited from best child */ inheritedScores: number[]; /** Player to play turn from this node */ activePlayer: number; /** Best child as selected by {@link Node.aim}*/ child: Node | undefined; /**`true` if any children of node have been pruned, `false` if full search */ pruned: boolean; /** Count of decendant nodes */ descendantCount: number; /** * @param type Defines location within tree. See {@link NodeType}. * @param gamestate Gamestate used to create the node. Should be a clone of that used in the actual game. * @param move Move used to reach this node. For root node, use a `Null` version of the correct data type. * @param data Extra data accessible by the evaluation function. If not used, set to 0. * @param aim Defines how best child node is selected. * @param moves Reference to all the possible moves from this node. */ constructor(type: NodeType, gamestate: GS, move: M, data: D, aim?: NodeAim, moves?: Array); }