Skip to content
Swifter edited this page Oct 19, 2024 · 1 revision

Randomizing

  • rm.random takes a minimum and maximum number and returns a random number in between.
rm.random(0, 3) // something between 0 and 3
  • rm.seededRandom generates a unique sequence of random numbers from a seed. It returns a function which generates the next number in this sequence every time it's called with a minimum and maximum.
const mySeededRandom = rm.seededRandom(2)

mySeededRandom(0, 2) // 1.4685...
mySeededRandom(3, 4) // 3.7342...
mySeededRandom(2, 5) // 4.2027...

Hashing

Hashing is the process of taking some input value and generating an output that is seemingly random, but uniquely tied to the input.

  • rm.hashInteger takes in some integer number and hashes it into a number between 0 and 1.
rm.hashInteger(3) // 0.7202..
rm.hashInteger(4) // 0.9236..
  • rm.hashString takes in a string and hashes it into a number between 0 and 1.
rm.hashString('my hash') // 0.6337...

Clone this wiki locally