Class VariantAGP
- All Implemented Interfaces:
IGamePosition<VariantAGP>
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record holding the information provided toGeneratorfunctions for determining the bounds of a generated child node.static classA class that stores the settings for aVariantAGPtree. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BigIntegerName of this node which denotes its position in the tree.final VariantAGP.SettingsTheVariantAGP.Settingsobject which characterises the tree this node is from. -
Constructor Summary
ConstructorsConstructorDescriptionVariantAGP(boolean adversarial, long initial_seed, int maxWidth, Generator.Width width, long initial_range, Generator.Bounds distribution, double growth_factor, double force_relevance_chance) Gives the root node of the tree characterised by the given parameters.VariantAGP(VariantAGP.Settings settings) Gives the root node of the tree characterised by the givenVariantAGP.Settingsobject. -
Method Summary
Modifier and TypeMethodDescriptionlonghash()This method should be implemented with a hash that still remains different from similar states if a mask is applied to the hash.doubleThe lower-bound value is the lower bound on the game-theoretical mini-max value of this game position.booleannext()parent()toString()doubleThe upper-bound value is the upper bound on the game-theoretical mini-max value of this game position.
-
Field Details
-
settings
TheVariantAGP.Settingsobject which characterises the tree this node is from. -
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 named0.For example, a node named
100in a tree withVariantAGP.Settings.maxWidth== 5has children named501, 502, 503, 504,and505.
-
-
Constructor Details
-
VariantAGP
Gives the root node of the tree characterised by the givenVariantAGP.Settingsobject.- Parameters:
settings- theVariantAGP.Settingsobject which characterises the tree
-
VariantAGP
public VariantAGP(boolean adversarial, long initial_seed, int maxWidth, Generator.Width width, long initial_range, Generator.Bounds distribution, double growth_factor, double force_relevance_chance) Gives the root node of the tree characterised by the given parameters.- Parameters:
adversarial-VariantAGP.Settings.adversarial, denotes whether this tree is an adversarial tree or notinitial_seed-VariantAGP.Settings.initial_seed, denotes a unique tree generation sequencemaxWidth-VariantAGP.Settings.maxWidth, maximum branching factor of the tree, has to be greater than or equal to 2width-VariantAGP.Settings.width, a generator for providing the number of children at each nodeinitial_range-VariantAGP.Settings.initial_range, has to be greater than 0distribution-VariantAGP.Settings.distribution, a generator providing the bounds of children at each nodegrowth_factor-VariantAGP.Settings.growth_factor, has to be greater than 0force_relevance_chance-VariantAGP.Settings.force_relevance_chance, has to be greater than or equal to 0 and smaller than or equal to 1
-
-
Method Details
-
next
- Specified by:
nextin interfaceIGamePosition<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:IGamePositionThe 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:
upperboundin interfaceIGamePosition<VariantAGP>- Returns:
- The upper-bound value for this game position
-
lowerbound
public double lowerbound()Description copied from interface:IGamePositionThe 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:
lowerboundin interfaceIGamePosition<VariantAGP>- Returns:
- The lower-bound value for this game position
-
maximising
public boolean maximising()- Specified by:
maximisingin interfaceIGamePosition<VariantAGP>- Returns:
trueif the current player-to-move is maximising the score, orfalseif it is minimising the score.
-
hash
public long hash()Description copied from interface:IGamePositionThis 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:
hashin interfaceIGamePosition<VariantAGP>- Returns:
- a 64-bit zobrist hash or other kind of game-state hash that represents this state.
-
parent
- Returns:
- The parent of this node. This is required for random access of
VariantAGPobjects.
-
toString
-