LUNAR for C and Rust

I've written before that my first exposure to computers was a simple text-based "Lunar Lander" game.

Earlier this year I did some research and I found the original LUNAR source code, which is in the FOCAL programming language, and some translations to BASIC.

I decided I needed to port this to a modern programming language like C.

(Yes, that's intended ironically.)

The result is "LUNAR for C", which you can find on GitHub: kristopherjohnson/lunar-c.

I also decided to port it to Rust, which I was exploring at the time. Porting to Rust was not straightforward, because the original source code has goto-based control flow, and Rust doesn't have a goto statement. One way to deal with this is to implement a simple state machine in Rust, and the result of that experiment is available in a Gist: But I also planned to do some machine-learning experiments to find the ideal solution to the lunar-landing problem, so I created a very over-engineered "LUNAR for Rust" version that is available on GitHub: kristopherjohnson/lunar-rust.

If you want to play the game yourself, and you have a C compiler, I recommend building the C version.

Thank you to Jim Storer (the original author of LUNAR), to David H. Ahl (author of the BASIC ports), and to every other programmer who has created a lunar-landing game that I've played.

© 2003-2023 Kristopher Johnson