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 › random seed not consistent
Page Index Toggle Pages: 1
random seed not consistent (Read 558 times)
random seed not consistent
May 2nd, 2010, 8:31am
 
Hi all,

I'm making something that generates randomly varying video and sends data via OSC to Max/MSP for audio, and want to make a movie file of it.  I'm fine with getting the frames out, it's the randomSeed() function I'm having problems with.

I need to have two runs of the program, one capturing the frames, one sending the data to record in Max.  I used randomSeed(10) to fix the numbers, but it's different when I go to change from one run to the other.  I.e. I start the frame export run and its random numbers are fixed every time I do that, but when I comment out the export section and run it again to get the audio they change to a different set of fixed random numbers.  I can switch back to the export and the first set of fixed random numbers come back, and likewise if I switch back to the audio run.

I don't know how randomSeed decides what number to generate, but it changes when I alter the code.  I have tried exporting it as an application and using keystrokes to switch between the two runs, but to no avail, the same problem occurs.

Any help or insights would be most welcome.
Re: random seed not consistent
Reply #1 - May 2nd, 2010, 8:56am
 
After a bit of further testing, it's not randSeed that is wrong.  It's my use of the millis() function to enforce a bit of regular timekeeping in the program, which when it has to slow down to export the frames means the clock is going faster than when it doesn't have to.

I'm still not sure why this makes the random numbers get out of sync, because the random functions are being called at the same point every time.  Maybe I'll work it out.  Seems like just typing stuff out on here is a help, haha.
Page Index Toggle Pages: 1