Class XORShiftRandom

java.lang.Object
java.util.Random
net.demilich.metastone.game.logic.XORShiftRandom
All Implemented Interfaces:
Serializable, Cloneable, RandomGenerator

public class XORShiftRandom extends Random implements Serializable, Cloneable
A non-thread-safe random number generator that uses the "XOR Shift" pattern to produce numbers.

This instance is serializable and cloneable. It can be used to reproducibly create sequences of random numbers.

See Also:
  • Constructor Details

    • XORShiftRandom

      public XORShiftRandom(long state)
  • Method Details

    • createSeed

      public static long createSeed()
      Creates a valid, highly probably unique seed.
      Returns:
      A Long seed that can be passed to a constructor of Random
    • next

      protected int next(int nbits)
      Overrides:
      next in class Random
    • clone

      public XORShiftRandom clone()
      Overrides:
      clone in class Object
    • getState

      public long getState()
    • setState

      public XORShiftRandom setState(long state)