One long route search freezes the whole game for a moment
On a big map a single search can take longer than a frame, and the screen hitches whenever someone clicks far away. Here is how to spread one search over many frames and still get exactly the same route at the end.
Why this works
A freeze is one task hogging a moment that belongs to everyone. Doing a small, fixed share of the search each picture, with everything kept in one place, spreads the work thin and still reaches the same answer.
When not to use it
Skip it on small maps where a search ends in a blink, or when the unit must react in the very same moment. Slicing there only adds delay and bookkeeping you do not need.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 2 common mistakes and the fix
- 55 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "One long route search freezes the whole game for a moment" (read_entry path-search-in-slices-per-frame) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP