Building adventure games with ScottKit

You can build your own games, that’s what! Adventure games of the GO NORTH, GET LAMP, KILL TROLL variety. If that seems limited to you, consider that the same mechanisms can easily underlie games in any setting, and with any theme. It’s a style of gaming that gets you a lot of game for relatively little work: for example, the source code for Scott Adams’s own classic Adventureland, as decompiled with scottkit -d, comes to only 22 Kb.

The original late-1970s artwork for Adventureland. In those days, any kind of cover art was unusual: quality was not always assured.

I’ll write more about the charms of this kind of game creation in a subsequent post, but today I want to get you started in creating games.

Step 1. Install ScottKit

You’ll need Ruby. Installing that will depend on your operating system. Any Linux distribution will have it in a package: use apt-get install ruby on Debian-based distributions (including Ubuntu), yum install ruby on Red Hat-based distributions (including CentOS), or whatever package manager you use. If you’re on a Mac, MacPorts and homebrew both have packages: use something like port install ruby or brew install ruby.

Once you have Ruby installed, you also have its gem system for installing Ruby packages. Then you can simply gem install scottkit to get the latest released version (currently v1.1.0):

(Note: depending on your setup, some or all of these steps may need to be done as root, the administrative superuser. If you are told you lack permission to do any of these steps, prefix your commands with sudo, and enter your usual password when prompted.)

Step 2. Create source code and compile it

Fire up your favourite text editor (that’ll be Emacs, of course) and write a file called game1.sck. (“game1” is the name of the game — you might want to pick something more evocative. “sck” is the usual extension for a ScottKit source file, but you don’t need to use it if you don’t want to.)

That’s it: a complete game. It consists of two rooms, connected along the east-west line, which you can move between. (I didn’t say it was a good game.) Here’s a map:

Now you can compile it:

mike@sauropod:~$ scottkit -c game1.sck > game1.sao
mike@sauropod:~$

You now have a compiled game file called game1.sao. (Again, “game1” is just the name of the game — you’ll want to use the same name as for the source file. And “sao” is the usual extension for compiled games.)

Step 3. Play the game

You’ve got a few choices here. You can play the game using ScottKit itself:

mike@sauropod:~$ scottkit game1.sao
ScottKit, a Scott Adams game toolkit in Ruby.
Release 1.0, (C) 2010 Mike Taylor <mike@miketaylor.org.uk>
Distributed under the GNU software license
I'm in a square chamber
Obvious exits: East.
Tell me what to do ? go east
I'm in a gloomy dungeon
Obvious exits: West.
Tell me what to do ? go west
I'm in a square chamber
Obvious exits: East.
Tell me what to do ? help
You use word(s) I don't know!
Tell me what to do ?

But ScottKit plays games in a relatively primitive way, simply emitting text in a stream. That’s good for some purposes (for example, it makes for great regression tests) but not necessarily what you want. You can get a more authentic 1980s Scott Adams adventure experience using ScottFree, which is available as a package for many operating systems:

Now you can use this curses-based program to play in split-screen mode, with the location description above the line and the dialogue below, using scottfree game1.sao:

“But Mike”, you ask: “Can ScottKit be used to make even more exciting games than this?”

Why, yes. Yes, it can. But more on that next time. If you’re keen to get ahead, you might be interested in the bare-bones tutorial, which builds on the two-room game we just created; and then in the reference manual, which explains the source language in detail.

5 responses to “Building adventure games with ScottKit”

You simply must monkeypatch one of your compiled gamelets, into an actual SA interpreter. I want to see your hello world gamelet on a vic-20 screen :) (I used to do it with a Atari Portfolio, one of the first handhelds; it ran DOS3 if I remember right, so I was able to hav this cranky old handheld running a modded interpreter, running one of my experiments. Useless, but these things amuse me :)

I was not aware of the * leading asterisk trick; does that work in the original games, I wonder?

Do SA games support player death, and monster (mobile items?) .. I forget; too many years!

I don’t know how to get my own games running on an emulated VIC-20. No doubt there is an interpreter out there somewhere, that someone has disentangled from the specific game it came with, but I’ve not seen it. Let me know if you come across such a thing.

I am afraid to say that in Scott Adams games, the definition of a treasure is “an item whose name begins with an asterisk”, and the definition of the score is “the percentage of treasures that have been placed in the designated room”. So one area of inflexibility is that you can’t easily implement your own scoring system.

(I say you can’t easily do this, because of course you can hack it: add two rooms that cannot be reached from the game. One of them contains a “treasure” for each point you want the player to be able to score, and the other is the designated treasury. When the player does an action that you want to score points, just have an action move the corresponding treasure across.)

The Scott Adams engine supports two forms of player death: one takes you to a “limbo” room: if you wish, you can provide a means for the player to be resurrected from there. The other ends the game directly.

There is no direct support for mobile items, but it’s easy to implement them yourself using the primitives that are provided. (You might equivalently have asked whether the 6502 instruction set supports multiplication, and I could reply “no, but it’s easy to implement it yourself using the primitives that are provided”.)