Safe Haskell | None |
---|---|
Language | Haskell2010 |
Representation of probabilities and random computations.
Synopsis
- type Rnd a = State StdGen a
- randomR :: Random a => (a, a) -> Rnd a
- random :: Random a => Rnd a
- oneOf :: [a] -> Rnd a
- frequency :: Show a => Frequency a -> Rnd a
- type Chance = Rational
- chance :: Chance -> Rnd Bool
- castDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Int
- chanceDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Bool
- castDiceXY :: AbsDepth -> AbsDepth -> DiceXY -> Rnd (Int, Int)
- foldrM :: Foldable t => (a -> b -> Rnd b) -> b -> t a -> Rnd b
- foldlM' :: Foldable t => (b -> a -> Rnd b) -> b -> t a -> Rnd b
- rollFreq :: Show a => Frequency a -> StdGen -> (a, StdGen)
The Rng
monad
Random operations
randomR :: Random a => (a, a) -> Rnd a Source #
Get a random object within a range with a uniform distribution.
random :: Random a => Rnd a Source #
Get a random object of a given type with a uniform distribution.
frequency :: Show a => Frequency a -> Rnd a Source #
Gen an element according to a frequency distribution.
Fractional chance
Casting dice scaled with level
castDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Int Source #
Cast dice scaled with current level depth. Note that at the first level, the scaled dice are always ignored.
chanceDice :: AbsDepth -> AbsDepth -> Dice -> Rnd Bool Source #
Cast dice scaled with current level depth and return True
if the results is greater than 50.
castDiceXY :: AbsDepth -> AbsDepth -> DiceXY -> Rnd (Int, Int) Source #
Cast dice, scaled with current level depth, for coordinates.