LambdaHack-0.2.6: A roguelike game engine in early and active development

Safe HaskellNone

Game.LambdaHack.Utils.Frequency

Contents

Description

A list of items with relative frequencies of appearance.

Synopsis

The Frequency type

data Frequency a Source

The frequency distribution type.

Construction

uniformFreq :: String -> [a] -> Frequency aSource

Uniform discrete frequency distribution.

toFreq :: String -> [(Int, a)] -> Frequency aSource

Takes a name and a list of frequencies and items into the frequency distribution.

Transformation

scaleFreq :: Show a => Int -> Frequency a -> Frequency aSource

Scale frequecy distribution, multiplying it by a positive integer constant.

renameFreq :: String -> Frequency a -> Frequency aSource

Change the description of the frequency.

Consumption

rollFreq :: Show a => Frequency a -> StdGen -> (a, StdGen)Source

Randomly choose an item according to the distribution.

nullFreq :: Frequency a -> BoolSource

Test if the frequency distribution is empty.

runFrequency :: Frequency a -> [(Int, a)]Source

give acces to raw frequency values

nameFrequency :: Frequency a -> StringSource

short description for debug, etc.