datastrophic-games / dice

Immutable Random Numbers Generator

Version Matrix

🎲 Dice – an immutable RNG 🎲

Because rollInt > nextInt.

🎲 Usage 🎲

sbt:

"games.datastrophic" %% "dice" % "0.2.2",

An example:

val (newDice, randomInt) = dice.rollInt(N)

This works well with State:

for {

  amount <- State[Dice, Int](_.rollInt(math.max(1, math.pow(value, 1d / 9).toInt)))
  
  spread <- State[Dice, ValueSpread](_.unsafeRollOneOf(List(SpreadEqually, SpreadStepOne, SpreadSquare)))
  
  bar <- foo(amount, spread)
  
} yield bar

🎲 Status 🎲

WIP, but used in our game: Blackout Age for almost every random thing there.

🎲 PCG – Permuted Congruential Generator 🎲

Internal RNG is based on The PCG Paper, implementation is adapted from PCG-Java.

Watch this great lecture of the paper's author to learn how that's different from java.util.Random.