Class RNG

java.lang.Object
moe.maika.ygofm.gamedata.RNG

public class RNG extends Object
An implementation of the RNG used in Forbidden Memories. The constructors of this class are not particularly useful to the end user. Consider using the SeedSearch class to explore seeds for RNG manipulation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RNG()
    Creates a new RNG with the default seed value (0x55555555) and delta of 0.
    RNG(int seed, int delta)
    Creates a new RNG with the given seed and delta values.
    RNG(RNG toCopy)
    Creates a new RNG with the same seed and delta as the given RNG.
  • Method Summary

    Modifier and Type
    Method
    Description
    static RNG
    fromDelta(int delta)
    Creates a new RNG seeded with the default value of 0x55555555 and advances the RNG state by the given number of rand() calls.
    int
    Gets the number of rand() calls that have been made.
    int
    Gets the current seed value.
    int
    Generates a random number and updates internal state exactly how FM does.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RNG

      public RNG()
      Creates a new RNG with the default seed value (0x55555555) and delta of 0.
    • RNG

      public RNG(int seed, int delta)
      Creates a new RNG with the given seed and delta values. This constructor does not actually advance the RNG state and simply initializes its internal state to the given values. Use fromDelta(int) to simulate actual RNG advancement.
      Parameters:
      seed - the initial seed value
      delta - the number of rand() calls that have been made
    • RNG

      public RNG(RNG toCopy)
      Creates a new RNG with the same seed and delta as the given RNG.
      Parameters:
      toCopy - the RNG to copy
  • Method Details

    • rand

      public int rand()
      Generates a random number and updates internal state exactly how FM does.
      Returns:
      a random number
    • getSeed

      public int getSeed()
      Gets the current seed value.
      Returns:
      the current seed value
    • getDelta

      public int getDelta()
      Gets the number of rand() calls that have been made.
      Returns:
      the number of rand() calls
    • fromDelta

      public static RNG fromDelta(int delta)
      Creates a new RNG seeded with the default value of 0x55555555 and advances the RNG state by the given number of rand() calls.
      Parameters:
      delta - how many rand() calls to make
      Returns:
      a new RNG with the given seed value