# Autopickup exception

Contents

1 Syntax
2 Strategy

2.1 Suggested rules
2.2 Corpses
2.3 Things too good to miss
2.4 Define pickup / drop in-game
2.5 One of each kind of magical object
2.6 Keeping ammunition out of monsters' hands
2.7 Avoiding loadstones
2.8 Only exceptions pick stuff up

3 References
4 External references

AUTOPICKUP_EXCEPTION is a configuration option that allows you to define what items are automatically picked up, based on the name of the item. This gives more precision on top of pickup_types. You need to have autopickup on for autopickup exceptions to be active.
In NetHack 3.6 autopickup exceptions are compiled in by default. The NAO version of NetHack 3.4.3 has them as well.

Syntax
An autopickup exception rule is expressed as either a &lt; or a &gt;, followed by a regular expression. The leading character determines whether items whose names match the regular expression are picked up: a &lt; rule flags the matched item for pickup, while a &gt; rule ignores the matched item.
The regular expression is matched against the singular form of the name of the item, plus any preceding article or number: "a gold piece" matches a single gold piece, "2 gold piece" matches a stack of 2 gold pieces, but "2 gold pieces" would match nothing.[1] Any "called ..." or "named ..." suffixes added with the #name command are included, so take note of your own naming habits and write your autopickup exceptions accordingly.
As of version 3.6.4, autopickup exceptions override one another sequentially the same way menucolors and MSGTYPEs do, with rules specified later in the config file taking precedence over those specified earlier, and rules specified during play via the O command taking precedence over everything. Order is all that matters; neither &lt; nor &gt; takes precedence over the other. Pickup_types is consulted if and only if no matching rule is found. 
In the configuration file, exceptions are specified by the string AUTOPICKUP_EXCEPTION= followed by the rule enclosed in double quotes. When adding an exception via the O command, you're just prompted for the rule without quotes.

Strategy
Autopickup exceptions can greatly simplify dungeon exploration. 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.
Some items, such as gold, are useful only in the early game. You can add and remove rules in-game with the O command, though the settings will revert the next time you run the program. If your needs change much over the course of a long game, the easiest way to update the exceptions is to comment or uncomment the lines in your nethackrc, save the game, and restore. You can also use pickup_types as an in-game switch to distinguish between early-game and late-game configurations by simply not mentioning items you want to default to pickup_types.

Suggested rules
First, it's necessary to turn on autopickup, and set some pickup_types that will act as a catch-all assuming none of our autopickup exception rules match. Highly recommended — but not necessary — is adapting pickup_burden.

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

Individually #name the real Amulet of Yendor right away and you'll never fall for a fake:

AUTOPICKUP_EXCEPTION="&gt;Amulet of Yendor"
AUTOPICKUP_EXCEPTION="

<amulet "="" "<"="" #="" #autopickup_exception="&gt;wand .* cold$" #naming="" %="" -="" a="" add="" after="" all="" also="" and="" and,="" are="" around="" artifacts.="" at="" autopickup="" autopickup,="" autopickup_exception="&lt;athame" avoid="" beneath="" beneficial="" blast="" but="" by="" careful="" carrying="" case="" certain="" changing="" chickatrice="" class="" cockatrice="" comestible="" containing="" corpse="" corpses="" corpses,="" create="" cross-aligned="" dangerous.="" death="" decay="" define="" do="" don't="" drop="" dust:="" eaten.="" effects="" elbereth="" emergencies.="" empty="" endgame,="" enough="" even="" exception:="" exceptions="" extremely="" eyes,="" fight,="" floating="" floor:="" following="" food,="" for="" formally="" good="" grab="" have="" heavy="" identified="" if="" in="" in-game="" include="" includes="" invaluable="" is="" item="" items="" items,="" juiblex's="" known-blessed="" lamps,="" lasting="" latter="" leave="" left="" let="" lichen="" lightweight="" likely="" lines="" lizards,="" magic="" manually="" markers,="" may="" mind.="" miss="" monster="" monsters="" most="" much:="" named"="" newts,="" not="" nothing:="" of="" on="" one="" ones="" or="" other="" over="" override="" peace="" people="" pick="" picks="" pickup="" pickup_types="" prohibitively="" rays="" requires="" rule:="" rules="" scare="" scrolls="" shooting="" some="" strings="" swamp="" the="" then="" these,="" things="" this="" though="" to="" too="" turning="" unidentified="" up="" useful="" walk="" wands="" want="" watching:="" weight="" well="" when="" which="" will="" wishing,="" with="" without="" worth="" wraiths,="" yendor="" you="" you.="" your="" yourself="" zapping="" —="">":

AUTOPICKUP_EXCEPTION="&lt;&lt;"
AUTOPICKUP_EXCEPTION="&gt;&gt;"

Because rules defined later take precedence over ones defined earlier, if you want these manual overrides to take effect unconditionally, you have to put them at the end of the file.  If you want to be able to name a class of unidentified items with "&gt;" to leave them alone and then individually-name one of those items with "&lt;" to pick it up, add the following rules below that:

autopickup_exception="&lt; named .*&lt;"
autopickup_exception="&gt; named .*&gt;"

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. You could call the Minetown watchmen's helmets "plain", turning it from its name from its unidentified description to "a helmet called plain" and removing it from the pickup list. See Tjr's config for other item types, although it needs to be updated for NetHack 3.6 regex format.

# AUTOPICKUP_EXCEPTION="&lt;robe"
# AUTOPICKUP_EXCEPTION="&lt;faded pall"
# AUTOPICKUP_EXCEPTION="&lt;apron"
# AUTOPICKUP_EXCEPTION="&lt;polished silver shield"
# AUTOPICKUP_EXCEPTION="&lt;smooth shield" # blind description

AUTOPICKUP_EXCEPTION="&gt;helmet"
AUTOPICKUP_EXCEPTION="&lt;conical hat"
AUTOPICKUP_EXCEPTION="&lt;plumed helmet"
AUTOPICKUP_EXCEPTION="&lt;etched helmet"
AUTOPICKUP_EXCEPTION="&lt;crested helmet"
AUTOPICKUP_EXCEPTION="&lt;visored helmet"

AUTOPICKUP_EXCEPTION="&gt;cloak"
AUTOPICKUP_EXCEPTION="&lt;tattered cape"
AUTOPICKUP_EXCEPTION="&lt;opera cloak"
AUTOPICKUP_EXCEPTION="&lt;ornamental cope"
AUTOPICKUP_EXCEPTION="&lt;piece of cloth"

AUTOPICKUP_EXCEPTION="&gt;gloves"
AUTOPICKUP_EXCEPTION="&lt;old gloves"
AUTOPICKUP_EXCEPTION="&lt;padded gloves"
AUTOPICKUP_EXCEPTION="&lt;riding gloves"
AUTOPICKUP_EXCEPTION="&lt;fencing gloves"

AUTOPICKUP_EXCEPTION="&gt;boots"
AUTOPICKUP_EXCEPTION="&lt;combat boots"
AUTOPICKUP_EXCEPTION="&lt;jungle boots"
AUTOPICKUP_EXCEPTION="&lt;hiking boots"
AUTOPICKUP_EXCEPTION="&lt;mud boots"
AUTOPICKUP_EXCEPTION="&lt;buckled boots"
AUTOPICKUP_EXCEPTION="&lt;riding boots"
AUTOPICKUP_EXCEPTION="&lt;snow boots"

Keeping ammunition out of monsters' hands
Especially in the Mines, you will want to collect lightweight but dangerous projectiles and deposit them in a safe location &amp;endash; on a square with a scroll of scare monster, the downstair on a previously cleared level, or underneath a boulder. This keeps monsters from reusing them against you. (Deactivate daggers if you don't throw them yourself — they're heavy.)

AUTOPICKUP_EXCEPTION="&lt; arrow"
## AUTOPICKUP_EXCEPTION="&lt;elven arrow"
## AUTOPICKUP_EXCEPTION="&lt;orcish arrow"
## AUTOPICKUP_EXCEPTION="&lt;silver arrow"
## AUTOPICKUP_EXCEPTION="&lt;runed arrow"
## AUTOPICKUP_EXCEPTION="&lt;crude arrow"
AUTOPICKUP_EXCEPTION="&lt; ya"

## AUTOPICKUP_EXCEPTION="&lt;bamboo arrow"
AUTOPICKUP_EXCEPTION="&lt;crossbow bolt"
AUTOPICKUP_EXCEPTION="&lt;dart"
AUTOPICKUP_EXCEPTION="&lt;shuriken"
AUTOPICKUP_EXCEPTION="&lt;throwing star"

AUTOPICKUP_EXCEPTION="&lt;dagger"
## AUTOPICKUP_EXCEPTION="&lt;elven dagger"
## AUTOPICKUP_EXCEPTION="&lt;orcish dagger"
## AUTOPICKUP_EXCEPTION="&lt;runed dagger"
## AUTOPICKUP_EXCEPTION="&lt;crude dagger"
## AUTOPICKUP_EXCEPTION="&lt;silver dagger"
AUTOPICKUP_EXCEPTION="&lt;knife"

Avoiding loadstones
With these rules, you should never pick up a loadstone, regardless of your knowledge of loadstones:

AUTOPICKUP_EXCEPTION="&gt; loadstone"
AUTOPICKUP_EXCEPTION="&lt;stone called luck"
AUTOPICKUP_EXCEPTION="&lt; luckstone"
#AUTOPICKUP_EXCEPTION="&lt; touchstone"
AUTOPICKUP_EXCEPTION="&gt; rock"
AUTOPICKUP_EXCEPTION="&gt; gray stone"

When blind, gems and worthless glass are called "gems", and all other * are called "stones", so with the following rule, you won't risk picking up loadstones while blind, either:

AUTOPICKUP_EXCEPTION="&gt;^[a0-9]+ stone"

The leading ^[a0-9]+ ensures that valuable gems with "stone" in their identified name (amber stones, turquoise stones, etc.) are not matched.

Only exceptions pick stuff up
If you want only the exceptions to pick anything up, put this rule at the beginning of your file:

AUTOPICKUP_EXCEPTION="&gt;.*"

This excludes everything, so that you can turn on autopickup, but not actually autopickup anything unless you say so with an exception.

References

↑ makesingular in objnam.c

External references
Tjr's config file on NAO contains a full list of all item descriptions to match against, and an object names mini-spoiler.
a RGRN thread with many corpse-related ideas
Autopickup mini-spoiler (the part about empty pickup_types is wrong)

</amulet>