Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

Ruby Random

For general discussion related FlowStone

Ruby Random

Postby billv » Sat Aug 17, 2013 10:24 pm

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....?
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia

Re: Ruby Random

Postby trogluddite » Mon Aug 19, 2013 11:45 am

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

Re: Ruby Random

Postby billv » Mon Aug 19, 2013 12:28 pm

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....
billv
 
Posts: 1157
Joined: Tue Aug 31, 2010 3:34 pm
Location: Australia


Return to General

Who is online

Users browsing this forum: Google [Bot] and 76 guests