Print

Print


On Aug 23, 2005, at 1:24 PM, Michael Makowsky wrote:

> I am confused as to how to schedule embodied agents. What I would like
> to do is create agents that have two orders of steps.
>
> So my agent class implements Steppable, but I would like there to be
> two orders of events within the class. So every time the schedule is
> pulsed: 1) All of the agents run a method called setIncome() and,
> after all of the agents have run it, cycle back through and 2) All
> agents partner with a random neighbor and exchange goods.
>
> In the tutorial3 with second order steps the second order step is a
> decreaser that exists within the start() method, and acts on a
> different agent set. I want to operated on the same set of agents.

MASON's steppable objects only take a single method step().  So let's
say that you have an agent with two methods foo() and bar(), each of
which you want pulsed at different times.  You could do this:

final Agent agent = .... ;  // he needs to be final to use
                                                // in the Steppables below

schedule.scheduleRepeating(Schedule.EPOCH,0, /* 0 ordering */
                                                new Steppable()
                                                        {
                                                        public void step(SimState state)
                                                                { agent.foo(); }
                                                        });

schedule.scheduleRepeating(Schedule.EPOCH,1, /* 1 ordering */
                                                new Steppable()
                                                        {
                                                        public void step(SimState state)
                                                                { agent.bar(); }
                                                        });

Or perhaps your agent *is* a Steppable, and you need its step() method
called in order 0 say, and its baz() method called in order 1.  You
could do this:

final Agent agent = .... ;
schedule.scheduleRepeating(Schedule.EPOCH,0,agent);
schedule.scheduleRepeating(Schedule.EPOCH,1, /* 1 ordering */
                                                new Steppable()
                                                        {
                                                        public void step(SimState state)
                                                                { agent.baz(); }
                                                        });

Sean