Class Rng

java.lang.Object
com.codename1.gaming.platformer.Rng

public final class Rng extends Object

SplitMix64, the simulation's only source of randomness.

Seeded from the level and the run, it yields the same sequence on every runtime, so an enemy that picks a random patrol turn picks the same one in a replay.

  • Constructor Details

    • Rng

      public Rng(long seed)

      Creates a generator.

      Parameters
      • seed: the seed
  • Method Details

    • nextLong

      public long nextLong()

      The next 64 random bits.

      Returns

      a random long

    • nextInt

      public int nextInt(int bound)

      A random whole number in [0, bound).

      Parameters
      • bound: the exclusive upper bound, positive
      Returns

      a random whole number

    • state

      public long state()

      The generator's state, folded into the world hash.

      Returns

      the internal state