Monday, February 11, 2019

Games 43-44: Lunar Landers

Computer scientists of the transistor age clearly loved space. As popular early software like SpaceWar and Computer Space show, these formative years of computer technology were driven by space just as much as by war. It’s difficult to appreciate how exciting the Apollo missions must have been in the 1960’s, but they once represented impossible heights of human achievement and technology, and given the need to perform inhumanly immense amounts of precise calculations with no room for error, computers played no small role. The appeal to space and math obsessed nerds is obvious, and it’s no surprise that computer hobbyists would try their hand at writing space simulation programs.

On July 20th, 1969, NASA’s lunar module undocked from the command module orbiting the moon, and landed on the moon’s surface after a 2 ½ hour descent, bringing a climax to one of the most thrilling episodes of human history, and was broadcast to the world in real-time.

Game 43: Lunar

Download my VB.NET port of Lunar here:

Before the end of the year, the first known hobbyist lunar lander simulation was written by Jim Storer, a high school student. This was written in FOCAL-69, published in a DEC newsletter, and subsequently ported to BASIC in many versions and iterations.

The FOCAL-69 source code is easily found on the Internet, and three different BASIC derivatives were published in David Ahl's seminal book 101 BASIC Computer Games. I’ve compared the original to the BASIC versions, and decided that all of the BASIC versions deviated from the original enough that I would try my hand at porting it myself, the goal to preserve identical gameplay behavior. I used VB.NET, and found I could translate the FOCAL-69 without too much trouble. GoTo commands work in VB.NET, Do commands can be replaced with function calls, and other than a tricky order-of-operations gotcha in line 8.10, the effort was straightforward, and my initial output matched a sample output almost exactly. There was only a very minor variance in my impact velocity and remaining fuel, likely attributable to differences in floating point precision.

So, what’s going on here? Well, the lander is 120 miles above the surface of the moon in free fall, descending at 3,600 MPH with 16,000 pounds of fuel, and your job is to land safely by ensuring the lander touches down at a slow enough speed. Your only method of control is to adjust the amount of fuel burned by the downward thrusters, which may be re-adjusted every ten seconds. We’ve spent the first 70 seconds in freefall, descending down to about 47.5 miles above the surface, and accelerating to 3852 MPH. Then the descent thrusters are engaged for the next 80 seconds, burning most of the fuel and quickly slowing the descent as the lander reaches the final mile of its drop. Thrusters are disengaged, the lander falls again, and one final thrust is given during the last 652 feet to slow the descent before impact. As you can tell, it isn’t enough.

After hours of trial and error, over a hundred lives lost and billions wasted, I was able to land poorly but intact, with an impact speed of 3.13 MPH. Then while fine-tuning my descent, I realized that I could enter fuel rates in decimal format, not just integers. I don’t know if the FOCAL-69 version would have allowed that, but it makes sense to me that it would, as variables in FOCAL-69 are stored in floating point format. With that epiphany and just a bit more trial and error, I landed perfectly.

Now, the descent here only took three minutes and 17 seconds. Apollo 11’s descent lasted more than two hours. I don’t think this is an entirely realistic depiction of lunar descent. Even with that considered, there’s one thing in particular that really bothers me.

We burned more than 98% of our fuel just to land. How exactly are we supposed to get back up?

Unplayed: Moonlander

I haven’t got a lot of information on this that isn’t from Wikipedia. But this was the first graphical iteration of Lunar Lander, and looks similar enough to the famous Atari version that I expect it influenced it in some way. From the fuzzy photograph, we can see that there’s sinusoidal terrain, the lander appears to be rotatable, and the top of the screen has readouts for fuel, altitude, and velocity.

The source code for Moonlander was easily found, but it’s in some kind of RT-11 assembly and is well beyond my ability to understand, much less convert.

Game 44: Lunar Lander

In 1979, Atari developed a new arcade graphics engine, which used sharp monochrome vectors rather than chunky colorful pixels, and decided to use it for a Lunar Lander arcade game. BASIC adaptations of the text-based Lunar were already widespread at this point, but Atari’s take on the concept is the game that would be best remembered for decades to come.

It’s clearly a very different game from the 1969 original. In the original you only had to worry about altitude, descent velocity, and calculating when to begin thrusting and how hard in order to slow your descent to zero just in time to land. There is no steering, the lunar terrain is not a factor, and of course there is no skill or dexterity involved.

Here, the lunar terrain is comprised of peaks and valleys, and you must decide where you are going to land. Only flat terrain is safe to land on, and certain zones are worth more points than others. The lander has horizontal velocity as well as descent velocity, and must be thrust at an angle in order to steer.

Also, while the original gave you just barely enough fuel to land safely, Atari’s gives you quite a bit more than you need. In fact, once you do land (or crash), if you have remaining fuel, your lander instantly goes back into high altitude, and you can try to land again for more points. The challenge here is more in the dexterity of pulling off landing maneuvers than in performing space calculations. I was able to land multiple times on a single coin’s worth of fuel… at least on the easiest difficulty setting.

Higher difficulty settings increase the strength of gravity. The stronger the gravity, the more fuel you spend fighting it. Gravity peaks on the second highest difficulty, at which point the lander free falls so fast that if you stop thrusting for even a second, it will very quickly reach an uncontrollable falling speed. Even thrusting at an angle is risky, and might not be enough to counteract gravity.

Once I found myself aligned with my landing zone and my horizontal velocity at zero, I straightened out the lander and used the altitude and velocity meters to guide my descent. At maximum gravity, it took almost constant thrusting with light releases to allow a slow fall, and it burned so much fuel that there was no way a second landing would be possible, but I did it.

Interestingly, you can change the difficulty setting any time, even in the middle of a landing. If you’re going for a high score, you might as well stick with the easiest setting. No matter how good you are, stronger gravity means more fuel burnt while landing, which means fewer landings and fewer points. That said, score is a bit pointless, as you get more fuel by inserting a coin at any time. You can keep buying more fuel and playing indefinitely.

The hardest difficulty setting has less gravity than the penultimate one, but has one very strange feature; the lander’s rotation becomes subject to inertia. Start spinning clockwise, and it will keep spinning clockwise, until you counter-spin in the other direction just enough to stabilize your angle. The natural inclination to press and hold a rotation button quickly leads to the lander spinning out of control.

Once I got over the shock of this new feature, and came to grips with how to get the lander to point in the direction I wanted, I actually found this a bit easier than the previous difficulty, as the weaker gravity made the act of landing more forgiving. I learned to tap a rotation button, wait for the lander to rotate to the position I wanted, and then to tap the reverse rotation button to halt the rotation. This took more time than the conventional control scheme of holding the rotation button until the lander was at the right angle and then letting go, but the lower gravity meant I had more time.

Atari’s Lunar Lander is an interesting idea, a novel break from the shooters and sports games that dominated arcades even by 1979, and showed that an action game needn’t be fast paced in order to be challenging. The barren atmosphere and sparse sound is well fitting for the moon landing scenario, and the physics feel spot-on. It would have been very interesting to play the 1973 Moonlander just to see how similar it really was to Atari’s incarnation of it.

Unfortunately, it’s just not that interesting to replay. Without any kind of opponent, the only challenge is in coming to grips with the lander’s controls and physics, and the moon terrain isn’t varied enough to make one playthrough any different from another. I landed the craft on a high scoring landing zone on the hardest difficulty setting, and could probably do it again, but why bother?


  1. Ahhh... memories.. we had a BASIC version of this on an old shareware disk for our Tandy 1000. Probably acquired it around 1985-6. Many a poor astronaut was smushed in our hands!

    I'd not heard of FOCAL-69 before... interesting piece of history.

  2. "We burned more than 98% of our fuel just to land. How exactly are we supposed to get back up?"

    Apollo LM had a completely separate ascent stage for take off and return to orbit, with its own engine and fuel tanks. Apollo 11 for instance landed with just 770 pounds of fuel left in the descent stage tanks(about 45 seconds).

  3. This comment has been removed by the author.

  4. Two photos of the GT40 version that were taken in 1999:
    From a modern perspective, the most notable features of the GT40 version are probably:
    - You control the game by moving a light pen along two sliders, one for burn rate and the other for rotating the lander.
    - The game has a McDonald's Easter egg (or alternate ending?).
    - According to Eric's page above, the collision detection and other math routines aren't very smart, and an expert player can exploit them.

  5. The version I'm using ignores the decimal and rounds down, but I was finally able to get the perfect landing (.22 mph) by tweaking the last few values of your perfect run. I used identical rates up until T=170, then I used rates of: 21 15 10 9 11.


Most popular posts