Class ArtificialGamePosition
- All Implemented Interfaces:
IGamePosition<ArtificialGamePosition>,Serializable
name, which is
derived from its position in the tree.
The tree is characterised by a ArtificialGamePosition.Settings object, which defines parameters such as
the branching factor (ArtificialGamePosition.Settings.width), growth factor (ArtificialGamePosition.Settings.growth_factor), and initial
range (ArtificialGamePosition.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.
- Version:
- 1.0
- Author:
- Pascal Anema
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA class that stores the settings for aArtificialGamePositiontree. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BigIntegerName of this node which denotes its position in the tree.TheArtificialGamePosition.Settingsobject which characterises the tree this node is from. -
Constructor Summary
ConstructorsConstructorDescriptionArtificialGamePosition(boolean adversarial, long initial_seed, int width, long initial_range, int num_alts, double growth_factor, double force_relevance_chance) Gives the root node of the tree characterised by the given parameters.Gives the root node of the tree characterised by the givenArtificialGamePosition.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.booleanstatic longmaxV(long[] values) Finds the maximum value of an arraystatic longminV(long[] values) Finds the minimum value of an arraynext()parent()static longsafeSum(long x, long y) Sums two values such that the result does not 'overflow' from positive to negative or vice versa.toString()doubleThe upper-bound value is the upper bound on the game-theoretical mini-max value of this game position.
-
Field Details
-
settings
TheArtificialGamePosition.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 withArtificialGamePosition.Settings.width== 5has children named501, 502, 503, 504,and505.
-
-
Constructor Details
-
ArtificialGamePosition
Gives the root node of the tree characterised by the givenArtificialGamePosition.Settingsobject.- Parameters:
settings- theArtificialGamePosition.Settingsobject which characterises the tree
-
ArtificialGamePosition
public ArtificialGamePosition(boolean adversarial, long initial_seed, int width, long initial_range, int num_alts, double growth_factor, double force_relevance_chance) Gives the root node of the tree characterised by the given parameters.- Parameters:
adversarial-ArtificialGamePosition.Settings.adversarial, denotes whether this tree is an adversarial tree or notinitial_seed-ArtificialGamePosition.Settings.initial_seed, denotes a unique tree generation sequencewidth-ArtificialGamePosition.Settings.width, has to be greater than or equal to 2initial_range-ArtificialGamePosition.Settings.initial_range, has to be greater than 0num_alts-ArtificialGamePosition.Settings.num_alts, has to be greater than or equal to 2growth_factor-ArtificialGamePosition.Settings.growth_factor, has to be greater than 0force_relevance_chance-ArtificialGamePosition.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<ArtificialGamePosition>- 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<ArtificialGamePosition>- 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<ArtificialGamePosition>- Returns:
- The lower-bound value for this game position
-
maximising
public boolean maximising()- Specified by:
maximisingin interfaceIGamePosition<ArtificialGamePosition>- 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<ArtificialGamePosition>- 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
ArtificialGamePositionobjects.
-
minV
public static long minV(long[] values) Finds the minimum value of an array- Parameters:
values- the array of values to search- Returns:
- the minimum value of the provided
valuesarray.
-
maxV
public static long maxV(long[] values) Finds the maximum value of an array- Parameters:
values- the array of values to search- Returns:
- the maximum value of the provided
valuesarray.
-
safeSum
public static long safeSum(long x, long y) Sums two values such that the result does not 'overflow' from positive to negative or vice versa.- Parameters:
x- some valuey- another value- Returns:
x + yunless overflow or underflow occurs, in which caseLong.MAX_VALUEorLong.MIN_VALUErespectively.
-
toString
-