ThalesGroup / kessler-game

Kessler is a simulation environment loosely modeled after our internal project PsiBee and the external project Fuzzy Asteroids. The game has ships that shoot bullets at asteroids to gain score. Ships can collide with asteroids and other ships and lose lives.
https://github.com/ThalesGroup/kessler-game
Apache License 2.0
10 stars 11 forks source link

Bullet/asteroid/mine/ship culling can be optimized #38

Closed Jie-F closed 8 months ago

Jie-F commented 9 months ago

The current way the game does the culling, it always recreates the lists of objects even if there's nothing to be culled.

Additionally, mines can potentially remove many asteroids at once, and the existence check within the list comprehension is checking whether the index is within a list. Changing list to set will speed up this check. For the other culling, the list is probably always super small so there's no point changing to a set and incurring the additional hashing overhead, but for mines I think it's worth it.