Data Structure for Small Number of Agents in a Relatively Big 2D World

Posted by Seçkin Savasçi on Programmers See other posts from Programmers or by Seçkin Savasçi
Published on 2013-10-23T22:26:40Z Indexed on 2013/10/24 4:07 UTC
Read the original article Hit count: 273

I'm working on a project where we will implement a kind of world simulation where there is a square 2D world. Agents live on this world and make decisions like moving or replicating themselves based on their neighbor cells(world=grid) and some extra parameters(which are not based on the state of the world). I'm looking for a data structure to implement such a project.

My concerns are : I will implement this 3 times: sequential, using OpenMP, using MPI. So if I can use the same structure that will be quite good.

The first thing comes up is keeping a 2D array for the world and storing agent references in it. And simulate the world for each time slice by checking every cell in each iteration and further processing if an agents is found in the cell. The downside is what if I have 1000x1000 world and only 5 agents in it. It will be an overkill for both sequential and parallel versions to check each cell and look for possible agents in them. I can use quadtree and store agents in it, but then how can I get the information about neighbor cells then?

Please let me know if I should elaborate more.

© Programmers or respective owner

Related posts about data-structures

Related posts about Parallelism