Get current random seed
current_random_seed
Returns the current random seed.
This can be set via the fns use_random_seed
and with_random_seed
. It is incremented every time you use the random number generator via fns such as choose
and rand
.
Introduced in v2.10
Examples
# Example 1 |
puts current_random_seed
|
# Print out the current random seed
|
# Example 2 |
puts rand
puts rand
a = current_random_seed
puts rand
puts rand
use_random_seed a
puts rand
puts rand
|
# Resetting the seed back to a known place
#=> 0.75006103515625
#=> 0.733917236328125
# Grab the current seed
#=> 0.464202880859375
#=> 0.24249267578125
# Restore the seed
# we'll now get the same random values:
#=> 0.464202880859375
#=> 0.24249267578125
|