Solo dev, working for some time on a top-down mass-defense roguelite in Godot 4.7. Huge enemy counts were the core idea from the start, so a lot of my time went into the crowd sim.
This is a test scene running the actual game sim: 5k / 20k / 50k / 100k /200k enemies on screen
What runs every tick (fixed 60 ticks/s, no LOD on the sim side):
- neighbor search over a spatial grid (16 px cells, rebuilt every tick)
- separation against all neighbors, in parallel
- movement over the game's flow field (32 px cells, line-of-sight paths)
- sim in C++ as a GDExtension, deterministic, with a GDScript mirror that has to match bit for bit (hash tests)
- rendering: positions written natively into a buffer, uploaded to a MultiMesh, shape LOD by zoom
Numbers (Ryzen 7 9800X3D + RX 7900 XT, so i would consider a best case, not an average PC):
- 200k: sim tick around 5.5-6.6 ms, always for all 200k, no matter where the camera is
- the sim runs at a fixed 60 ticks/s, rendering is decoupled, so FPS can be higher than 60 and only about every second frame contains a tick
- FPS depends on zoom, because only what's on screen gets drawn:
- zoomed in (a few thousand visible): ~135-150 FPS
- mid zoom (all 200k visible, still in the detailed shape): ~70-90 FPS, the worst case
- zoomed out (simpler shape via LOD): ~160 FPS
- tbh, in the real game the unit cap is 25k right now (40k already tested for late game), it's only lifted for this scene to see where the limits are.
This is a pure crowd sim test: no towers, no combat, no deaths or effects, one enemy
type. Separation is soft, so units overlap a bit, that's why the crowd gets through the gap almost at full speed. And yes, the straight dark line through the middle is a flow field bug I haven't fixed yet ahah.
The biggest single win was moving the sim from GDScript to a GDExtension. Later I moved effect drawing to native too, which took a full scene with towers and effects from 38 to 13 ms per frame.
Happy to answer questions about any part of it.