1 definition module randomstream
3 /** This module implements a number of infinite random streams.
4 For predictable games, the onesStream can be used.
10 :: Stream a :== [a] // an infinite list of random values
11 :: P :== Real // 0<=x<=1.0
14 creates a stream of random (positive and negative) Integer values.
16 creates a stream of random (positive and negative) Real values.
18 creates a stream of random Bool values.
19 probabilityRandomStream
20 creates a stream of random P values.
22 creates a stream of one values.
24 intRandomStream :: !RandomSeed -> Stream Int
25 realRandomStream :: !RandomSeed -> Stream Real
26 boolRandomStream :: !RandomSeed -> Stream Bool
27 probabilityRandomStream :: !RandomSeed -> Stream P
28 onesStream :: Stream P
30 /** nextRandom<Type> creates a next pseudo random value of given type.
32 nextRandomInt :: !RandomSeed -> .(!Int, !RandomSeed)
33 nextRandomReal :: !RandomSeed -> .(!Real,!RandomSeed)
34 nextRandomBool :: !RandomSeed -> .(!Bool,!RandomSeed)
35 nextRandomP :: !RandomSeed -> .(!P, !RandomSeed)
36 next1 :: !RandomSeed -> .(!P, !RandomSeed)
38 /** make the random realistic, as in, small errors occur more often:
39 \r -> 1.0-r^4 (zero <= r <= 1.0)
41 makeRandomRealistic :: !P -> P
43 makeRandomRealisticSkilled :: !P -> P
45 /** selectMostProbableAction randomly selects one of the elements of the list that have the same
47 If all probabilities are equal to zero, then Nothing is returned.
49 selectMostProbableAction :: ![(P,a)] !RandomSeed -> (!Maybe a,!RandomSeed)