Ruby Random

For general discussion related FlowStone
Post Reply
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Ruby Random

Post 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....?
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Ruby Random

Post 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.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
billv
Posts: 1165
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia
Contact:

Re: Ruby Random

Post 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....
Post Reply