Autopickup exception

From NetHackWiki
Revision as of 11:31, 6 April 2013 by Tjr (talk | contribs) (Define pickup / drop in-game: wordsmithing)
Jump to navigation Jump to search

AUTOPICKUP_EXCEPTION is a configuration option that allows you to define what items are automatically picked up, with more precision than pickup_types gives. You also need to have autopickup on and pickup_types match the AUTOPICKUP_EXCEPTION -lines. Highly recommended but not necessary is adapting pickup_burden.

OPTIONS=autopickup
OPTIONS=pickup_types:$?!/(
OPTIONS=pickup_burden:unencumbered

In NetHack 3.4.3 autopickup exceptions are not compiled in by default, and they're marked as experimental, so most builds probably won't have them. NAO does, however.

You can either define the exceptions in the options screen or in your configuration file by putting the following lines in it:

AUTOPICKUP_EXCEPTION=">*chest*"

This will make the hero never pick up all items that match the string "*chest*".

AUTOPICKUP_EXCEPTION="<*dagger"

This will make the hero always pick up all items that match the string "*dagger".

If the first character inside the quoted string is a greater-than sign (>), then the matched items will be not be picked up; if it's a less-than sign (<), the items will be picked up. The rest of the string defines what items will match for that rule. The string matching allows for basic wildcards, where asterisk (*) matches any number of characters and question mark (?) matches any one character. A "never pickup" rule takes precedence over an "always pickup" rule if both match an item. If no rule matches, autopickup defaults to pickup_types.

NetHack attempts to convert the object names and called-classnames to singular form before matching them against your exceptions. This usually makes writing exceptions easier; however, when you use #name to give an object a called-classname, like "a gem called worthless", NetHack will mangle the called-classname as well, possibly making it harder to match against. In particular, it will attempt to make the word "worthless" singular by removing an "s", but only if the word comes at the end of the name. Thus, to drop all worthless glass, (whether formally or informally IDed) you should say ">*worthles*", not ">*worthless*".[1]

How to use it effectively

Autopickup exceptions can greatly simplify dungeon exploration. However, the very limited nature of their regular expression syntax makes them a bit hard to configure.

You can use them to keep dangerous items out of monsters' hands, to conveniently sort through large piles of loot, to automate things you might forget, to save a turn when fleeing or on speed runs, to remove good morphs from your polypiling line without paying attention, etc.

Use pickup_types as an in-game switch to distinguish between early-game and late-game configurations. In your nethackrc, simply don't mention items you want to default to pickup_types.

A few items are useful only in the early game (such as gold). You can remove according autopickup exceptions in-game with the O command. They will re-appear when you restore or start a new game. If your needs change much over the course of a long game, the easiest way to update the exceptions is to (un)comment lines in your config file, save the game, and restore.

A user has suggested improving this page or section as follows:

"Simplify the examples using real regex. NAO now has them."

Easy ones

Individually-name the real Amulet right away, and you'll never fall for a fake:

AUTOPICKUP_EXCEPTION=">*Amulet of Yendor"
AUTOPICKUP_EXCEPTION="<*Amulet of Yendor named ?*"

Avoid turning your scrolls of scare monster to dust:

AUTOPICKUP_EXCEPTION=">*scroll of scare monster"
AUTOPICKUP_EXCEPTION=">*scroll called scare monster"

Walk in peace over empty wands:

autopickup_exception="*:0)*"
AUTOPICKUP_EXCEPTION=">* named empty"

Good items left after a fight, but requires careful weight watching:

# autopickup_exception="<*full healing"
# autopickup_exception="<*extra healing"
# autopickup_exception="<*potion of healing"
# autopickup_exception="<*gain level"

Pick up formally identified artifacts. Don't blast yourself to death with a cross-aligned one — leave unidentified ones on the floor.

autopickup_exception="<the*"

Some people also want known-blessed items, but this likely picks up too much.

#  autopickup_exception="<blessed *"

Never pick up corpses except lizards

Since you can't define an exception from an exception, you have to enumerate the possibilities. The trailing asterisk takes care of individually named monsters.

Other reasonable double-exceptions could be wraith or even newt and lichen corpses.

# AUTOPICKUP_EXCEPTION="<*lizard corpse"
# "blessed/(un)cursed greased partly-eaten monstertype/unique's corpse"
AUTOPICKUP_EXCEPTION=">*a corpse*"
AUTOPICKUP_EXCEPTION=">*b corpse*"
AUTOPICKUP_EXCEPTION=">*c corpse*"
AUTOPICKUP_EXCEPTION=">*e corpse*"
AUTOPICKUP_EXCEPTION=">*f corpse*"
AUTOPICKUP_EXCEPTION=">*g corpse*"
AUTOPICKUP_EXCEPTION=">*h corpse*"
AUTOPICKUP_EXCEPTION=">*i corpse*"
AUTOPICKUP_EXCEPTION=">*k corpse*"
AUTOPICKUP_EXCEPTION=">*l corpse*"
AUTOPICKUP_EXCEPTION=">*m corpse*"
AUTOPICKUP_EXCEPTION=">*n corpse*"
AUTOPICKUP_EXCEPTION=">*o corpse*"
AUTOPICKUP_EXCEPTION=">*p corpse*"
AUTOPICKUP_EXCEPTION=">*r corpse*"
AUTOPICKUP_EXCEPTION=">*s corpse*"
AUTOPICKUP_EXCEPTION=">*' corpse*"
AUTOPICKUP_EXCEPTION=">*t corpse*"
AUTOPICKUP_EXCEPTION=">*u corpse*"
AUTOPICKUP_EXCEPTION=">*v corpse*"
AUTOPICKUP_EXCEPTION=">*x corpse*"
AUTOPICKUP_EXCEPTION=">*y corpse*"
AUTOPICKUP_EXCEPTION=">*ld corpse*"
AUTOPICKUP_EXCEPTION=">*nd corpse*"
AUTOPICKUP_EXCEPTION=">*ud corpse*"
AUTOPICKUP_EXCEPTION=">*ord corpse*"
AUTOPICKUP_EXCEPTION=">*uard corpse*"
AUTOPICKUP_EXCEPTION=">*wizard corpse*"

Define pickup / drop in-game

Without editing your config, you want to say "pick up all such objects" or "always leave this one on the floor". We will pick an object up if its individual name or called-classname ends with "<", and drop if ">".

In unpatched vanilla NetHack, the challenge are individual exceptions: You want to pick up your "blessed bag called CAUTION holding> named MY ONE AND ONLY<". But you want to leave any other "blessed bag called CAUTION holding>" on the floor, so you can't accidentally put it into your main bag and cause an explosion. In short, you want the individual object name to override the called-classname. You'd think this ruleset should work:

# good-faith attempt, doesn't work
autopickup_exception=">* called *>"
autopickup_exception=">* named *>"
autopickup_exception=">* called *< named *>"
autopickup_exception="<* called *<"
autopickup_exception="<* named *<"
autopickup_exception="<* called *> named *<"

But it fails. In the bag of holding example, both the first rule (drop) and the last one (pickup) match. Whenever conflicting rules match, the item is dropped. The solution is: The called-classname drop rule must not match individually named items unless the individual name's last character is ">". So the rule must not end with a wildcard. And since you cannot use regular expressions, you have to enumerate all possible different last characters. That's why we test only for the single last character of the individual item name, instead of longer keywords such as "pick this up".

This example rule-set picks up (<) and drops (>) items according to the last character of their called-classname and individual name.

##pick up items whose individual name ends with <
autopickup_exception="<* named *<"
autopickup_exception="<* named *< (?:?)"
autopickup_exception="<* named *< (?:??)"
#
##pick up items whose called-classname ends with <
autopickup_exception="<* called *<"
autopickup_exception="<* called *< named ?*"
## The above rule is OK because if both the rules
## for "called <" and "named >" match, it's dropped.
#
##drop items whose individual names ends with >
autopickup_exception=">* named *>"
#
##drop items whose called-classname ends with >
##.... items without individual names:
autopickup_exception=">* called *>"
#
##.... items with individual names, whose last character is not <
## sadly, "last is not <" means list every other possibility
## note ">* called *>?*" would also match "x called foo>bar named <"
## or "x called foobar named recalled> foo<".
autopickup_exception=">* called *> named *a"
autopickup_exception=">* called *> named *b"
autopickup_exception=">* called *> named *c"
autopickup_exception=">* called *> named *d"
autopickup_exception=">* called *> named *e"
autopickup_exception=">* called *> named *f"
autopickup_exception=">* called *> named *g"
autopickup_exception=">* called *> named *h"
autopickup_exception=">* called *> named *i"
autopickup_exception=">* called *> named *j"
autopickup_exception=">* called *> named *k"
autopickup_exception=">* called *> named *l"
autopickup_exception=">* called *> named *m"
autopickup_exception=">* called *> named *n"
autopickup_exception=">* called *> named *o"
autopickup_exception=">* called *> named *p"
autopickup_exception=">* called *> named *q"
autopickup_exception=">* called *> named *r"
autopickup_exception=">* called *> named *s"
autopickup_exception=">* called *> named *t"
autopickup_exception=">* called *> named *u"
autopickup_exception=">* called *> named *v"
autopickup_exception=">* called *> named *w"
autopickup_exception=">* called *> named *x"
autopickup_exception=">* called *> named *y"
autopickup_exception=">* called *> named *z"
autopickup_exception=">* called *> named *A"
autopickup_exception=">* called *> named *B"
autopickup_exception=">* called *> named *C"
autopickup_exception=">* called *> named *D"
autopickup_exception=">* called *> named *E"
autopickup_exception=">* called *> named *F"
autopickup_exception=">* called *> named *G"
autopickup_exception=">* called *> named *H"
autopickup_exception=">* called *> named *I"
autopickup_exception=">* called *> named *J"
autopickup_exception=">* called *> named *K"
autopickup_exception=">* called *> named *L"
autopickup_exception=">* called *> named *M"
autopickup_exception=">* called *> named *N"
autopickup_exception=">* called *> named *O"
autopickup_exception=">* called *> named *P"
autopickup_exception=">* called *> named *Q"
autopickup_exception=">* called *> named *R"
autopickup_exception=">* called *> named *S"
autopickup_exception=">* called *> named *T"
autopickup_exception=">* called *> named *U"
autopickup_exception=">* called *> named *V"
autopickup_exception=">* called *> named *W"
autopickup_exception=">* called *> named *X"
autopickup_exception=">* called *> named *Y"
autopickup_exception=">* called *> named *Z"
autopickup_exception=">* called *> named *^"
autopickup_exception=">* called *> named *!"
autopickup_exception=">* called *> named *$"
autopickup_exception=">* called *> named *%"
autopickup_exception=">* called *> named *&"
autopickup_exception=">* called *> named */"
autopickup_exception=">* called *> named *("
# #items with charges are always fully ID'd,
# #don't display their called-classname, thus we won't worry about
# #"wand called nothing> named stash< (0:12)"
autopickup_exception=">* called *> named *)"
autopickup_exception=">* called *> named *="
autopickup_exception=">* called *> named *`"
autopickup_exception=">* called *> named *+"
autopickup_exception=">* called *> named *,"
autopickup_exception=">* called *> named *;"
autopickup_exception=">* called *> named *."
autopickup_exception=">* called *> named *:"
autopickup_exception=">* called *> named *-"
autopickup_exception=">* called *> named *_"
autopickup_exception=">* called *> named *["
autopickup_exception=">* called *> named *]"
autopickup_exception=">* called *> named *{"
autopickup_exception=">* called *> named *}"
autopickup_exception=">* called *> named *|"
autopickup_exception=">* called *> named *\"
autopickup_exception=">* called *> named *0"
autopickup_exception=">* called *> named *1"
autopickup_exception=">* called *> named *2"
autopickup_exception=">* called *> named *3"
autopickup_exception=">* called *> named *4"
autopickup_exception=">* called *> named *5"
autopickup_exception=">* called *> named *6"
autopickup_exception=">* called *> named *7"
autopickup_exception=">* called *> named *8"
autopickup_exception=">* called *> named *9"

One of each kind of magical object

Usually, you need only one of each type of magical armor / ring / amulet / spellbook / magical tool. Wouldn't it be nice if the game managed that for you? It can if you're willing to class-name all objects immediately.

Below are the rules for armor. E.g. call the mine town watchmens' helmets "plain", and call magical but cursed helmet from a bones pile is "#2 bones <" (to pick up a second one). See Tjr's config for other item types.

# AUTOPICKUP_EXCEPTION="<*robe"
# AUTOPICKUP_EXCEPTION="<*faded pall"
# AUTOPICKUP_EXCEPTION="<*apron"
# AUTOPICKUP_EXCEPTION="<*polished silver shield"
# AUTOPICKUP_EXCEPTION="<*smooth shield"
# #              blind       ^^^^^^
AUTOPICKUP_EXCEPTION="<*conical hat"
AUTOPICKUP_EXCEPTION="<*plumed helmet"
AUTOPICKUP_EXCEPTION="<*etched helmet"
AUTOPICKUP_EXCEPTION="<*crested helmet"
AUTOPICKUP_EXCEPTION="<*visored helmet"
AUTOPICKUP_EXCEPTION="<*tattered cape"
AUTOPICKUP_EXCEPTION="<*opera cloak"
AUTOPICKUP_EXCEPTION="<*ornamental cope"
AUTOPICKUP_EXCEPTION="<*piece of cloth"
AUTOPICKUP_EXCEPTION="<*old gloves"
AUTOPICKUP_EXCEPTION="<*padded gloves"
AUTOPICKUP_EXCEPTION="<*riding gloves"
AUTOPICKUP_EXCEPTION="<*fencing gloves"
AUTOPICKUP_EXCEPTION="<*combat boots"
AUTOPICKUP_EXCEPTION="<*jungle boots"
AUTOPICKUP_EXCEPTION="<*hiking boots"
AUTOPICKUP_EXCEPTION="<*mud boots"
AUTOPICKUP_EXCEPTION="<*buckled boots"
AUTOPICKUP_EXCEPTION="<*riding boots"
AUTOPICKUP_EXCEPTION="<*snow boots"

Keeping ammunition out of monsters' hands

Especially in the Mines, you want to collect lightweight but dangerous projectiles and deposit then on an Elbereth square. This keeps monsters from reusing them against you over and over. (Deactivate daggers if you don't fire them yourself — they're heavy.)

AUTOPICKUP_EXCEPTION="<*arrow"
## AUTOPICKUP_EXCEPTION="<*elven arrow"
## AUTOPICKUP_EXCEPTION="<*orcish arrow"
## AUTOPICKUP_EXCEPTION="<*silver arrow"
## AUTOPICKUP_EXCEPTION="<*runed arrow"
## AUTOPICKUP_EXCEPTION="<*crude arrow"
AUTOPICKUP_EXCEPTION="<*ya"
## AUTOPICKUP_EXCEPTION="<*bamboo arrow"
AUTOPICKUP_EXCEPTION="<*crossbow bolt"
AUTOPICKUP_EXCEPTION="<*dart"
AUTOPICKUP_EXCEPTION="<*shuriken"
AUTOPICKUP_EXCEPTION="<*throwing star"
AUTOPICKUP_EXCEPTION="<*dagger"
## AUTOPICKUP_EXCEPTION="<*elven dagger"
## AUTOPICKUP_EXCEPTION="<*orcish dagger"
## AUTOPICKUP_EXCEPTION="<*runed dagger"
## AUTOPICKUP_EXCEPTION="<*crude dagger"
## AUTOPICKUP_EXCEPTION="<*silver dagger"
AUTOPICKUP_EXCEPTION="<*knife"

Things too good to miss

Wands of wishing, magic lamps, magic markers, and wands of permanent Elbereth are useful even in the ascension run or when farming. In those situations, you likely have enough other things on your mind. You don't want monsters zapping create monster or shooting death rays at you.

AUTOPICKUP_EXCEPTION="<*wand of wishing"
AUTOPICKUP_EXCEPTION="<*wand called wish"
AUTOPICKUP_EXCEPTION="<*wand of create monster"
AUTOPICKUP_EXCEPTION="<*wand of teleportation"
AUTOPICKUP_EXCEPTION="<*wand called tele"
# AUTOPICKUP_EXCEPTION="<*wand of polymorph"
# AUTOPICKUP_EXCEPTION="<*wand called poly"
AUTOPICKUP_EXCEPTION="<*wand of fire"
AUTOPICKUP_EXCEPTION="<*wand of lightning"
AUTOPICKUP_EXCEPTION="<*wand of death"
# # Cold is used for Juiblex swamp, etc.
# AUTOPICKUP_EXCEPTION=">*wand of cold"
AUTOPICKUP_EXCEPTION="<*magic marker"
AUTOPICKUP_EXCEPTION="<*magic lamp"
AUTOPICKUP_EXCEPTION="<lamp"
AUTOPICKUP_EXCEPTION="<*d lamp"
AUTOPICKUP_EXCEPTION="<*amulet of life saving"
AUTOPICKUP_EXCEPTION="<*amulet called life"
AUTOPICKUP_EXCEPTION="<*athame"


Avoiding loadstones

This rule-set should never pick up a loadstone, regardless of your blindness or knowledge of loadstones. You can still automatically pick up agate stones, etc.

AUTOPICKUP_EXCEPTION=">*stone called loa*"
AUTOPICKUP_EXCEPTION=">*loadstone"
AUTOPICKUP_EXCEPTION=">*loadstone named *"
AUTOPICKUP_EXCEPTION=">*gray stone"
# #blind: glass/gems show up as gem, all else as stone.
AUTOPICKUP_EXCEPTION=">stone"
# # blessed, uncursed, cursed, greased
AUTOPICKUP_EXCEPTION=">*sed stone"

Only exceptions pick stuff up

If you want only the exceptions to pick anything up, you would normally set pickup_tyes to "" (empty). Unfortunately, that picks up everything. The solution is iron balls:

OPTIONS=pickup_types:0
AUTOPICKUP_EXCEPTION=">*heavy iron ball*"

References

External references