Project: Write a one-room text adventure

“Interactive fiction” is a fancy phrase for what we used to call “text adventure games”. In the days when most computers lacked graphics capabilities, and often did not have the ability to interact with the user in real-time, the only sort of game you could make was some kind of text-based, turn-based system. Text adventures gave the user textual descriptions of what was going on, while the user entered commands (directed at the in-game “avatar”). An hypothetical session might looks something like this:

You are in a grassy meadow, ringed with poplar and cedar trees. A small brook
quietly winds its way through the weeds. The open meadow continues to the 
north and east, while to the south you can see the nearby mountains over the
tops of the trees, and to the west the dark forest closes in quickly.

> LOOK BROOK

The brook is only a few feet wide, with a shallow stream of clear water, rushing
off to who knows where.

> GO NORTH

The grass of the meadow is shorter here, and a few lumps of granite break up
the field here and there. From here, you can see a wisp of smoke rising from
the trees to the north. 

Some bird has built its nest on top of one of the rocky outcroppings.

> LOOK NEST

There is a small egg in the nest.

> GET EGG

and so forth.

Zork is a classic example of a text adventure; you can play it only here. I suggest you give it a try so you can see what we’re aiming for!

Some things to note:

At the beginning, your game will be quite simple, featuring only a single location and object. As we go on, you’ll add more locations and objects, and add richer commands for interacting with them.

Although the stages of the project build on each other, you should expect to rewrite significant portions of your program from scratch for each stage. Trying to keep everything you have from one stage to the next, only adding new code, is a recipe for a huge mess. You’ll find it much easier in the long run if you rewrite code as we learn new and better ways of doing things.