CIA Adventure is a text adventure game written for DOS in 1982, which I have been fascinated with for 40 years. Frustrated with trying to get the ruby out of the glass case at the end of the game, I peeked into the BASIC code to find the answer.
CIA.bas consists of 271 lines of dense, unreadable spaghetti code. Working my way through the code line by line, I discovered the glass case needed to be cut with a razor blade! The problem was solved, but it created a life-long obsession. As I lay in bed that night, I had a crystal-clear image in my mind of how the code should look like.
Over the years, I have written and rewritten CIA over and over, in various languages, such as Pascal, C++, and Java. Each try brought me closer, but fell short of my vision because of language constraints. A domain-specific language I wrote in 2011 came incredibly close. It was concise and readable, but ultimately didn’t have the power or flexibility I wanted.
With the completion of JPascal this May, I decided to have some fun and take another shot at CIA. (JPascal is a tree-walk interpreter prototype of Algol-24). The result is exactly what I dreamed of 40 years ago! 30 rooms, 50 items, and 19 verbs. The code is concise and easy-to-read, but still has the power and flexibility I wanted. As a matter of fact, it turned out even better than I had envisioned. It has a full regression of 170 unit tests which was invaluable in converting all of the rooms and items to prototypes.
I am very proud of this accomplishment. It is the proof-of-concept showcasing Algol-24, and it the foundation on which PRISM will be built. But more than that, it captures my love of programming as an art form. There is no better code demonstrating who I am as a programmer, from the language syntax, all the way to the storybook style!
Take a look:
CIA Adventure