initial framework added
[fp1415-soccerfun.git] / src / Game / randomstream.dcl
1 definition module randomstream
2
3 /** This module implements a number of infinite random streams.
4 For predictable games, the onesStream can be used.
5 */
6 import StdClass
7 import StdMaybe
8 import RandomExt
9
10 :: Stream a :== [a] // an infinite list of random values
11 :: P :== Real // 0<=x<=1.0
12
13 /** intRandomStream
14 creates a stream of random (positive and negative) Integer values.
15 realRandomStream
16 creates a stream of random (positive and negative) Real values.
17 boolRandomStream
18 creates a stream of random Bool values.
19 probabilityRandomStream
20 creates a stream of random P values.
21 onesStream
22 creates a stream of one values.
23 */
24 intRandomStream :: !RandomSeed -> Stream Int
25 realRandomStream :: !RandomSeed -> Stream Real
26 boolRandomStream :: !RandomSeed -> Stream Bool
27 probabilityRandomStream :: !RandomSeed -> Stream P
28 onesStream :: Stream P
29
30 /** nextRandom<Type> creates a next pseudo random value of given type.
31 */
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)
37
38 /** make the random realistic, as in, small errors occur more often:
39 \r -> 1.0-r^4 (zero <= r <= 1.0)
40 */
41 makeRandomRealistic :: !P -> P
42 // \r -> 1-r^10
43 makeRandomRealisticSkilled :: !P -> P
44
45 /** selectMostProbableAction randomly selects one of the elements of the list that have the same
46 highest probability.
47 If all probabilities are equal to zero, then Nothing is returned.
48 */
49 selectMostProbableAction :: ![(P,a)] !RandomSeed -> (!Maybe a,!RandomSeed)