Documentation
¶
Overview ¶
Package random is used instead of the math/rand or math/rand/v2 packages when a random number is required inside the emulation.
The Random type is an instance of the standard rand.Rand type and in addition, provides the Rewindable() function.
The Rewindable() function returns numbers based on the current television coordinates. The number will always return the same number for the same coordinates. As such it is compatible with the emulator's rewind system.
If predictable random numbers are required from the Rewindable() function then set ZeroSeed to true. This can be enabled and disabled at any time. Predicable random numbers is useful for testing purposes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Random ¶
type Random struct {
*rand.Rand
// causes the Rewindable() function to use only tv coordinates for the random number. useful for
// testing purposes where predictable random numbers are required
ZeroSeed bool
// contains filtered or unexported fields
}
Random is a random number generator that is sensitive to time within the emulation.
func (*Random) Rewindable ¶
Rewindable generates a random number very quickly and based on the current television coordinates. It's only really suitable for use in a running emulation.
It does however have the property of being predictable during a sesssion and so is compatible with the rewind system.
The returned number will between zero and value given in the n parameter.
type TV ¶
type TV interface {
GetCoords() coords.TelevisionCoords
}
TV defines the television functions required by the Random type.