|
From: | Crile Doscher |
Subject: | [Swarm-Support] Multiple Agents in One Cell |
Date: | Wed, 24 Aug 2005 12:23:03 -0400 |
Hi there SwarmList,I'm trying to work out multiple agents in a cell using lists, as suggested by some previous posts (if that doesn't work, I'll try using MultiGrid2D). The primary agents are volumes of water flowing over a riverbed (the cell surface, a Discrete2d which contains the cells), so I need each cell to hold an elevation value as well as a list of agents. I have borrowed some methods from MultiGrid2d (my thanks to Paul Johnson and Opinion2.0). The elevation values come from an ascii file originating as a GIS raster grid and are read into each cell after the agent list has been created but before any agents are added (the collection is created when the cell is created, well, during -createEnd a la Opinion, to be exact). During runtime, a method gets called from the agent to the cell surface that determines which cell is the best to move to by calculating local slopes from that particular cell. The problem is that where before I could easily read in the elevations, calculate the slopes and move the agents around (until two ended up in one cell, of course), I now get NaN returned when the cell surface queries a cells for its elevation values (and a subsequent crash). A -getCellAtX: Y: method is used to access the cell's elevation value - this worked fine prior to implementing the list. It seems like creating the list has either made the elevation value inaccessible, or perhaps the list has overwritten them. So, have I been sloppy in creating my lists? My gut feeling is that my cells should be able to hold both elevations and lists and I simply haven't implemented this well. Could the order in which the list is added and elevation values read in be causing a problem? Any thoughts?
Thanks - Crile Dr Crile Doscher Natural Resources Engineering Lincoln University Canterbury New Zealand"What if the hokey pokey is what it's all about?"
[Prev in Thread] | Current Thread | [Next in Thread] |