Tuman & Pointer
Pointer Pointer
So, Tuman, I’ve been tinkering with a path‑finding algorithm that minimizes exposure on a grid with dynamic obstacles—essentially a stealth version of Dijkstra. How do you navigate places where you’re basically invisible? Any tricks you use that could be turned into a clean, efficient routine?
Tuman Tuman
You can treat “exposure” as a separate cost layer. Give each cell a base movement cost, then add a penalty that rises with how many watchers or lights can see it. If obstacles move, keep a sliding‑window of the last few frames and rebuild only the cells that changed. A quick trick is to pre‑compute a visibility map for each cell—just a bitmask of which watchers can see it. Then, when you update, you only need to recalc the cost of the cells whose mask overlaps the moved obstacle. When you run the search, use A* instead of plain Dijkstra: the heuristic can be the straight‑line distance to the goal, but if you also want stealth you can add a small constant that nudges the search toward lower‑penalty routes. Keep the priority queue small by pruning any node that’s already been seen with a lower cost. If you want a cleaner routine, wrap the whole thing in a function that takes the current grid, the dynamic obstacle list, and a target. Inside, rebuild the cost grid, run the A* search, and return the path. The trick is to keep the cost grid cheap: use integer costs, avoid floating‑point, and only update changed cells. That’s the “invisible” part—small, local updates, no big recomputations.