real-dice-0.1.0.5: Random number generation based on physical media touched by humans
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

Synopsis

Documentation

data DieGen Source #

Stores a balanced table of random integers and an index pointing at the next value to return

roll1d Source #

Arguments

:: Int

The number of sides on the die

-> DieGen

The DieGen to use

-> (Int, DieGen) 

Generates a random integer value between 1 and n via a simple table lookup

Examples

Expand
>>> 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

Expand
>>> 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

Expand
>>> mkDieGenCustom 143 [1, 0, 4, 3, 2]
{143, [1, 0, 4, 3, 2]}
>>> mkDieGenCustom 143 []
{143, rdIntsPrime}