Potentially a silly question, but how would you alter the Gridlock GeoMASON demo so that the agents go to their goal location and then return home straight away and do *NOT* wait for all other agents to reach their goal locations?
I've tried to play around with the code and switch things on and off and change the order of things, but to no avail. I've been focused on the Steppable code below, but can't see what needs to change. Any help would be appreciated. Still quite new to ABM/Java.
/** Steppable that flips Agent paths once everyone reaches their destinations*/
Steppable flipper = new Steppable()
{
@Override
public void step(SimState state)
{
Gridlock gstate = (Gridlock) state;
// pass to check if anyone has not yet reached work
for (Agent a : gstate.agentList)
{
if (!a.reachedDestination)
{
return; // someone is still moving: let him do so
}
}
// send everyone back in the opposite direction now
boolean toWork = gstate.goToWork;
gstate.goToWork = !toWork;
// otherwise everyone has reached their latest destination:
// turn them back
for (Agent a : gstate.agentList)
{
a.flipPath();
}
}
};
schedule.scheduleRepeating(flipper, 10);