What is pathfinding? How game enemies find their way
What is pathfinding? It is the method a game uses to get a character from where it is to where it wants to be without walking through walls. Every chasing enemy and every unit you order across a map depends on it. This guide explains the core ideas in plain terms, walks through a small example by hand, and then shows how to read enemy movement in a real browser game so you can use it against them.
What is pathfinding? How game enemies find their way
A game enemy has no eyes and no sense of direction. It has a position, a goal, and a map made of data. Pathfinding is the step that turns those three things into a route: a list of places to move through, in order, that ends at the goal.
Two jobs are often mixed up here. The first is deciding where to go: the player, a base, a pickup. That is a decision, and it belongs to the wider game AI. The second is working out how to get there. That is pathfinding. A good enemy needs both. A clever goal with a bad route looks broken. A perfect route to a silly goal looks dumb.
How game maps become grids, nodes and graphs
Before a computer can search a map, the map has to become something it can count. The easiest form is a grid. You cut the level into equal squares, called tiles, and mark each one as open or blocked.
Each open tile becomes a node. Two nodes are joined by an edge when a character can step from one to the other. A set of nodes and edges is called a graph, and almost every pathfinding method is really a way of searching a graph.
Grids are not the only option. Many 3D games use a navigation mesh, which covers walkable floor with shapes and treats each shape as a node. The search ideas below still apply, because it is a graph underneath.
Breadth-first search, Dijkstra and A*: how enemies pick a route
Three classic methods cover most of what you need to know.
Breadth-first search
Breadth-first search spreads out from the start like a ripple. It visits every tile one step away, then every tile two steps away, and so on, until it reaches the goal. Each tile remembers which tile it was reached from. To get the path, you follow those notes backward from the goal to the start.
Try it by hand. Picture a 5 by 5 grid. The enemy is at the top left. The goal is at the bottom left. A wall fills the middle row except for its right-most tile. The ripple moves along the top row, finds the gap on the right, pours through, and then sweeps back left along the bottom. The path it returns runs right, down through the gap, and left. No shorter route exists, and breadth-first search always finds the one with the fewest steps when every step costs the same.

Dijkstra's algorithm
Real maps are rarely that even. Mud is slow. Roads are fast. Dijkstra's algorithm handles this by giving each edge a cost and always expanding the cheapest unexplored tile next. It finds the cheapest route, not just the shortest one in steps.
A*
Dijkstra searches in every direction, which wastes time when the goal is clearly to the east. A* fixes that. For each tile it adds two numbers: the cost paid so far, and a guess of the cost still left. It always expands the tile with the lowest total. The guess pulls the search toward the goal, so it checks far fewer tiles. On a grid with four-way movement, a common guess is the Manhattan distance: the number of columns plus the number of rows between the tile and the goal.
Heuristics and costs: why enemies avoid walls, water and danger
The guess in A* is called a heuristic. If it never overestimates the real remaining cost, A* still returns the best route. If it overestimates, A* gets faster but may pick a worse path, a trade video games often accept.
Costs are where designers shape behavior. Set water to impossible and enemies route around rivers. Set it to expensive and they cross only when the detour is long. The search itself does not change; the numbers decide what the enemy seems to care about.
Breakable walls are a good case. A wall you can shoot through is not really closed. It is open with a delay. A designer can give it a high cost instead of blocking it, so an enemy will push through when going around is worse.
How enemy tanks hunt you in Tank City Reboot (and how to exploit it)
Tank City Reboot is a free tank game that plays in your browser. You drive an antivirus tank that guards the CPU core at the bottom of a circuit board. Each map is 13 by 13 tiles, which makes it a clean example of a grid world.
Know what the malware wants
In the first game, malware tanks head mostly for the CPU core, sometimes for you, and sometimes anywhere. That mix of goals is the key fact. Most of the pressure lands on the core, so you do not need to chase every tank. Sit where their routes converge and let them come. The beginner tips cover where to stand in more detail.
Speed matters too. Your tank moves at 50. A worm moves at 30 and a rootkit at 34, so you can outpace them. A trojan moves at 58, faster than you, so meet trojans head on instead of trying to escape them.
Use terrain the way the grid sees it
Each terrain type acts like a different cost in the graph:
- Coolant blocks tanks but not shots. On the COOLANT stage, two coolant rivers cross the map, each with one gap on the left and one on the right. Every enemy that wants the core must funnel through those gaps. You can fire across the river at them while they cannot reach you directly.
- Firewall breaks under fire, a block at a time. It is a closed tile that can become open, so a wall you rely on may not last.
- Silicon stops every shot until your cannon is fully overclocked.
- Encrypted zones hide any tank inside them, but shots pass straight through. If an enemy vanishes into one, fire along its last line of travel.
- Data bus tiles are slippery. Your tank slides about three quarters of a tile after you let go, so plan your stop early.
Zero Day: hunters and fair arenas
In Tank City Zero Day, botnet drones come in threes and hunt you, not the core. That is a different goal on the same map, and it changes how you play. Drones follow you, so you can lead them away from the core and fight them on ground you pick. When their shots close in, dash: a dash lasts a fifth of a second and you cannot be hit during it. The controls guide lists the dash buttons for keyboard, gamepad and touch.
Zero Day also shows pathfinding used by the level, not just the enemies. Every wave is a freshly generated arena. An arena counts as fair only when every enemy gate and the player start can reach the core by going round silicon and coolant. Firewall counts as open, since any tank can shoot through it. If an arena fails that check, it is drawn again. That is a reachability search, the same idea as the ripple above, used to throw out broken maps. You can read more about how this kind of map building works in what procedural generation is.

One threat ignores routing entirely. The zero-day boss of every fifth wave breaks through any wall. When a tank can go anywhere, walls stop being a plan. Keep moving and keep firing.
Frequently asked questions
Is A* still used for pathfinding in modern games?
Yes. A* and its variants are a standard choice in games, often run on a navigation mesh instead of a tile grid.
What is the difference between pathfinding and game AI?
Game AI decides what a character wants to do, such as attack, flee or guard. Pathfinding only answers how to get to the chosen spot. One picks the goal; the other plans the route.
Why do game enemies sometimes get stuck on walls?
Usually the map data and the real shapes disagree, or the enemy moves straight at its target with no search at all. A gap that looks open on the grid can be too narrow for the character's body, so it pushes against the corner forever.
How does pathfinding work in procedurally generated levels?
The game builds the graph after it builds the level, then searches it as normal. A generator can also run a search to confirm the level can be finished and rebuild it if not, which is what Zero Day does with its arenas.
Get started
Open the first game and play the COOLANT stage with this guide in mind. Watch where the tanks squeeze through the river gaps, then set up to fire across the water. Once that feels easy, try Zero Day and pull the botnet drones away from the core. If you want points on top of survival, read up on chains and multipliers.
Play Tank City Reboot: it is free, plays in your browser on a computer or a phone, and needs no account.
Comments
No comments yet.
Sign in or make an account to comment.