MASON-INTEREST-L Archives

May 2017

MASON-INTEREST-L@LISTSERV.GMU.EDU

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

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

Print Reply
Mime-Version:
1.0
Content-Type:
text/plain; charset="UTF-8"
Date:
Thu, 25 May 2017 06:36:34 -0400
Reply-To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Subject:
Content-Transfer-Encoding:
8bit
Message-ID:
Sender:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
From:
Kurtis Garbutt <[log in to unmask]>
Parts/Attachments:
text/plain (36 lines)
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