Ch.10: RTS Game Design: Why Your Units Get Stuck
Outline
- 0:00 The gate that jams an army
- 1:07 One click, forty destinations
- 2:16 Movement took a team
- 3:10 A star solves the route
- 4:14 Formation versus responsiveness
- 5:39 One flow field for an army
- 7:01 Why flow fields still fail
- 8:18 Multiplayer demands exact agreement
- 9:27 1,500 archers on 28.8
- 10:52 Debug the jam layer by layer
Transcript
0:00 You select 40 units, you click one spot across open ground, and you watch. The front row hesitates. The middle bunches up. Three knights at the back turn around and walk the wrong way. And the gap they're all fighting over? Half empty. And the destination is right there. Nothing between the army and the click but one narrow opening. Every RTS player has stared at that jam thinking, this is one job. Walk. I've yelled at that gate, honestly. And for years my diagnosis was a single word: pathfinding. Bad pathfinding.
0:34 Right, and the common mistake is stopping there, one broken algorithm. That word actually hides four different jobs, and picking the route is the easy one. Right, so here's the promise. We'll split that jam into its four layers, route planning, destination assignment, formation policy, and local collisions, and then we'll hit the twist: in multiplayer, every machine has to make the exact same mess. Down to the last collision. The result is a skill: by the end, you'll name which layer broke just from watching the jam.
1:07 So rewind to the click itself, before any route exists. You clicked a point. One point. 40 units can't stand on one point, so the game has to invent 40 destinations you never specified. Huh. I'd never framed it that way. My one click is really a request for 40 separate arrivals. And someone has to hand those out. Who takes the front slots, who anchors the edges, and whether the group should arrive as a shape at all or just get there any way it can. Okay, but let me defend the lazy model, because it's the one I believed.
1:44 Why can't each unit just walk toward the cursor and sort things out on arrival? Because arrival is where the fight starts. Imagine the first 10 units taking the good ground, the next 10 finding it occupied, and the last 20 now solving a parking problem inside a crowd while new orders keep coming in. So one click is not one path. It's a traffic plan for an army. That's the model to keep. And it splits the work, which means the route itself, the famous part, is only one job of four. Now, here's the detail that broke the single-algorithm picture for me.
2:21 Age of Empires two. The team's own postmortem, linked in the description, says movement in Age of Kings ran on three pathfinders and two obstruction systems. Hold on. Why would walking need three separate systems? Three, at different scales. Their high-level route across the map could afford to ignore individual bodies, and the close-range behavior couldn't, because it lives entirely inside the crowd. Five people worked on that machinery. Five people. On walking. On walking. And this was a team that, by their own account, had taken real criticism for the first game's pathfinding.
2:58 The fix they shipped wasn't one better algorithm. It was layers. Which quietly answers the forum thread we've all read, just fix the pathfinding. Now we can see the comeback: fix which of the three? So let's give the algorithm its due, because one does sit in there. A star, the classic search: hand it a map graph, it hands back a low-cost route. That part is genuinely solved. And honestly, that was my whole mental model. Pathfinding equals A star, everything else is polish. I didn't realize the route was the easy part.
3:31 It's a clean model that, you know, evaporates once units move at the same time. For example: the route was valid when computed, but mid-march the destination has filled with your own units, a neighbor blocks the next step, and a fresh order just broke the formation, so the rear ranks stall and re-plan. So shortest can be true and useless at once. The road was right. The traffic was never consulted. Yeah, and there's a budget stacked on top, because all of this recomputes constantly, for every unit, on a machine that's also running combat, economy, and rendering. Which means the next fight isn't math at all.
4:10 It's about which promise the player cares about. That promise fight is real, and responsiveness is its front line. Let's say my army's caught in a bad spot and I click away to retreat. What I want is simple: everyone runs, now. And the formation players will tell you the opposite, they post it every patch cycle: a formation that shatters on every click is useless. So the logic regroups first, assembles the shape, then moves out in good order. Which is defensible. Sure, in a vacuum. But mid-fight? Regrouping before running is how armies die.
4:47 Age of Empires two's team shipped an answer to that exact tension in an official update, and the patch notes read like our complaint list: regrouping backward before moving forward, freezing, jamming in tight gaps. Okay, so what did they change? They added a command. Control plus right-click now skips the formation promise entirely and just runs for the target. Wait. The escape hatch they shipped is a button? Yep. And the same notes admit why: preserving old behavior can make responsiveness worse.
5:20 They didn't tune the tradeoff away. They handed the choice to the player, and the game asks which promise wins this time. A design conflict promoted to a keybinding, and I kind of respect the honesty. That sets up the next problem, though: all of this movement machinery still bills per unit. And Supreme Commander two ran that bill the other way. It had to move hundreds, sometimes thousands of units, and its engineer published the architecture. Step 1: chop the map into sectors and route at the sector level, through their connecting doorways, the portals.
5:56 Coarse first. No unit is following that route directly yet. Not yet. Step 2 lives only in the tiles the route actually touches, and the end product is simple: a direction arrow painted in every cell. From here, step that way. Okay, but something has to decide which step out of a cell is the cheap one. Who computes the arrows? Two passes. First a price tag on every cell, how expensive it is to walk through, swamp pricier than open road. Then a pass that, Folds those price tags into each cell's distance to the goal, and the arrow just points toward the cheapest neighbor.
6:34 So a single unit never asks for its own personal path. It stands in a cell, reads the arrow under its feet, takes the step, and reads the next one. Exactly, and that's what pays for the whole design. Consider a hundred units heading the same way: they share one field instead of computing a hundred full routes. The route stops being a per-unit possession and becomes infrastructure. 1 field, a whole army. Before we crown flow fields, though, my first thought here was suspicion. If shared fields existed back in 2010, why does my army still jam at a gate today?
7:12 Because none of it is a drop-in part, and the write-up itself is upfront about the leftovers. Take a tank and a hovercraft: they can't share one cost map, because different movement types price terrain differently. And what happens when I drop a new building right on top of your beautiful field? Part of it goes stale on the spot, and rebuilding costs real frame time, so fields get cached and construction gets sliced across frames. And fixing one layer keeps exposing the next: that complaint-list update we quoted wasn't the last one; they were still shipping movement fixes years later.
7:48 Right, and the bodies still exist. Two units reading the same arrow can still, I mean, want the same spot at the same moment. Which is local physics and collision, same as ever. The field answers one question, which way is cheaper from here. It never promises your neighbor won't be standing in the answer. So the layers didn't collapse, and nobody's hiding a finished fix. Sharing made the route layer cheap, and everything underneath it is still on duty. Now take everything we just stacked, routes, endpoints, formation rules, collisions, all of them approximations under a time budget, and drop that same battle into multiplayer.
8:29 One more requirement lands on top, with a completely different personality. Different how? Every layer so far just had to look good enough. This one has to be exact. Take a pair of units meeting head-on, and say the engine breaks the tie by deciding who steps left. My machine says left. Yours says right. Oh, man. Then my copy of the battle and your copy just became different battles. That's the threat, and the left-versus-right case is only an illustration. One divergent micro-decision, and from that frame on the two simulations are describing different worlds. Players call it a desync.
9:07 And notice it's not lag. Lag is the network being slow. This is two computers disagreeing about what happened. Which is why the movement stack carries one constraint nobody sees on screen: whatever messy compromise it picks, it has to pick identically, everywhere, every time. So now the question is how anyone affords that. From that cost question comes a famous answer, with numbers that sound impossible today. Ensemble's own write-up, literally titled fifteen hundred archers on a 28.8, lays out their original targets: eight players, Pentium 90 machines, 16 megabytes of memory, dial-up modems at exactly that speed.
9:46 So streaming the live state of every unit, every position update for an entire army, through that straw. They tried, and they report even compressed per-object updates capped the moving-unit count. So they flipped the design. Don't send the movie. Run the full simulation on every machine and send only the players' commands, scheduled slightly ahead, flowing all match long. Because the commands are tiny. A click is a click whether it moves 10 units or 1,000. That's the lockstep bet, and it's why exactness stopped being optional.
10:19 The article's famous illustration is a deer: one machine's deer wanders a step differently, and from there the two matches quietly stop being the same match. I love that the same bet handed them replays almost for free. Same starting state, same command stream. Replay the inputs and the whole game reconstructs itself. Yeah, and it's not a relic either. Factorio's official docs describe the same shape today, every peer simulating the entire match while only player actions travel. Everyone must agree, and the slowest machine sets the pace.
10:52 So let's take the opening jam back through the stack, layer by layer, the way the engine team would debug it. Top layer first, the big route. Honestly, that one's usually innocent. The map-level path through the gap was probably fine. Next, destinations. 40 units were promised standing room near the click, and a narrow gap means most of those arrival slots are contested or flat-out unreachable right now. Then formation policy. If the group is protecting a shape, the shape itself can order the back rows to wait or circle around, and that's your knights walking backward with, you know, perfect logic and terrible optics.
11:29 It's also the one layer you already have a button for. And at the bottom, the choke is a collision festival. Imagine units arriving, re-planning, nudging each other out of the very cells the arrows call cheapest. Four layers, four different repairs, and none of them is "the algorithm is dumb." Right, four separate failures wearing one name. And multiplayer never joined that list, because it isn't a 5th cause. It's a constraint sitting over all 4: whichever compromise the engine picks at each layer, every machine has to pick it identically.
12:05 So imperfect movement is survivable. Disagreement isn't. That's the contradiction in one line. A route can be approximate. The simulation cannot disagree about it. Next time your army piles up at a gate, you'll know which layer to interrogate. Thanks for listening to Learning Podcasts.