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