They pointed out my core mistake: I was trying to solve a vision problem with a math solution.
Hardcoding is a symptom of bad agent perception. If you are writing spaghetti code to figure out where a wall goes, your bot is using the wrong eyes.
Navigation is fundamentally about how your agent perceives the shape of the world, not just how units walk from A to B. The base SC2 API gives you a simple pathing grid. It tells you what exists, but it doesn’t tell you what matters.
If you stop at the API floor, your bot will always be reactive. To solve complex problems, you need to understand the difference between layers and tools.
Layers are how your bot represents the world. You build these on top of the base grid:
- Influence Maps (Value): A grid layer that smears enemy positions into zones of danger.
- Memory Grids (Time): A layer that tracks what the bot saw before the fog of war rolled back in.
- Feature Layers (Patterns): PySC2 natively splits the game into roughly 25 stacked grids (terrain, visibility, unit type, ownership) so a neural network can “see” the screen.
Tools are how you read those layers.
- Raycasting (Measurement): Shooting lines through a grid to dynamically find gaps, walls, or line of sight.
- Pathfinding (Navigation): Algorithms like A* that read the grid to plot the fastest or safest route.
- Gradient Following (Positioning): Reading an influence map cell by cell and stepping toward the safer or higher-value neighbor.
This was my exact mistake with the wall. Instead of trying to math out choke points from a flat grid, I should have used a tool like raycasting to dynamically measure the gaps. But looking back I realized a pattern.
Navigation is at the heart of all AI behavior in games.
This matters way beyond StarCraft 2. Whether you are building bots to play other games or explore complex environments, everything your bot does assumes it can reliably move through the level.
If it can’t navigate, it tries to flank but walks into its own wall. It retreats but routes through enemy fire. Every higher behavior inherits the blindness underneath.
Understanding and expanding your bot’s perception layers and picking the right tools to read them is how you teach it to actually understand the world.
Your bot can only solve problems it can clearly see.