game-probability-1.1: Simple probability library for dice rolls, card games and similar

Numeric.Probability.Game.Query

Description

A module with functions for querying the probabilities of various outcomes.

Synopsis

Documentation

chancePred :: (a -> Bool) -> EventM a -> RationalSource

Gets the probability that the outcome will satisfy the given predicate. For example:

 chancePred (<= 2) d6 == 1/3   -- The chance of getting 2 or less on a d6
 chancePred even d6 == 1/2     -- The chance of rolling an event number on a d6

chanceRel :: (a -> a -> Bool) -> EventM a -> EventM a -> RationalSource

Gets the probability that the given relation will hold between the two events. For example:

 chanceRel (==) d6 d6 == 1/6   -- The chance of rolling doubles on d6
 chanceRel (>) (2*d6) d12      -- The chance of beating a d12 with two d6

chanceTrue :: EventM Bool -> RationalSource

Gets the probability that the given boolean-outcome event will give a True outcome. For example:

 chanceTrue coinToss == 1/2
 chanceTrue ((== 3) <$> d6) == 1/6

(For the latter example, chancePred is more concise.)