MASON-INTEREST-L Archives

May 2017

MASON-INTEREST-L@LISTSERV.GMU.EDU

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

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

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Fri, 26 May 2017 11:33:12 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
I'm cc:ing Mark Coletti, who was the original author of this application I believe.  Mark?

On May 25, 2017, at 12:36 PM, Kurtis Garbutt <[log in to unmask]> wrote:

> 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);

ATOM RSS1 RSS2