August 2007


Options: Use Monospaced Font
Show HTML Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Glen E. P. Ropella" <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Thu, 16 Aug 2007 15:00:45 -0700
text/plain (87 lines)
Hash: SHA1

Sean Luke wrote:
> The actual method is an internal, non-public method called
> setRandomNumberGenerator(int).  Agreed, not a good name, nor is it
> public.  I'll think about making it public; in the meantime, you
> *probably* can just make it public in  It'll be fine as
> long as it's not being called from within the simulation thread proper
> -- that is, from within a Steppable.  If you call it from some GUI
> object or from your main() thread, you're probably fine.

Thanks!  However, Console.startSimulation() looks like:

   void startSimulation()
      removeAllInspectors(true);      // clear inspectors

So, when it calls startSimulation(), it will use randomSeed, which is
only set via Console(), Console.pressStop(), or at its declaration.  So,
even if I call setRandomGenerator(int), it won't affect the value of
console.randomSeed.  Hence, after you press the stop button, the _next_
simulation will use either the currentTimeMillis() or
currentTimeMillis() + 1.

So your recommendation would force me to call
setRandomNumberGenerator(myseed) in my over-ridden GUIState.start()
method.  Plus, your recommendation doesn't help in programmatically
setting the incrementSeedOnPlay toggle.

What I want is to use the same seed for each subsequent run without
having to click on the Console tab, click inside the randomField, type
my number, hit enter, then hit play().  I.e. when I pressStop() I don't
want it to go back to the currentTimeMillis() value of randomSeed.  I
want it to go back to the integer I chose.  In other words, I need to
change the value of randomSeed.  So, I'd be more interested in a public

public class Console extends JFrame implements Controller {
   public void setRandomSeed(int v) { randomSeed = v; }

That way when startSimulation() is called, it will re-set to my integer.
 Right now, I simply create a mirror package (so I can gain access to
the protected variables and methods of sim.display.Console) called
sim.display and put my new sub-class in that mirror package.  I.e.

package sim.display;
public class MyConsole extends sim.display.Console {
   public MyConsole(int rngSeed, sim.display.GUIState s) {
      randomSeed = rngSeed;
      randomField.setValue("" + randomSeed);
- ------------------------------------------------------------------------

This sort of thing is important for those of us who use live
visualization (via a GUIState) to verify and debug simulations.  The
alternative is to engage in the 4 mouse clicks, number and enter
keystrokes everytime you want to re-run the simulation.  (Or, you could
change and re-compile the mason console, thereby breaking  your
simulation when you upgrade mason.... ugh... I'd rather have all my
relevant code under my source code repository. ... or you could restrict
yourself to off-line visualization and always verify/debug the
simulation using batch mode.)

- --
glen e. p. ropella, 971-219-3846,
If you haven't found something strange during the day, it hasn't been
much of a day. -- John A. Wheeler

Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla -