I mean I could attempt to mess around with that, my java is rusty. For my own edification, when is the agent added to the GeomVectorField? I see the reference being added to the arraylist, is the addgeometry function adding it to GeomVectorField? Also should I be using the "world" variable instead since its already pointing at the gridlock class?

-----Original Message-----
From: MASON Multiagent Simulation Toolkit [mailto:[log in to unmask]] On Behalf Of Sean Luke
Sent: Friday, June 23, 2017 4:36 PM
To: [log in to unmask]
Subject: Re: Modifying gridlock so agents know position of other nearby agents

The basic problem is that the gridlock example is storing agents in a GeomVectorField.  This field uses a QuadTree as its backing store.  This means that if an agent moves, the QuadTree has to be rebuilt, an O(n log n) operation at least.  Yuck.

The app should have used the Continuous class; agents can move in O(1).  

So what does this mean for you?  It basically means that for the time being, going through the agent list is probably your best option.  But if the app example had done this correctly, you could instead do a range query on the Continuous class and go this significantly faster (if there are a lot of agents).


On Jun 23, 2017, at 10:23 PM, Jonathan M West <[log in to unmask]> wrote:

> As a tutorial for myself I am trying to modify Gridlock so that the agents know the position of other agents nearby. Is the best way to do this similar to the students tutorial (creating references to the Gridlock class in the agent class)? Or is there another better way to reference the other agents in the step function? The end goal is to have the red dots on the map turn black when they get in traffic jams. I want to calculate a "roadrage" score based on the closeness of the other other agents on the map and then use that to change the shading of the portrayal dot. Currently getting the list of other agents like this
> Gridlock gridlock = (Gridlock) state;
> ArrayList<Agent> othercars= gridlock.agentList;
> I can iterate through "othercars" and pull the location member of each agent in that list to perform simple distance math. Am I going about it the right way?
> Thank You
> Jon West