Overhead2DView.updateScapeGraphics() has the following code:
for (Iterator iterator = network.iterator(); iterator.hasNext();) {
Cell target = (Cell) iterator.next();
int x2 = ((Coordinate2DDiscrete) target.getCoordinate()).getXValue();
int y2 = ((Coordinate2DDiscrete) target.getCoordinate()).getYValue();
bufferedGraphics.drawLine(x * agentSize + agentSize / 2 - 1, y * agentSize + agentSize / 2 - 1, x2 * agentSize + agentSize / 2 - 1, y2 * agentSize + agentSize / 2 - 1);
The problem is that when things are stepped in AGENT_ORDER, between the time target is added to the list of the cell's network and the time the scape is redrawn, target may have died (see, for further clarification, note 29 on pp. 39-40 of Epstein & Axtell, "Growing Artificial Societies"), which means that its coordinates are null and the assignments to x2 and y2 raise NullPointerExceptions. This can be seen when you run the example GAS_II_5. The fix is to enclose this code in a test for null-value on target.getCoordinate().
for (Iterator iterator = network.iterator(); iterator.hasNext();) {
Cell target = (Cell) iterator.next();
Coordinate2DDiscrete coord = (Coordinate2DDiscrete)target.getCoordinate();
if (coord != null) {
int x2 = coord.getXValue();
int y2 = coord.getYValue();
bufferedGraphics.drawLine(x * agentSize + agentSize / 2 - 1, y * agentSize + agentSize / 2 - 1, x2 * agentSize + agentSize / 2 - 1, y2 * agentSize + agentSize / 2 - 1);
+ }
I have attached a patch file.
Patch for Overhead2DView.java
Jonathon,
For some reason I'm still not getting notifications of these bug reports. Grr.. Anyway, I'm afraid that I've just been way too occupied anyway. Say, how would you like committer rights..? :)
Miles
Hmm... On the specific issue you mentioned, that should be be impossible. In other words, model and view interactions are guaranteed never to occur at the same time.
If you want to make sure I see your reply, please also send me a note at milesparker @ g____.com