1 - Lesson One


1.1 - The most basic adventure

The absolutely most basic text adventure that can be written in Alan would name one location and specify that the adventure starts at that location. The Alan source code for such a basic adventure would look like this:

This would be a very boring adventure game. No descriptive text would appear on screen. There would just be the word Itsaplace displayed and a > symbol on the next line prompting the player to enter a command. However there are no commands the player could use as none have been specified in the source code. There is not even a command to exit from the game. Pressing the Ctrl and C keys simultaneously will crash out of it on most versions of Alan. On the Apple MacIntosh version use Command-Q.

1.2 - Adding direction commands

So lets elaborate the source code for our example text adventure a little before we look at how to compile and play Alan games.

Firstly we can add a second location so we can at least move between two places. We'll call it AnotherPlace . (Note that the names for items in the Alan language cannot have spaces in them. You might want to use underscore characters in location names, eg: Another_Place , to make them easier to read.)

We can decide that "AnotherPlace" will be to the north of our "ItsAPlace" location. To allow the player to move north from "ItsAPlace" to "AnotherPlace" we would add an EXIT specification to the section of source code describing the "ItsAPlace" location:

So the player can move back from "AnotherPlace" to "ItsAPlace" we could add an EXIT south specification to the source code for "AnotherPlace"

1.3 - Adding location descriptions

Someone playing this game would now be able to type north when they are at "ItsAPlace" to go to "AnotherPlace" and then south to move back from "AnotherPlace." However the player would not know this. The game needs to provide some information to the player about where they are. This is done by writing some descriptive text in a location DESCRIPTION section such as this:

The text within double-quotes will be displayed on screen when the player moves to the location. A similar DESCRIPTION section can be added in the code for "AnotherPlace:"

1.4 - Compile the Example

Try compiling this game with Alan. The source code is included with this tutorial in the file lesson1.ala - so the command to compile it is

You can then try playing it with Arun though remember you'll need to use ctrl-c to exit from the game. The command to play the compiled game is

You could also write your own little two-location game with north and south 'exits' to go between the locations. You can write the game in any text editor or wordprocessor program. A wordprocessor is not the best as you must remember to save the file in plain text format and automatic word wrapping may mess up the layout of your source code.

If your game doesn't compile look for missing full-stops ('periods'). Just like sentences, all blocks of Alan code need a full-stop to mark the end. So EXIT statements need to finish with a full-stop and the END LOCATION lines need full-stops as well.


Example Alan source code | Table of Contents | Next Lesson