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.

Sokoban is reached by a second upstair in the Dungeons of Doom located on the level immediately below the Oracle level (and therefore between DL 6 and DL 10).

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 (equally likely chance in both final maps[1][2]) on a burnt Elbereth and a cursed scroll of scare monster. The levels are ascending in dungeon depth, i.e., the 2nd level is above the 1st etc. It is possible that the amulet of reflection will be cursed (with the same odds as any randomly generated amulet[3]), but will still grant reflection. The bag of holding is always uncursed[4]. Some monsters may ignore the cursed scroll of scare monster and pick up the amulet of reflection; watch for this if the amulet is missing.

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 four (stacks of) food items. Sokoban is an excellent place to stock up on comestibles.

Each level is fully mapped upon arrival. However, if you enter while hallucinating, the boulders, traps, and other items will appear as you would normally perceive things while hallucinating.

If playing with text mode, you might want to change the boulder symbol to 0.

Sokoban and Luck

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, polymorphing a statue into a boulder (not the other way around), or bringing in a boulder as a polymorphedgiant, do not entail a penalty, either.

In NetHack 3.6.0 and later versions, performing any of these actions on a solved level (i.e., one where all traps are filled with boulders) does not incur a luck penalty.

Strategy

The articles about the individual levels contain a full solution to all the levels. Some general strategy tips include:

Puzzle

Think ahead, the entire level is mapped and all the levels are solvable without 'cheating', barring some unfortunate monster generation.

If you want to try out something, push the boulders only in ways you can undo - never create a square of four boulders, or two neighbors against a wall.

Be careful, a typo may render a boulder immobile against the wall. Try to move diagonally or with the goto-key (underscore) whenever possible, as these commands will not push a boulder.

If a pit is open, falling through it to the level below lets you get back to the stairs. This can be useful in certain situations where a boulder is pushed the wrong way.

Polymorphing into a creature with the phasing ability will not help. Instead, you get the message "The Sokoban walls resist your ability."

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

It's arguably degenerate, but you can use a text editor or grid paper to try to work out the solutions before actually attempting them in-game.

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.

Strategies for when a boulder got stuck

If you must take a Luck penalty, do so as early as possible. Put away any gray stones that might be luckstones, unless you are sure that your natural Luck is positive. The sooner you take that Luck penalty, the more likely it will have timed out the next time you encounter a critical Luck-influenced event, such as needing to pray.

If you mistakenly moved a boulder between yourself and the stairs from the previous level, dig down to create a hole and fall through. (no penalty) Be sure to choose a safe place to dig. You may wish to use a spare boulder to fill the hole afterward.

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!)

Polymorph 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!)

Dropping a wand of striking so that a monster picks it up, and positioning yourself between that monster and the boulder you want destroyed, can sometimes help you get rid of stuck boulders while avoiding the 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. If you have a magic whistle, you can stand next to the boulder and apply the whistle until your pet appears on the other side of the boulder. Let your pet kill the obstructing monster and then use the whistle to get them out of the way.

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.

If you're pining for a Bag of Holding and at the upper limit of carrying capacity, don't pick up all that food sitting around--you can eat it off the floor when you need to. On the other hand, grab every scroll and wand you see so a monster can't pick them up and use them to your disadvantage.

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. You can use pickup_types and/or autopickup exception to limit yourself to only picking up the type of item you are trying to grab.

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 you 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:

If there is an altar nearby, Sokoban can be used to control your Luck and avoid crowning during altar farming.

The first level also contains two scrolls of earth. Remember to #name them as such as soon as you find them. Note also that some monsters will read scrolls of earth. In particular, you may want to keep them in a container if there are nymphs around, as they can pluck the scroll from your inventory and then read it.

nhss

nhss (originally by IanK of iank.org) is a C/terminal 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.

SLASH'EM

In SLASH'EM, there are 15 new level variants, but otherwise Sokoban is the same as Vanilla, with a 50% chance of either a bag of holding or an amulet of reflection at the end. Given that ordinary sacks and oilskin sacks can be upgraded to a bag of holding in SLASH'EM, the latter is more desirable even than in Vanilla.

Note that several public server versions of SLASH'EM include a patch adding the acid hound, which corrodes the floor to create pits when killed, and can be very troublesome if they appear in Sokoban, as they may make solving the level without using a scroll of earth impossible.

UnNetHack

UnNetHack introduces Sokoban levels not available in Vanilla; additionally, any level can be mirrored.

Any UnNetHack Sokoban has only three levels -- the Vanilla maps for levels one and two may all be used to create level one.

From UnNetHack 4.1.1 onwards and on the un.nethack.nu public server, cheating in Sokoban does not incur a Luck penalty. Instead, solving Sokoban without cheating is tracked as a new conduct. However to compensate, the scrolls of earth typically found on the first level are not guaranteed.

NetHack Fourk

NetHack Fourk introduces a number of additional Sokoban levels. Player feedback so far suggests that these are on average easier than the vanilla ones. Additionally, the luck penalty does not apply if you are carrying a non-cursed luckstone and can also be dodged via hallucination, at the cost of having a hallucinatory boulder drop on your head (which in some cases can even be useful).

SporkHack

SporkHack can mirror the levels vertically and/or horizontally, but does not add new levels.

Trivia

The presence of three doors in the treasure zoo, with a prize behind one of them, is probably a reference to the Monty Hall Problem.

Encyclopedia entry

Sokoban (Japanese for "warehouse person") is a puzzle-type
game where the player must push around treasure to a goal
area. It apparently won first prize in a Japanese programming
contest.