April 2013


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
Mark Coletti <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Thu, 4 Apr 2013 15:56:53 -0400
text/plain (2099 bytes) , text/html (3339 bytes)
On Wed, Mar 27, 2013 at 4:07 PM, Luís de Sousa <[log in to unmask]>

> I noted today that geometries that have been removed using this method
> continue to be drawn in the display. I have an Agent class that
> inherits from MasonGeometry; this particular agent can "die" during
> simulation and its stop() method is invoked. When this happens with an
> agent stored in a Continuous2D, for instance, invoking the remove()
> method is enough to prevent it from being drawn again.
> After invoking removeGeometry() is there anything else referencing the

More than likely you are not un-scheduling the agent, so the MASON schedule
has the lone reference to your agent.  I just modified the CampusWorld demo
to have a single agent that's deleted after 200 steps, and that appears to
work ok.

Essentially, in I added a Stoppable, used that when adding
the single agent, and then added a new function, removeAgent(), to
unschedule same and remove it from its field:

    Stoppable agentStoppable; // Used to unschedule agent

     * Add agents to the simulation and to the agent GeomVectorField. Note
     * each agent does not have any attributes.
    void addAgents()
        for (int i = 0; i < numAgents; i++)
            Agent a = new Agent(this);


            // Remember the Stoppable here
            agentStoppable = schedule.scheduleRepeating(a);

    void removeAgent()
        // first remove the agent from the scheduler

        // then remove it from the field; there's only one agent, so just
        // remove the first guy

Then to put all the parts in motion I added this to start():

         // After 200 time steps remove the one agent
        schedule.scheduleOnce(200, new Steppable() {
            public void step(SimState ss)

Sure enough, after 200 steps the lone agent pops out of existence.