Page 1 of 1

Ruby Random

Posted: Sat Aug 17, 2013 10:24 pm
by billv
Have replaced a green random set up using simply
=rand(100) or =rand(0..100)

Seems to work great, but i don't know how ruby is actually "doing it"

My question is..should i build it like the green set up that I use now,
that gets a new seed based on the current time???

...will "new.seed" make it better, or time displacement???

or is ruby already doing these things to a certain extent with just =rand(100) or =rand(0..100) ???
so maybe just leave it as it is???

Proper random was a interesting issue back at SM....
....has anyone already gone down this path in Ruby....?

Re: Ruby Random

Posted: Mon Aug 19, 2013 11:45 am
by trogluddite
Hi billy,
From the Ruby API docs, it looks that the seeding is handled automatically - a time/process ID based seed is created on the first call unless you use the 'srand' call to set one explicitly.

Re: Ruby Random

Posted: Mon Aug 19, 2013 12:28 pm
by billv
trogluddite wrote:seeding is handled automatically - a time/process ID based seed is created on the first call

So no need to use this 'new.seed' thing to add variation, or mess with the time like we did in SM.
trogluddite wrote:unless you use the 'srand' call to set one explicitly.

and we have the power to customize it.

Wow...well thought out...
Destroys the old random issue in one hit..... :D
thanks Trog
...Ruby claims another victim.....my SM parts slowly diss-appearing....