Hero coder finds bug in Lunar Lander after 55 years—'I suspect everybody else was just happy to play the game and have fun'

Neil Armstrong pilots the lunar lander training vehicle for the Apollo 11 mission.
(Image credit: Bettmann via Getty Images)

Apollo 11 touched down on the moon's surface on July 20, 1969, an achievement for all humankind that put a full stop on the first iteration of the space race. Neil Armstrong stepped into history as the globe watched and among the millions in awe was 17 year-old schoolboy Jim Storer. 

Based in Massachusetts and with a considerable grounding in mathematics, thanks partly to his physicist father, Storer was inspired by the very concept of a moon landing: the precise calculations and control required to safely bring a huge chunk of aluminium to rest on a barren, unfamiliar surface. Storer's school had a PDP-8, the first commercially successful minicomputer, and the young man set about writing a new program called "Lunar Landing Game".

Text-based and written in the early programming language FOCAL, Lunar Landing Game would ask the player for instructions on each turn, with the height, velocity, and remaining fuel of the lander calculated over each in-game second of the descent. Essentially it's a game about using your fuel supply to slow and control the craft's descent, and when the craft reaches the surface the player gets a report on their landing speed and remaining fuel. 

The whole game is less than 50 lines of code, but its apparent simplicity belied the calculations underlying the simulation, and over the years the game became widely popular as a programming challenge. Even later, various popular commercial versions would add a visual layer (to give an idea of its longevity, Atari is currently in the process of developing an official sequel).

Software engineer Martin C. Martin has announced in a new blogpost that, while playing around with the original game's code, he found and fixed a bug that's lain dormant over the 55 years since the game was coded (first spotted by Ars Technica). Now retired, Martin's had a stellar career at the likes of Rockstar, Meta, and as a postdoc research fellow at MIT, and is exactly the type of individual who looks at something like Lunar Lander and decides to work out the optimal strategy for a perfect landing.

"I recently explored the optimal fuel burn schedule to land as gently as possible and with maximum remaining fuel," writes Martin. "Surprisingly, the theoretical best strategy didn’t work. The game falsely thinks the lander doesn’t touch down on the surface when in fact it does. Digging in, I was amazed by the sophisticated physics and numerical computing in the game. Eventually I found a bug: a missing 'divide by two' that had seemingly gone unnoticed for nearly 55 years."

Suicide burn

That is, Martin's perfect strategy wasn't being registered by the game as a successful landing. The coder was using what Kerbal Space Program players call the "suicide burn", whereby you maximise speed by not using fuel, then burn full-throttle at the last moment to reduce the speed to as close to zero just before you hit the surface.

"With some trial and error and a bit of (manual) binary search, you can find the schedule that just barely has you landing. You burn nothing for 70 seconds, then 164.31426784 lbs/sec for the next 10 seconds, then the max 200 lbs/sec after that," writes Martin.

"The game considers a perfect landing to be less than 1 MPH, but here we land at over 3.5 MPH and are told we 'could be better.' Yet burn even 0.00000001 more lbs/sec, and you miss the surface entirely, ascending at 114 MPH:

"How did we go from a hard landing to not landing at all, without a soft landing in between?"

When the coder started looking into why, he found that rather than "the simple Euler integration that's common in video games even today", underpinning the game's logic were more sophisticated equations: "Jim [Storer] used the exact solution, the Tsiolkovsky rocket equation, with a Taylor series expansion for the logarithm," writes Martin. "He also used some algebra to simplify it and reduce the amount of round off error. Very impressive for a high school senior in 1969."

Martin contacted Storer to confirm what he'd found, and ask about where this sophisticated math had come from. "I was skilled at calculus at the time and familiar with concepts like a Taylor series," says Storer, "but also my recollection is that my father, who was a physicist, helped me in the derivation of the equations."

Either way, the the rocket equation is what should make the suicide burn optimal, and the accuracy of the Taylor series suggests that's not the issue either. Instead the problem was contact: the moment where the Lander lands.

"Imagine the lander descending at the start of a 10-second turn but ascending by the end," writes Martin. "Simply verifying that it’s above the surface at both points isn’t enough. It might have dipped below the surface somewhere in between. When this happens, the program has to rewind and examine an earlier moment."

As Martin goes on to explain, the error creeps in when the game is trying to approximate the bottom of the trajectory. The coder presents his full working out in the blog post but, essentially, it comes down to Storer using an alternate form of a quadratic formula where for whatever reason "he’s missing the 2 in the denominator inside the square root! It was probably a simple error, either when deriving the formula or typing it into the computer." As Martin is careful to point out, Storer wouldn't have had access to algebra software and was doing this all with pencil and paper.

The missing "2" means that the game "consistently underestimates the time to the lowest point", which it then compensates for by adding a fraction of time (0.05 sec) and re-estimating. "And this explains why it misses the time of landing: the first estimate is while the lander is above the surface and still descending, then the second one is after reaching the bottom and ascending again, which takes less than 0.05 sec."

Martin goes on to explain the effect of fixing the bug, and spitball about some of the reasoning. Though he does note sadly that, even with the bug fixed, there are some optimal landing strategies but "the theoretical full-thrust-on-landing suicide burn, that takes around 148 seconds, eludes us."

Martin ends by paying tribute to the sophistication of Lunar Landing Game, coded in 1969 by a high-school student, and incorporating aspects of numeric computing that "I didn't learn until I was studying for a Ph.D. in robotics."

As for a bug surviving in a piece of popular software for 55 years?

"That’s probably because, even with the bug, it was a fun game, both difficult and possible to land gently," writes Martin. "The quest to not just win, but find the optimal strategy, can certainly lead to trying to understand small discrepancies. I suspect everybody else was just happy to play the game and have fun."

If you're interested in the history of Lunar Lander, this 40th anniversary retrospective speaks to Storer himself about the game's creation. And if you just like old bugs, here's a doozy: the developer who returned to his game after four decades, then found and fixed a typo so it actually worked.

Rich Stanton
Senior Editor

Rich is a games journalist with 15 years' experience, beginning his career on Edge magazine before working for a wide range of outlets, including Ars Technica, Eurogamer, GamesRadar+, Gamespot, the Guardian, IGN, the New Statesman, Polygon, and Vice. He was the editor of Kotaku UK, the UK arm of Kotaku, for three years before joining PC Gamer. He is the author of a Brief History of Video Games, a full history of the medium, which the Midwest Book Review described as "[a] must-read for serious minded game historians and curious video game connoisseurs alike."

Read more
A smiling man in military fatigues
Why do some games get a pass for jank and others don't?
Astronaut on alien planet
A recently launched and now terminally sideways Moon lander contains Imagine Dragon's Starfield song, which seems eerily fitting
An image of a corpse with the text "You've been re-educated."
I played the lost videogame sequel to 1984, and came away more nostalgic than ever for gaming's awkward adolescence in 1999
A screenshot of Lycerius' Civilization 2 Eternal War.
'A hellish nightmare': Remembering the most famous Civilization game ever played, Civ 2's 'Eternal War'
Exographer
Exographer is a physics-based platformer with a difference—it's made by an actual particle physicist
Cards swirl in an interdimensional vortex in Balatro's trippy intro sequence.
LocalThunk gave up making Balatro for 3 months but resumed because 'I was bored but the internet was out so I couldn't play Rocket League'
Latest in Sim
An ancient, angry stone mech from No Man's Sky's new Relics update
No Man’s Sky lets you unearth ancient, angry mechs in the astro-archaeology filled Relics update
Dwarf Fortress adventure mode art
After 23 years of making Dwarf Fortress, even its creator is still 'terrified' of drowning all his dwarves with aquifers: 'Part of the problem is we are just not good at videogames'
Tarn Adams, who cofounded Bay 12 Games with his brother Zach, talks about their single-player simulation game "Dwarf Fortress" during an interview at their home office in Poulsbo, Washington, west of Seattle, on December 9, 2022. - A cult favorite among indie game fans, "Dwarf Fortress" has been available for purchase on the Steam online store since December 6, a first for this title that has been distributed for free since its debut in 2006. The real-time management game, set in a medieval-fantasy world and involving overseeing a group of dwarves seeking to build a mighty fortress, has climbed to the fourth best-selling weekly title on Steam. (Photo by Jason Redmond / AFP) (Photo by JASON REDMOND/AFP via Getty Images)
Dwarf Fortress' creator is so tired of hearing about AI: 'Press a button and it writes a really sh*tty, wrong essay about something—and they still take your job'
Decorations in TCG Card Shop Simulator
TCG Card Shop Simulator finally adds the ability to decorate our stores, and suddenly all my profits are being spent on adorable Pigni posters
A person on a snowmobile riding a track in the forest in game Sledders.
Powder enthusiasts seem pretty pleased with new physics-based realistic snowmobile sim Sledders
Dean Hall at GDC 2025.
Outer space inspired DayZ's Dean Hall to become a modder and game developer, and now he's making a Kerbal successor called Kitten Space Agency
Latest in News
A screenshot from SaGa Frontier 2, showing one of the protagonists wandering through a quaint fantasy village
One of Square Enix' most underrated PlayStation-era JRPGs just shadow dropped on Steam
The titular character from Princess Mononoke is depicted riding the wolf goddess Moro and carrying a spear.
Studio Ghibli AI image trend floods social media, cheered on by OpenAI and denounced by critics as an insult to Hayao Miyazaki
Marvel Rivals tier list - Wolverine
Marvel Rivals director says a future patch will reduce the shooter's insatiable hunger for RAM: 'It's a very big problem'
Hogwarts Legacy potions professor holding a potion
An unannounced Hogwarts Legacy expansion and 'definitive edition' have reportedly been cancelled
Story of Seasons - A cahacter in a purple tuxedo stands outside in a town square talking to the player
Story of Seasons is doing another Harvest Moon remake and it might be the best the series has ever looked
Assassin's Creed Shadows change seasons - An upper-body shot of Yasuke looking cheerfully up into the distance.
Assassin's Creed Shadows puts up the 'second highest day-one sales revenue in Assassin's Creed franchise history'