| 1 | |
|---|
| 2 | :- protocol(randomp). |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | :- info([ |
|---|
| 6 | version is 1.0, |
|---|
| 7 | author is 'Paulo Moura', |
|---|
| 8 | date is 2000/7/24, |
|---|
| 9 | comment is 'Random number generator protocol.']). |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | :- public(random/1). |
|---|
| 13 | |
|---|
| 14 | :- mode(random(-float), one). |
|---|
| 15 | |
|---|
| 16 | :- info(random/1, [ |
|---|
| 17 | comment is 'Returns a new random float value in the interval [0.0, 1.0[.', |
|---|
| 18 | argnames is ['Random']]). |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | :- public(random/3). |
|---|
| 22 | |
|---|
| 23 | :- mode(random(+integer, +integer, -integer), zero_or_one). |
|---|
| 24 | :- mode(random(+float, +float, -float), zero_or_one). |
|---|
| 25 | |
|---|
| 26 | :- info(random/3, [ |
|---|
| 27 | comment is 'Returns a new random value in the interval [Lower, Upper[.', |
|---|
| 28 | argnames is ['Lower', 'Upper', 'Random']]). |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | :- public(randseq/4). |
|---|
| 32 | |
|---|
| 33 | :- mode(randseq(+integer, +integer, +integer, -list), zero_or_one). |
|---|
| 34 | :- mode(randseq(+integer, +float, +float, -list), zero_or_one). |
|---|
| 35 | |
|---|
| 36 | :- info(randseq/4, [ |
|---|
| 37 | comment is 'Returns a list of Length random values in the interval [Lower, Upper[.', |
|---|
| 38 | argnames is ['Length', 'Lower', 'Upper', 'List']]). |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | :- public(randset/4). |
|---|
| 42 | |
|---|
| 43 | :- mode(randset(+integer, +integer, +integer, -list), zero_or_one). |
|---|
| 44 | :- mode(randset(+integer, +float, +float, -list), zero_or_one). |
|---|
| 45 | |
|---|
| 46 | :- info(randset/4, [ |
|---|
| 47 | comment is 'Returns an ordered set of Length random values in the interval [Lower, Upper[.', |
|---|
| 48 | argnames is ['Length', 'Lower', 'Upper', 'Set']]). |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | :- public(reset_seed/0). |
|---|
| 52 | |
|---|
| 53 | :- mode(reset_seed, one). |
|---|
| 54 | |
|---|
| 55 | :- info(reset_seed/0, [ |
|---|
| 56 | comment is 'Resets the random seed to its default value.']). |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | :- public(set_seed/1). |
|---|
| 60 | |
|---|
| 61 | :- mode(set_seed(+integer), zero_or_one). |
|---|
| 62 | |
|---|
| 63 | :- info(set_seed/1, [ |
|---|
| 64 | comment is 'Sets the random seed to the given value.', |
|---|
| 65 | argnames is ['Seed']]). |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | :- end_protocol. |
|---|