home
wiki
classes/clusters list
class information
+
Point of view
All features
ANY
INTERNALS_HANDLER
All features
deferred class RANDOM_NUMBER_GENERATOR
Summary
top
Common abstract definition of a random number generator. The SmartEiffel library provides two implementations:
MINIMAL_RANDOM_NUMBER_GENERATOR
, and
PRESS_RANDOM_NUMBER_GENERATOR
. Most applications can safely rely on
MINIMAL_RANDOM_NUMBER_GENERATOR
. If you really need high quality randomizing, consider
PRESS_RANDOM_NUMBER_GENERATOR
.
Direct parents
insert list:
ANY
Known children
inherit list:
MINIMAL_RANDOM_NUMBER_GENERATOR
Overview
top
features
make
Create (or reset) the random number generator with an automatic hazardous setting of the
seed_value
based on the CPU clock.
with_seed
(seed_value:
INTEGER_32
)
Create (or reset) the random number generator with an explicit
seed_value
.
next
Prepare the next random number in sequence.
last_real
:
REAL_64
The last computed number in range 0.0 to 1.0 excluded (see ensure).
last_integer
(n:
INTEGER_32
):
INTEGER_32
The last computed number in range 1 to
n
(see ensure).
clock_based_random_seed
:
INTEGER_32
Some positive random value to be used as a seed which may change as much as possible in a random way.
make
deferred procedure
top
Create (or reset) the random number generator with an automatic hazardous setting of the
seed_value
based on the CPU clock.
See also
with_seed
.
with_seed
(seed_value:
INTEGER_32
)
deferred procedure
top
Create (or reset) the random number generator with an explicit
seed_value
.
By using and explicit
seed_value
, one can replay more than once the very same hasardous sequence.
See also
make
.
next
deferred procedure
top
Prepare the next random number in sequence.
Change internal memory of
Current
in order to prepare the next random number in sequence.
See also
last_real
,
last_integer
.
last_real
:
REAL_64
deferred function
top
The last computed number in range 0.0 to 1.0 excluded (see ensure).
Internal memory is not changed and two calls will give the same
Result
. Use
next
to get a new random
last_real
value.
See also
last_integer
.
ensure
Result > 0 and Result <= 1
last_integer
(n:
INTEGER_32
):
INTEGER_32
deferred function
top
The last computed number in range 1 to
n
(see ensure).
Internal memory is not changed and two calls will give the same
Result
. Use
next
to get a new random
last_integer
value.
See also
last_real
.
require
n >= 1
ensure
1 <= Result and Result <= n
clock_based_random_seed
:
INTEGER_32
effective function
top
Some positive random value to be used as a seed which may change as much as possible in a random way.
ensure
Result > 0