Subject: | |
From: | |
Reply To: | |
Date: | Fri, 19 Aug 2011 17:12:09 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On Aug 19, 2011, at 10:33 AM, Chris Wright wrote:
> When running the example "Flockers" program without a GUI, the results
> compared to a non-GUI version with the same seed seem to differ
> significantly. More specifically, the positioning of the "dead"
> flockers
> appears to be the same but those of the live flockers are vastly
> different
> at the same number of iterations. Both give consistent, but different,
> results each run.
Took me a while to realize what was happening, but it's simple: the
GUI version of Flockers uses the random number generator to produce
the random colors of each flocker! If you change these lines in
FlockersWithUI.
new Color( 128 + state.random.nextInt(128),
128 + state.random.nextInt(128),
128 + state.random.nextInt(128)),
to...
Color.red,
Then the problem goes away. But of course the flockers are no longer
pretty. So that brings up an interesting question: do we want to
guarantee the same exact result on the GUI versus the command line
even if the GUI version uses the random number generator? If this
isn't a big deal (and it probably isn't) then no. But if it matters,
then we'd probably need a separate RNG just for the GUI, which is
entirely doable -- we could just build a MersenneTwister and use it,
for example. Not a hard thing to add. But would an additional RNG be
confusing?
Sean
|
|
|