Package moe.maika.ygofm.gamedata
Class RNG
java.lang.Object
moe.maika.ygofm.gamedata.RNG
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic RNG
fromDelta
(int delta) Creates a new RNG seeded with the default value of 0x55555555 and advances the RNG state by the given number ofrand()
calls.int
getDelta()
Gets the number ofrand()
calls that have been made.int
getSeed()
Gets the current seed value.int
rand()
Generates a random number and updates internal state exactly how FM does.
-
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. UsefromDelta(int)
to simulate actual RNG advancement.- Parameters:
seed
- the initial seed valuedelta
- the number ofrand()
calls that have been made
-
RNG
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 ofrand()
calls that have been made.- Returns:
- the number of
rand()
calls
-
fromDelta
Creates a new RNG seeded with the default value of 0x55555555 and advances the RNG state by the given number ofrand()
calls.- Parameters:
delta
- how manyrand()
calls to make- Returns:
- a new RNG with the given seed value
-