Reputation: 11
I am attempting to simulate a dice roll using the RANDOM class in the BASE library. With my current code, it only ever prints out 5.
class
APPLICATION
create
make
feature
make
local
random_obj: RANDOM
do
create random_obj.make
io.put_integer (random_obj.next_random (random_obj.item) \\ 6 + 1)
end
end
Upvotes: 0
Views: 69
Reputation: 36650
You're always using the default seed. You need to set a different seed on each run.
create random_obj.set_seed (...)
The current time in seconds as an INTEGER_32
is a good option for a seed that will be different on each run.
Upvotes: 0