Print

Print


Christopher, I'd need a concrete and simple example of this.  I presume you're referring to SparseGrid2D.

getNeighborsMaxDistance(x, y, dist, toroidal, result, xPos, yPos) just calls getNeighborsMaxDistance(x, y, dist, toroidal, xPos, yPos), which returns all the <X,Y> locations that are [dist] away from <x,y>.  Then it just looks up the hash for each location and returns the objects in that hash.  It's a pretty straightforwrd function.  The only ways it could possibly return multiple objects would be:

- A given <X,Y> location is being returned multiple times.  This might be possible in the toroidal code -- are you doing toroidal? -- but it seems unlikely in the non-toroidal code on first glance.

- The hash is broken (unlikely).

Sean

On Aug 9, 2012, at 7:08 PM, Chris Hollander wrote:

> So, I'm not sure if this is a bug or intended... and it's been around
> for a LONG time, so it might be fixed already on the SVN... but when
> you call getNeighborsMaxDistance with a sufficiently large distance
> (say, the size of the grid width or height), you get duplicates in the
> returned bag.
> 
> So if I have 10 agents with a unique ID 1, 2, .. 10 on a 10x10 grid
> and I call getNeighborsMaxDistance with a radius of 10, I'll get back
> a bag that has multiple copies of each agent... which means I can't
> exactly iterate over the raw bag. Of course, this is easy enough to
> handle by simply dumping all the elements in the bag in to a set, but
> should that have to be done? Shouldn't the returned list of neighbors
> be guaranteed to not contain duplicates?
> 
> 
> Christopher Hollander
> University of Central Florida