Sokoban

Sokoban (warehouse keeper in Japanese) is a branch of the dungeon modeled on and named after a game where a character is navigated through a series of levels. The object is to move objects to cover goal squares. In the traditional game, the character must move only in the cardinal directions (north, south, east, and west) and push the objects from behind to move them. A player fails by getting objects stuck or boxing himself/herself in, as objects cannot be pulled, created, or destroyed.

In the case of NetHack, the objects are boulders and the goal squares are pits or holes, which block the way forward. There are four levels in each game and two versions of each, for a total of 8 different levels. Diagonal moves of the boulders are not allowed, although the player may move diagonally if there is space to do so, and may attack, fire or cast spells diagonally. At the end of the Sokoban dungeon branch is a Treasure Zoo guarding a bag of holding or amulet of reflection, depending on which version of level 4 you are given. The levels are ascending in dungeon depth, i.e., the 2nd level is above the 1st etc.

NetHack Sokoban is complicated by the presence of monsters in the puzzles, so some concessions have been made. It is possible to create or destroy boulders, and there is limited opportunity to move over boulders, but Luck penalties are assessed for each offense.

All walls in Sokoban are undiggable and unphasable. The floor is undiggable only on the first level. All levels are no-teleport, and it is impossible (for the player only) to level-teleport between Sokoban levels.

On each level, there is one randomly chosen ring, one randomly chosen wand, and several food items.

It is possible to solve every Sokoban level just by moving boulders around in the normal fashion. However, there are some actions that are legal in Nethack but cheat the Sokoban mini-game in some way. Whenever you perform such an action, your Luck is penalized. The following actions incur penalties of -1 when done in Sokoban:

Jumping (to avoid the penalty, press escape when asked where)

Breaking a boulder.

Squeezing past a boulder (or walking over one, when polymorphed into a giant)

Hurtling through the air due to Newton's 3rd Law. (i.e. throwing something while levitating)

Note that teleporting a boulder does not incur a luck penalty, but may move the boulder somewhere odd. Falling down a level onto a boulder, or bringing in a boulder as a poly-selfed giant, do not entail a penalty, either.

Remember, not all of the boulders have to be used, but also remember to keep enough to fill all the pits.

Monster-puzzle interaction

Check whether there are monsters in front of the pits.

Use a magic whistle for pets, or leave them behind one level, and visit their level every 74 turns or less to avoid them losing tameness points. Alternatively, known-cursed items can help keep pets out of the pit area.

Be aware of mimics imitating boulders. Unlike real boulders, mimics will not appear until they are in your line of sight, but a space containing a boulder may also contain a mimic mimicking a boulder, if that makes sense. You can move diagonally between mimicked boulders.

Drop everything in your inventory (including armor) and squeeze into the same square as a boulder. This will help you separate boulders stuck together, but not a boulder stuck against a wall. This way, you can also kill monsters trapped between boulders and holes which block the way. (luck penalty!)

Polyself into a giant and step over boulders. You still cannot lift them, however; neither can monsters (pets). (luck penalty!)

Summon more boulders with a scroll of earth, which can be found on the 1st sokoban level. Note that a non-cursed scroll will summon multiple boulders, possibly making the situation worse. (luck penalty!)

If the boulder is stuck because of a monster behind it, you can shoot missiles past the boulder to kill the monster. Note, however, that unicorns can be generated in Sokoban, and you risk a large luck penalty for killing a coaligned one. If you determine by whatever means that the unicorn behind a boulder is coaligned, you can toss gems to it to somewhat compensate for the inevitable luck hit. Sokoban is no-teleport, so the unicorn cannot leave of its own accord. Also note that you cannot kill unicorns with rocks, an easily accessible missile weapon. Other peaceful monsters may also be generated (but peaceful humans cannot). Force bolts and wands of striking will destroy boulders, but other methods are safe. Pacifists may want to strip naked and displace their pet onto the boulder.

Hit the boulder with a wand of teleport after you finish as many other boulders as possible. While the new location may not be better than the old one, it often can't be much worse, and you avoid any luck penalty.

Other

Upon completion, check under unmoved boulders for useful items.

Items can sometimes be generated over holes. Pushing a boulder over the hole will bury the item. If you wish to retrieve the item instead, you may:

Kick the item away; it will fall down another hole and appear somewhere on the level below. This will destroy the item if it is fragile, and on the top level will wake the monsters in the zoo.

Repeatedly step on the space containing the item; it will eventually fall down with you, although not necessarily onto your space. This will never break the item.

Turn on autopickup and step on the space containing the item; you will pick it up before you fall. Beware of loadstones, both over the hole and on the levels below.

Use a grappling hook

Monsters can attack you with the guaranteed wand if applicable. If you have not already found it, be careful clearing the zoo, e.g. send your pet in without entering line of fire.

If the reach the end of level 4b without finding the amulet, it is probable that some @ picked it up. Be sure to claim the amulet immediately after killing said monster, since you don't want your new amulet of reflection to become a snack for a rust monster or rock mole. Nothing will ever pick up the bag of holding, however.

The first level of sokoban, once completed, is often used as a stash level, for several reasons:

nhss is a tool that sets up a nethack-like environment (basic movement and boulder pushing only) that can be used to figure a level out before actually playing it, thus reducing the chances of rendering a level unsolvable. It can also record sessions and play them back step by step.