JACK WHITHAM PhD MEng
Professional Activities - Publications - Software - Articles
   
       
    Software -> Tilehack (Nethack with Graphical Tiles - Online!)    

Tilehack

Nethack with Graphical Tiles - Online!

Nethack is the definitive "roguelike" adventure game. It's a huge, complicated and challenging game, both frustrating and rewarding. Most computers can run the game software locally, but it's also fun to play online, for a high score on alt.org or prizes from the /dev/null Nethack Tournament.

Online Nethack servers usually only offer Nethack via the text-only Telnet protocol. Only the classical text interface is available (right). But some players prefer the graphical interface that has been a standard part of offline Nethack since version 3.2 (released 1996).

One way to enable online tiled play is to guess a suitable tile to replace each on-screen character, based on its attributes, and substitute accordingly. This is the strategy used by David McCallum's program Ebonhack. It works for any Nethack server, but it isn't completely ideal. The text display does not contain as much information as a tiled display - some characters could represent more than one tile, and sometimes a page of text is mistaken for a map and vice versa. A better strategy (introduced by Justin Hiltscher for TelnetTiles) extends Nethack to generate hints about the correct tiles alongside the text characters.

Tilehack is a new approach to TelnetTiles, moving the client into Javascript running in a web browser. It is compatible with text mode and the popular dgamelaunch software. This makes it cross-platform and easy to use, and ensures that the tile set used by the players always matches the one used by the server. Naturally, a player can switch between tiled mode and text mode without starting a new game.

The Tilehack interface is similar to the graphical Nethack interface for MS-DOS: there is no mouse and menus are still text. However, the tiles appear exactly as they do within Nethack for Windows, Mac, MS-DOS and Linux (right).

Tilehack Servers

I ran my own experimental server for three months at the beginning of 2010, but I found that I could not spare the time needed to build a really good online Nethack service, which is about much more than the game software! The final scores are still archived below.

How it Works

Tilehack is based on shellinabox. In short, I modified Shellinabox to be able to display tiles as well as text. There are three major components to Tilehack.

1. Patch for Nethack

Translating text characters into tiles is not ideal, so Nethack must state precisely which tile is needed for each location on the screen. My patch for vanilla Nethack 3.4.3 (unified diff) adds the new "vtiles" module to sys/unix and win/tty. The patch should be compiled into Nethack.

It takes effect only when $TERM = "tilehack". Tiles are drawn using VT100-style escape codes; there are additional escape codes to set the cursor colour according to the player's HP, as in Qt Nethack. These escape codes are chosen for compactness rather than compatibility with non-tiled terminals: unrecognised escape codes are supposed to be ignored, but some terminals try to interpret them anyway, so there is no way to produce output that is compatible both with Tilehack (or TelnetTiles) and with absolutely all non-tiled terminals.

2. Shellinabox-based Server

A modified version of Shellinabox is used as the client. Here's the modified version (based on SVN version 239). The modifications alter the Javascript code to add support for the tile-drawing escape codes. Some features are disabled, e.g. printing, and the cursor keys are enabled for Nethack.

(There is also an earlier version based on shellinabox-2.10, and here is the diff for version 2.10 and the diff for SVN version 239.)

3. Tiles

The Nethack tiles need to be converted into PNG format. Here is the standard tile set, converted appropriately. Each file is named number.png. These files should be hosted on the same web server as Tilehack.

The low 12 bits of number are the tile number, as used within Nethack's glyph2tile data structure. The 12th bit indicates if the tile represents a pet: if so, a small "heart" icon is added to the corner. For version 3.4.3, there are 1080 tiles, resulting in 2160 PNG images.

Setup

To run your own Tilehack server, you first need to get text-mode Nethack working with dgamelaunch, so that you can telnet to your server and play. This must be the patched version of Nethack described above.

Then, the steps are (roughly) as follows:

  1. Install the "tilehack" terminfo file on the Nethack server. Copy the "xterm" entry to a new entry named "tilehack". On Debian Linux, you can do this as follows: cp /usr/share/terminfo/x/xterm /usr/share/terminfo/t/tilehack. Unfortunately, this step is different on every OS, but without the "tilehack" terminfo file, you may see messages such as "Unknown terminal type: tilehack" and (if using dgamelaunch) you may not get any visible output!
  2. Set up a web server such as Apache to serve the tile set under an URL such as http://example.com/nhtiles/ (substituting example.com for your web server's address).
  3. Configure the web server to act as a reverse proxy whenever an URL such as /nethack/ is accessed. This reverse proxy should forward to "localhost" port 4200, the default port used by shellinabox. Here is an explanation of the procedure for Apache. No need to use SSL.
  4. Run shellinaboxd with a command line such as:
    shellinaboxd -t -s '/:$user:$group:/:$command'
    In this command line, you must substitute $user and $group with the names of a valid user and group on your system. For testing, use your own username and group (the first two fields that are printed by the "id" command). For a real server, you should think about setting up a "chroot" environment and using dummy user accounts for extra security.

    $command should be "telnet -E $nethackserver", or an equivalent that respects your chroot environment. For regular telnet, -E is important: it disables the telnet escape sequences, which might otherwise allow a user to start a shell on your server.
Note that the Nethack server and the web/shellinabox server can be different machines.

Acknowledgements

I would like to thank all the Nethack players who spent time playing "Nethack with Graphical Tiles - Online". I appreciate your efforts in testing the service and your email feedback. I'd also like to thank David Stone for the feedback he sent while configuring his server (amuletofyendor.com) and paxed from NAO.

Shellinabox is GPLv2-licensed software, written and copyright by Markus Gutschke. Tilehack would have been much more difficult if I had not been able to build upon this excellent piece of free software.

Future Work

A standard for tile escape codes is being established on nethack.alt.org. Future versions of Tilehack may adopt these codes for interoperability with nethack.alt.org and other tile-based clients.

Test Server - Final Information

By the end of the three month testing period, 1651 games had been played on the server. 136 were not completed. There were no ascensions, although "trif" the human male Tourist made it to the elemental planes with the amulet, where he died an unlucky death from a cockatrice-wielding Archon.

Here is the final high score table. Once again, my thanks to all who took part.

ScoreLevelMax
Level
End DateClass/Race/
Gender/Align
NameReason for endgame
2313906-15320091230Tou Hum Mal Neu   trifpetrified by an Archon (with the Amulet)
206174212120100123Mon Hum Mal Neu   CatStevenskilled by a rock troll
153622171320100130Val Hum Fem Law   CatStevenskilled by a fire giant
136632141620100124Bar Hum Fem Cha   robcypherkilled by a rock troll
126312252620100216Sam Hum Mal Law   trabickilled by a touch of death
12263661120100221Bar Hum Fem Neu   robcypherpoisoned by a rotted black naga corpse
11329231020100218Mon Hum Mal Neu   hansel0killed by a fire ant, while helpless
96386212120100103Bar Orc Fem Cha   Jackkilled by an air elemental
79750121320100110Val Hum Fem Law   trifkilled by a winter wolf, while helpless
7025211120100109Val Hum Fem Law   trifescaped
4038781120100116Mon Hum Fem Neu   Xevkilled by an ettin mummy, while helpless
28605111120100130Wiz Hum Fem Neu   Xevkilled by an energy vortex
223017920100327Wiz Elf Fem Cha   Xevkilled by a soldier ant
17773101020100101Sam Hum Fem Law   robcypherkilled by a vampire
1690451020100129Wiz Elf Mal Cha   Voltarikilled by a scroll of earth
121387720091226Kni Hum Mal Law   robcypherkilled by an owlbear
117866920100314Kni Hum Mal Law   iigneouskilled by a soldier ant
11405121220091228Cav Hum Mal Neu   trifkilled by a dwarf
104708820100202Ran Hum Fem Cha   robcypherpetrified by a chickatrice
80056620100121Kni Hum Fem Law   Xevkilled by a soldier ant
77267720100115Hea Hum Mal Neu   LawyerGuyquit
64968820100126Arc Dwa Mal Law   robcypherkilled by a leocrotta
51548820091227Ran Orc Fem Cha   boldbjornkilled by a watch captain
51026620100324Sam Hum Mal Law   iigneouskilled by an Uruk-hai
45455520091230Rog Hum Fem Cha   trifkilled by an ape
45122720091226Ran Elf Fem Cha   Spadenkilled by a rothe
42657720100303Pri Hum Mal Neu   light3killed by a black unicorn
30918820100318Arc Gno Mal Neu   morukilled by a giant spider
28506620091230Rog Hum Mal Cha   trifkilled by a jaguar
25375520100111Pri Elf Mal Cha   robcypherpoisoned by a rotted gray ooze corpse
25367720100228Cav Hum Mal Neu   light3killed by a giant bat
24229920100326Pri Elf Mal Cha   iigneouskilled by a soldier ant
23549920091225Tou Hum Mal Neu   Jackkilled by a dwarf
19366620100209Arc Hum Mal Neu   Voltarikilled by a magic missile
15844520100225Hea Hum Mal Neu   iznogoudkilled by a pony, while helpless
15275520091228Tou Hum Fem Neu   trifkilled by a killer bee
10027720100111Hea Gno Fem Neu   robcypherkilled by a small mimic, while helpless
8415520100305Rog Orc Mal Cha   iigneouskilled by a dwarf zombie
7193320100323Cav Gno Mal Neu   someone13killed by a bat
See also:
raw logfile, raw record file.


       
  Copyright (C) Jack Whitham 1997-2011