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

Safe HaskellSafe-Infered

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.

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