Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
RealDice.Die
Description
This module provides the DieGen data type and functions for using Dice to generate random positive integers via balanced tables randomized by the RealDice data or custom integer tables
Documentation
Stores a balanced table of random integers and an index pointing at the next value to return
Generates a random integer value between 1 and n via a simple table lookup
Examples
>>>
roll1d 20 (mkDieGen 143)
(12, {144, rdIntsPrime})
mkDieGen :: Int -> DieGen Source #
Creates a new DieGen with the given index and the default Int table
Examples
>>>
mkDieGen 143
{143, rdIntsPrime}
mkDieGenCustom :: Int -> [Int] -> DieGen Source #
Creates a new DieGen with the given index and Int table
Defaults to the RealDice balanced table of random integers if an empty list is given
Examples
>>>
mkDieGenCustom 143 [1, 0, 4, 3, 2]
{143, [1, 0, 4, 3, 2]}>>>
mkDieGenCustom 143 []
{143, rdIntsPrime}