Deep within the source code of this online multiplayer game lies an enigmatic number that puzzles and inspires experts to this day
Game developers didn’t have it easy in the 1990s. Because they had extremely limited computing power, they had to write their code as efficiently as possible. Consider the first-person shooter Quake III Arena, usually called Quake 3, for example: players navigated a three-dimensional world, so the programmers had to find the cleverest ways to handle 3D graphics and the associated calculations.
Quake 3 released in 1999 and is considered one of the best computer games of its time. It had a lasting impact on the industry. This legacy wasn’t so much due to the story, but rather because Quake 3 was one of the first multiplayer first-person shooters. Players could connect their computers via network cables or the internet to compete in real time.
The game’s code left a mark too. It included an extremely efficient algorithm that still amazes experts and sparks curiosity among scientists.
On supporting science journalism
If you're enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.
A strange code
To figure out the orientations of objects, characters or other players in three-dimensional space mathematically, you create a vector, which is essentially an arrow that shows direction. To compare vectors, they need to be normalized to the same length, so you have to scale them accordingly. And that’s where a tricky calculation comes up: the inverse square root, which is one divided by the square root of a number.
If I asked you to calculate the inverse square root of 26 without a calculator, you’d probably be stuck for a while—and honestly, so would I. Back in the 1990s computers faced the same challenge. Although they could crunch the numbers, the process demanded a lot of processing power—which can mean the calculation takes a lot of time. One problem was the square root itself; another was the division. That’s why the Quake 3 programmers hunted for a better way to find this inverse square root. And indeed, their source code revealed an ingenious solution.
What’s fascinating is that the developers never advertised their trick. If Quake 3’s source code hadn’t gone open source, their method might have stayed hidden forever. But once it was released, curious enthusiasts took notice. When they discovered the code snippet for calculating the inverse square root, they were baffled—it was difficult to follow, and the developers’ accompanying comments weren’t particularly helpful. But gradually people figured out how the code worked.
... continue reading