nhss

Nethack Sokoban Solver

Intro

Sokoban, in nethack, is an optional set of levels which resemble the puzzle game sokoban. You push boulders into pits, creating a path to the next staircase. Unfortunately, there's no magic reset button, so you only get one shot.

nhss creates a nethack-like environment, which will read in the level from a file, and allow the user to attempt to solve it without messing up the game. It also records the user's moves for replay after solving.

Useful? Yep.
Cheating? Only if you're completely rabid. ;)

Thoughts

Part of why nethack is so cool (and hard) is that there is no capability to reload old savegames (well, there is, if you cp them out of the savedir before you start nethack[1], but that /is/ cheating =). Using a program like nhss to figure out sokoban (resetting a few times in the process) before trying it in nethack is, in essence, reloading an old savegame.

On the other hand, unlike the rest of the game, sokoban is mostly deterministic[2]. Using nhss is analagous to solving a level on paper, but more convenient.

The name is also a bit misleading. I'm good at that. nhss does not solve sokoban for you, it merely creates an environment in which you can attempt to do so yourself. (Having nhss solve them would be pointless anyway; There are a finite number of levels, and a spoiler exists with the solution for each).

Usage

nhss levelfile recfile [-r]

levelfile is a file containing a nethack level like the one shown below, and recfile is the file in which nhss should place recorded moves. The optional switch -r will cause nhss to play back the moves in recfile step by step (each keystroke advances by one).

Note that you must edit out any characters that are not one of {wall,player,pit,floor,boulder}. Any characters that nhss does not recognize will be treated as walls.

Download

Example level
Tarball
[1] AKA ``save-scumming''
[2] The RNG plays a small role by spawning monsters and items as usual, but that doesn't apply to nhss, which only deals with boulders and pits
back contact