April 13, 2005

Ultrarogue

by peterb

In 1986, I nearly failed out of college because I spent so much time playing urogue.

That's not the game's fault, of course. No doubt if it wasn't urogue it would have been some other addictive little distraction that I found more interesting than my classes. But nonetheless, urogue ("UltraRogue v 1.03"), Herb Chong's little creation, was my bête noir, and so it has always maintained a barren little corner in my heart.

If you haven't played it yourself, that's not surprising. In the decades-long legal battles over who owned Unix, all of the rogue games became part of the collateral damage. There were a number of versions of the game, all descended from the original AT&T rogue, with varying names: UltraRogue. Advanced Rogue. SuperRogue. XRogue. You can think of them all as simply being "rogue, with More Stuff." Their legal status was uncertain. Even the people who owned them didn't really know whether distribution of them was OK.

The Game

Rogue, for those of you not familiar with it, is a text-based non-real-time role playing game. Your avatar on screen is a little at-sign, "@", who wanders around a crudely-drawn dungeon whacking monsters, represented by letters, on the head. Along the way your avatar will find magic scrolls, strange potions, magic rings, and the like. Your ultimate goal is to find that fabled artifact, the Amulet of Yendor.

UltraRogue (and friends) add More Stuff to this, such as character classes, so you can be a magic-user, or priest, or fighter. They add a much larger group of monsters, including greater gods and demons who are greedy for mithril and might summon you at a moment's notice. They add stores, where you can buy equipment. They add more and different types of equipment, and more artifacts in addition to the Amulet.

Compared to today's rogue-like games (Nethack, Angband, Diablo) the dungeons are simple; every level may have at most 9 rooms. Picture a tic-tac-toe board. Every section of the board might have a room (or, possibly, a dead end). All rooms are connected, although sometimes doors are hidden. This makes progressing through the game mindless in an extremely satisfying way.

The difficulty curve goes from insanely easy to insanely hard somewhere around level 20 of the dungeon. The deepest I have ever made it is to around level 50, collecting 4 artifacts along the way. It doesn't particularly bother me that I can't "win". Winning isn't the point of playing. It's like knitting. You play it just because.

The Source Code

The code for all of the Rogue Plus More Stuff games was nearly identical. Apart from subtle feature set differences, the main way you could tell you were looking at one rather than another was by who had ripped off and thrown away the AT&T TRADE SECRET copyright notice and replaced it with their own names.

Nonetheless, in the 80's I somehow ended up with the source code for both urogue 1.03 and Advanced Rogue 5.8. In the mid-90's, I ported both of them to then-current versions of Linux and BSD Unix, mostly so that I could play them.

Porting them is somewhat painful. All of the function signatures were (of course) K&R style, rather than ANSI C. They used ancient and long-obsolete forms of varargs macros, and deprecated interfaces to curses, the screen drawing package.

Perhaps the most evil portions of the code centered around save and restore. UltraRogue didn't really have data "structures" per se. They were more "data vague suggestions". Everything was a global. When you wanted to save the game, the program found the top of the data segment (using sbrk(0)) and wrote the entire data segment into a file.

Then when you restored later, the program read the file into memory and reset the data segment pointer to point to the blob of garbage you had just read in, using brk().

It is, in short, a minor miracle that save and restore ever worked at all, even at the time they were written.

I rewrote the save and restore code and got it working. I replaced the ridiculous memory management tricks with straightforward code that serialized all the interesting things in memory onto disk. Then at restore time, you just them back in in an orderly fashion. But it was still fragile, because I got bored about halfway through serializing every one of the hundreds of globals (per app), and decided to think of a better way to do it. What I eventually settled on — but never got around to implementing, because I had a day job — was that with about a day and a perl script, I could probably move all of those globals on to the heap. Once you have things on the heap, the technique of just dumping everything to a file and reading it back in again as a single lump becomes more reasonable.

On a whim, I decided to write to Herb Chong, putative author of urogue, to see if he'd let me release my patches to the 'net. Surely, I shouldn't be the only person to enjoy this bounty? Could I release the source to keep these relics alive?

Herb's reply, summarized, was: "No."

So that was that. In the end, It wasn't my code to give away, and while I felt no guilt about keeping copies for personal use, I wasn't about to stomp on someone else's copyright. Besides, I think it would be easier to reimplement the games from scratch than to completely salvage them.

I do still take them out and play them every so often, though.

And now, you can play them too. It appears that the Roguelike Restoration Project has succeeded where I have failed, in that they've manged to get clearance to distribute the source code. They've also done a lot of the same cleanup that I did years ago. There's still a lot of work left for them to do (particularly in save/restore), but I'm planning on offering them my changes. We'll see how it goes.

They've made a number of changes to the urogue interface that I don't like. But I suspect that most of my irritation with the UI comes from the fact that it's not exactly like I remember, which presumably won't matter to anyone other than me. Their version of Advanced Rogue is actually much closer to my Platonic ideal of urogue than is their version of urogue.

Try them all, and see which ones you like. And if you're not into knitting, you could always try letting the Rog-o-matic play for you. The Dungeons of Doom await you.

Posted by peterb at April 13, 2005 06:22 PM | Bookmark This
Comments

What, Nethack isn't good enough? :)

Posted by Paul at April 13, 2005 11:45 PM

http://www.metafilter.com/mefi/41210

Posted by joshua at April 13, 2005 11:57 PM

Paul,

Nethack is great if I ever declare a roguelike to be a Playable Classic, it will probably be Nethack but urogue is more pure. And obscure. And as regular readers know, I'm all about the obscurity.

Joshua,

Once again, Mister Jones, I demonstrate that there is no subject that Metafilter can post on that I can not address, better and in more detail, first.

Posted by peterb at April 14, 2005 09:53 AM

Hmm think youre right about that Arogue is more like the original Urogue than urogue is....

Nethack is good ....but The original Urogue is still the best ever... Arogue is close but not close enough for me ....

Posted by Jorgen at May 29, 2005 04:08 PM

Please help support Tea Leaves by visiting our sponsors.
Archives

2006
November October September August July June May April March February January

2005
December November October September August July June May April March February January

2004
December November October September August July June May April March February January