Class Tree<GS, M, D>

Representation of a game tree for any turn based game with any number of players.

Type Parameters

  • GS

    The object representing the state of the game

  • M

    The object representing a move in the game

  • D

    Extra data used in evaluation not suitable for storing in the gamestate

Hierarchy

  • Tree

Constructors

  • Type Parameters

    • GS

    • M

    • D

    Parameters

    • root: Node<GS, M, D>

    Returns Tree<GS, M, D>

Properties

root: Node<GS, M, D>

Original root when tree was created

activeRoot: Node<GS, M, D>

Active root used for the creation and searching of tree. Set to root in constructor.

nodeCount: number = 0

Number of nodes in tree

leafCount: number = 0

Number of leaf nodes in tree

activeDepth: number = 0

Maximum depth of current search

GetMoves: GetMovesFunc<GS, M, D> = ...

Callback to get the moves for a gamestate attached to a Node.

CreateChildNode: CreateChildNodeFunc<GS, M, D> = ...

Callback to create a child of a parent node using a move

Methods

  • Generates all children of given node. Does nothing if branches and children already present

    Returns

    true if nodes created, false if already existed

    Parameters

    • node: Node<GS, M, D>

      Node to create children for

    Returns boolean

  • Creates the full game tree recursively starting from given node

    Parameters

    • node: Node<GS, M, D>

      Parent node

    Returns void

  • Generate all the children of node, starting from those already created

    Parameters

    • node: Node<GS, M, D>

      Node to create children for

    Returns Generator<Node<GS, M, D>, any, unknown>

Generated using TypeDoc