Sunday 15 January 2012

python - Best data structure for finding nearby xyz points by distance? -


I am working on Python, but I think it does not affect the question.

I am working on a game, and I need to store the institutions, each of which has [x, y, z] in the world.

These institutions will continue for a long time.

What would be the most effective way for institutions to store them as fast as possible?

Already suggested that as an alternative, if you do not need an accurate distance You can also use it, which is quite easy to implement.

In summary, you have to think of your world as a grid where each room in the grid will be consistent for a bucket in the hash table, because your institution is often running, And can rebuild the institutions and put the institutions in the related bucket on the basis of their position. Then, for any unit, you can check nearby cells and get the list of institutions.

No comments:

Post a Comment