A unicorn is a type of monster that appears in the dungeon starting at mid-game. Unicorns are extremely fast (even to a player with intrinsic speed), and always stay a knight's move or more away, so as to be out of range of both melee and ranged attacks. If the unicorn is pinned down in a corner, it may very well teleport away before the player can approach.
There are three types of unicorns: white, grey, and black, which correspond to lawful, neutral, and chaotic alignments respectively. The unicorn of your alignment will be peaceful; all others will be hostile. Unicorns in bones files or created by polymorph traps may be exceptions to this rule, but killing a unicorn of your own alignment always carries a -5 Luck penalty. (As is usual in NetHack, this penalty will not apply if you encourage your pet to kill it.)
Unicorns do surprising amounts of damage, getting in multiple kicks and butts per turn. However, because they will not intentionally move into melee range, it is usually not difficult to avoid combat with them. This avoidance of melee doesn’t seem to be true if you have a unicorn as a pet: it will attack monsters just like a cat or a dog would.
In the beginning of the game, when you typically are weak and need the horn, the most sound strategy for fighting unicorn is to let a pet take it out. Attacking with projectiles and rays which bounce from walls is also a good way to hit a unicorn which stays out of the direct line of sight. You can also use either a pit or a beartrap so you can attack it from a distance. It will fall in only once. If neither option is available try having it follow you down a long hall while you fire at it from a safe distance. A boomerang can be handy in this situation as well. Some other tactics are to wear a cloak of displacement and try to move to a throwing position. If the unicorn attacks your displaced image, you may have a chance to attack with ranged weapons. Also, if you are very fast, you will have occasional chances to attack with ranged weapons. Especially later in the game, if you are strong enough in melee combat, you may be able to simply defeat it in direct combat.
Unicorns cannot see invisible; once you obtain invisibility, you will have a much easier time lining them up for attacks or gems. However, note that invisibility can backfire for a weak character. If the unicorn can't see you, it will not know to stay a knight's move away. Its high speed makes it likely to randomly wander adjacent to your position, at which point it will notice you and attack.
Unicorn horns and corpses
When killed, a unicorn is guaranteed to leave a unicorn horn with its corpse, unless it has been revived or is a polymorphed monster from a polymorph trap, in which case it has only 1/20 chance of leaving one. Eating a unicorn corpse has a chance of giving poison resistance.
[a]pplying a unicorn horn has a chance of curing blindness, hallucination, confusion, stunning status effects, making a unicorn horn a recommended item for all adventurers able to obtain one. A unicorn can also use its own horn to cure status effects that are affecting it, with a message "The tip of the color unicorn's horn glows!"
A player polymorphed into a unicorn can use the #monster extended command to use their horn, which will cure ailments just like applying a noncursed horn does.
Sacrificing a unicorn at an altar is a special case and is covered in the page on sacrifices. Simply put, to receive alignment and Luck benefits, you should sacrifice on your own altar a unicorn of a different alignment. If the corpse, the altar, and you are three different alignment, it is just a regular sacrifice. Otherwise, bad things can happen.
A comprehensive table of unicorn sacrifices is located under sacrifice.
Unicorns and gems
Coaligned unicorns are great to improve your Luck and to sort out worthless glass.
Throwing any gem to any hostile unicorn will make it peaceful. A tame one will catch and immediately drop the gem, without any effect on Luck or identification. If the gem is worthless glass, a rock, or a gray stone, he will "graciously" accept it without affecting your Luck. (This may also say that the unicorn is "not interested in your junk", depending on whether the gem is type-named or not.) If it is valuable, a co-aligned unicorn "gratefully" keeps the gem and improves your Luck. The change of Luck is 5 points if the gem is formally identified, 2 points if type-named, and 1 point if non-identified. The game does not check what the gem is named, or what its type is called, as long as one of them is defined. Therefore, you should name all gems before throwing them at coaligned unicorns.
A cross-aligned unicorn will "hesitatingly" accept a valuable gem, and your Luck may increase or decrease by one point if the gem is not formally identified and by up to three points if it is. Because your Luck might go down, it is not generally a good idea to throw gems at these unicorns, unless you're pretty sure they're glass.
It is easiest to fling gems at a unicorn in a non-teleport zone. Sokoban is a good such place, as unicorns are commonly seen there and they can't teleport away.
If you are sure you will not need the unicorn again, you might want to encourage a pet to kill it. This way, you can recover your gems without any Luck penalty.
Unicorns also pick up gems and stones, worthless or not.
In lore, the unicorn is an (almost) unattainable target - impossible to catch, the horn of which has magical properties.
In slashem, a unicorn horn needs to be enchanted, in order to work reliably.
"The color unicorn's recently regrown horn crumbles to dust."
- A revived unicorn died, but did not drop a unicorn horn.
"The tip of the color unicorn's horn glows!"
- A unicorn cured a status problem using its horn.
Men have always sought the elusive unicorn, for the single twisted horn which projected from its forehead was thought to be a powerful talisman. It was said that the unicorn had simply to dip the tip of its horn in a muddy pool for the water to become pure. Men also believed that to drink from this horn was a protection against all sickness, and that if the horn was ground to a powder it would act as an antidote to all poisons. Less than 200 years ago in France, the horn of a unicorn was used in a ceremony to test the royal food for poison.
Although only the size of a small horse, the unicorn is a very fierce beast, capable of killing an elephant with a single thrust from its horn. Its fleetness of foot also makes this solitary creature difficult to capture. However, it can be tamed and captured by a maiden. Made gentle by the sight of a virgin, the unicorn can be lured to lay its head in her lap, and in this docile mood, the maiden may secure it with a golden rope.
Martin took a small sip of beer. "Almost ready," he said.
"You hold your beer awfully well."
Tlingel laughed. "A unicorn's horn is a detoxicant. Its possession is a universal remedy. I wait until I reach the warm glow stage, then I use my horn to burn off any excess and keep me right there."