
Creates an environment (similar to R6 class) of random uniform numbers to be drawn from
Source:R/input_f.R
random_stream.Rd
Creates an environment (similar to R6 class) of random uniform numbers to be drawn from
Details
This function creates an environment object that behaves similar to an R6 class but offers more speed vs. an R6 class.
The object is always initialized (see example below) to a specific vector of
random uniform values. The user can then call the object with obj$draw_number(n)
,
where n is an integer, and will return the first n elements of the created
vector of uniform values. It will automatically remove those indexes from the
vector, so the next time the user calls obj$draw_n()
it will already consider
the next index.
The user can also access the latest elements drawn by accessing obj$random_n
(useful for when performing a luck adjustment), the current stream still
to be drawn using obj$stream
and the original size (when created) using
obj$stream_size
.
If performing luck adjustment, the user can always modify the random value
by using obj$random_n <- luck_adj(...)
(only valid if used with the expression
approach, not with modify_item
)