We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Randomness conundrum
Page Index Toggle Pages: 1
Randomness conundrum (Read 1352 times)
Randomness conundrum
Jun 2nd, 2010, 1:27pm
 
I'm having an issue with controlling randomness. I have a simulation that depends on some randomness. I would like to have the random seed be controllable before the simulation starts. I want any given simulation to be reproducible simply by specifying the seed at the beginning and then pressing play.

The problem is that when the random function is called within the draw method it produces a random number every time. This is how it is supposed to work and that is necessary for my simulation. But this has the side effect that the simulation ends up running totally different depending on when I press play.

I am setting the random seed with a GUI textfield. If I pause the whole program with noLoop() I can't interact with the textfield so I simply created a boolean called "paused" and wrapped everything inside the draw method in an if statement checking if paused was true. then when I press play it sets paused = false. However with this strategy the random generator keeps churning in the background because frames are still playing, just nothing is getting redrawn.

I guess I either need a way to pause the sketch and still interact with the text field or some way to "pause the randomness". How does Processing still accept keyboard input even when noLoop() is set?
Re: Randomness conundrum
Reply #1 - Jun 2nd, 2010, 3:36pm
 
Hi Moss,

http://processing.org/reference/randomSeed_.html

?

Furthermore, indeed, when noLoop() is set, it won't take any input calls. But no worry, an empty draw() draws no cpu power.

ps. you might want to delete the other two of the triple post you accidentally posted.
Page Index Toggle Pages: 1