Roguelike column thumbnail ['@ Play' is a bi-weekly column by John Harris which discusses the history, present and future of the Roguelike dungeon exploring genre.]

I ask you to halt your busy day for a moment and consider the challenges inherent in getting a computer to play a game. Not to sponsor a game for human beings, but actually play the game, itself. To manipulate virtual controls in order to successfully maneuver through a game made for human play.

There is at least one computer game made specifically for the computer itself to play, although it is really more of a joke. And there are ways to get the machine to play through the game itself and display the results. Some action games that have an ability to record demos, in fact, work by "playing" the game. When the user plays, the game software records the sequences of control inputs, in the order and timing in which they are made, and stores them in a file. When the demo is played back, the opponents and level structure are handled as if it were a real game, and the program substitutes the recorded control stream for a player.

One may object to this, saying that this is not really playing, but it is, from the computer's standpoint. If the game is the same every time, if there is no randomness, then the process of a human playing it is actually the process of discovering the essential control inputs needed to win, and once that sequence is discovered one need only feed that sequence into the world simulation, like stimulating a brain in a jar, to cause the computer to play itself.

But the process of discovering that sequence, that is really where the game lies, isn't it? Getting a computer to play back a recorded set of inputs is easy, but designing a program to examine what a human being would see, then send the game process the discovered control stimuli to play with no prior knowledge of the game world, that is much harder. In the roguelike genre of computer games, in which all dungeons are created randomly each time and even the identities of the items shift from game to game, it is much harder to create a computer program that can play well. So hard as to be impossible, one might think.

It is so impossible, it has been done twice.

Rog-O-Matic: It Dies Dozens Of Times So You Don't Have To

The first automatic roguelike player, or "borg" as they have come to be known, was written for Rogue itself. Rog-O-Matic is a program that, if you have the fairly specific, ancient Unix hardware it runs under, plays Rogue 3.6, and plays it extremely well. It runs as another task on the machine that intercepts the output coming from the game process and supplies it with its algorithmically-determined input, and thus cannot "cheat" with inside knowledge of the hidden portions of the game's state. It has exactly the same information that a human player would have in a game.

Very few people have the means to run Rog-O-Matic any more. In fact, although the source was available from Boudewijn Waijers' Rogue page (his site was, for a long while, just about the only notable roguelike game resource on the Web) that link seems to be broken now. Like many of the earlier roguelikes themselves, the program is sliding into obscurity, and may already be permanently lost. But we do have the paper they presented at the Conference of the Canadian Society for Computational Studies of Intelligence, and it makes for an interesting read, from standpoints both of player and programmer.

Rogue, like Nethack but unlike some other roguelikes like Angband, places as heavy emphasis on the item discovery aspects of the game as combat tactics, so an automatic player will have to actually figure out aspects of the game world instead of merely exploring it. Since it begins every game with no knowledge of the identities of potions, scrolls, wands or rings, and information on these things is difficult to come by during play, there is a large component of luck in any player's progress, whether it is soft- or wet-ware.

Rog-O-Matic does not cheat, in that it has no knowledge of the game a human player could not obtain, say by reading the memory of the game process or examining the executable, but it does use what amounts to spoilers. It begins with a hard-coded list of all the possible items in the game, and it has some built-in tricks for figuring out what they do, which is important for such items like scrolls of scare monster which are not used in the normal way. This information would be hard-won to a person playing, so the game begins with what amounts to a fairly significant spoiler. This kind of cunning, the ability to figure out non-typical item uses, is something that a programmer would indeed find it difficult with which to imbue an algorithm with, so Rog-O-Matic gets around it by granting that knowledge to the borg. However, it does seek to learn the abilities of monsters honestly, keeping notes in a monster memory file between runs, in which it records whatever data it has been able to acquire about monster statistics and abilities. (It is rumored that this feature was added to universalize the algorithm, to make it less vulnerable to changes made by Rogue's developers specifically to counter Rog-O-Matic's effectiveness.)

So then, how well does it play? According to the paper, very well, as well as the best human players. It cannot win every game, neither can anyone, for Rogue is random enough so that victory is never absolutely certain even given perfect knowledge, so this is about as well as can be expected. The skill with which Rog-O-Matic plays makes sense when one considers that Rogue is, ultimately, a logic game married to a tactical combat simulation.

The procedure for identifying items is a puzzle with many special cases that need to be accounted for in order to obtain the most information from each test. Potions of object detection do not identify from use if there is nothing on the level to locate, scrolls of scare monster can be conclusively identified without touching the object, and rings of regeneration are obvious when worn if the player thinks to watch what his hit points do after taking damage. Once all these special rules are built into the system, what is left are the true challenges of writing an automatic roguelike player: optimizing player actions to minimize the resources consumed during the player's trip through the dungeon and creating an excellent tactical combatant.

(Trivia: One of the authors of Rog-O-Matic, Michael L. Mauldin, went on to found Lycos.)


Uh, Did Three Of Eight Just Tell Sauron Resistance Is Futile?

The other significant automatic roguelike player was created by Ben Harrison during his run as maintainer of Angband, and although it has the advantage of being a branch of the Angband source tree, which means it doesn't have to decipher a terminal data stream to figure out what is going on (it is said not to utilize any secret knowledge), it has a much more difficult task to accomplish. Rogue had a strong item discovery focus, but in Angband's play concerns itself more with defeating ever-stronger opponents than simple survival.

Angband's item discovery game is much more shallow than Rogue's, but that game has shops from which scrolls can be purchased, and levels can be regenerated indefinitely to generate more scrolls of identify if need be, so piecing together such knowledge requires a lot less effort from the machine. On the other hand, Angband has many, many more kinds of foes than Rogue, and they can do many more kinds of things to the player (like summon in large numbers of additional foes), so the Angband Borg doesn't make an attempt to learn what the monsters can do, it just uses its built-in knowledge of the bestiary. There are also monsters that can kill even a perfectly-equipped player in just a few turns, and from a distance, meaning that a successful borg must prepare for and be alert to such problems so they can be death with at a moment's notice. Angband's tactical depth is a bit deeper than Rogue's as well: players can dig their own tunnels, block off spaces from monsters with glyphs, or randomly warp a region of the dungeon around the player.

The original Borg is no longer being actively worked on, with Harrison having passed the Angband torch off to others. Currently, the primary fork of the Borg in development is the APWBorg[http://www.itctel.com/~apwhite/andrew.html]. Watching it play can be either a humbling or inspiring experience, depending on what one thinks about the potential of computers. The Borg has been known to win at Angband on occaision, but unlike Rog-O-Matic it tends to not be as good as an experienced human player. Watching it in action (and saving and reloading often to get around an annoying crash bug) shows it has an inordinate fondness for level 1, spending much of its time there even after it has achieved experience level 19. (The Angband dungeon is 100 levels deep, and maximum character level is 50.)

Unless the program is slowed down by adjusting a configuration file the game passes by much too fast to be able to tell what's happening, but once slowed down watching the Borg in action can be a useful way to gain ideas for how to play. Or, and here we're moving from the realm of simply cool to full-fledged awesome, there is a version of the APWBorg that works as a Windows screen saver! It you are unable to see the coolness inherent in having your computer play a game on itself at spare moments then I sincerely suggest that you turn in your geek badge, as it clearly must be a forgery.