Class ArtificialGamePosition

java.lang.Object
gametree.ArtificialGamePosition
All Implemented Interfaces:
IGamePosition<ArtificialGamePosition>, Serializable

public class ArtificialGamePosition extends Object implements IGamePosition<ArtificialGamePosition>, Serializable
Represents a game position in an artificial game tree. This class models both adversarial and non-adversarial game trees with a fixed 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 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:
  • Field Details

  • Constructor Details

  • Method Details

    • next

      public List<ArtificialGamePosition> next()
      Specified by:
      next in interface IGamePosition<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: 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<ArtificialGamePosition>
      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<ArtificialGamePosition>
      Returns:
      The lower-bound value for this game position
    • maximising

      public boolean maximising()
      Specified by:
      maximising in interface IGamePosition<ArtificialGamePosition>
      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<ArtificialGamePosition>
      Returns:
      a 64-bit zobrist hash or other kind of game-state hash that represents this state.
    • parent

      public ArtificialGamePosition parent()
      Returns:
      The parent of this node. This is required for random access of ArtificialGamePosition objects.
    • 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 values array.
    • 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 values array.
    • 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 value
      y - another value
      Returns:
      x + y unless overflow or underflow occurs, in which case Long.MAX_VALUE or Long.MIN_VALUE respectively.
    • toString

      public String toString()
      Overrides:
      toString in class Object