Class VariantAGP

java.lang.Object
gametree.VariantAGP
All Implemented Interfaces:
IGamePosition<VariantAGP>

public class VariantAGP extends Object implements IGamePosition<VariantAGP>
Represents a game position in a variant artificial game tree. This class models both adversarial and non-adversarial game trees with a variable branching factor and integer valued nodes. Each node is uniquely identified by its name, which is derived from its position in the tree.

The tree is characterised by a VariantAGP.Settings object, which defines parameters such as the maximum branching factor (VariantAGP.Settings.maxWidth), growth factor (VariantAGP.Settings.growth_factor), and initial range (VariantAGP.Settings.initial_range). Nodes are generated deterministically based on these settings and a pseudo-random number generator seed, ensuring reproducibility of the tree structure.

This class is designed for use in scenarios where deterministic and reproducible game trees are required, such as in testing game tree search algorithms or simulations.

Based on ArtificialGamePosition, this class can be used to model the same trees, but is a generalisation which can generate more complex trees as well. The number of children at each node can be determined by a function, which allows for more complexity and additional rules for tree structure. Additionally, the bounds of generated nodes are also provided by a function, which also allows for more flexibility, complexity, and additional rules. See the Generator class for various examples of generators that can be used, or make your own for more flexibility.

Version:
1.0
Author:
Pascal Anema
  • Field Details

    • settings

      public final VariantAGP.Settings settings
      The VariantAGP.Settings object which characterises the tree this node is from.
    • name

      public final BigInteger name
      Name of this node which denotes its position in the tree. Nodes are named after their parent node and their position relative to their sibling nodes. The root node is always named 0.

      For example, a node named 100 in a tree with VariantAGP.Settings.maxWidth == 5 has children named 501, 502, 503, 504, and 505.

  • Constructor Details

  • Method Details

    • next

      public List<VariantAGP> next()
      Specified by:
      next in interface IGamePosition<VariantAGP>
      Returns:
      The collection of game positions directly reachable by moves from the current player to move in this game position.
    • upperbound

      public double upperbound()
      Description copied from interface: IGamePosition
      The upper-bound value is the upper bound on the game-theoretical mini-max value of this game position.

      For the maximising player this is the best value achievable under perfect play.

      For the minimising player this is the worst-case value achievable under perfect play.

      Specified by:
      upperbound in interface IGamePosition<VariantAGP>
      Returns:
      The upper-bound value for this game position
    • lowerbound

      public double lowerbound()
      Description copied from interface: IGamePosition
      The lower-bound value is the lower bound on the game-theoretical mini-max value of this game position.

      For the maximising player this is the minimum value that can be guaranteed under perfect play.

      For the minimising player this is the best value achievable under perfect play.

      Specified by:
      lowerbound in interface IGamePosition<VariantAGP>
      Returns:
      The lower-bound value for this game position
    • maximising

      public boolean maximising()
      Specified by:
      maximising in interface IGamePosition<VariantAGP>
      Returns:
      true if the current player-to-move is maximising the score, or false if it is minimising the score.
    • hash

      public long hash()
      Description copied from interface: IGamePosition
      This method should be implemented with a hash that still remains different from similar states if a mask is applied to the hash. Commonly, a transposition table implementation may only use the first 20 to 26 bits of the hash to use as an index, so the hash should try to minimise collisions regardless of how many bits are included for the index.
      Specified by:
      hash in interface IGamePosition<VariantAGP>
      Returns:
      a 64-bit zobrist hash or other kind of game-state hash that represents this state.
    • parent

      public VariantAGP parent()
      Returns:
      The parent of this node. This is required for random access of VariantAGP objects.
    • toString

      public String toString()
      Overrides:
      toString in class Object