On of the first programs I ever ran on a computer was a text adventure game, also known as Interactive Fiction. I think the first one I played was Adventureland by Scott Adams, which was based on the first ever text adventure called Adventure by Crowther and Woods. Adventureland was the first text adventure available for personal computers.
Not long after that I discovered Zork I, the first game by Infocom. I loved the Infocom games, I played most of them, spending many hours solving the games.
Where the Scott Adam’s games had a parser that only allowed 2 words (verb object, such as ‘get lamp’), The Infocom games had a much more sophisticated parser. You could be as complicated as ‘Robot, give the rusty lamp to the ugly troll.’.
This was about the same time I was just learning programming in basic. I wanted to write my own text adventures, and I wondered how Infocom’s parser worked. I think this is what sparked my interest in parser, compilers, and interpreters to this day.
So, to get to the point, I wanted a project to do something more challenging in Clojure, and I remembered that I wanted to write a adventure game when I was a kid.
ifgame is a Clojure library for writing interactive fiction games. It just a start, but really not a bad one. You can define rooms and their connections to other rooms, and what objects they contain. You define objects and what properties they contain. You can also define all the actions in the game, such as ‘get’, and ‘drop’, or whatever you want. Each room or object can have handlers that can modify the behavior of the standard actions and really make up the interesting parts of the game.
An example is included, which is basically the Heidi example defined in the Inform Beginner’s Manual. Inform is a modern version of Infocom’s ZIL programming language which they used to create their games. It in itself, is a an amazing system for creating these games. ifgame is based on Inform 6. Check out Inform 7 for an even more amazing system. You basically program the game in English. Big props to Graham Nelson, the creator of Inform.
I hope you find ifgame interesting and it inspires you to dive into the fascinating world of Interactive Fiction.