Writing A Text Adventure In Alan 3
For the past few months, the only hobby I've practiced was writing. That's because every time I tried programming for pleasure I found myself giving up in minutes -- that's how badly I was burnt out. There's been one exception to this: writing a text adventure in Alan 3.
Of course, Catch That Cat isn't a new adventure. Initially written as a demo for a homebrew authoring system and later ported to TADS 3, it's more like my own personal Cloak of Darkness, albeit one that's rather large and complex for the task, having a bigger than needed map (like everything I design) and two NPCs with radically different behavior. But that only makes it more suitable for exploring a new authoring system in depth.
Well, not entirely new. Ever since I first looked at Alan 3, it was my intention to try and use it seriously. Maybe it's because I always root for the underdog, out of a reflex to avoid monocultures. Maybe it's because of the system's exotic flavor. That you don't absolutely need a standard library to use the language is definitely attractive, and indeed I ended up writing my own instead of using the official one; more about this in the next article.
Where to begin? Alan 3 is one of those programming languages that do their best to be friendly and natural-looking. It does not, however, try to pass for English. The syntax is simple and for the most part uniform, with terse but clear error messages. I'd say the language can appeal to both programmers and non-programmers alike. Alan does seem to be overly verbose initially, but the game came out smaller than in TADS 3. So much for first impressions!
Also, while Alan appears inflexible on the surface, what with the hardcoded parser and everything, it does in fact offer a surprising amount of control. I suspect that with a bit of fiddling I could even have simulated the retro-styled auto-listing of visible objects and exits (well, doors -- you can't manipulate exits programmatically in Alan). But that would have required me to wrestle with the language instead of writing my little story, so I decided to go with the flow.
The one major limitation I found is the impossibility to trigger actions from code. That means no redirecting verbs, and implicit commands can only be implemented with ample code duplication. For an example, consider the very common case of trying to enter a locked door:
> west (first opening the big red door) (first unlocking the big red door) (with the small brass key)
Unless I've missed something big, the amount of work required to make that happen in Alan would be absurd. But you know what? Take that as an incentive to replace locked doors, which are a very tired trope, with more imaginative obstacles. Say, a tunnel with a security system you can trick by shadowing a robot on its cleaning tour.
That, by the way, is especially easy to do in Alan thanks to the system of "scripts" built into actors -- think theatrical scripts. (Or, if you're a programmer, finite state automata.) That's similar to the actor states in TADS, except here I was able to figure them out fully without spending too much time.
I do have a number of quibbles with the language, such as the "after" verb qualifier being made nearly useless by the overreaching scope of "only", (also, what's up with the "or" operator precedence?) but overall I was able to achieve more or less what I wanted with less effort than I'm used to. Where the manual wasn't clear enough, a quick look at the beginner's guide or standard library set me on the right path. More on this next time.
To draw some sort of conclusion, I'd say Alan 3 is the ideal language to experiment with if you're looking to do something unusual, such as keyword-driven games or rooms representing states of mind. Arbitrary exit names, as well as the ease of declaring verbs per location, seem made for that. I would also choose it if I wanted to make something like The Fire Tower, with a big, open map and little in the way of puzzles. Only if you require hyperlinks or online play should you look elsewhere from the start.
On the game's page you'll find this new implementation with source.