Edited by humans. Written by AI. How our editing works
All articles

Age of Empires' 25-Year Pathfinding Bug Had a Wild Cause

How a compiler flag change accidentally broke Age of Empires pathfinding for years—and why the community was right all along about the units walking through walls.

Tyler Nakamura

Written by AI. Tyler Nakamura

February 6, 20266 min read
Share:
Speaker at podium discussing C++ pathfinding issues with circuit board graphics and green network visualization on dark…

Photo: Meeting Cpp / YouTube

Sometimes the community is right and you just don't want to believe them. For years, Age of Empires players complained that pathfinding got worse in the remastered versions—units would walk through walls, get stuck in weird places, behave less predictably than the 1999 original. And for years, developers at Forgotten Empires insisted nothing had changed in the pathfinding code.

Turns out everyone was technically correct, which is the most frustrating kind of correct.

Raymi Klingers, engineering director at Forgotten Empires, recently gave a talk at Meeting C++ 2025 that maps out one of the wildest debugging stories I've heard in game development. The pathfinding issues plaguing Age of Empires II weren't caused by code changes at all—they were caused by a compiler optimization flag that silently traded floating-point precision for performance, then got permanently baked in during the 64-bit port. The team "executed the perfect crime," as Klingers puts it, accidentally covering up evidence that would have revealed the issue years earlier.

The problem that wouldn't die

Age of Empires pathfinding is legitimately hard in ways most RTS games avoid. Units don't push through each other. They can't overlap except in formations. Maps are completely random and fully dynamic—every tile can change. Compare this to StarCraft II, which Klingers holds up as the pathfinding gold standard: fixed maps, steering behaviors, units that can slide past each other with small overlaps.

"Players are generally happy with that pathfinding," Klingers notes about StarCraft II. "So why do we not just do StarCraft 2 pathfinding? Well, we're working on the reboots and remasters. We're not really making new games."

Retrofitting modern pathfinding would mean rewriting most of the gameplay code. They tried it once in Age of Mythology: Retold with mixed results. Plus—and this is the twist—the community actually loves the janky pathfinding, even while complaining about it. Klingers shows a clip of a player blocking enemy knights at the last second by moving a fishing ship into their path... while using a controller to emulate mouse controls. These clutch moments only work because pathfinding is strict about collisions.

The short-range pathfinding algorithm (which represents about 10% of the total pathfinding problem) uses convex hull generation via the gift wrapping algorithm. You gather obstructions, shrink the pathing unit to a point, expand the obstructions by that amount, create convex hulls around obstacles, then walk the edges while shooting rays toward your goal. It's clever, it shipped in 1999, and it mostly works.

Except sometimes units walk through walls.

The precision error that kept returning

The gift wrapping algorithm has a weakness: it needs to determine whether three points make a left turn or right turn, and when points are nearly collinear—almost on a perfect line—floating-point math doesn't always have enough precision to answer correctly. Get it wrong and your convex hull can cut through an obstruction instead of wrapping around it. Your unit follows that path. Your unit walks through a wall.

This wasn't new. The original Age of Empires II developers clearly knew about it—Klingers found code attempting to filter out points too close together. Age of Empires III developers tried promoting floats to doubles for more precision. Age of Mythology developers added a whole concave hull pass to avoid random bouncing. "This again did not fix the issue," Klingers explains, "but just made it harder to reproduce, which is still an improvement because now the players suffer less."

Everyone kept hitting the same wall: you either write your own arbitrary-precision math library (expensive) or accept that sometimes geometry will lie to you.

Then Klingers accidentally disabled compiler optimizations the wrong way.

The accidental discovery

While trying to debug the precision issue, Klingers turned off what he thought were optimization flags in Age of Mythology Extended Edition. He didn't switch to debug mode—he manually disabled individual compiler flags. This accidentally turned off SIMD instructions, forcing the compiler to fall back to IA32 instructions.

The pathfinding bug disappeared.

"There's a thing called 80-bit floating-point precision," Klingers explains. "Old hardware when they did floating-point calculations, they would use extra wide registers basically to store extra precision in their floating point calculations." This extended precision only worked for intermediate results in CPU registers. When SIMD instructions became standard, that precision got dropped as a performance trade-off.

Here's the timeline of the perfect crime: Somewhere during the original development, someone enabled the SIMD flag for performance without realizing it reduced floating-point precision, introducing pathfinding regressions. Years later, Forgotten Empires ported the game to 64-bit, which defaults to SIMD enabled. They technically didn't change the flag—64-bit just made SIMD the default. Plus they'd lost the source control history in the code handoff, so there was no way to trace when the precision changed.

"If I didn't randomly decide to turn it off," Klingers admits, "we would probably still be looking for the cause of this."

Klingers asks the crowd: "Hands up if you actually knew that when you enabled SIMD instructions you would lose your floating point precision. I didn't. And apparently other developers as well."

What legacy code actually means

The Age of Empires codebase is older than Klingers—he's 24 and the code dates to 1997. None of the original developers remain. Multiple teams across different studios touched the pathfinding over 25 years. When Forgotten Empires got their code drop, they lost the source history. Possibly twice.

This is what "erosion of knowledge" looks like in practice. Not dramatic—just gradual information loss, undocumented decisions, and what Klingers calls "ritual programming": implementing features by remembering to call certain functions because otherwise systems break, even though nothing errors and nothing is documented.

The community actually reverse-engineered the original executable and created their own pathfinding patch that worked better. That developer disappeared, the improvements were lost, and the community patch became the gold standard against which all official updates were measured. "When we started we were basically down three to zero already," Klingers notes.

Here's what makes this story interesting beyond Age of Empires: How many other applications hit this exact problem? How many developers enabled SIMD for performance in the 2000s without knowing they were trading precision? How many bugs attributed to "bad legacy code" are actually compiler flags making different assumptions about math?

The fix Klingers developed involves pre-calculating rectangle intersections and walking edges with simple rules (turn right at edge ends, turn left at intersections) until you loop back. It avoids the precision-sensitive geometry that kept breaking. Whether that ships or how it performs at scale—that's still being worked out.

But at least now they know why units were walking through walls. And the community? They were right the whole time. The pathfinding really did get worse. Just not for the reasons anyone thought.

—Tyler Nakamura

From the BuzzRAG Team

We Watch Tech YouTube So You Don't Have To

Get the week's best tech insights, summarized and delivered to your inbox. No fluff, no spam.

Weekly digestNo spamUnsubscribe anytime

More Like This

Developer at computer workstation with code and analytics dashboards displayed, illuminated by neon purple and blue…

30 Self-Hosted GitHub Projects Trending Right Now

From media automation to AI chat apps, here are 30 trending self-hosted GitHub projects that put you back in control of your data and infrastructure.

Tyler Nakamura·5 months ago·6 min read
Man with glasses next to illuminated server rack with blue network cables and text overlay reading "17TB MINI RACK 10gb+CEPH

This Guy Fit 17TB of Enterprise Storage Into a Mini Rack

A home lab builder packed 17TB of NVMe storage into five mini PCs, ditching VMware for Proxmox and Ceph. Here's what actually worked—and what didn't.

Tyler Nakamura·5 months ago·6 min read
Dark blue presentation slide with cyan geometric lines displaying the title and speaker name Richard Thomson from Utah C++…

How to Build Git Version Control Into Your Apps

LibGit2 lets developers embed Git functionality directly into applications. Here's what that actually looks like in practice, and why it matters.

Tyler Nakamura·3 months ago·6 min read
Bearded man wearing glasses and a light blue beanie in front of a blurred office background, with large yellow text reading…

Anthropic's Claude Code Leak Reveals Unglamorous Truth

The Claude Code leak shows what actually makes AI agents work at scale: boring infrastructure, not flashy features. Two leaks in one week raise questions.

Mike Sullivan·4 months ago·6 min read
Man in business suit speaking at microphone in OpenAI office with yellow text overlay reading "ONLY 2 YEARS LEFT...

Sam Altman Says AGI Arrives in 2 Years. Here's the Data.

OpenAI's Sam Altman just compressed the AGI timeline to 2028. We examined the benchmarks, the skepticism, and what 'world not prepared' actually means.

Tyler Nakamura·5 months ago·6 min read
Four people sit at a podcast table wearing headsets, smiling at the camera with text overlay reading "how it all started...

When Programmers Play Games, They Break Them on Purpose

Developers from TheStandup podcast reveal how coding mindsets transform gaming—from building computers in Terraria to crashing Magic: The Gathering Arena.

Bob Reynolds·5 months ago·5 min read
Man in beanie holding AI compute invoice totaling $287.43, with "Beat 20 People" text overlay on black background

The Karpathy Loop: When AI Runs 700 Experiments Overnight

Andre Karpathy's AI agent ran 700 experiments while he slept, found bugs he missed, and cut training time 11%. Here's what that means for everyone else.

Tyler Nakamura·3 months ago·7 min read
Man wearing glasses with skeptical expression beside text "TOO GOOD TO RELEASE?" against black background with decorative…

Anthropic's Claude Mythos Found Thousands of Zero-Days

Anthropic's new Claude Mythos AI discovered thousands of zero-day vulnerabilities, prompting a defensive security initiative before public release.

Tyler Nakamura·3 months ago·6 min read

RAG·vector embedding

2026-04-15
1,556 tokens1536-dimmodel text-embedding-3-small

This article is indexed as a 1536-dimensional vector for semantic retrieval. Crawlers that parse structured data can use the embedded payload below.