January 24, 2011

Interhack and TAEB Postmortem

Interhack

Interhack, a "smart" telnet client for server NetHack play, initially started because the annual /dev/null tournament didn't have any of nethack.alt.org's interface patches - most importantly Color HP Monitor. In vanilla NetHack, your HP display doesn't change color as you take damage, so in the tournament we would simply not notice we were being slaughtered because we had been subconsciously trained to notice damage using only our peripheral vision, which detects changes in color far more effectively than changes in numbers.

To avoid rewriting history, I should note that in the IRC logs from Interhack's inception, someone else named Stevie-O first wrote his own similar tool that made it obvious to him that his character was growing hungry. But we quickly took the idea (but importantly, neither the code nor the name) and ran with it. Interhack developed many more features beyond what we initially brainstormed but it was never designed to be driven by some other code. Interhack was always merely user interface enhancements. What was cool about the project was that such enhancements did not require patching NetHack, so Interhack could be used on NAO and /dev/null.

Also, I only added (or permitted) features that would not take actions on the user's behalf. I was worried that such actions could misfire because of bugs in Interhack and cause someone to lose their game. In which case they'd have every right to be angry at me personally. In all of Interhack's usage I only heard of a couple of incidents where Interhack screwed someone up badly. In one, the person didn't get their wish because of a bug in Interhack's accidental-wish-escape protection. When you press an arrow key or other non-character keys, NetHack sees that as a sequence of characters beginning with escape, so it thinks you're trying to cancel your wish, which earns you a random item instead of a really powerful, useful one. We added code to catch that escape key and prompt you, asking if you really did mean to cancel your wish, which was certainly useful and saved wishes that would have been lost, but for whatever reason in that one instance Interhack hung at that prompt, so he had to kill it. When he restarted NetHack, which doesn't keep enough state in its save file to remember that you were at a wish prompt, it came back up with a wasted wish. Oops!

Interhack lost steam because of a poor implementation (do FILE is entirely insufficient for a plugin system. No, really.) and NetHack bot development.

TAEB

TAEB started as my fifth or so NetHack bot, this time with a thoughtful design instead of just winging it (see above). Because as designed TAEB's AI was separate from the rest of the codebase, and thus very trivially pluggable, TAEB's name (Tactical Amulet Extraction Bot) has actually never been accurate. But it was such a great name, inciting laughter in anyone we told who was at least as geeky as we are, so we naturally wouldn't change it. TAEB was really a bot framework which happened to ship with a bunch of different AIs. We also (partly as a joke, but partly as a debugging tool) included a Human AI that just prompted the terminal what to do every turn. I was fond of labeling TAEB "a framework for programmatic NetHack". Nowadays I'd just shorten that to "a NetHack API", but I was a little more pretentious back then.

TAEB::AI::Interhack

That "programmatic NetHack" label hints at the fundamental design difference between TAEB and Interhack. Because TAEB asserts complete control over the interaction with NetHack (exposing a proper API instead of proxying a practically opaque stream of characters representing NetHack commands), we could go so much further with new interface features that were only a dream in Interhack. For example, autoexplore could never work in Interhack - its conception of the map was about as good as your terminal's (i.e. just a 2d array of colored characters) - but autoexplore would be trivial in TAEB. I even had a pretty good design for an autoplay feature: just use one of TAEB's AI modules until a sufficiently challenging situation came up, then ask the human what to do. Beyond that the human could advise the bot on strategical issues (head to Minetown first, then Sokoban, then Mine's End) instead of tactical or trifling issues (like remembering to pick up food and eating, fighting weak monsters, and navigating across levels to a particular landmark like the nearest altar). In addition to autoexplore and autoplay we could have plugins like: remember which tiles you've ever stepped on for finding the vibrating square and astral portals and even just evading hidden traps, perfect memory of where every item on the ground is (even if your character has been stricken with amnesia), estimating the risk of monsters to determine if they can be windshielded or if they need to be taken out with more caution using magic; ranged weapons; kiting; etc, and even little things like an automap that doesn't suck - it would just know which level you're on and fill in the unexplored sections of the map for you.

I wanted someone else to build that Interhack on top of TAEB so that I could continue working on the TAEB bits and contribute the occasional patch to the new Interhack. But no one was ever up for the task. It could very well have been that TAEB was not complete enough (which absolutely does matter when it asserts complete control over the interaction with NetHack) to embark on that project. But I know now that if I had just started working on a cool useful project, contributors would have come and eventually someone else could have taken over. Actually, now that I think of it, TAEB gained far more contributors than any other project I've ever started. We've even given a few talks about it at Perl conferences.

In all it was a great time and I'm proud of what we accomplished. But I no longer have any desire to break NetHack. Hell I barely even play it any more (much less any other roguelike). Maybe if there's a new release I'll come back just to noodle with all the new stuff. In the meantime I'll continue working on my newer less programmatic hobbies.