Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Slash'EM: The Sum of All NetHacks

by Howard Wen
06/12/2003

NetHack's family tree is big. This free, open source dungeon exploration game has been around for so long (16 years and counting) that it's spawned many unofficial variants, including patches and graphical front-ends ("window interfaces"). Over the years, NetHack fans with programming savvy, impatient for the next release, have implemented their own ideas to improve or enhance the game. Most of these variants have a legacy in Slash'EM--all branches in the NetHack tree eventually lead to it.

Slash'EM most noticeably extends the simple glyphs that NetHack uses for its graphics with several more attractive tilesets. But the real difference between it and many NetHack window interfaces lies beneath such superficialities. Slash'EM alters the original's game play, while most other window interfaces, like AllegroHack and Falcon's Eye, do not change the fundamental way that NetHack plays.

The added gaming elements that Slash'EM adds to NetHack include:

Related Articles:

Jaakko Peltonen on Falcon's Eye -- Falcon's Eye, an impressive graphical front-end to the venerable text-only Nethack is a milestone in open source gaming. In this interview, Howard Wen talks with Jaakko Peltonen, creator of Falcon's Eye, about the technical and social issues the project has faced.

Falcon's Eye: The Making-Over of Nethack -- Few games have the staying power of Nethack, yet its interface hasn't strayed from its roguelike roots. Enter Jaakko Peltonen's Falcon's Eye. Gaming author Howard Wen explores the new clothes on a classic game.

Mashing-Up Two NetHack Variants

Slash'EM's origins trace back to 1997 when Warren Cheung first merged a variant of NetHack, called Slash, with another patch for the game called the Wizard Patch. The current Slash'EM development team came together in 2001. Its goal has been to continue Slash'EM's legacy of maintaining its interdependence with NetHack. They make it a point to incorporate new versions of NetHack into Slash'EM, working with the NetHack developers to integrate improvements they themselves have made to NetHack.

Slash'EM is written in C, with its Qt windowing interface in C++. Of course, because of its NetHack lineage, the current release contains lots of code which the present team did not develop originally. Normally, incorporating code from outside a project can be a problem due to incompatibilities among various open source licenses, but things work differently within the NetHack family. J. Ali Harlow, 36, a programmer for the Applied Vision Research Centre of City University in London, England and one of the current maintainers of Slash'EM, says, "There's no such problem with code that has been written to be used with NetHack. We seek to use the best of these whenever possible."

Cheung, 23, today works as a Computer Science research assistant at the University of British Columbia in Vancouver, British Columbia. He says that the hardest technical challenge that he surmounted in creating Slash'EM was the very first one: combining the Slash variant and Wizard Patch together. At that point he had no knowledge of C and had never compiled anything before. His first attempt at merging the two failed. About a year went by before he gave the idea another shot and, that time, he got it to work. Slash'EM was born. "Whenever I'm writing any code that doesn't work," reflects Cheung, "I just think back to that and tell myself, 'If I could make Slash'EM work without knowing anything about programming C, I can at least do this.'"

Fine-Tuning the Proxy Window Interface

One of the continuing technical challenges has been perfecting Slash'EM's proxy window interface. The concept of a proxy window interface is relatively simple: the game runs as one process and the window interface runs as another, separate process. They may perhaps even run on different machines. But they need to talk to each other using a mutually-understood protocol.

Harlow has been been working on this element for well over a year now. The first major challenge has been to design a protocol which is independent of machine architecture and doesn't require much overhead. Harlow settled on RFC 1014. He says, "I'm still working on fine-tuning the protocol to reduce overhead. One obvious improvement would be to move to an asynchronous protocol, rather than the current, simple synchronous protocol."

The next challenge for him deals with the fact that all existing window interfaces have been part of the main process, and so they have had access to the variables and functions of the game. NetHack has a well-defined API for use when the game calls window interfaces, but very little in the way of an API for the window interface to use when querying the game. The remedy for this has had to be designed from scratch.

"The process is complicated by the fact that we need to be flexible enough that future window interfaces will have everything they need, but not so flexible that an external window interface could be used to cheat when playing with an official binary," says Harlow. "I believe I have achieved the latter, but I'm still a long way off achieving the former."

NetHack, the Vampire Player

The next release of Slash'EM (code-named "Vampire") has been in development for almost two years. (The Slash'EM project team is hoping to release the first beta early this year.) Some of the new features include:

An Amazingly Complex Program

Advising those who want to develop yet another flavor of NetHack or interface to add to the game's family, Harlow suggests, "Whatever you decide to do, make sure that you're doing it because you enjoy it and not just because you think it should be done. Try and understand how long it is going to take you to do what you're planning, and decide if you can really afford the time. There's nothing more soul-destroying than a half-completed job."

Ironically, Cheung would not recommend that others attempt what he did, which was to begin by looking at the NetHack source code without prior knowledge of C. Things will be much easier if you're not trying to both figure out the programming language and what the program is doing--this might be obvious but he thinks it's worth emphasizing.

"Start with a small modification, then work out all the ramifications," says Cheung. "It's amazing how everything in NetHack can interact, and the player can do almost any action with any object. So one simple addition can lead to many more ideas that are interconnected. NetHack is an amazingly complex program, and small changes can have far-reaching, unexpected effects."

Although he himself has much less time now to work on the project he started, Cheung is amazed that Slash'EM continues going so strongly in the open source gaming community without his regular involvement and by how it's affected him personally: "My long history with Slash'EM has led to it becoming part of how I think. Whenever I'm playing a new game or watching a movie, one of the thoughts that will invariably cross my mind is, 'This would make a neat addition to Slash'EM.'"

Howard Wen is a freelance writer who has contributed frequently to O'Reilly Network and written for Salon.com, Playboy.com, and Wired, among others.


Return to the Linux DevCenter.

Copyright © 2009 O'Reilly Media, Inc.