-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate using spatial hashing to optimize collision detection #44
Comments
Did some testing with the below code (This works with asteroids/bullets/mines as dictionaries) and got worse performance than just looping through all asteroids normally 😢
|
We've discussed this idea before and tabled it for a few reasons - we expect better performance and less overall headaches from moving to vectorized or compiled code. Not that you couldn't also do this, but those would likely increase performance enough to not have to do this for the numbers of asteroids expected in scenarios. |
I'm investigating this idea to speed up my own controller, and if I get promising results, I can implement this in Kessler as well.
Within kessler_game.py's update() loop, there's lots of stuff like "for each bullet, go through each asteroid" or "for each mine, go through each asteroid". There can be hundreds of asteroids so these loops are slow. If we can use spatial hashing (put each asteroid into a bucket in space) to narrow down the list of asteroids to a small subset that can potentially intersect with each bullet/mine/ship, then the loops will be made much smaller.
The text was updated successfully, but these errors were encountered: