Jump forward random generator
rand_skip amount (number)
Jump the random generator forward essentially skipping the next call to rand
. You may specify an amount to jump allowing you to skip n calls to rand
.
Introduced in v2.7
Examples
# Example 1 |
puts rand
rand_skip
puts rand
|
# Basic rand stream skip
# prints 0.75006103515625
# jump random stream forward one
# typically the next rand is 0.733917236328125
# prints 0.464202880859375
|
# Example 2 |
puts rand
puts rand
puts rand
puts rand
rand_reset
puts rand
rand_skip(2)
puts rand 0.24249267578125
|
# Jumping forward multiple places in the rand stream
# prints 0.75006103515625
# prints 0.733917236328125
# prints 0.464202880859375
# prints 0.24249267578125
# reset the random stream
# prints 0.75006103515625
# jump random stream forward three places
# the result of the next call to rand will be
# exactly the same as if rand had been called
# three times
|