LambdaHack-0.2.0: A roguelike game engine in early and very 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 :: [a] -> Frequency aSource

Uniform discrete frequency distribution.

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

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

Transformation

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

Scale frequecy distribution, multiplying it by an integer constant.

filterFreq :: (a -> Bool) -> Frequency a -> Frequency aSource

Leave only items that satisfy a predicate.

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.