User:Agulp/Tool Assisted Speedrun

From NetHackWiki
Jump to navigation Jump to search

Purpose

The purpose of this page is to document the NetHack 3.4.3 Tool-Assisted Speedrun. This is a living document, and anyone that is actively contributing to or interested in joining the project is free to edit it.

Current Status

Currently TAS-ing Turn 832.

To-Do List

  • Rewrite turns 824-836. Turn 826 is an error, and effectively a dead turn, as noted below.
  • Turn 879 uses an obsolete luck manipulation method. m-bumping monsters also uses up random numbers and is faster / less spammy.

Documentation

This section was initially copied from ais523's Current Turn-by-Turn Explanation and formatted into the form of a wiki page.

Preamble

Before the first turn there is some setup we need to do to get an optimal start. One of the most important variables for the run is the date and time that the computer's clock is set to upon loading NetHack; this is what controls the initial RNG seed, and several elements essential to getting the fastest possible time are decided right at the start of the game before we have any chance to manipulate the RNG. NetHack is also pretty unusual in that the date and time are what determine the difficulty level, with some days being luckier or unluckier than others.

In order to allow us to "play on the hardest difficulty", Ilari searched for maximally unlucky days; it turns out that there have been none at all since the release of NetHack 3.4.3, so we picked the first one that will occur, Friday 13 November 2015. In addition to being a Friday 13, there will also be a new moon on that day, making the game even harder (although Friday 13 has a much stronger effect than the phase of the moon). (Amusingly, this dependence on the moon phase can cause desyncs on occasion; this is likely the only TAS that will have been desynced by running a script on a full moon by mistake.) The time chosen (by dwangoAC, who wrote the luck manipulation bots, and who did most of the early luck manipulation while ais523 got up to speed with how to use them) was 00:13:02; playing just after midnight leaves undead at their most dangerous, and the minutes and seconds are chosen for luck manipulation purposes. This means that there's a hard limit of 46 minutes 58 seconds for the run, because at 1am, the game would become slightly less difficult as undead damage reverted to normal, so we would no longer be playing at highest difficulty. The seed value was 1447373582 which maps to Fri, 13 Nov 2015 00:13:02 GMT.

We were looking for several things in our luck manipulation. The most obvious is the depth of the dungeon; the length of the game is slightly randomized, and leaving it as short as possible is obviously helpful. The seed we chose leaves it at the minimum possible depth of 45 levels. We also controlled the location of some of the special levels to increase the gain from sequence breaks; in particular, the portal to the Wizard of Yendor's Tower (with that seed, on level 43) was manipulated to be as far as possible from the tower itself (which occupies levels 36 to 38 inclusive with that seed). In addition to the dungeon layout, we also manipulated the materials of which some rings were made. Eating rings is the only way to get certain properties intrinsically, saving on ring slots, but not all rings are edible in any given game, and it's random which are which. We needed to ensure that, at least, polymorph and polymorph control were edible.

Character selection was also important (in fact, we originally messed up and had to hex in a different character; this required redoing the first level of the run, but luckily it synched after that, which says something about NetHack's incredible sync-stability). We chose to play as a Wizard due to the possibility of eventually learning to cast a four-square jumping spell, something which no other class has the magical ability to manage. Playing neutral is required to be able to use certain artifacts, most importantly the Eyes of the Overworld, which enable even blind monsters to see. This is vital because the fastest polymorph form in the game is blind, and yet vision is required at several points which means the Eyes are needed to avoid having to change into a suboptimal form on occasion. Race and gender are less important; we play as a gnome for entertainment purposes (they can see warm-blooded monsters in the dark, thus giving a better clue as to what's going on towards the start of the run), and although we specified an explicit gender (male) for luck manipulation purposes, being female would have worked just as well, as gender is almost cosmetic in NetHack. (Not to mention that we end up changing gender frequently during the run itself for various reasons.)

Our starting inventory wasn't massively important as we can always get more items later, but we end up using much of it anyway. For reference, it contains a quarterstaff and cloak of magic resistance (as always for a wizard), scrolls of gold detection, teleportation, and light, spellbooks of force bolt and scare monster, potions of enlightenment, object detection, and extra healing, rings of free action and teleportation, and a wand of striking. The most important for our purposes are the scroll of teleportation and potion of object detection; the scroll is used for a sequence break (one which was placed there deliberately by the game's developers, but nonetheless not the normal course of things), and although we never actually drink the potion, it was invaluable in luck manipulation early on (when manipulating for particular items, we could see if we succeeded by drinking the potion, then loadstating to revert the turn it spent; this was considerably easier than memory watching would have been).

We also change some options at the start of the game. These are chosen for four main reasons. First, some options are required for the fastest speed through the game, most notably the autopickup options (autopickup and pickup_types), which tell our character what they should and shouldn't pick up as they move (saving turns picking up and/or dropping items manually). Incidentally, we had to adjust these options several times after the run was underway to hex in different things to pick up, such as statues. Next, we turn off the mail option in order to avoid desyncs (it causes the RNG to depend to a small extent on the number of keystrokes typed; not by enough for it to be at all efficient for luck manipulation, but by enough to make it very hard to hex in corrections for past mistakes with the option on). Some options were also changed (or kept at their original values) to streamline the controls to allow us to reduce the amount of input required: confirm prayconfirm cmdassist autodig number_pad. (This is a large difference between a TAS and an unassisted run already; no sane player turns off confirm in an unassisted run, because it's so useful for catching typos.) Finally, some option values were chosen in order to make the game look visually better and to remove time-consuming animations: IBMgraphics color sparkle timed_delay runmode. (Whether IBMgraphics or DECgraphics looks better is a typical flamewar subject among NetHack fans, but luckily DECgraphics doesn't work on the DOS version, making the choice obvious.) Options we didn't care about were just left at their defaults. Most options can be changed without affecting luck, meaning that DECgraphics can be optionally used as part of a ttyrec of the Linux execution of the run.

Turn-by-Turn Play

Turn Purpose Explanation
1 - 13 Movement At the very start of the game, there's not much we can do to speed up our play as we have basically no resources (although some of the equipment in our starting inventory could be used here, we have better use for it later). Thus, we demonstrate the most obvious use for TAS tools in a roguelike game by walking directly to the stairs to the next level via the shortest route. The lichen touches us, but fails to grab hold of us, while our pet kitten roams the level picking up items. (We leave the kitten, behind: it would only slow us down, and it would take far too much manipulation to keep it alive with the strategy we're using. The kitten does survive the TAS, though, making it one of the few starting pets in NetHack to escape with its life.) We ignore all the items in view which we don't care about, which as it happens is all of them.
14-16 Obtain cursed scroll of teleportation via prayer This is the first break from a typical NetHack strategy, as we decide to pray to our god for help; this takes 3 turns, taking us through to turn 17. Because it's only turn 14 (waiting until turn 300, or 100 if we were actually in trouble, would be required in order for the prayer to have any chance of success), and because it's Friday 13 (which prevents prayer until at least one point of good luck is gained to cancel out its bad luck, arguably the most dangerous effect from difficulty in NetHack), the prayer fails quite drastically, with our god Thoth getting justifiably angry with us. His response is to send a curse at our inventory, although due to the first real luck manipulation of the game, it only affects the scroll of teleport. Cursed scrolls of teleport teleport vertically rather than horizontally, making it possible to skip levels and thus go through the game in an unusual sequence; however, with our current equipment, it would skip only about one or two levels, so it isn't worth using yet.
17 Luck Manipulation This is the first really major luck manipulation of the game. The largest source of useful items in the game is upon level generation, especially on levels high in the dungeon which often contain shops. Most pressing for us is to generate a particular set of rings, to enable the polymorph-self strategy used in all the fastest gametime speedruns (whether tool-assisted or not), so we manipulate a huge ring shop that contains all the rings we need (together with a large number that we don't, as it happens) as we go downstairs. Luck manipulation is typically done by walking into a wall, incidentally, which we can do up to 750 times a second, and advances the RNG with, generally, no other effects (the random number is generated for the purpose of eroding engravings on the current square, but typically there aren't any); we explicitly try to stay next to walls throughout the TAS for this reason.
18 Movement We end up in our first real combat of the game as we go down the stairs; we're next to a newt, and apparently the only exit to the room is to the east, beyond the newt, and apparently without enough space to run around it without taking a hit. Although we could beat the newt easily, we have no need to, and so we demonstrate here how a TAS can avoid combat much more perfectly than an unassisted game can. We start off by exploiting the fact that monsters cannot move on the turn they are generated (a consequence of the game's speed system) to move next to a wall (and in the direction we want to go anyway).
19 Destroy secret door The newt is now able to move, but we're now next to a wall and so able to manipulate. The door in the east wall actually goes in the wrong direction, but it turns out that there's a secret door in this room (something trivial to verify in a TAS; we routinely looked for secret doors by savestating, going into debug mode, then loadstating again). The guaranteed starting spell for a Wizard, "force bolt", destroys doors, so we use it to destroy the secret door to avoid having to first locate it and then open it, wasting time. The newt attacks us, but just misses; an incredibly lucky result (if you try this in realtime, you'll find that a newt nearly always hits a starting wizard, although for a negligible amount of damage).
20-34 Movement Leaving the newt behind (as we can outrun it), we simply continue along the corridor via the shortest path. Nothing particularly interesting here.
35 Combat A grid bug blocks our path, so we show off the Wizard's melee combat ability by oneshotting it with our quarterstaff (which takes a small amount of luck manipulation, but not a lot; grid bugs are really weak, and a quarterstaff isn't ridiculously bad as weapons go). This is actually the only time in the entire game where we simply hit an enemy with a stick to kill it, and only possible because we're still facing very early-game monsters.
36-59 More simple and boring walking to the shop via the shortest path. This is still interesting due to how quickly it goes in realtime, though, managing some incredibly fast movement speeds due to the game accepting input several times a frame; also, this is one of your last real chances to see us walking around, as we'll have faster means of movement soon.
60 We couldn't just walk diagonally into the shop because you need to line up with a doorway that still has an open door in order to walk through it (another reason we destroyed the secret door altogether earlier, rather than just opening it and walking through). So this turn is spent moving next to the doorway so we can walk through.
61 Finally, we've entered the shop; it's a shame it was generated this far from the stairs, but it was necessary to get the rings we needed in a reasonable amount of realtime (and no gametime is lost from our final time due to the turn 2000 barrier). We're greeted by Juyn, who is apparently a jeweler, and who wants to sell us rings and gems. Shopkeepers are some of the most dangerous monsters in NetHack; to beat one this early unassisted would be basically impossible (it can be done via a combination of AI abuses and getting incredibly lucky, but even then requires a weapon capable of damaging the shopkeeper quickly, which we don't have). Still, with no gold, we aren't exactly going to be able to afford anything here.
62-63 Note that we're toggling autopickup as we walk about the shop. We know exactly which rings here are valuable to us, and which are worthless; the @ command that changes autopickup settings is used to instruct our character in advance of stepping onto a square whether he should pick up the item on that square or not. Thus, we save turns in the shop that would otherwise be needed to look at the items available and pick up the ones we wanted.
64-66 Time to go shopping! Although we can't afford any of the rings in this shop (being completely broke), the shopkeeper will at least let us try them on. We pick up a silver, sapphire, and shiny ring, each of which is incredibly expensive for an early-game character. The silver ring is a ring of polymorph, the sapphire ring a ring of teleport control, and the shiny ring a ring of polymorph control.
67 We put on the ring of teleport control. This lets us choose the destination of random teleports; although in a TAS you would expect us to be able to manipulate the destinations anyway, and we can to some extent, there are a large number of possibilities for a typical vertical teleport that have no chance of happening unless controlled, so the teleport control is absolutely vital for our strategy to work (as well as having the pleasant side effect of making luck manipulation much simpler).
68 OK, so this is where we leave the usual sequence of the game behind forever. It's intentional that you can use a cursed scroll of teleport to skip levels (although because you have to do them anyway right at the end of the game during the escape sequence, most players prefer to clear them out in advance), but our destination is level 26, far too deep for a typical level 1 character with almost no useful equipment to survive. This is actually the deepest it's possible to get with a single scroll from level 2, but we're actually aiming for dungeon level 25, the Castle, with its wand of wishing. The Castle is considered something of a threshold in a typical non-speedrun game, in that if you can reach the Castle, the wishes you will be granted there are normally enough to win the game. The reason we go via dungeon level 26 is that we want to raid the Castle from below, to allow us to escape it more easily after grabbing the

wand; so instead of going there directly, we go to the level below so we can approach it from behind.

There's a bunch of manipulation going on here, incidentally; although we're going to leave level 26 almost immediately, it's still important to have it arranged as we want it for later on, with levels being generated the first time you visit them. Thus, as well as manipulating a landing near the stairs, we also manipulate a favourable level layout, even though it won't become relevant until later.

Our dramatic exit from the shop, of course, gets the shopkeeper angry at us, and we have a nice little bunch of messages explaining what's going on. Our theft of 1200 zorkmids of merchandise summons the police, the Keystone Kops, to chase us down; but fortunately, they're all stuck up on dungeon level 2 looking for a player who's since sequence-broken all the way to the Valley of the Dead. Who knows, maybe we'll turn up later and see how they're getting on looking for us.

69-70 We can hardly see any of the Valley as we arrive; we just get an ominous message about the awful smells and sounds of this place. Don't worry, you'll get to see more of it later; in fact, we come back here several times in the TAS for various reasons. What is notable, though, is that we landed right next to the stairs (and better, right next to a wall); after a swift bit of luck manipulation, we walk to the stairs, and up them, to the Castle.
71-73 The Castle looks pretty uninspiring at first glance; we're actually in a small maze of corridors behind it. (The stairs up from the Valley are one-way; they can be used upwards, but not downwards, so we're currently trapped in this maze.) Out of the three rings we stole, the ring of teleport control's been used already to sequence-break all the way down here, but we stole another two as well; it's time to put them to use. We spend one turn removing the original ring to free up ring fingers, then put on the rings of polymorph control and polymorph (in that order). The ring of polymorph is the #1 most important item for a TAS of NetHack, for several reasons. What it does is to every now and then (at a 1% chance per turn) polymorph the player into a monster; polymorph control makes it possible to choose which monster to polymorph into (rather than spend several minutes or even hours of realtime luck-manipulating getting the right one by chance, especially on top of the 1% chance that a polymorph happens at all). Obviously, quite a bit of manipulation was needed to make the ring trigger immediately.

The ability to become a monster is hugely useful for several different purposes; pretty much anything you might want to do, some monster will be good at it. Thus, the ring of polymorph effectively substitutes for hundreds of different other items. Better still, there are some monster forms that have abilities that can't be replicated any other way. The other massive reason to use a polymorph-based strategy is that the stats of a monster form are effectively fixed; this makes them weaker than a typically overpowered player late-game (although still strong enough to win even unassisted), but much stronger earlier on, and the fact that we're still only experience level 1 is thus strongly mitigated; this is pretty much the only reason we can survive this deep in the game. This first form we use, the xorn, is one that we will return to several times during the TAS (although TASing in xorn form is really annoying, to the point that an effective collective groan went up whenever we had to use it again). Its major ability is that it can walk through most walls as if they aren't there, being a monster who lives its entire life swimming through rock. Over the next few turns, we're going to abuse this property to sequence-break the Castle quite badly.

Polymorphing into a xorn has one other immediate effect that may seem irrelevant or even negative, but becomes important later. Xorns are too large to fit in a typical magical cloak, so our cloak of magic resistance, which previously protected us from not only magic, but also a wide range of monster special attacks, broke during the polymorph. This was entirely deliberate; generally speaking, if we get hit by a special attack, it's because we want to be, and we'll be taking quite a lot of deliberate hits over the course of the TAS in order to abuse various side-effects of them; having near-perfect resistance from them would have required a huge amount of manipulation just to get monsters to hit us, which would have been ironic to say the least.

(Incidentally, we also became female at this point; the gender change is permanent, and an occupational hazard of repeatedly polymorphing. Our gender changes back and forth repeatedly this TAS, and is irrelevant anyway, so we're going to stop mentioning it.)

74 With perfect luck, this turn wouldn't actually be needed, but we were faced with large amounts of "RNG jitter". A quick explanation: NetHack's RNG works by always returning a fixed sequence of numbers (where it starts depends on the initial date and time, and the sequence is really stupidly long, around 31*2^31*(2^31-1) = 142962266504677031936 or approximately 2^66.95 elements), and all luck manipulation does is determine which element in the sequence is used to determine random events in the game. Of course, different numbers have different meanings in different contexts, so it's not as if there are "good random numbers" or "bad random numbers" to use in different places; we just try to find a nearby location in the sequence that gives favourable luck. (What walking into walls does is use numbers in the sequence for engraving erosion, which is a side-effect that is basically irrelevant to us.)

The RNG jitter issue happens when the number of random numbers consumed by something is itself random, as happens quite a bit in NetHack, especially on very crowded levels like the Valley or Castle, and double especially when generating them for the first time. As anyone who studies randomness knows, using an RNG to advance itself actually makes it less random (rather than more random as some programmers seem to think), because several positions in the sequence will probably end up jumping to the same position, effectively making the two seeds identical. RNG jitter can get very bad sometimes, with 20, 30, or even 50 different seeds generating essentially the same level; this severely dilutes the effectiveness of luck manipulation. As a result, we had to choose what we would manipulate on the Castle level and what we wouldn't, and settled for getting merely near to the best possible location in the maze, rather than at that location. In this case, we'd want to be at the left edge of the small maze over the right, but settled for being a space away from that edge, in order to get more favourable randomness elsewhere in the level; thus, this turn is spent moving to where we'd like to have arrived. As noted, the goal choice is to complete the game in the fewest number of in-game turns, but the 2,000 turn limit boundary means that we have the flexibility to (ab)use those extra turns like this every once in a while. We strive to use every turn in the most entertaining and efficient way possible despite this freedom, however.

76 First off, one of you (the only one who actually read this far and is still paying attention) is probably asking "Hey, what happened to turn 75?". This demonstrates the first drawback of xorn form (hey, there had to be tradeoffs somewhere…); xorns are rather slow, and skip a turn every now and then for this reason. (They aren't nearly as bad in this respect as some forms we use later, but unlike what we do later on in those forms, we aren't abusing the speed system yet, because it would take too much realtime and is anyway unnecessary here.)

This turn also shows another nasty disadvantage of xorn form. Remember that we're doing nearly all our luck manipulation by walking into walls? Well, xorns exist for the purpose of walking through walls, and so obviously walking into them would actually succeed, rather than fail and advance the RNG. Thus, this next section doesn't get perfect luck like in some other places in the TAS, because manipulation via non-turn-consuming means would take a huge amount of realtime (we could exploit an artifact naming glitch at this point to advance the RNG, but it takes ages). Some amount of manipulation is necessary, though, and it's easiest here to simply manipulate via the route we take; however, some aspects of the route cannot easily be changed, and what we do here is actually to wait a turn in order to get more favourable randomness and AI behaviour over the next several turns. (In particular, we're manipulating a nearby shark to go in the wrong direction; we'd be bitten to death by the shark if we didn't wait now, but as it is, with its AI manipulated to go the wrong way we never even see the shark.)

77 A quick demonstration of a xorn's ability to walk through walls. Who needs to solve mazes when you can just slip through the side wall and escape that way?
78, 80-82 Here's another advantage of being in monster form. Typically speaking, moving along the bottom of a moat causes a character to drown, but xorns, used as they are to living inside solid rock, don't actually need to breathe. Thus, we can drop harmlessly to the bottom of the Castle moat. It takes us four actions (five turns due to being forced to skip turn 79) to move along the moat to the particular location we want to phase through the Castle wall. (We're going round this way to avoid dangerous wildlife in the moat, which would otherwise join in while we tried to attack the soldiers inside the castle through the wall.) There's also a side-effect to this that would ruin most games, but again we're using deliberately; our scrolls, spellbooks and potions end up being "blanked" by all the water damage, with the ink running off the scrolls and spellbooks and leaving them as blank paper, and the potions likewise diluting into

pure water. Surprisingly, they're actually more useful this way; blank paper to write on tends to be at a premium during speedruns.

84 (Turn 83 was lost to xorn slowness, as is every fourth turn in xorn form. We'll stop noting this from now on.) This is an example of why being underwater can be a bad idea; we end up unable to move this turn due to turbulence in a moat (and unable to manipulate it away due to being a xorn). (This may seem a little implausible, but water in NetHack tends to be incredibly dangerous, with hard-hitting sharks, eels that can instakill the character, and electric eels that can destroy rings and wands. With that amount of dangerous wildlife around, a little turbulence doesn't really surprise me.)
85 We finally manage to clamber out of the water and through the wall of the castle, where we're faced with a couple of soldiers. This is almost certainly the easiest direction to raid the Castle from; the rest of the castle is much, much worse. The Yendorian Army seems to be equal-opportunities, with a female soldier swinging her sword at us and missing (both the soldiers guarding this tower happen to be girls, for some reason); unfortunately, she doesn't have the sense to run.
86, 88-89 The combat against the first of the two soldiers. (The other one is in range, but not doing a whole lot.) Notice what's happening to our HP bar; we sit there and take damage rather than trying to dodge around the soldier. We're also a whole lot more effective in melee combat than we were in natural form (grid bugs notwithstanding); we start off with our quarterstaff in any given turn, but also get to attack with some of our other hands, and also bite, doing quite a lot more than the staff alone would. The damage taken would have been hard to manipulate away, but anyway is, surprisingly, wanted. While polymorphed, damage, rather than killing you, forces you out of monster form when you accumulate enough; this is by far the easiest way to stop being a xorn, as the 1% chance of spontaneously polymorphing into something else can be hard to manipulate. We also get a level-up for killing an enemy that's massively more

powerful than you'd typically expect to fight at experience level 1.

90, 92 The combat against the other soldier. This one went rather better; not because of the level-up, simply due to luck. As we wanted, we ended up low on health, but not completely out of it; and got another level-up as a result. Ironically, we'd be better off at a lower level here, but not by much, and it ends up not really mattering.
93 Here is the reason we killed the soldiers. (At least the first one had to die due to standing on this square.) The word "Elbereth" has quite some significance in NetHack, and we use it later on ourselves; when you see it in the game naturally, especially burnt into the ground, it's a big clue that there's an important item on the square (although it very occasionally turns up at random). This is the chest that contains the Castle wand, that the soldiers were guarding; there are a huge number of other guards, too, but we sequence-broke past them all, making this one of the fastest ways to get the wand (it would normally take well over 100 turns to fight through the Castle itself, let alone the whole game up to that point.) The other "several objects" are the dead soldier's equipment. Autopickup is off for this, because we don't care about the chest the wand is in, just the wand itself which is a platinum wand.
94 Just being able to open the chest and take the wand out is somewhat anti-climactic; also flukishly lucky, and well worth arriving a square further from the chest than we'd have wanted to. Typically speaking, it'd be locked or trapped; quite possibly both. (And it's not unheard of for the chest to contain a trap which destroys the wand…)
96-98, 100-101 In order to avoid most of the rest of the guards here in the Castle, we take a shortcut through a gem storeroom on our way back out; there are guards outside the door to the storeroom (a secret door to its west), but none inside the room itself. However, one of the guards in the Castle is itself a Xorn, which catches up with us on the way out by phasing through the walls itself and does the last few points of damage needed to force us back into gnomish form, while failing to hurt us any further. (This was actually a pretty sensible strategy for the castle guards; xorns are almost impossible to chase due to their crazy movement properties, so it would make sense to set another xorn after them.) We end up embedded in a wall as we unpolymorph, but can still move out of it; this is pretty useful as it gives us a wall to luck-manipulate with, even though we're going to exit the Castle on our next step.
102 Here's our exit to the Castle. The storerooms have a bunch of trapdoors outside that lead to the Valley; why bother spending soldiers and ammunition on killing an enemy when you can just drop them directly to the gateway to hell? A little luck-manipulation is used here to land in the right part of the Valley (comfortably near to a vampire, who we're going to use soon to trigger a glitch), although it's impossible to land too far away from the stairs, so our choice of destinations is limited.
103 Time to start using that wand of wishing we went through so much effort to get. Generally speaking, when you're as unlucky as we are (starting on Friday 13 is bad enough, but annoying your god makes things much worse), wands of wishing tend to malfunction quite badly, and in fact a lot of luck manipulation is needed to make the wand work at all. And our wish? "4 dark". Although not nearly as broken as Family Feud for NES's text parser, NetHack's wish text parser allows for some pretty weird input at times; in this case, we went for the minimalist option of a surprisingly short wish, and the game rewards us with something dark, in this case a set of dark potions. These happen to be potions of full healing in this game, which will be used soon to set up a glitch; and not only did the game give us the wish in the first place (unlikely), it also gave us all four potions we requested (also unlikely), and blessed them for us

(also unlikely). As you can imagine, this turn took quite a lot of manipulation.

104-106 This is the start of the setup for an infinite max HP and max Pw glitch. (Pw in NetHack is vaguely like MP in other games, and is spent to use magical effects like spells and monster special magical attacks, and regenerates over time.) One of the prerequisites for the glitch to work is that our max HP and max Pw need to be considerably higher than average for our stats, class, and experience level; here, we use 3 of the 4 the blessed potions of full healing for an overhealing effect, where healing via potion if at max HP already increases your max HP slightly. In the case of a blessed potion of full healing, the highest-possible quality of healing potion, the increase is 8 points, and takes us up to 48 max HP, twice the value we originally had, and noticeably above average for our stats. Meanwhile, the time we spend drinking the potions allows a vampire (red V) to catch up with us (and also a ghost, but ghosts in NetHack

are very defensive, taking hardly any damage from attacks but doing hardly any either, and so it can be safely ignored).

107-108 This is the start of the glitch proper, which relies on the fact that the formula for max HP and max Pw gain from gaining a level from stat randomisation due to failed polymorph is different from the formula for max HP and max Pw loss from level drain. What happens is that the vampire's level-drain attack reduces our max HP and max Pw by a fixed amount, so we still have 39 of our max HP remaining even though we were just drained from level 3 to level 1, hugely above average for our stats at that level. Our max Pw is not high enough to benefit from the glitch; but as the glitch involves deliberately taking damage, we first use the glitch to increase our max HP enough to be able to set up the glitch for Pw as well; basically, partially applying the glitch in order to be able to apply it completely.
109-110 Here's the other half of the glitch. We spend two turns running away from the vampire in order to get our polymorphitis from the ring (which we haven't taken off since we used it to become a xorn) to trigger (the RNG jitter here is sufficiently bad that doing it in just one turn would have required so much walking into walls that there'd be a long pause in realtime). When asked what to polymorph into, we say "gnome"; because we're a gnome already anyway, our stats are randomized as a result, and due to luck manipulation, our level increases to 2, approximately doubling our max HP. This interaction of losing a fixed amount of max HP, then gaining a proportion, exponentially quickly increases our max HP to amounts that we want.
111 We take another hit in order to get drained back down to level 1; we now have 68 max HP, as opposed to the 39 max HP we had last time we were at level 1. Unfortunately, we only have 3 current HP left; this is a typical issue with glitches that require you to take damage to work. Unlike in a regular game, though, in a TAS there's no urgent need to heal up instantly; as we only take hits when we want to, we're in no actual danger of dying.
112-116 We continue to run away from the vampire to get polymorphitis to trigger, and end back up at experience level 2. Our route through the level at the moment is actually quite complicated; it might look like we're just running around aimlessly until we get the glitch to trigger, but we're actually trying to manipulate the movement of other monsters in the level to not interfere with the glitch. By far the biggest influence on enemy monster movement is your own movement, although a random factor is sometimes involved as well.
117 So as to be able to continue taking damage to do the glitch without death, we drink the remaining potion of full healing to get back up to full HP (plus 8 to max HP, as some of the 400 points of healing it provided were wasted, the trigger for the overhealing effect). As we'd taken level drain in the past, the potion also restored one of our drained levels as a side-effect; this was slightly undesirable (in that it needs to be drained again to continue the glitch), but not a massive problem. Note that due to the difficulty level, this glitch requires taking much more damage than we normally would; within an hour after midnight, damage from undead, including the vampire, is doubled.
118 Now that our HP is high enough that we're not in danger of death from taking damage to perform the glitch, we prepare to do the glitch properly, with both a max HP and max Pw boost. Therefore, we need to increase our max Pw to substantially above average values, so we use the wand of wishing to wish for "4 gain energy potions" (a very mild parser abuse as the item is actually called "potions of gain energy"; the "of" reversal can be used on all non-artifact items, and is intended for things like "speed boots" vs "boots of speed" where it may be hard for the player to remember which way round the item is). Not only does the wish work, and grant us all 4 potions we requested, but they even come out blessed; with our large amounts of negative luck, this is rather unlikely and takes substantial manipulation. Therefore, we unfortunately couldn't get the vampire to drain us on the same turn as we'd have wanted, but it isn't a major issue.
119 Here's where we use our other starting spell, "slow monster", to slow down the vampire. (Vampires actually have a pretty good chance to resist it, but we manipulated it to affect this one.) The vampire responds by draining us back to level 2. Slowing the vampire like this allows us to run round it and back the way it came without getting blocked in by a huge number of monsters at once (the Valley is swarming with monsters, even though it might not have looked like it so far); most undead are rather slow, and with the (comparatively fast) vampire slowed to a comparable speed to a zombie, we can herd the undead and manipulate their AIs more easily.
120-121 We start going round the vampire, back the way we came. Turn 120 moves round it; turn 121 stays in the same position so that the vampire can catch up with us and drain a level. We're now back to level 1, but with 135 max HP this time.
122-125 These turns are spent running round the pack of monsters that was chasing us; we avoid a kobold zombie (brown Z), and encounter a ghost (who will be used to manipulate the vampire's movement path, as two monsters can't occupy the same square). Ghosts are rather hard to see, incidentally; the trick is that adjacent squares, which normally show . if nothing is there or a wall or monster symbol, are replaced by blank space if there's a ghost on the square.
126-127 We drink the first two potions of gain energy, getting unusually high max Pw gain from each of them (towards the top of the range). Note how the zombie catches up with us, but due to being very slow-moving, cannot hit us; as a result of the ghost and zombie blocking the way, the vampire is forced to go a bit of a longer way round.
128-130 Here's the third potion of gain energy, preceded by running away in order to get the monsters to stay behind us rather than surrounding us. There's a vampire bat nearby (out of sight), which also needs to be manipulated to not turn up (they deal decent damage, but move randomly, so unlike other monsters can be manipulated to go the wrong way very easily). Because we aren't next to a wall when we drink the potion, we can't easily manipulate the Pw gain from it directly; the gain was actually manipulated in advance on turn 128 when we were.
131-132 And here's the final potion of gain energy, again running away in order to keep the crowd of monsters behind us. Our max Pw is now high enough that doing the polyself glitch will increase it as well as our max HP (previously, it was decreasing slightly).
133 After a lot of luck manipulation (to control the next few turns, as we won't be next to a wall for one of them), we step to the left, and autopickup a scroll labeled YUM YUM as we do so. This is actually a scroll of charging, which we can use to refill our wand of wishing (such wands can be recharged only once, for 3 wishes (before charge) + 3 wishes (after charge) + 1 wish ("wresting" a charge from an empty wand), a total of 7). This was all the more surprising to us because we didn't actually manipulate the scroll to spawn, it was just there by chance. Although in a TAS you can manipulate away bad luck or cause good luck, you aren't also manipulating away any good luck you'd have got naturally; on top of the luck you make yourself there are also nice bonuses like this to discover that save us from having to come up with another method to recharge the wand.
134-136 Nothing particularly special here, just more uses of the polyself glitch. We cut across the corridor and then move back towards the vampire in order to help keep the mob of enemies behind us rather than getting surrounded although there are new enemies turning up, a human zombie (white Z) and kobold mummy (brown M). Along the way, we take another failed polyself and a level drain to almost double our max Hp and Pw again. Our new max HP of 255 is a little above the average for a typical character upon completing the entire game.
137-140 More repeats of the polyself glitch, this time moving along the south wall and manipulating an extra-large level gain from the polyself to level 3, rather than level 2, almost tripling our stats rather than almost doubling them. (Due to the RNG jitter here, we weren't aiming for a doubling or tripling in particular, but just any boost that we could get reasonably quickly.) Other results from a failed polyself include a stat randomization while staying at the same level (useless for performing the glitch), and a level and stat reduction (which, at level 1, is fatal, making this glitch a dangerous one to try unassisted although it can be done via the use of a huge number of amulets of life saving which are NetHack's equivalent of extra lives).
141-142 We move diagonally back towards the crowd and take another level-drain from the vampire; our HP is now high enough that we can effectively ignore hits from everything else, as they don't do significant damage compared to the amount of HP we have, and care about the vampire only because of the level drain effect. This strategy of moving horizontally away and then running diagonally back, incidentally, helps to avoid an even larger crowd chasing us because it leaves monsters less certain as to our position and also reduces the chance of guessing it correctly, although some enemies have infravision and are able to see our body heat through the darkness anyway and chase us regardless (just like we can see the vampire at range, because gnomes also have infravision).
143 Despite being almost surrounded, we can actually afford to just wait a turn here, and do so; this exploits the fact that undead are generally slow (vampires aren't, but we slowed it ourselves), and this turn we happen to get a free turn against all of them but the vampire, who courteously level-drains us down to 1, allowing us to perform the glitch again. (The glitch works best at level 1 because the max HP and max Pw gain is approximately equal to the ratio between the old and new levels; so going from 1 to 2 would double the maximum, whereas going from, say, 10 to 11 would only increase it by around 10 percent.)
144-146 These turns demonstrate just how almost surrounded we were, ending up confined to the north edge of this wide corridor due to a whole row of monsters below us. We nevertheless can move just about fast enough to slip past the west end of the row, because the ghost at the end of the row moves very slowly, and out into the middle of the corridor, where we failed-polyself to level 3 again (thanks to manipulation on earlier turns). The vampire also manages to push through the crowd to end up only one space away from us.
147-153 Again, we manipulate the vampire to level-drain us twice, this time over at the south end of the corridor, first moving back the way we came then forwards again, then cross back up to the north end and trigger a polyself. This movement pattern causes some of the monsters chasing us to think we're going east and move in the wrong direction, or at least stay where they are, whilst allowing the vampire (who's slightly faster than most of the other monsters despite being slowed) to come towards us.
154-158 Our final iteration of the polyself glitch, running back to be drained then away to polymorph, takes us up to 2222 current / 8763 max HP and 2625 current / 3101 max Pw, values high enough to be pretty much impractical to reach without use of a glitch (whether the polyself glitch as used here, or the much slower pudding farming method which is used occasionally in unassisted games that aim to show off with high statistics rather than speed). Because we no longer have a need to manipulate the vampire to stay ahead of the other monsters involved, we simply run away in a straight line in order to trigger polyself, to leave the crowd as far as possible behind us. The blue ! is a potion, but we ignore it because it's worthless to us.
159 We use the third of our wishes, emptying the wand of wishing. Our wish here is for "5 blessed scrolls of teleportation". NetHack players might have been wondering why we didn't just specify "blessed" in previous wishes rather than manipulating them to give blessed items at random; the reason is shown here, in that requesting blessed items has no chance to work when you're as unlucky as we are, instead causing the items to be automatically cursed. Of course, cursed scrolls of teleportation are what we actually wanted, as they're our only real means of moving around the dungeon, with walking from stairs to stairs being far too slow. Also of note is that wishing for a quantity of 5 is rarely attempted in normal runs due to the low success rate of 1 out of 6 although this ratio is trivial to overcome with luck manipulation abuse.
160 Before leaving the Valley, we recharge our wand of wishing using the scroll of charging we randomly picked up. This one happens to be merely uncursed (NetHack's description of an item which isn't blessed, but isn't cursed either), rather than blessed like is normally used to recharge a wand of wishing, so a small amount of manipulation is required to ensure that it really does fully recharge the wand so we get the maximum possible number of wishes out of it.
161-162 Several monsters in NetHack can follow the player when they change levels (imagine them sharing in your teleport by touching you just as it takes place, or something like that). Of the monsters near us, the vampire can, but the vampire bat can't; so since we can outrun the slowed vampire, we simply do so, leaving us alone and ready to leave the Valley without being chased. (Don't worry, Valley of the Dead fans, if indeed there are any reading this: we come back here several times later.)
163 As we're no longer wearing the ring of teleport control, when we read one of the cursed scrolls of teleportation we just wished for, we end up on a random level. A huge amount of manipulation (several hours of work by a luck manipulation bot, together with trying out various possibilities it found by hand) went into this turn to make sure we landed somewhere useful; we land on dungeon level 16, a normal randomly-generated level (as opposed to a "special level" like the Castle or Valley which has its own generation rules). This level will serve a bit like a home base for us; this particular level layout for level 16 was manipulated to contain useful terrain, useful items, useful monsters, and to be almost free of RNG jitter (it's almost empty of monsters, and what monsters are there mostly have non-jittery AIs).

Where we landed on the level was incredibly lucky, though; we manipulated for the level itself, but not for a particular location on it. As it happens, we landed right on top of a magic lamp, in a shop; such lamps contain djinn, and upon releasing them they have a chance to give you a wish. Complicating things is the shopkeeper; shopkeepers are some of the most dangerous monsters in NetHack when they get angry, and will fight to the death to protect their shops from thieves. They also charge for pretty much everything, so it's not surprising that they'd charge for releasing a djinni. Autopickup was set before even arriving on the level so that we'd pick up the lamp upon arrival.

164 Right next to the magic lamp is another extremely useful item, a magic marker. These things are almost better than multiple wishes, in that they can be used to write on blank spells or spellbooks in order to make them into magical scrolls or spellbooks, letting us equip ourselves quite easily; this one also happens to have a lot of ink remaining (although the game won't tell us that yet). The shopkeeper attempts to charge us for the marker, although as always, shopkeepers allow you to examine merchandise before paying for it, something which can be exploited quite heavily in both a TAS and a regular game.
165 We rub the magic lamp in order to release the djinni (unwielding our quarterstaff as a side effect, because we need to hold the lamp in one hand to rub it with the other; we never use the quarterstaff again). The shopkeeper rather amusingly tries to charge us for using the lamp, and won't let us out of the shop until we pay for it. The djinni offers us a wish in return for releasing him (presumably he doesn't like being trapped in a lamp and then charged for); we ask him for a "very dull spellbook", a little in-joke, because we're going to end up using the spell from the resulting spellbook a lot in order to level up our divination skills. (This is another parser abuse; you can write "very" in front of pretty much arbitrary items and the game won't complain.) The djinni gives us a dull spellbook of detect monsters in return for his freedom, then vanishes, never to be seen again. The weight of the spellbook burdens us

(we have rather low Strength and Constitution), slowing down our actions slightly, but in a peaceful area like this it isn't a major problem.

166-169 Reading spellbooks takes quite some time in-game; inside a shop, with the shopkeeper guarding the door (primarily to prevent you leaving, but it works just as well to prevent anything else entering), is a very safe place to do so in an unassisted run; in a TAS, you have a broader range of safe locations due to the ability to manipulate luck, but if you're in a shop already, why bother looking for anywhere else? Reading the book to learn the detect monsters spell takes four turns, relatively fast compared to most spells. The learning of the spell is slowed marginally due to being burdened, but dropping items to avoid burden, then needing to pick them up afterwards, would waste more time than it saves.

It's worth a quick explanation as to why we learnt a divination spell, something which would seem mostly useless in a TAS. We actually don't need detect monsters to complete the game at all, nor to make things faster; however, later in the game, having a constant detect monsters effect up is more or less the only way that people watching the TAS would be able to follow what was going on. Thus, this would be a speed-entertainment tradeoff in most cases. However, the T:2000 barrier means that we can actually spend the time it takes to practice divination casting enough to reach skilled divination (for a level 1 spell like detect monsters, 80 casts), and not lose any time overall; and yet allow people watching to see exactly what happens later in the game.

170 Ugh, the dreaded xorn form, again. Although a huge pain to TAS in, there are several reasons to use xorn form unrelated to its ability to walk through walls. This turn demonstrates the first: the physical size and strength of a xorn means it can carry heavier items without being burdened, and although the gnome was struggling with a backpack of spellbooks, the xorn has no such issues.
172 (Xorn slowness made us skip turn 171, and will continue to make us skip every fourth turn while in xorn form.) Here's another use of xorn form. As a monster that swims through rock, it isn't surprising that a xorn would have an unusual diet; and as it happens, xorns are capable of eating metal. The ring of polymorph on our finger happens to be cursed (not really a major issue, it just prevents removal of the ring); we eat it off our own finger (well, claw), and its effect is manipulated to spread throughout our body (a 1 in 3 chance), meaning we now have its polymorphitis effect permanently, freeing up the ring finger for other purposes. Because the ring is cursed, the silver is rotten; this would typically have bad side-effects but we manipulated them away.
173-174 We need luck manipulation for the next few turns but xorns walk straight through walls and thus cannot walk into them for luck manipulation purposes. So what we do instead, here, is to change the order in which we do things; we want to practice detect monsters up to skilled, and so by casting detect monsters whenever we'd get unfavourable luck for whatever we actually want to do, we can wait until a turn on which we get favourable luck for the luck-requiring parts, and yet still get something accomplished in the meantime.

The result of the spell itself also shows the paucity of monsters on this level; there are two hidden mimics (brown m) pretending to be items, which we don't need to worry about as they don't jitter the RNG while hidden; ourself, a xorn (brown X); the shopkeeper (white @); and a tengu (cyan i), a sort of minor demon, which becomes important later.

176-177 We eat two more of our rings. First is the ring of polymorph control, which we've been using to keep the ring of polymorph in check all TAS already; second is the ring of teleportation that was in our starting inventory, and that so far we haven't used. Teleportitis (granted by the ring of teleportation we just ate) plus teleport control (which we do not yet have) is a similar combo to polymorphitis plus polymorph control; every turn from now on, we have a 1 in 100 chance of polymorphing into a creature of our choice (as before), but also now a 1 in 85 chance of teleporting onto a square of our choice. This basically puts an end to any walking around dungeons that might happen, apart from the very many levels which ban horizontal teleports (most of the special levels), where teleportitis does nothing at all. Still, the ability to teleport horizontally will come in useful on occasion, such as on this level, an ordinary level without any teleport restrictions.
178, 180-182, 184-186, 188 More casting of detect monsters for luck manipulation purposes. The tengu has teleportitis itself, and demonstrates what effect it normally has in an unassisted game by bouncing around the level to some extent (compare its position on successive casts of the spell); teleportitis is considered incredibly annoying by most NetHack players, but in a TAS it can be manipulated away (or caused to happen) when necessary, meaning we don't have to act like the tengu demonstrates here. The tengu finishes up by landing right in the shop, just next to us.
189-190 One nice thing about being in xorn form is that it doesn't really matter what weapon you're wielding, as you have a mouth and lots of spare hands. We demonstrate this here by bashing the tengu to death with our lamp in only two turns; of course, it isn't the lamp itself that's doing most of the damage, but our bite and remaining hands. (It was just faster to do it this way than to waste time unwielding the lamp, now an ordinary oil lamp because the djinni has left). We also get a level up from the tengu, an enemy typically too difficult to fight at experience level 2; levels are welcome rather than unwelcome from now on, as we've already done the polyself glitch, and they improve our spell failure chances (which will be important later, as we need to get the chance of casting various hard-to-cast spells above 0%), and reaching at least level 14 is required to complete the game.
192-194, 196-198, 200-213 We step onto the tengu corpse (instructing our character not to pick it up), and cast some more detect monsters for luck manipulation. Finally, we eat the corpse, and Yad the shopkeeper, being a complete moneygrubber like NetHack shopkeepers are, rather hilariously tries to charge us for its corpse (hey, it landed in the shop when we killed it…). As tengu are rather large, it takes a lot of turns to finish eating the corpse (which aren't affected by xorn slowness). One of the less likely results from eating a tengu corpse but the one everyone typically actually wants is teleport control, which we got here; if you're wondering why we didn't just eat the ring, it's that teleport control rings aren't made of metal with this game seed and thus xorns can't digest them (and nor can anything else, as it happens). Finally, we move back to where we were, again for luck manipulation.
214 Unpolymorphing from xorn form is always a tricky issue, as we can't easily manipulate the 1% chance of polymorphitis triggering without a sufficiently solid wall to walk against. In this case, we do something really quite dramatic. Remember the wand of striking in our starting inventory? These wands are quite hilarious (they attack by flying through the air and physically beating up whatever they target, a pity that the game doesn't animate that onscreen…), but exactly duplicate the "force bolt" spell that we already have, and so we have no real use for the wand. However, a xorn is easily strong enough to snap the wand in two, causing all the magical energy in it to be released at once, and that's what we do here. First, there's a small explosion which has several effects: it hits the shopkeeper, doing only slight damage (as he resists it); it hits a nearby small mimic pretending to be an item (worrying it into

switching back into its natural form, ready for combat); and it hits us, doing minimal damage. The resulting pieces of the wand, however, fly into the surrounding region and start beating things up. One piece hits Yad, again doing slight damage; another misses the mimic, and finally the wand is laid to rest.

Obviously, the surrounding monsters are going to reply to this on their turn. The shopkeeper uses a wand of magic missile against us, hitting us on both the main attack and the rebound; and the small mimic does enough damage to unpolymorph us. (We actually manipulated the enemies into doing a lot of damage here; typically, they wouldn't do quite enough to unpolymorph us.)

215 We don't get to move this turn due to the speed penalty of being burdened, but the shopkeeper does. Twice. (We told you they were dangerous; that's one of the reasons why.) He continues pelting us with the wand of magic missile, but the damage is pretty minimal compared to our insane number of hitpoints.
216 After a huge amount of luck manipulation, we drop our entire inventory, apart from the scrolls of teleport. There are three main reasons to do this: first, it prevents us being burdened, letting us do this fight more efficiently (the least major reason); second, we want to transport one very heavy object soon, and need to free up inventory weight to do so; third, we're going to do two of the game's mandatory sidequests, one of which is pretty difficult, without any inventory but the scrolls because going around the game without inventory is generally considered suicidal; it's a case of picking a particular route for entertainment reasons.

One other thing to note here; normally, we allow the game to display messages to show what's going on, but in this case we skipped them (by pressing escape) because it's just a lot of "You drop the item. Yad seems uninterested." (If you were a shopkeeper, wouldn't you be uninterested in buying items if someone had released a djinni you were trying to sell, and then tried to blow you up?)

Once the dropping is over (and Yad shoots a couple of magic missile bolts at us), polymorphitis triggers (this is what all the luck manipulation at the start of the turn was for). We choose to become a master mind flayer (purple h), who has one of the most powerful attacks in the game, as a demonstration of how a TAS can deal with a shopkeeper at pretty much any stage of the game. (This tactic would have worked just as well up on dungeon level 2; it's just that we had no reason to kill the shopkeeper there.)

217 After a bit of manipulation to do above-average damage, we punch Yad, then attach our tentacles to his head and start eating his brain. We hit every time (which is sort-of unlikely at -4 luck against a shopkeeper), and oneshot him (raising our experience to level 4 in the process). As the shopkeeper is human, and always starts out peaceful, the game considers this murder, and reduces our luck further to -6 as a penalty, meaning we're now sufficiently unlucky that most sources of wishing have no chance of working at all. (That -6 is -1 from Friday 13, -2 from murder, and -3 from trying to pray too early back near the start of the game.)
218 Our next aim is to make amends to our god for all our bad behaviour over the previous turns. Angry gods are generally quite hard to please, demanding the sacrifice of a single very poweful monster to make amends (rather than several sacrifices of anything like they usually do, which is typically easier to come across). Luckily, we happen to have a shopkeeper corpse handy; unluckily, they're very heavy. So as we step onto the corpse, we spontaneously polymorph into a red dragon (red D), a form sufficiently strong to carry the corpse. (Dragons are some of the strongest monsters in the game, not only having the maximum possible natural Strength, but also being incredibly large physically. As for why we picked red, it's because not only do they have the second most powerful breath but several of the monsters we're going to encounter soon are vulnerable to fire, the element with which red dragons are associated.)
219 We pick up the shopkeeper corpse, which is sufficiently heavy that even a dragon struggles with it slightly, becoming burdened. (There are several other burden statuses as well as unburdened and burdened: stressed, strained, overtaxed, and overloaded. Nearly all other polyforms would be doing much worse on that scale; for instance, the master mind flayer isn't strong enough to pick up the corpse at all.) The small mimic hits us, doing a tiny amount of damage, but we don't particularly care; what we manipulated this turn was for our newly-obtained teleportitis to trigger, letting us go to a square of our choice. We pick a square well out of view, that "just happens" to have an altar to Thoth on it (of course, we knew it was there already, and had in fact manipulated for the level to create one back when it first generated).

Although we're not aiming for a perfect realtime duration in this run preferring entertainment instead, that's no reason to waste time when we can help it, and thus a cursor movement trick is used at this point (and at every teleportitis prompt from now on). Normally, to move the cursor to an altar, you can just press underscore to mean altar (they're drawn as underscores onscreen), but that obviously doesn't work if the character doesn't know the altar is there. Instead, we exploit an interesting feature; we're playing using the number_pad controls where 12346789 are used to move around (and the main keyboard numbers work just as well for this as the actual numeric keypad; such a control scheme is really confusing, but we had to get used to it for making the TAS partly due to using keyboards without numeric keypads on them), but the game has a second control scheme that we aren't using where hjklyubn are used to move (which is more suited towards laptops and simialr systems). A little-known feature of NetHack is that at direction prompts when using numpad controls you can use the letter-based controls to move 8 squares at a time, even though they normally do something entirely different when using numpad controls. This lets us move the cursor to the altar square much more quickly than would typically be possible.

220 Time to go mollify Thoth. We sacrifice the shopkeeper corpse on the altar and he forgives us for all our past misdeeds, resetting the god's mood to its default and setting our luck up to +0 (note that the Friday 13 penalty was wiped out along with the penalty for violating a neutral code of conduct; I'm not sure if this is a glitch or not, but it's definitely useful). Thanks to a lot of manipulation this turn, teleportitis immediately triggers again and we choose to teleport into an apparently uninteresting room. (We use the cursor movement trick we used last turn, and actually overshoot the room in order to reduce the number of keypresses needed altogether, and thus the amount of processing time and thus lag; it's faster for the distance we teleport to move beyond and then back than it would be to not overshoot.)
221 Here we demonstrate why we went to this room in particular; there's a level teleport trap here, and using it helps to save on cursed scrolls of teleportation. Our actual intended destination is in Gehennom (also known as Hell), in the deepest depths of the dungeon; however, we can't go past the Valley on the way down in just one level teleport. (It works rather like the warp whistles in Super Mario Bros 3; you can warp to the Valley from anywhere but in order to warp past it you need to be there already.) We manipulate our arrival point within the Valley to be on the south path, but not so far along it that we take damage upon arrival.
223-224 (Like xorns, dragons are slower than normal so we skipped turn 222 due to our slowness and continue skipping every fourth turn while we remain in dragon form.) As we have to go via the Valley anyway, we may as well exploit it while we're here. The next portion of the TAS is dedicated to gaining experience levels while en route to our next destination; we're going to start off by killing several of the undead here. We start off next to a different vampire from the one we were exploiting for the polyself glitch earlier and demonstrate one of the abilities of a red dragon by breathing fire at it twice (while dodging the bounce of our own breath weapon against the wall, although it wouldn't do any damage to us even if it hit). This takes us up to experience level 5.
225, 227-229 We continue along the south path in the Valley (which is actually a dead end as it happens but we're aiming for the large mass of monsters at the end of it in order to gain more levels). We ignore a dwarf zombie along the route (red Z; it really isn't very threatening) and the corpses (variously-coloured % signs strewn around for flavour reasons), and breathe fire once into the darkness, and again at the vampire who comes into view, two-shotting it and gaining experience level 6. This was one of the hardest luck manipulations in the TAS, and for relatively little gain at that; it's just that being suboptimal is frustrating. (The vampire in question had 59 hitpoints, and will always regenerate 1 between attacks, thus 60 damage is needed to two-shot it. The fire breath attack of a red dragon does damage equal to the total of six 6-sided dice to a vampire; and so on average, we need to roll at least 5 on each of those

twelve dice. A special tool was used for this, showing the results of die rolls into the future, scanning for runs with a high average by eye; because the RNG sequence is fixed and all that luck manipulation does is choose which location in the sequence is used for which random event, we could aim for those particular combinations of dice via repeated wallwalking once we knew where they'd be in the sequence.)

231-233, 235-237, 239 As the ghost nearby would take too long to kill, and the zombie is worthless, we just fly round them and onwards along the corridor. We blast fire into the distance in order to wound a vampire bat that's blocking the way, then walk up to it, and bite it and claw it to finish it off. (Like xorns, dragons get multiple melee attacks in a turn, although unlike xorns, none are with a weapon.) The vampire bat takes us up to experience level 7; it might look like we're getting these levels really easily, but it's because we're fighting monsters massively powerful compared to our own level, and thus we get a huge amount of bonus experience. (It isn't possible to gain more than one level per kill, by the way, which is why we're going up one level at a time.)
240-259 (skipping every fourth turn) Nothing much happens within these turns; we just continue flying along the corridor. The valley is a no-horizontal-teleport level, so we can't just teleport to where we're aiming, but rather have to fly there by hand. Eventually, we end up next to a gray W and a wraith, which is the reason we came here in the first place; the area around us is swarming with the things, and eating a wraith corpse causes an instant level gain, being one of the easiest ways to gain levels when we're already at a high enough level that we can't easily gain levels from normal combat.

Incidentally, here we encounter one of the very few visual differences between the unhacked, official NetHack game itself that the run plays, and the hacked version that syncs against it that was used to create the run. In the hacked Linux version, wraiths are blue instead of gray. (This was a side effect of using a different codepath to draw the screen, due to using a different operating system with different rules for console color code specification.) Thus, people watching us make the TAS live will have seen a slightly different color scheme here from the run itself.

260 One of the big problems with trying to play in this "graveyard" area of the Valley is that there are a lot of monsters, some of which we care about (wraiths), some of which are weak, get in the way, and don't even give useful experience (most of the zombies and mummies), and some of which are hard to kill and interfere with our attempts to round up wraiths (ghosts, demons). Thus, our first action upon arriving here is to fire a bolt of fire into the crowd, destroying two weak monsters and waking some other monsters in the region. The adjacent wraith responds by touching us, but the touch does not do much (it can drain levels, but we manipulated it so it didn't.)
261 An eventful turn, this one. We walk north into the graveyard area proper, and are instantly greeted with a warning. Typically, you get "Run away! Run away!" upon entering a graveyard during the hour after midnight, the period in which undead do double damage, in order to remind you that you probably did something quite stupid; however, dragons don't run but fly, and so the game does a rather amusing substitution of verb. Then, a nearby wraith decides to drink its cursed potion of invisibility; such potions do turn their drinker invisible, but also alert all their enemies to their current location, so we get to see where the wraith was when it drank the potion. (This is not particularly useful in a TAS, as we know where it was anyway; as we don't have see invisible, this will actually be more confusing than useful, as although we knew its position when making the run it won't come up on the screen when replaying it.

We'll try to point out where it went when it's relevant.) Then, we take a couple of weak attacks; then, teleportitis triggers (but does nothing as it's a no-teleport level), then, polymorphitis triggers, and we choose to become a quantum mechanic, a monster form we haven't used so far.

Quantum mechanics (cyan Q) are a bit weird as they're relatively weak in most respects, and don't do much damage. They're pretty much completely based on silly physics jokes; upon hitting things they make their position uncertain, upon being eaten they make their consumer's speed uncertain, and enemy quantum mechanics sometimes carry a box which contain a cat that might be either alive or dead (and, of course, the state of the cat isn't determined until you open the box). The on-hit effect is the reason we turned into quantum mechanic form here; several of the monsters around here would take too long to kill, but all that we care about is getting them out of the way, so we can use the uncertainty attack to send them to a different part of the level.

263-265 Here's the uncertainty attack in action. In order to start surrounding ourselves with wraiths, we send away a ghost, a vampire, and a human zombie (white Z) to other parts of the level. We now have two wraiths adjacent rather than one.
266 We finish off our quantum mechanic usage by sending away the other human zombie (the order in which we attacked them was very relevant as we were manipulating the AI, via luck manipulation and via actions, to send wraiths near us and other monsters further away); and polymorph back into a master mind flayer in order to continue our combat against the surrounding enemies in a form better suited for it. Unfortunately, we also ended up getting level-drained in the process; due to all the RNG jitter around here, it was impossible to get perfect luck for this turn. It's irrelevant anyway, though; if you are only drained one level, your next kill will immediately regain that level, as you're drained to 1 experience point below the amount needed to level up. Thus, it ends up making no difference in the long run.
267 Ghosts might be incredibly defensive and hard to kill in NetHack, but it seems that they nonetheless have edible brains, so we oneshot this one via the good old brain consumption method. (Mind flayers can see invisible, so the invisible wraith shows up onscreen.) Manipulation was used here, and over the next several turns, to mostly avoid level drains from the wraiths in question, although avoiding damage altogether would have been nearly impossible. Killing the ghost regains us level 7.
268 Killing wraiths in the Valley and getting them to leave corpses is not an easy task; not only are there a lot of enemies that need to be manipulated to not level-drain you in the process, but they only have a very small chance (around 6%) of actually leaving a corpse here (it's higher on most levels, but as it happens all the wraith-killing this run is done on levels with the lowest chance). Nonetheless, we aren't surrounded yet, so we have time to kill the wraith, manipulating it to leave a corpse, and manage to avoid being level-drained in the process.
269 Although we're not going to actually eat the wraith corpse yet (we'll eat it somewhere quieter, although we have to eat it relatively soon to avoid it spoiling), we nonetheless need to pick it up so we can take it somewhere less crowded. The version of autopickup used in the official version of NetHack only lets you distinguish between item classes, so at first it might seem impossible to autopickup the wraith corpse without also picking up the elf corpse that happens to be on the same square. However, we use a trick with burden levels; you're warned if you try to pick up something too heavy for you to easily carry, and we exploit the fact that the warning happens between the pickup of the two corpses to cancel one pickup whilst allowing the other to occur, ending up with just the item we want. At the same time, the AI manipulation finally reaches the conclusion we want, with five wraiths and no other monsters adjacent.
270 The next issue is how to get the wraiths out of here so we can kill and eat them in peace. Although there are five wraiths visible, one is actually asleep; so we kick it in order to wake it up, so it's alert enough to chase it from level to level. (This does only minimal damage to it.) The combined damage of the wraiths, now all alert and trying to kill us, is enough to send us back to our natural form, but we manage to take no leveldrain even from five draining attacks.
271 This is one of the more disappointing turns in the TAS, due to our inability to get anything near what perfect luck would be. One of the good things we can say about it is that we didn't take any level drain, and that we safely managed to transport all five wraiths to dungeon level 36 via a cursed scroll of teleportation (we can go below the Valley now, as our teleport started from it already). The amount of RNG jitter here was enormous; only about eight or nine different versions of dungeon level 36 were generated in the first hundred seeds, and so in the end we settled for something good enough, if hardly optimal.

Anyway, as to why we're here. Although this level also only has around a 6% chance of wraiths leaving a corpse, it has a maze layout (as do most levels below the Valley), meaning that only a couple of wraiths can get at us at a time, and also that they have limited places to run (and if they run, monsters can't get between us and them as it's just corridor in the way). In fact, multiple wraiths ended up on the other side of a wall in a more or less completely different part of the maze; this is good for avoiding attacks from them while we hunt them down to kill and eat them, but bad for actually finding them, and the reason I'm so disappointed is that one of the wraiths ends up too far away to reasonably hunt down, meaning that we only get to kill and eat four of them over the next few turns.

272 It's time for us to use Elbereth ourselves, to scare the wraiths into running away so that we can kill them one at a time. Quickly scribbling it in the dust with our fingers, like we do here, has a 72% chance of working, and scares most sorts of adjacent enemies into running away and being incapable of attacking in melee. (The history of Elbereth is an interesting one, incidentally; for years it was a cheat code, kept a closely guarded secret by NetHack developers, but word of it leaked out (as is inevitable with an open source game), and it became such an integral part of gameplay over the years that the developers relented and placed a note about it in the manual. Nowadays it's just another tool in the toolbox, if a rather clunky one, and many players feel it's rather overpowered; in an unassisted game, it's at its most broken when it's repeatedly spammed, but ironically, in a TAS its only real use is to manipulate monster AI, like we do here.)

We also trigger polymorphitis this turn (this level is also no-teleport but we can polymorph just fine) and become a jabberwock (orange J), another new form. Jabberwocks are just a pure combat form, with nothing much to distinguish them but a powerful melee attack; playing as a jabberwock here allows us to oneshot wraiths pretty much guaranteed allowing us to focus our efforts on making them leave corpses.

273-280 We start off our wraith-hunting with the two nearby wraiths, killing each of them (going to experience level 8 after killing the first) and immediately autopickuping their corpses as we move onto their square. The third wraith manages to get a few squares away in the process but is almost as easy to hunt down and kill as the first two; we turn into a xorn as we step onto its corpse so that we can phase through the wall to chase the next wraith. This bit went as well as could be hoped; unfortunately, the time spent doing this allowed the other two wraiths to get away to some extent.
281-282 Here's a nice example of randomly occurring luck (rather than manipulated luck) in TASes; we phase through the wall separating us from the fourth wraith, and immediately polymorph back into a jabberwock on the other side due to happening to hit that 1% chance at just the right moment saving us from worrying about how we were going to unpolymorph this time.

The other interesting thing to note here is that unlike other times we became a xorn we didn't skip any turns (normally, the turns skipped in xorn form start with the second). The reason for this is NetHack's version of subpixel carryover in the form of movement energy carryover; the game remembers what fraction of a turn you had remaining when you polymorph and applies its effect to whatever new form you choose. The last time we were in a slower-than-normal form it was the red dragon and it skipped turn 262, the last turn before turning into a normal-speed monster once more. Thus, the skipped turn next time we become a slow monster comes later than it would normally. This can be abused, but it's mostly only useful to abuse it on enemy monsters than on the player ourself because later on past T:2000, when we're going for as many actions per turn as possible, there's a much better abuse we can use.

283-285 Here, we're hunting down the fourth wraith. This one's invisible but we know where it is anyway. In order to get the first hit on it we let it come to us on the final turn rather than us coming to it so after taking two steps towards it, we spend a turn practicing our monster detection in order to not waste the turn.

This is a good time to talk about the level we're on, too. Rather than just being an ordinary maze level this level also contains the Wizard of Yendor's Tower, a squarish space in the middle of the level surrounded by impenetrable walls. This is the final level of a sidequest; the game lets you see the outside of the level early to taunt you but there's meant to be no way to enter the centre of the level to actually fight the Wizard of Yendor (that purple @ in the middle of the level, nicknamed "Rodney") without doing a lot more of the game and entering the tower via a magic portal much deeper in the dungeon.

Another important feature to note of the monsters on this level is that although the fourth wraith is very near, the fifth wraith has mostly escaped, and we don't put in the turns and extra uses of xorn form to chase it now; it would just take too long for too little gain. Thus, we settle with getting enough wraith corpses to reach level 13 for now; there's plenty of time before we need to become level 14, after all. There are two other enemies around here that become relevant; the bright cyan D nearby is a silver dragon who we end up in combat with soon and the other purple @ (not in the centre), an Elvenking who chases us through the next several turns and almost ends up catching us.

286 Although it's pretty obvious that the invisible wraith moved next to us last turn the character doesn't know that, so merely stepping on its square wouldn't attack it. Instead, we use the F command to attack a square regardless if there seems to be a monster there and oneshot the invisible wraith. (The game says "it" rather than "the invisible wraith"; NetHack uses pronouns to refer to monsters you can't see to keep up the suspense about what they actually are.)
287 Manipulating the wraith to drop a corpse last turn also made it death-drop something else, a tin. There's no possible autopickup abuse we can use in order to pick up the wraith corpse but not the tin (they both fall into the category of "comestibles" or edible items, and the wraith corpse has no weight so we can't use a carry capacity abuse), so we simply take the tin as well. (Incidentally, the tin happens to contain elf meat, an excellent source of sleep resistance, but that's a resistance we don't really need at the moment.)
288-290 Now that we've collected all the wraith corpses we're going to get we continue with the reason we picked this level in particular to lure the wraiths to: sequence-breaking the Wizard of Yendor sidequest (this has nothing to do with the wraiths but saves on level teleports to get from wherever we would have been to here). Actually solving the maze would take far too long and be very boring (as even though we know the shortest path it's still quite a long one), so we do what we've been doing all TAS and turn into xorn form so as to be able to simply walk through the walls. These turns are also spent manipulating the silver dragon's AI from out of sight to go easy on us when we walk past it.
291 Yep, that's a silver dragon going easy on us. At least we survived the attack without being forced out of xorn form; this might look like one of the worse results we could have got, but it's actually one of the better ones.
293-309, skipping every fourth turn These turns are simply spent phasing through the walls of the maze to reach the right position to do the Rodney sequence-break. There are several positions from which the sequence break in question can be done; three of them are actually in the accessible area of the corridor (meaning that it isn't just an off-by-one error, but an off-by-two error!), but the nearest is actually this one which is weirdly embedded in the wall and so can only be reached in xorn form.
310-311, 313-315 We now have five wraith corpses on us, one carried from the Valley and the other four freshly killed; the first was obtained on turn 268, so we have to eat them relatively soon to avoid them spoiling. (Exactly how quickly corpses spoil is random to some extent; although we didn't need it, we actually used a trick here to make the corpses last longer, as instead of taking the age of the oldest corpse in a stack, the game takes the average age, and so the set of corpses collectively would spoil later than the first corpse would spoil alone.) This is as good a time to eat them as any, so we eat them now. As we finish eating the fifth corpse, getting us up to level 13, we polymorphitis back into a master mind flayer; strangely, we're selecting it not for its powerful melee attack, but for its very weak and almost useless ranged attack, as it's that attack that's needed to perform the sequence break in question. (If you're

wondering about how we manipulated the polymorph in xorn form, remember that Rodney's tower is surrounded by impenetrable walls which not even xorns can walk through; walking against these unphasable walls lets us wallwalk in xorn form just like a gnome walking into an ordinary wall.) Right at the end, the Elvenking comes into view; we managed to finish eating just in time to avoid getting into combat with it.

317 Time to actually do the Rodney's Tower sequence break. (Strictly speaking, we don't need to do this one as we'd have time to do this sidequest the normal way but it's still more interesting to see a quest sequence-broken past than done normally.) The way this works is by exploiting a cheating AI; even though this level is no-teleport, Rodney has a teleport-regardless-of-anything ability. Thus, although we can't teleport over to meet him, he can teleport out to meet us; the issue is trying to persuade him to do so.

The walls around here, which are basically impenetrable, prevent us using any of the usual methods to damage Rodney at range or to make enough noise to wake him, or anything like that. However, the mind flayer's mind blast attack is a weak attack which randomly targets all targets in a radius, and does not respect the usual barrier that unphaseable walls provide. Although it only does tiny amounts of damage even a tiny amount of damage is enough to wake Rodney up to make him come out and chase us for revenge.

This sequence break is a really annoying one to get right; due to the huge number of monsters near Rodney, the chance of hitting the right one is quite remote and the mind blast attack often doesn't hit anyone at all. Additionally, there's no visible indication that it's worked either; hitting Rodney with the attack just refers to him as "it" just like it would refer to all the other out-of-sight monsters. Thus, we went to quite a lot of effort writing a patch to the game that effectively memory-watches boss HPs, mostly simply so that we could determine whether this sequence-break worked on any particular RNG seed.

Therefore, it was incredibly ironic when it worked on the first try.

Although this turn gives no visual indication that Rodney actually woke up as a result, he did indeed wake up from the mind blast we did on this turn; he never acts immediately upon waking, though (he'll start to act on the next turn). Amazingly, despite the low chance of it working, this glitch is regularly done in unassisted gametime speedruns via the simple method of trying it repeatedly until it works (because there's no penalty for failure), although it can take several tens of tries before anything happens.

318 Now Rodney is awake, the next issue is to get him to actually use his ability to teleport out of his tower even though that isn't allowed on this level. Unlike most monsters, Rodney's AI is very complex with a huge number of possible actions; and rather than depending mostly on our own actions, it depends mostly on a random factor. This makes him a real pain to fight unassisted (at least, unless you exploit his weakness to instadeath weapons), but unexpectedly easy to control in a TAS. A bit of luck manipulation on this turn caused him to teleport over to us and attack immediately (rather than buffing himself or healing up, some of the other possibilities), and also summon a winged gargoyle at us (which we ignore as we're about to leave the level anyway, and it doesn't follow).

The other thing to note on this turn is the hilarious fate of the Elvenking. We knew that bear trap was there all along, but the Elvenking didn't, so we stopped it chasing us (it has quite a powerful attack) by letting it stumble into the trap. (It does get itself disentangled eventually, but we're long gone by then.)

319 We're done with dungeon level 36 for the time being so it's time to go fight the next boss (and kill Rodney along the way). This is actually a reverse-sidequest-order run; the Quest, normally the first mandatory sidequest, has to be done last of all in order to get a perfect turncount and we did Rodney, normally the last of those three quests, first. (Upon dying, Rodney harasses the player for the rest of the game, hurling spells from afar and even respawning on occasion; this is dangerous in a normal game but harmless or even beneficial in a TAS, as his effects can be manipulated away when unwanted, and manipulated to occur if they happen to be useful for whatever reason.) Our destination is dungeon level 34, which coincidentally happens to be the level of a minor boss (which is mostly annoying because it ends up being no-teleport for that reason; we never actually meet the boss on the TAS); we're here not because of

that, but because it also contains the entrance to Vlad's Tower, which unlike Rodney's is not embedded in the main dungeon, but off to one side, and thus has to be entered the normal way. Although Rodney follows us, his AI decides to spend the turn healing, so he's waiting on the stairs to level 33, a couple of squares from where we land.

This is another level with a suboptimal layout, by the way; we're very physically near to both sets of upstairs on the level, but the ones we want to go up via are on the other side of a wall. Again, we settled for this because the level generation had huge RNG jitter causing most of the levels that were generated through luck manipulation to be identical; most of the levels down here in Gehennom are like that, both due to the way the maze generator works and because they have a lot more monsters than regular dungeon levels do.

320 It takes over half a second of walking into a wall to manipulate it (ouch jitter…), but we manage to polymorph after walking just one square and Rodney teleports over to us in the process. We're using another new polymorph form, the black dragon; this is mostly similar to the red dragon but instead of the fire breath we now have a disintegration breath weapon that instakills enemies. (We didn't use this in the Valley, incidentally, because disintegrating wraiths would have been counterproductive due to not leaving a corpse behind so we settled for the second-most-powerful dragon form there.) As usual, Rodney does a couple of attacks after teleporting; first punching us (doing damage that is completely irrelevant as we immediately polymorph afterwards and reset the damage-to-unpolymorph counter), then casting "aggravate monster", one of his least threatening spells (it alerts other monsters on the level to your location, but we won't be here long).
321 "The Wizard of Yendor is disintegrated!" Easiest boss kill ever.

The design of Rodney is pretty interesting; he's relatively tough to kill in regular combat, but weak to instant-death weapons, which encourages you to use your death charges against him (and indeed, people mostly do save them for that purpose). However, he keeps respawning after death (although in a TAS, we can manipulate him to respawn no more than once, which is the absolute minimum), and so often you eventually have to settle for killing him the other way. And yet, there are monsters later in the game that are arguably better targets for instant-death attacks than Rodney is, so it's an interesting tradeoff when to use them. In this TAS, we can ignore the issue completely; black dragon breath costs just 20 Pw to use which is normally a lot (and a limiting factor on black dragon abuse in an unassisted game, as Pw can take ages to regenerate), but we certainly aren't short of Pw at the moment.

322-327 Annoyingly, although the stairs are incredibly close as the crow flies they're a very long away following the maze from where we are, so we pretty much have no other option than to use xorn form again to reach them. Doubly annoyingly, this level has a lot of RNG jitter, and it took us an entire six turns before we could manipulate polymorphitising into a xorn in a reasonable length of time, which we spent walking back and forth. In the process, we pick up the "papyrus spellbook" (the Book of the Dead), the reward for beating Rodney, and one of only a few items absolutely required to win the game. (We won't have much use for it for many turns, though.)
329-331 Now we're in xorn form again, it's just a short walk through the wall and up the stairs to Vlad's Tower. This level has a mostly fixed layout, such that there isn't anything all that useful to manipulate here; we tried several different seeds to see if there was anything worth manipulating, but it turned out there wasn't (at least not within the reasonably accessible seeds) so we just took the first one available to spare the trouble of manipulating in xorn form.
333-335 Normally, to do the first level of Vlad's you have to walk all the way over to the other side of the level and back again. In xorn form, we don't care about that, and just walk directly to the ladder up to the next level (32).

These turns also show off yet another special property of xorn form. Something is breathing fire at us from the east (we're not entirely sure whether it's the red dragon or the red naga which are both over there; we'd need to write a complicated memory watch script to find out, which isn't worth it as it doesn't matter at all), but being made mostly of rock, a little heat doesn't harm us at all. Elemental resistance tends to be absolute in NetHack; it can be gained intrinsically just like we have intrinsic controlled polymorphitis and controlled teleportitis, but as long as we can keep polymorphing, there isn't really a need.

337-339 We go up to the second level of Vlad's Tower and continue our plan of just phasing around the intended route to avoid fighting anything. (We do take some damage from a hell hound pup along the way, useful as we use combat damage to turn back into regular form once we've reached our destination.) The place we end up at the end of turn 339 (as turn 341 starts) is actually out of bounds, although it's hard to see on this run; why fight past monsters when you can just go round? (As for how we managed to get out of bounds here, it's just a trivial oversight; the NetHack developers forgot to mark the bounds of the level as unphaseable for xorns. It's not exploitable in any way other than to come back in bounds on the other side of a monster; the game simply doesn't let you move past the normal valid range of coordinates on the outer border.)
341-343, 345-347, 349 The rest of the second floor of Vlad's Tower is extremely uneventful, just more phasing through walls at a weird angle. It should be noted that moving diagonally around the edge of the level like we did there is the same distance as going in a straight line; diagonal movement is just as fast as straight movement in NetHack, meaning that there are many possible shortest routes from one square to a square some distance north, west, south, or east of it.
350-351, 353-355 Vlad's Tower is three floors high, and so we enter the third floor (31) and walk straight through the wall to the throne Vlad sits on. He wakes up and deals damage to us, unpolymorphing us just as we reach the throne, which is exactly what we wanted; we don't even take damage to our regular health bar. Vlad (a purple V) has the same teleport-anywhere ability that Rodney has, but it ends up working against him here, letting us reach the throne and leaving him forced to wait next to it.
357-358 There are many possible uses for a throne. The one we use here is the approximately 1.7% chance that sitting on a throne will grant a wish, and that the throne will remain afterwards to allow more wishes to be made on it. (Running out of wishes is not really an issue in a TAS; thrones allow unlimited numbers of wishes to be farmed with perfect luck manipulation. And they aren't even the only unlimited source of wishes.) We use this throne to wish for artifacts; the Eyes of the Overworld on turn 357, the Orb of Fate on turn 358.

Both of these artifacts aren't too happy about being wished for (they like neutral players, but not wizards), but after blasting us and doing a bit of damage, they settle down for their new lives in our inventories. The Eyes are vital to save turns later on in the game; although they have several different abilities, the one that we care about is the ability to cure all forms of blindness, important because later on we'll be using polymorph forms which have no eyes. (Being an artifact, it's powerful enough to overcome even such an apparently final obstacle to sight as eyelessness.) The Orb is less necessary, but we have two main reasons to wish for it; one is that it has a level teleport power that saves on cursed scrolls of teleport, and the other is that it halves all damage take from any source, meaning that it takes twice as much damage to unpolymorph us. It also levels the playing field against Vlad, with its damage halving cancelling out the damage doubling from the difficulty level (Vlad, being a vampire, is undead).

359-419 As is mentioned earlier, we need to do a lot of skill grinding on the detect monsters spell in order to be able to keep it up constantly, and doing so would normally be very boring, so what better time to do it than the middle of a boss fight? Hopefully, instead of becoming more and more boring as time goes on like grinding normally does, this becomes more and more ridiculous instead. Vlad is famous for being incredibly weak, almost a joke boss; he isn't actually weak on an absolute scale, but he's much weaker than you'd expect a boss to be in his place in the game (it's said that the most dangerous thing he can do to you is to read a cursed scroll of teleport, forcing you to figure out where he ran to and chase him down). Thus, here's a little demonstration to demonstrate what he's actually like: we cast 61 of the 80 casts of detect monsters required to exercise it up to the "skilled" level right now in combat with Vlad,

to see how much damage is taken. (We do use a little luck manipulation in order to avoid him level-draining us, and a little more to manipulate enemy AIs to prevent any other monsters joining the fight, but this is otherwise a completely fair fight, with our orb of fate cancelling out the midnight damage bonus.) Other things to note during the fight are the "you feel vaguely nervous" at the end of turn 373 (start of turn 374), which is Rodney trying to cast a spell from beyond the grave, but failing; the trapper (green t) spawning but not doing anything (as it's hiding waiting for us to stumble into it, and we aren't going to as we know where it is); and the orcish shaman (bright blue o) taking one look at us tanking a major boss's attacks and running away (we manipulated this, but it's still pretty funny, and exactly what you would expect an orc to do in that situation).

During our skill training, we took a little under 900 points of damage, which would be enough to kill any normal character. On the other hand, we had no armour and weren't attacking; most players would have had a lot of defense against Vlad's attacks, reducing his combat damage to effectively zero, by the time they reached this point (as well as immunity or resistance to his level-drain attack, simulated here by manipulating it to fail). Therefore, the obvious conclusion is that if you're prepared enough to survive everything else around here you're almost certainly prepared enough to trivially beat Vlad, even if he isn't that weak in an absolute sense.

420 It's not entirely clear if we're being cruel or kind to Vlad this run. On the one hand, we didn't just outright kill him like some players do, or kill him in a hideously embarrassing fashion to demonstrate how weak he is like most players do; but on the other side, we must be making him feel pretty impotent. After tanking nearly 900 points of damage, we just sit on his throne again, and miraculously are healed up to full health! (The 1.7% chance of this happening with the throne surviving is the same as the chance of getting a wish with the throne surviving, incidentally.) Getting to full health when you have as much max HP as we do is kind-of tricky, with potions of full healing only healing 400 hitpoints; doing it this way was likely simplest.
421 Of course, one issue with people typically killing Vlad in some hilariously embarrassing fashion is that most of the ways to do that have already been done unassisted, so replicating one of them in a TAS would not be particularly impressive or entertaining. Instead, as we do the 80th cast of detect monsters (we cast it 18 times before entering Vlad's, and 62 times inside), we polymorphitis into a succubus. Instead of killing the boss and getting the mandatory item he guards that way, we're going to leave Vlad alive and get the Candelabrum a different way.
422 This is us technically defeating Vlad (or, at least, getting the Candelabrum of Invocation, the reward for beating him and an item required to defeat the game). In case you aren't watching with frame advance, here's the text for this turn: "You smile at Vlad the Impaler seductively. You steal: I - a candelabrum (no candles attached). You hit Vlad the Impaler. You hit Vlad the Impaler. Vlad the Impaler hits! Vlad the Impaler bites!". Yep, we just flirted the MacGuffin off him. Given that there are no sufficiently embarrassing ways to kill him, we'll just leave him now. He survives the entire TAS, which is kind of unusual for bosses in any game (and particularly unusual for Vlad in NetHack.)
423 It's time to leave Vlad's, but first we need to take steps to ensure he doesn't chase us or leaving him alive will have been pointless. Thus, we scrawl an Elbereth on the floor in blood, a fittingly gruesome way for a demon like a succubus to write it. This scares Vlad into not wanting to follow when we level teleport away next turn.
424 Before leaving Vlad's we first go into the skills menu and specify that we do in fact want to enhance divination spells. Future castings of "detect monsters" will now, instead of just giving us a snapshot of enemy monster locations, give us a continuous effect for several turns letting us see monsters; we'll put this up whenever it would be useful to follow what's going on for your viewing entertainment.

Once that's done (which takes no in-game time) we return to level 16 via invoking the Orb of Fate's level teleport power (which also returns us to gnomish form). Unfortunately, it would take too much manipulation to land exactly on the square in level 16 where we want to be, and manipulate the Orb of Fate to have a low invoke timeout (letting it recharge sooner, enabling us to be able to use it again in the near future), at the same time; the invoke timeout is more important, so we end up at the wrong end of the shop.

425 This turn, we return to our stash on dungeon level 16 (using teleportitis) and pick up all the items there. Together with the invocation artifacts (Book of the Dead and Candelabrum of Invocation) and other artifacts (Orb of Fate and Eyes of the Overworld) we're carrying the weight is enough to make us stressed, which would double the time it takes us to do all actions (or to be more precise, halve the amount of movement energy we got per turn, which comes to much the same thing). (The Orb of Fate is so heavy that it is frequently referred to as the Orb of Weight.) In order to fix this, we polymorphitis into a titan (purple H) in the same turn; this form was chosen because it was strong and large (immediately fixing the carry capacity issue), and humanoid; being in a form with actual fingers allows us to use the magic marker to write scrolls and spellbooks. It is also faster than our regular form, being able to take one

and a half actions per turn (to be more precise, it alternates between one-action and two-action turns, based on the amount of remaining movement energy, as always); however, our temporary stressedness reduces our movement energy reservoir (equivalent to having a bad subpixel), preventing this action boost kicking in for a bit.

426 In order that we can perform very time-consuming actions in peace (without being constantly interrupted by monsters), we need to kill the mimic adjacent to us. (There is actually a second mimic on the level, but its AI is set to hide and attempt an ambush rather than to attack, and we don't do anything that might cause it to come out of hiding, so it's irrelevant.) Therefore, we simply use our basic attack spell, force bolt, to attack the mimic, manipulating it to miss in response.
427 One hit of a force bolt isn't enough to kill a small mimic at this depth in the dungeon, so we attack it again to finish it off. A moderate amount of luck manipulation was needed here to get a high damage roll; two hits would not typically be enough either.
428 (action 1/2) Now we don't have to fear interference by the mimic, we can start on the next part of our strategy: obtaining the spells we will need for the rest of the game. There are several methods of obtaining spellbooks; one of the simplest methods is to use the magic marker that we found in the shop in order to write on the blank spellbooks we have in our inventory. (These are our starting spellbooks; we washed the ink off their pages as a side effect of walking along the bottom of the Castle moat, which we set up all the way back at turn 82.) The first spellbook we write is "charm monster" (unfortunately, the magic marker parser has no amusing abuses), a spell which has a chance (that can be luck-manipulated to always work) of turning enemies permanently tame, causing them to fight on our side for the rest of the game or until angered. This is actually one of the most powerful spells in the game, especially in combination with

TAS tools, and we make use of it to avoid or trivialise combat at points later on; however, the only reason we actually need it is that the ally AI does some things the enemy AI doesn't, allowing us to manipulate monsters in ways necessary for a glitch later on.

428 (action 2/2) (Unlike earlier, where we lost turns due to slow polyforms, the fast polyform we are in allows us to perform multiple actions in a turn, sometimes. The number of actions in a turn is determined at the start of the turn, based on a number of factors, but at the moment it strictly alternates between 1-action and 2-action turns.)

On the other blank spellbook, we write the "jumping" spell. When fully trained up, this spell gives us the ability to jump up to four squares orthogonally; although useful to cross moats and similar situations, its use in a TAS is as a very fast form of horizontal movement, in situations where teleportation does not work. (The timing properties of jumps are a little unusual; they cost one action plus the remainder of the turn, and thus are only worth using on the last action of a turn, a limitation that is mostly irrelevant now but will become very important later on when we become fast enough to take four actions per turn.) Incidentally, this sort of spellbook writing is far from guaranteed to work, especially given our neutral luck, but luck manipulation allows us to guarantee that we always write the right magic words in the book on the first attempt.

429-434 (action 1/2) We read the spellbook of charm monster that we just wrote. (Somehow, writing the words then reading them again are what's necessary to actually end up learning the spell…) Reading spellbooks can take a long time, especially high-level ones, and being in a fast polymorph form does not reduce the time. We make good use of the forced delay, though, as while we read the Orb of Fate has time to recharge, meaning that it will be ready for another level teleportation when we need it.
434 (action 2/2)-437 We read the other spellbook, the spellbook of jumping, and learn that spell too. The Orb of Fate is anyway still not fully recharged, so no real time is wasted by the time-consuming action.
438 (action 1/2) We want to write and read one more spellbook while here, because it will be needed in the near future (so it can't be left until later), and because we need to wait for the Orb to recharge anyway. However, we have no more blank spellbooks, so we need to wash the ink off one in order to be able to write in it again. This is an opportunity to use the otherwise useless potions we had at the start of the game (the potion of object detection was important to own as it made the TASing process easier, but useless in terms of actually using it ingame); back around turn 82, we let the potions dilute in the Castle moat (at the same time as sneaking into the Castle, and washing the ink off scrolls and spellbooks), and we can use the water that ended up in the potion bottle to wash the ink off a spellbook by hand. Although spells in NetHack are not memorised forever, they last for twenty thousand turns, and we'll have won by then.

Thus, all our existing spellbooks are now only useful for their paper, not for their spells; and we wash the spellbook of charm monster (an arbitrary choice) clean by hand, by dipping it into one of the diluted potions.

438 (action 2/2) Time to write the last of the spellbooks that we obtain via writing. (Magic markers have limited ink; although there's still plenty left in this marker, even a relatively full marker struggles to write high-level spells, and so it's most efficient to write low-level spells with the marker and gain the high-level spells we need via other means.) This time, we write the "stone to flesh" spell, a utility spell which finds a range of interesting uses throughout the run. The main reason we're writing it is because it's a necessary part of a glitch (the gold duplication glitch) that we need to pull off soon, using its ability to turn statues into the creatures they represent; but its ability to convert ordinary rock into generic meat also comes in handy later.
439 This turn is spent moving onto the square where the shopkeeper died; although shopkeepers tend not to have too many possessions that aren't already on sale, some of his personal items will come in useful later on the run.
440 (action 1) We actually pick up the items we wanted. One minor gain is a skeleton key; the shopkeeper had one of these in order to chase shoplifters who locked doors behind them in an attempt to foil pursuit, but we can use it ourselves to open locked containers if necessary (and later on, it will become necessary; there are other methods to open locked containers, but they all have drawbacks, and as we're picking up items on this square anyway we may as well pick up the key as it doesn't add anything to the time taken). More importantly, though, we swipe the contents of the cash register, picking up 1960 gold pieces that the shopkeeper would have used to pay us for items we sold him. Although gold would seem useless to us (given our typical treatment of shopkeepers so far…), it's a necessary component of the gold duplication glitch, which as you will see has ramifications far beyond mere infinite wealth.
440 (action 2) We wait an action to allow polymorphitis to kick in, as we need to be in a different polymorph form to prepare for the next part of the run. (It couldn't be triggered last action, as it only happens on turn boundaries; thus, waiting a turn lets us polymorph at the transition to turn 441.) Our new polymorph form, the stone golem, is one that is rarely used, due to its very slow speed (skipping every second turn), but has three properties we require for the next section: a strength and carry capacity equal to that of the titan (we're still carrying an amount of junk that would burden or even stress any normal character); hands, allowing us to hold items; and most importantly, a body made of stone. We're going to be slinging around very powerful petrification weapons in the near future, which need precautions to be taken to avoid falling to the same petrification effect ourselves; and being made of stone already is a

foolproof defense against being turned to stone, meaning that we can ignore the normal balancing effects of petrify-on-touch weapons. (More normally, gloves would be used, but we'd need to waste the time to find or wish for them, and put them on, as well as needing to use a polymorph form which not only had hands, but human-shaped hands, so that the gloves would fit.)

Note that it may get a little hard to track the location of the character while we stay in stone golem form; the symbol for a stone golem is a grey apostrophe, which rather blends in with all the grey dots around. Sorry; there's not much we could do about that.

441-446 We spend these turns reading the "stone to flesh" spellbook; the Orb of Fate recharges as we read it. There's actually a "mistake" at this point in the run: I was under the impression that slow polymorph forms read spellbooks as fast as our natural form, but I was wrong, thus wasting a small amount of time. It ends up making no difference in the long run, because we have to wait for the Quest to open anyway, but looks bad. (We aren't redoing the run because of this, though.)
448 Now the Orb of Fate has recharged, we use it to visit a previously unvisited level: level 6, the Oracle level. (Coincidentally, many of the levels that are important to this run seem to have numbers ending in 6…) This is (when taking a normal route!) the first "special level" in the game, which has a fixed or semi-fixed rather than random layout; its main purpose is as a source of spoilers for unspoiled players (the Oracle can be paid money in exchange for advice), and as a marker that indicates the location of the Sokoban branch (which is always entered from the level below the Oracle level). However, we don't care about either of those things (as they just give information that we either know anyway or can discover with memory watch), and instead use this level because it has very skewed probabilities for certain things we want. (It should also be noted that the difficulty of getting exactly what we wanted combined

with busy schedules caused a multiple month delay in the making of this TAS at this point in the run.)

As usual, the entire level is generated when we visit it; although it does not become relevant for a while, we need to manipulate certain things the instant we arrive on the level, because there is no chance to change them later. In this case, we're taking advantage of the unusually high chance of spellbooks on this level; it contains eight guaranteed statues, each of which has a moderately good chance of containing a random spellbook. This particular item set took quite a while to manipulate, because one of the spellbooks (polymorph) that was manipulated here is both incredibly costly to write, and very rare; another spellbook we need, haste self, also generates on the level at the same time, saving us the trouble of writing it (although we have enough marker charges left that we could write it if we needed to). Due to their current confinement inside statues, though, neither spellbook will be visible for a while. (Just to add to the confusion, we now have floor as grey dot, the player as a grey apostrophe, and the statues as grey backquotes; you'll need good eyes to be able to follow this bit unless you watch with a lot of slowdown.)

A lot more manipuation was needed to get the rare spellbook we needed than it might seem from the luck-manipulation-caused delay before we turn up here; what actually happened is that we worked out what RNG seed we needed at this point here first, then designed some of the actions on previous turns around it, to spread the delay needed over several turns. (Thus, the long delays for luck manipulation happened on previous turns instead.) This is nicer aesthetically, but the real reason to do it was to be able to more easily "hex in" changes to mistakes we might make (although an ordinary editor is enough to change the input files we were using, so "hexing" is a bit of a misnomer here).

450 So, given that the spellbooks needed later are trapped inside statues, what should we do with them? The obvious answer might be to break the statue (which we can trivially do with our force bolt spell), but given that we're in a hugely strong polymorph form at the moment, it's simpler to just autopickup the statue (a rather large statue of a plains centaur) and take it with us, so we do that. (This is also useful because we have a use for the statue itself later in the run…) Note that the adjacent mummy does not attack us; although we are slow, so are mummies, and it simply didn't get an action in all this time.
452 In addition to teleportitis making us sometimes teleport at random, we can also now use it to teleport deliberately (a perk of being a high-level wizard, although other classes get it too at even higher levels). On this turn, we demonstrate the ability; it costs us some Pw (irrelevant given the infinite maxhp/maxpw bug), and some nutrition (relevant because we don't have infinite amounts of that, although we can use polyself to reset our nutrition levels if necessary; it'd just be awkward as we'd have to drop everything to change into our natural form to do the reset). The blue open-braces are fountains, and four are guaranteed on the Oracle level; although the statues on this level are the reason we came here at all, the fountains are the reason we came here now, rather than some other time. They're also next to the Oracle, a light blue at sign, who is completely irrelevant to the run (except that she gets in the way

of both us and monsters); we're about to do some crazy things, but the Oracle will just sit there and watch the madness unfold. She does, however, give us a nice greeting as we teleport into her room.

454 Now is the start of a tricky luck-manipulation sequence involved with the infinite gold glitch. This turn took quite a bit of manipulation in order to get the least likely (and normally, most beneficial) of all results from drinking from a fountain; our attempt to drink releases a water demon, but instead of attacking us like demons normally do, she's sufficiently grateful that she decides to grant us a wish instead. (For some reason, I always find it hilarious when incidental monsters turn out to be randomly female; most computer games don't have touches like that…) We're back using the abusable wish parser again, and we go for some eye-of-newt style grammar, wishing for a "corpse of cockatrice", and a dead cockatrice turns up in our inventory as a result.

Cockatrices are one of the most deadly creatures in NetHack, having a remarkably high number of different ways to kill someone. (I don't have an exhaustive list to hand, although such lists do exist; I think there are over thirty ways.) The general rule is that touching a cockatrice (dead or alive) with bare skin is enough to instantly cause creatures to turn to stone, something that we can exploit by picking up the dead cockatrice (or "rubber chicken" as it's nicknamed by NetHack players, given that a cockatrice is physically very like a chicken except for the bizarre petrification property), and hitting enemies with it. Our stony body protects us from the effects ourselves, so we can use the corpse, one of the most powerful weapons in the game, with abandon. The reason we get the corpse, though, is not for its combat effects, but as a component of the infinite gold glitch.

456 Wow, this turn needed a lot of luck manipulation. (There were over 500 rerecords, mostly automated, on this turn alone.) We now have almost all the components for the gold duplication glitch: the gold itself to duplicate, a method of turning monsters to stone (cockatrice corpse), a method of turning monsters back from stone (stone to flesh spell), and a method of manipulating monster AI (charm monster spell). (A lot of experimentation in a testrun concluded that the default enemy AI, rather than the ally AI, would not perform the actions we wanted no matter what happened, so some method of AI manipulation was needed.) However, one last component is needed for the glitch; a monster that's capable of carrying the gold in question, and that has something about it that requires the game to save information about the monster's previous life in its corpse or statue. (The glitch itself works by exploiting a bug in the routine

for saving the monster's stats in its remains, which is why the extra data is needed; we don't actually care about what the extra data in question is, but it needs to be there so that the buggy codepath is used.)

If we just wanted a few thousands of gold pieces, or maybe tens of thousands of gold pieces, we could use pretty much any monster with the right sort of carry capacity. However, we're performing the glitch not to get moderate amounts of useless gold, but rather to overflow the gold counter, and so we need something with truly amazing carry capacity. There is one class of monsters in the game which actually have infinite carry capacity: nymphs. (It's unclear whether this is deliberate, or a bug; it's worth noting that players in nymph form don't get infinite carry capacity, so there's at least a weird asymmetry there.) As a result, we need to obtain a nymph as the last component in the glitch, and conveniently, another of the results from drinking from a fountain is that a water nymph (blue n) is attracted.

Although water nymphs are quite likely to turn up when drinking from a fountain (a 1 in 30 chance), the nymph would typically immediately follow that up by stealing one of our items and teleporting away (the Oracle level is not a no-teleport level). Rather than waste time trying to hunt her down (nontrivial even with TAS tools due to the way the speed system works, and which would anyway look sloppy), we manipulate the nymph to miss with her theft attack on the turn she is summoned; I think that's a 1 in 20 chance, although I'm not entirely sure (it's kind-of hard to calculate enemy hit chances, but the number of rerecords is consistent with that). The "pretends to be friendly" is the standard miss message for a nymph's theft attack.

458 Now we have all the components needed for the glitch, it's time to start with the glitch itself. We start off by charming the nymph, accomplishing three objectives at once: it stops her attacking us (and therefore stops her teleporting away), marks the nymph as containing information that must be stored in her corpse (because corpses of former allies give different results when sacrificed at altars than monsters that were never charmed), and changes her AI to one that performs a wider range of actions. In particular, we care that the AI is now capable of dropping items, and the nymph obligingly demonstrates by instantly dropping her looking glass.
460 The next bit of manipulation is less unlikely than some of the results on previous turns, but was a lot more fiddly, as it could not be easily automated; although there are still bursts of walking into walls in the next section of actions, that only has a limited effect on monster AI, which is one of the major things that needed manipulating in order to do the glitch. (The Wizard of Yendor is rather easy to defeat in a TAS for the same reason he's a pain in a real game: his AI is random. Most monsters, the nymph included, have an AI that depends much more strongly on player actions than on random factors.) Thus, for tens of turns from now on, all our actions that are not directly part of the glitch are seemingly random behaviour that was designed to manipulate the monster AI into doing what we needed. On this turn, for instance, it might seem more useful to throw our gold onto an empty square, allowing the nymph to pick

it up; but it turned out to be faster overall to drop it on our own square, letting the nymph pick it up the turn after instead.

462 More actions to manipulate monster AI. This time, we stepped diagonally around the Oracle (who was presumably either curious as to what on earth we were doing, or had used her oracular powers to see it coming in advance…). The nymph responded by stepping onto the money (meaning that she's just done a full circle of the Oracle, something that I wouldn't have expected would be the easiest way to manipulate her to end up with the cash, but it turned out that it was).
464 An important turn where both our character and the nymph prepare for the glitch. Our character wields the cockatrice corpse, ready to turn things into stone; the nymph picks up the gold (one stack of 1960 gold pieces), as it needs to be in her inventory for the glitch to work. (Note that this action would probably count as "incredibly stupid" or worse if TAS tools were not involved; the transformation into a stone golem lasts a random number of turns, and might end at any time due to failed polymorphitis, and so until we get rid of the corpse again we have a chance of losing our polymorph and instantly turning to stone. This lead to quite a lot of deaths during the making of the TAS, but hey, that's what savestates are for, right?)
466 Step two of the glitch: we hit the nymph with the cockatrice corpse (using the force-fight command in order to attack an ally) and turn her to stone. I'm sure the nymph herself didn't mind (I mean, she's been magically charmed, she has to approve of everything we do, right?) but the rumble of distant thunder indicates that our god Thoth, at least, rather dislikes our mistreatment of an ally. (The punishment we get for acting like this (reduced alignment record, reduced in-game luck stat) is an unfortunate side-effect of the glitch, and becomes a nuisance later on, but there's no getting around it, as all the other methods we tried to perform the glitch failed at the AI manipulation stage.)
468 Step three of the glitch: we use our stone to flesh spell to turn the statue back into a nymph again. (Fortunately, the way the timings work for unpetrifying a nymph, rather than attracting one through fountain quaffing, is that we get the next action, rather than her, afterwards; this prevents her stealing things and teleporting away, because if you attack and kill a tamed or charmed ally they end up no longer tame when resurrected.)
470 We cast our charm monster spell again, to manipulate the nymph's AI, and she follows up with step four of the glitch: dropping the stack of 1960 gold pieces, and dropping another stack of 1960 gold pieces. We just successfully duplicated the stack of gold! (In a way, it's a pity that the glitch only works with stacks of gold, but it does; it relies on the fact that the same stack is stored both as an object in the monster's inventory, and as a number (representing gold ownership) in the monster's stats, and whilst the game would normally only use one or the other, it gets commands in the wrong order and ends up storing it both ways in the statue, with both stacks becoming real upon unpetrification.) The two dropped stacks of gold combine, leading to a stack of 3920 gold pieces on the ground.
472 So now that we have a larger stack of gold, we merely continue by repeatedly duplicating it. Due to the various things we need to do to manipulate the monster AI (this turn, we're standing still and not doing anything), the glitch unfortunately can't simply be repeated by repeating the same actions, although the general idea remains the same.
474 After the nymph picks up 3920 gold pieces, turning the nymph back to stone is, at least, pretty standard and requires no manipulation.
476 Unpetrifying the nymph, however, does. One of our problems is that the success rate on our stone to flesh spell isn't too good (our character has no training in healing magic, and will have to learn on the job), so we have to manipulate it to work. Also important is for the nymph to behave correctly in the next few turns, which requires getting the RNG in the right sort of state in advance. Finally, we aren't alone on the level; the red numbers you may have seen moving around represent monsters detected by the Orb of Fate (an effect less strong than the detect monsters spell we learnt, and which doesn't show monsters it deems too weak to be a threat at all, but active constantly), and their behaviour needs to be manipulated too. As you can see, immediately upon unpetrifying the nymph, a pair of coyotes (brown d) turn up, although they are just about out of attack range.
478 Due to our manipulation last turn, the nearer coyote is in range of the charm monster spell (which is area-effect), in addition to the nymph. Thus, casting the spell this turn not only has the usual effects on the nymph's AI, but also charms the nearer coyote, preventing it attacking us, and indirectly attacking the further one as well. This means that we can get away with offensive, defensive, and glitch-advancing uses of one spell all in the same turn, a useful method of saving actions in a polymorph form as slow as this one. (Just leaving the coyotes to attack would have been a bad idea; they could deal enough damage to cause a depolymorph quite quickly, and while wielding the cockatrice corpse, a depolymorph would mean instadeath.) While the fight happens (and unfortunately, the hostile coyote does get in a hit on us), the nymph obligingly drops two stacks of 3920 gold pieces, so we now have a stack of 7840 gold on the ground.
480 More multitasking, and more manipulation of lots of things simultaneously. We hit the hostile coyote with the cockatrice corpse (hey, if we're wielding a weapon this powerful, may as well use it, right?) and trigger random teleportitis, which we use to move just one square. Meanwhile the tame coyote moves up to box in the nymph (she was showing something of a tendency to run away rather than pick up the gold otherwise), and the nymph picks up the gold.
482-486 Continuing with repeats of the glitch; we stone, unstone, charm, and the nymph drops two stacks of 7840 gold, so the new stack is 15680 gold large.
488 It took quite a lot of experimentation to find an action that would manipulate the AI suitably this turn. In the end, it turned out that teleporting into the doorway of the Oracle's room worked, and made the nymph pick up the gold and move adjacent to us. Meanwhile, that mummy we saw when we entered the level has finally ambled far enough round the level that we can actually see it.
490 Surprisingly, we actually needed some manipulation here to prevent the coyote standing on the nymph statue (which prevents unpetrifying it having the right effect), the first time in this sequence that the petrification turn has needed to be manipulated. (The mummy wisely decides to run away…)
492-494 Unpetrify, charm, again. Luckily, walking into walls was enough to manipulate these two turns the way we needed them.
496 This turn, however, needed something really bizarre to work properly. We step away from the nymph, to get her to pick up the gold; then teleportitis triggers and we teleport to the square in the other direction instead, manipulating the nymph to not drop the gold and to be unable to run to a square where we couldn't petrify her. Autopickup was turned off in order to avoid picking up the coyote statue (we're very near our burden limit at the moment, and it would have sent us over the top, making us even slower).
498 More standard turning things to stone; meanwhile, a rothe (brown q) turns up to join in the fun. (Hopefully, the various combat going on during the glitch helps to vary things up a bit and make it less repetitive; in non-TAS runs that used this glitch, it would typically be done in a no-teleport area with no other monsters and the nymph in a confined area to prevent her running away, but that's not only a lot more boring, but makes it much harder to find crazy actions with which to manipulate her to do her thing quickly.)
500 Although avoiding depolymorph is important, we can survive a turn (indeed, around three turns, or more with luck manipulation) against a rothe, so we unpetrify the nymph as normal and just ignore the rothe, taking a hit so that we can incidentally charm it in the blast of a charm monster spell next turn. Meanwhile, a second rothe comes into view.
502 We cast charm monster, manipulating both a fight between the two rothes (I hope they weren't brothers or something, that would be tragic…) and the nymph to both drop two stacks of gold and pick up the combined stack within the same one of our turns (we're in such a slow polymorph form that she's getting more turns than we are). However, this leaves the nymph out of range of our cockatrice corpse; it doesn't actually lose any time, though, as otherwise we'd have to wait for the nymph to pick up the money, rather than to make her wait for us to get into petrification range.
504 We move into range of the nymph. The rothe fight continues, but we can no longer see what's happening because walls get in the way, so we merely hear the combat continue.
506 More standard petrification of the nymph. However, the rothe moves up towards the nymph; this was hard to avoid, and ends up benefiting us eventually, but makes life harder over the next couple of turns.
508 This is why the rothe being near is an issue; the charmed rothe, and the hostile-for-two-turns nymph, are obviously hostile to each other, and so fight as soon as the nymph is unpetrified again. We clearly don't want the nymph to die; but we also don't want her to steal anything from the rothe, as it would make her teleport away. Luckily, the rothe doesn't have any items at the moment, so her steal attacks fail, and it doesn't do enough damage to kill her either.
510 Recharming the nymph again; she now drops two stacks of 62720 gold pieces. (The great thing about doubling-up glitches like this is the exponential growth; overflowing a counter would take far too long otherwise.) Meanwhile, the hostile rothe runs up to us, ready to attack, but doesn't quite reach us before our turn.
512-516 As if there weren't enough statues around here already, we use our turn to turn the hostile rothe to stone, while the nymph picks up the gold again. Then we follow the normal routine of stone, unstone, manipulating the charmed rothe to not get in the way.
518-534 We've now cast enough stone-to-flesh spells that we get a chance to train our healing spell ability; we take it, in order to reduce the fail chance for the spell to zero. (This is mostly just to make luck manipulation easier and less frustrating, and it doesn't take any in-game time.) Then we continue as before: charm the nymph into dropping gold, manipulate her into picking it up again (this time by stepping away from her), petrify her, unpetrify her. (At this point, in a slight change to the routine, we trigger teleportitis and teleport next to her, as she would otherwise be out of range for the charm monster spell.) Then the routine continues, with us performing random-looking movements interspersed with stoning, unstoning, and charming (catching yet another hostile rothe in the area of effect to prevent it being a problem); at the end of turn 534, the nymph has picked up a stack of just over a million gold pieces,

and another monster turns up (the mummy that was following us earlier, a gray M, which turns out to be an orc mummy).

536-540 A million gold pieces might be a huge amount by both real-life standards, and compared to a typical NetHack game, but it's not enough to overflow the gold counter, so we continue with the same routine, ignoring the orc mummy for now: stone, unstone, charm, moving into position when necessary. The orc mummy gets several hits in (reducing us to less than half health) but eventually ends up getting caught in the radius of a charm effect, and drops some money itself (a pitiful 19 gold pieces, compared to the millions that the nymph dropped).
542-572 The next cycle of the glitch requires unusual actions again; this time, we swap places with the orc mummy, which is apparently what was needed to manipulate the nymph into picking up the gold. Then stone, choose not to change polymorph form when polymorphitis randomly triggers (this extends the duration of our polymorph, so that we can get the glitch finished without randomly instadying), unstone (which happens to catch the statue of a coyote in the same beam, but it gets finished off by the charmed monsters almost instantly), charm, move into position, stone, unstone (and one of the rothes decides, rather cutely, that maybe it should fetch that 19 gold for me), charm (and watch a fourth rothe turn up and start fighting the charmed rothes), teleport past the Oracle (oh, the weird actions needed to manipulate monster AIs), stone, unstone, charm, charm again (to manipulate AI), stone, unstone, charm. After a while, there's only so much that can be said about the glitch…
574 This turn was a bit of a break from the norm just because the manipulation was unusually difficult; we got the nymph to pick up the gold using nothing but walking into walls, but it took a surprisingly large number of manipulations. The nymph now has 32112640 gold pieces.
576-598 More standard gold duplication: stone, unstone, charm, teleportitis to manipulate AI, wait one turn for the nymph to pick gold up again, step towards the nymph, stone, unstone, charm, wait for the nymph to pick up gold, stone, unstone, charm…
600 This turn was another one that require a lot of manipulation; it seemed that doing it before stoning the nymph helped get a good random behaviour sequence when she was unstoned again. More interestingly, though, this was turn 600, significant because some things in the game happen on 600-turn timers, either every 600 turns, or first on turn 600 and then randomly after that. In this case, two things happened: we regained a point of luck (not visible to the character, but luck penalties time out at the rate of 1 point per 600 turns, changing on multiples of 600), and we gained a point of Wisdom (which is visible and produced a message), due to the "exercise timer". The way this works is that the game tracks which of your actions are likely to increase and decrease your stats, and every so often changes your stats according to whether you've been exercising or abusing them. In our case, we just got a Wisdom boost; this

has very minor positive effects, but is mostly irrelevant (and in fact, our abilities are pretty much irrelevant overall, which is why we didn't manipulate the exercise timer).

602-610 More continuing with the same old glitch: stone, unstone, charm, wait a turn for AI manipulation, stone again. At this point, the game does a check to see what the Wizard of Yendor will do from beyond the grave (this cannot be manipulated away, and its timing is set when we kill the Wizard). However, we can manipulate what the event is, and we manipulate it to a neutral result (in fact, the only neutral result, with all the others generally being bad except for a TAS): "You feel vaguely nervous.", which simply causes the Wizard of Yendor to do nothing this time, and just set the timing for his next reappearance.
612-628 With Rodney safely out of the way, we can continue the glitch. Unstone, charm (and the nymph drops over a billion gold pieces, but even that isn't enough for us!), wait one turn to manipulate AI, stone again, polymorphitis into a stone golem again to refresh the polymorph timeout, unstone, charm (nymph drops over 2 billion gold pieces), wait a turn for AI manipulation, stone nymph, unstone nymph.
630 Finally, we've reached the end of our huge, long, repetitive, AI manipulating glitch session. At this point, for the pattern to continue, the nymph should drop just over 4 billion gold pieces if we charm her. However, gold is stored in a 32-bit signed integer, which just goes up to a little over 2 billion (but higher than our just over 2 billion value used for the gold); so as soon as the nymph drops the gold, we get an overflow. Instead of charming the nymph, we just kill her with our force bolt spell, which has the same effect of making her drop her gold. The two stacks of over 2 billion gold drop on the ground, and combine to form a stack of -184549376 gold pieces. (We also trigger teleportitis on the same turn to move over to the negative gold more quickly.)
632 After we've gone to all that trouble to produce negative gold, we pick it up, in order to enjoy its strange properties. The major useful property for a TAS (or indeed, an unassisted run) is the weight of the gold; a negative quantity of gold has negative weight. The result is that once the gold is in our wallet, the negative weight of the wallet cancels out the weight of anything else we might want to carry, effectively leading to infinite carry capacity (there's a separate limit of 52 items in open inventory, but if we needed to circumvent that we could do so using containers). From now on, we don't need to worry about the strength or carry capacity of the polymorph forms we change into; we can just use the amazing properties of antigold to sweep the problem under the carpet, meaning that we have a much wider range of forms to choose from in the future (many polymorph forms are unusable in normal play due to their tiny carry capacities).

Of course, this sort of glitch often comes with bizarre side-effects. The most obvious one in the case of this glitch in particular is that the stack of antigold cannot be split; we have to move the entire stack at at time, and cannot adjust its size in any way (except by picking up regular gold to cancel out the antigold). Luckily, this isn't much of a problem. The antigold also reacts strangely to a variety of other commands, generally in negative ways; but we don't care about that, as we can just leave it in inventory. Finally, it prevents us doing anything that might require us to own a positive amount of gold, but that isn't much of an issue anyway, as most such actions aren't useful to the run (there's one that would be, absolving alignment, but it can't be done before turn 5000, and if we spent that long we wouldn't even beat the unassisted record).

634 (Around this time we changed the platform we were using for virtualization from VirtualBox to KVM which significantly improved the restore time between luck manipulation attempts (moving to a faster computer shortly after the switch didn't hurt either). This proved to be especially helpful in the next two sections which required a significant amount of luck manipulation in order to trigger things like teleporting, polymorphing, and attack damage levels.)

Now that we can carry anything we like we immediately abuse it by picking up every remaining statue on the level. We trigger a teleport to land in the upper-right corner, immediately picking up a statue of a mountain centaur.

636(1/1)-637(2/2) Between turns at the end of turn 635 (start of turn 636), we manipulate a polymorph to trigger. Our stone golem form has served us well but it's time to switch to something a bit faster so we become a queen bee (purple a). This form isn't used frequently due to its incredibly poor carry capacity (generally insufficient to carry even a single item, as might be expected of a bee), but with the power of antigold, carrying several full-size statues is no problem. Polymorphing into a queen bee causes us to drop our weapon because we no longer have any hands, making us let go of the cockatrice corpse we've been (ab)using just before it has a chance to turn us to stone.

NetHack's speed system is slightly confused by polymorphs; polymorphitis triggering doesn't actually affect the actions per turn count until the turn after. Thus, we get one action on turn 636, as would be correct for a stone golem (because we got no actions on turn 635). Now that we're a queen bee, though, we get two actions on every turn from turn 637 onwards. (We abbreviate the actions-inside-turn count from now on, because many of the turns will have multiple actions and it would be wordy to write it out every time.) It's not far to the next statue so we fly down and to the left and pick up a statue of a plains centaur.

638(1/2)-638(2/2) We fly down a couple of spaces to trigger teleportitis and hop to the upper-left corner of the room to grab a statue of a forest centaur.
639(1/2)-639(2/2) A large amount of luck manipulation gets us a teleportitis teleport on the edge of the turn (as always, teleportitis only happens at the end of a turn), so we had to wait to skip the first action of turn 639. This nets us a statue of a mountain centaur.
640(1/2)-642(1/2) Rather than forcing a teleport through Ctrl+T (which uses nutrition) or manipulating a teleport through wallwalking (which proved to require an unusually large number of wallwalks), we instead simply fly to the next statue, which is a plains centaur.
642(2/2)-643(2/2) Teleportitis gets us to another plains centaur to the right of the room the oracle is in. Again, it proves hard to manipulate on this level (which is rather prone to RNG jitter), and thus the end of turn 643 had to be used rather than 642 in order to avoid a massive luck manipulation delay, with the movements in between serving to advance the RNG the right distance.
644(1/2)-644(2/2) After some manipulation, we wait another two actions to trigger teleportitis; it triggers at the end of turn 644, and we finally pick up the last statue, a forest centaur.
645(1/2) It's now time to fix our alignment, which at this point is somewhere near -325 (an astronomically, unrealistically bad alignment) as well as our luck (-7; the lower cap is -10, but there's a +3 bonus to our luck provided by the Orb of Fate that's unaffected by caps). This is a side effect of the infinite carry capacity glitch; turning a charmed monster (such as the nymph) to stone carries a 15-point alignment penalty, as well as a 1-point luck penalty. There are a number of ways to fix bad alignment but most of them are incredibly time-consuming (and more than likely boring). One way to raise alignment is to kill monsters; each kill gives us a few points of positive alignment (typically around 5 per kill) to help us dig our way out of the hole we're in. No RPG would be complete without a bit of grinding, but with that said, this is a TAS of an RPG, so if there's going to be grinding we might as well make it a one-sided slaughter-fest.

There aren't nearly enough monsters on the Oracle level for our purposes, so the next matter of business is levelporting somewhere else. We would ordinarily use the Orb to levelport, but this is not currently possible due to our horrible alignment (with negative alignment, none of our current artifacts will obey us). We have two cursed scrolls of teleport left so we read one now and choose to levelport to level 25, which may look familiar. We're back at the Castle, but this time, because we arrived from above, we're at the front entrance in a little maze on the left.

645(2/2) One of the rothes we charmed happened to follow us from the oracle level, but we'll essentially ignore it completely, as we've had a habit of doing with charmed monsters lately. We displace it (swapping places with it) to get closer to a minotaur that happens to be wandering around in the left maze area.
646(1/2) A minotaur is a very powerful monster but we go slightly out of our way to prove a point – don't mess with a queen bee that has the ability to dispense deadly poison. Bees in NetHack have three attacks: regular sting, poisoned sting, and deadly poisoned sting, and which one is used is random. With a little bit of manipulation, our first attack stings the minotaur, the sting turns out to be poisoned, and in fact our poison turns out to be deadly, killing any non-poison-resistant enemy (such as the minotaur) outright. This is a very unlikely result, making it another reason why queen bee form is bad for regular play, but the ability to manipulate it makes it very powerful in a TAS.

It's worth noting that deadly poison is more famous for working against the player, rather than in favour, being a common cause of early near-unavoidable deaths if the Random Number Generator is feeling particularly cruel that day. The attack we saw here (which is used by some other things too, such as spiked pits) is a major reason why poison resistance is considered one of the most vital resistances in NetHack. (In a TAS, though, it isn't needed, as anything that would poison us can simply be manipulated away.)

646(2/2)-650(2/2) Unlike the Oracle level, the Castle is a no-teleport level, so we have to walk (or in our case, fly) wherever we go. We deftly buzz past our rothe and head toward the entrance to the Castle.
651(1/2) We meet an Aleax and immediately run into a conundrum – an Aleax has various resistances, and specifically, has resistance to poison. This negates our ability to perform a oneshot kill (or even damage it significantly), so instead we completely ignore it by flying over the castle moat (which we can do in bee form). We manipulate the Aleax to change weapons rather than attack, and we also manipulate a giant eel that was hidden under the water in the moat to miss us twice (for the first attack we cannot see it, so we just get "It misses.", for the second attack it has surfaced so we get "The giant eel brushes against your rear limb."). Note that we could not have afforded a hit from the eel, as they have a two-turn instadeath attack that would have been hard to escape except via immediate level teleport or polyself.
651(1/2)-653(1/2) After leaving the Aleax and the eel behind (we easily outspeed them both), we approach the Castle's drawbridge. Typically, speedrunners would use a musical instrument to play a game of Mastermind against the drawbridge (which consumes no in-game time), eventually causing it to open, but we have no musical instrument, and anyway no usable hands to play it with (musical instruments are typically not designed to be played by bees). Instead, we just hit it with a force bolt (ever a useful spell against inanimate objects), causing the drawbridge to fall into the moat.
653(2/2) As we fly toward the drawbridge and into the courtyard, a mysterious force prevents us from teleporting (the usual message obtained upon attempts to teleport on a no-teleport level); this was an un-manipulated triggering of teleportitis, but it has no effect here, so we can simply ignore it.
654(1/2)-655(1/2) Just inside the castle's courtyard, we meet our first of many soldiers. We happen to be next to a wall so manipulating an instant kill is trivial. NetHack queen bees can apparently kill more than once just as well as their real-life counterparts.
655(2/2)-658(2/2) We make a beeline across the courtyard (pun intended) and enter a narrow corridor that leads to the throne room.
659(1/2)-661(2/2) As we enter the corridor a number of thrown projectiles miss us (thanks to luck manipulation), all thrown by enemies we cannot see. A number of monsters are referred to as "it" as we fly through this section and are shown on the screen as red numbers such as 1 and 2 (a consequence of the Orb of Fate's "warning" feature, which locates nearby monsters and assigns numbers to them according to how dangerous they are). The full magnitude of how many monsters are nearby should be more apparent now, but we'll worry about the monsters on the other side of the wall later. For now, we barrel down the corridor directly into a soldier who we quickly take out.
662(1/2)-663(2/2) A common theme on this level is that we completely ignore corpses and anything a monster may have been holding before turning green and immediately keeling over; there are a huge number of items dropped on this level, but they are typically standard soldier equipment, which is not useful to a run heavily based around polyself, and which would clog up our 52 inventory slots if we picked it up (although of course the weight is irrelevant). We fly over the corpse we just created and run smack-dab into a gnome mummy. As with the Aleax the gnome mummy is resistant to poison attacks (being undead), but being in a corridor, we can't just fly around it like we did before; instead, our options are to repeatedly sting the gnome mummy with our normal attack (which would take a very long time), or to ignore the problem by yet again employing charm monster (which is possibly the most broken spell in the game, although some we use

later arguably compete). Walking to the right displaces our new pet gnome mummy, and we proceed down the corridor to meet our next fate.

664(1/2)-665(2/2) After oneshotting a couple of soldiers (and manipulating a miss by another) we approach a xorn that's embedded in the wall (remember the xorn we came across hundreds of turns earlier, back when we were a xorn as well?). The xorn may be able to phase through walls, but our deadly poison quickly creates a xorn corpse in the wall. (It would be possible to free it from the wall if it were useful for anything, but there's no reason to bother.)
666(1/2)-666(2/2) After taking out another soldier we meet yet another poison-resistant monster, in the form of a dwarf mummy. Instead of taming it like we did with the gnome mummy, we instead wait one action to allow turn 666 to end, manipulating a polymorph at the turn boundary. We turn into a jabberwock (orange J), as the next few enemies on the level are all poison resistant. Being a Jabberwock isn't as fast as a queen bee (it's the same speed as our natural, gnomish form), but it's great at destroying monsters regardless of poison resistance, with probably the most powerful standard melee attack in the game (it hits four times per action, for huge damage each time).
667(1/2)-667(2/2) We take out the dwarf mummy in one action's worth of attacks, then move onto the next monster. Note that we got two actions this turn despite being in a one-action-per-turn form, again exploiting the turn's delay between a polymorph and its effects on the speed system.
668 The (guaranteed) liches in the Castle are generally some of the most dangerous monsters there (knowing a variety of spells, sometimes including annoying spells like item cursing or armour destruction, and possibly even instadeaths if the player was at a high enough level when the level was generated). However, the huge attack power of a jabberwock makes it look as trivial as many of the other enemies around here.
669-670 After the lich, the next monster, the human zombie, is rather easier in general, but we still manipulate monsters to miss us (or in one case, hit each other by mistake and miss us that way).
671 We start hitting a literate lieutenant, triggering a polymorph back into a queen bee at the turn boundary so we have more actions per turn to work with. Meanwhile, the lieutenant reads a scroll labeled THARR, which happens to be a scroll of create monster (and a glass piercer appears behind the lieutenant as a result); this is not a problem for us at all, because the created monster just gives us even more things to kill on our killing spree.
672(1/1)-673(2/2) We're easily able to finish off the lieutenant, and the glass piercer he summons; it apparently also has an adverse reaction when stung with poison. Meanwhile, the game tells us that the monsters have become "aware of your presence"; this is actually a result of an offscreen demilich casting the "aggravate" spell (which locates enemies, even outside LOS, and causes them to broadcast their location to surrounding monsters). The result is beneficial to us, as it causes monsters to tend to come to us rather than us having to chase them. (Again, notice the wonky actions-in-turn count caused by the polymorph.)
674(1/2)-675(2/2) As we enter the opulent throne room, we meet a disenchanter; it took an unusually high amount of manipulation, but the disenchanter was eventually poisoned, followed by a hapless soldier trapped in the action. At this point it is possible to see a large number of monsters on either side of the throne room but we'll leave the ones by the throne itself alone for now. We take some damage from a human zombie (we ignore it, as we cannot oneshot it and it would waste time to change form to eliminate it that way, and making it miss proved far too time-consuming to manipulate in addition to the oneshots), so instead we turn our focus on a hapless rust monster. These guaranteed equipment-damaging monsters are very annoying to most NetHack players, but we avoid any problems with them not merely by killing them quickly, but by not having any equipment in the first place.
676(1/2) We're currently blocked by a purple "4"; this is a demilich, by far the most powerful monster on the level, as it has a dangerous repertoire of spells (including the invisibility spell that prevents us seeing what it is). It's impossible to walk diagonally out of a door in NetHack; however, we have the "jump" spell memorised from earlier, so we simply jump diagonally through the doorway to the space the rust monster had been in (the range is somewhat limited at the moment due to our lack of practice in escape spells). We still can't see the demilich, but it uses its weak melee attack to cover us in frost causing some minor damage, and also casts a spell, making "monsters appear from nowhere!", giving us even more enemies to kill for alignment. It must be a rough crowd.

Note that the "jump" spell ends the turn when used; thus, we lose our second action in turn 676 and go straight to turn 677. This was deliberate as jumping later in the turn resulted in less favorable monster movement that kept blocking the square we were jumping to.

677(1/2)-677(2/2) It's our turn to do some damage, so we take out the rock troll that had just been summoned; but we're immediately clobbered by everything from the demilich's frost attack, to a gnome mummy. This puts us near to unpolymorph range; we want to change forms anyway, given all the poison-immune undead nearby, but not unpolymorphing means we get to carry the two actions per turn over to turn 678. To waste an action to manipulate a polymorph, we sting the gnome mummy, doing irrelevant damage but manipulating the random numbers the right way (on a very jittery level like the Castle, different actions can have a wildly different impact on the number of wallwalks required to manipulate something), and polymorph into a jabberwock at the turn boundary.
678(1/2)-682 Whilst being pummeled from all sides we take out an earth elemental, a gnome mummy, an "it" we can't see (the demilich, which is spamming both a regular melee attack and its frost attack), a human zombie, and a guardian naga hatchling. The amount of damage we take through this is basically impossible to manipulate away given the cramped circumstances and huge number of monsters around us, so instead we manipulate a new polymorph to happen just as the old one wears off through excessive damage. (We take a small amount of damage in our gnomish form as this happens, taking us from our max of 8,799 HP to 8,788, an obviously irrelevant injury.) At the end of turn 682, we turn back into a much faster queen bee, now that the nearby poison- resistant enemies are gone.
683(1/1)-684(1/2) We use our deadly sting to finish off a soldier, and a baluchitherium, while still taking damage from nearby enemies.
684(2/2)-685(2/2) At this point there are still a fair number of enemies that can't be seen by the viewer, as well as several unidentified enemies; although taking out monsters "blind" can be impressive, the next portion, clearing out the barracks, is probably easier to watch with all the monsters revealed. Thus, we cast our "detect monsters" spell to show just how much is still left on the level, and to allow the viewers to watch the next section with full information as to what is happening. (It was a good time to cast the spell for luck manipulation purposes as well.) The spell also turns up two adjacent invisible stalkers, and we quickly ensure that they can stalk us no more. Meanwhile, the other xorn on this level demonstrates that it's not just players who can eat rings. Whatever it was planning to do with it probably isn't nearly as insane as what we've been doing…
686(1/2)-686(2/2) The xorn who just ate a ring, despite being out in the open instead of being embedded in the wall, is just as vulnerable to our deadly poison as the first one. (It seems we never will get to find out what it was planning with that ring after all. We can only hope it wasn't speedrunning…) There's an ettin nearby which meets a similar fate, leaving this part of the throne room mostly empty, save for an air elemental that we intentionally leave alone, as it will come in useful later.
687(1/2)-688(1/2) We employ our force bolt spell to blast open the door to a narrow room that serves as a barracks and is chock full of soldiers, lieutenants, and various other officers. We're in queen bee form with 12 health as we step into the threshold of the room and enter the military barracks which triggers melee and ranged attacks from every soldier that thinks they can hit us with something. We manipulate them all to miss us, although several attacks hit the soldiers themselves in the confusion (and to add to the fun, one of the soliders has a wand of sleep, which would probably mean near-certain unpolymorph for us if it hit as we have no sleep resistance).
688(2/2)-701(1/2) There are 12 soldiers, 1 lieutenant, 4 sergeants, and one captain in the upper barracks. To say that what happens here is a slaughter is an understatement. Knives and daggers are thrown, sleep rays ricochet around the barracks, short swords are thrust, and military personnel of all caliber are mown down by a crazed queen bee on a mission of alignment improvement; throughout the fight, we manipulate every single attack against us to miss. Some highlights are using a force bolt at turn 690(1/2) and 694(1/2) to manipulate soldier positions and damage multiple soldiers at once, a bubbly potion thrown on the enemy turn at the end of 694(1/2) which we don't bother to name (because we know what every item in the game is anyway via memory watch; it's an uncursed potion of paralysis), and the fact that we essentially just keep going left in a straight line without slowing down.
701(2/2) We're now standing knee-deep (rather deeper, in fact, given how short a bee's legs are) in a pile of 18 corpses (strewn about the barracks) still with 12 health and a lot of blood on our stinger; but there's another barracks to clear out. Our alignment is at -135, much better than it was, but still a long way off from +0 where we need it to be.
702(1/2)-706(1/2) The trip to the lower barracks is relatively uneventful, although at turn 704(1/2) we ignore a poison resistant guardian naga hatchling, and at turn 705(1/2) we fly one step away from the wall to avoid being attacked by the air elemental which we want to keep alive for now.
706(2/2) As with the other barracks door we use a force bolt to get it out of the way. Unlike the other barracks, we throw caution to the wind and allow ourselves to be surrounded by soldiers, just to mix things up a bit; instead of going for a flawless clearance like we did with the first barracks, we instead show just how easily we can survive even hopeless-looking situations like being completely boxed in by monsters.
707(1/2) Also as with the last barracks entrance there is a lot of action as soon as we step into the doorway. We take some damage at various points while going through the second barracks, including here.
707(2/2)-709(1/2) We exact our revenge for our recent wound by flying into the corner and commencing a familiar slaughter.
709(2/2) We want to be truly surrounded so we opt to jump to the empty space down and two spaces to our left. This jump might seem implausible, especially for a bee; given that we're doing it via spellcasting, "it's magic" seems like a plausible enough explanation, except that nonmagical jumping sources would allow the same effect.
710(1/2)-723(2/2) Now that we're in the thick of things we return to our modus operandi, which is to say we poison everything in sight. Interesting moments in this segment include unpolymorphing at turn 711(1/2) and re-polymorphing into a bee at the end of turn 711 (this causes us to lose one action on turn 712 as a result of polymorph time system delay, although this was an acceptable trade-off as it allowed for better monster manipulation), re-casting detect monsters at turn 719(1/2), and the lack of the soldiers doing anything interesting (which is to say, anything that the soldiers did that impeded us has been manipulated away). After clearing out the second barracks, our alignment is now at -30.
724(1/2)-728(2/2) We now follow the lower wall and avoid a couple of boulders that are thrown at us before reaching and defeating the thrower, a stone giant, followed by a rock troll who happens to be holding a cream pie for reasons known only to him. (This item is key to one of the most powerful glitches in NetHack, an arbitrary memory corruption glitch, which is not used in this run because it can trivialize basically the entire game, making nearly all this strategy redundant. We may make a glitched run that abuses it at some point, but it's hard to work out the best way to use it.)
729(1/2)-734(2/2) Our next target is a troll, then a diagonal jaunt up and to the right-most wall where we off an ogre, then another diagonal flight up and to the left to poison another ogre. We step next to a wall to manipulate a deadly poison attack against a rock troll and last but not least we sting an ogre lord on turn 734(2/2). (It should be noted that in all cases where we've wandered away from the wall the luck manipulation happened a couple of turns ahead of time while we were still within range of a wall; luck manipulation is theoretically possible when not adjacent to a wall, but it looks a lot uglier and is much more timeconsuming in realtime, making it not worthwhile if at all avoidable.)
735(1/2)-735(2/2) Dispatching the ogre lord was the last kill we needed, setting our alignment exactly back to 0. This means that we now regain the ability to use the Orb of Fate to levelport, although our luck is still -7 (-10 with a +3 bump from the orb). The easiest way to reset our luck is to make a sacrifice to our god, so we turn on autopickup and step onto a square with a stone giant corpse, picking up a scroll of light and a scroll of create monster in the process, followed by walking back next to a wall to allow for easier luck manipulation.
736(1/2) We invoke the Orb of Fate which returns us to gnomish form and allows us to levelport back to our base at level 16. We manipulated a low Orb of Fate cooldown timeout of 17 here.
736(2/2) Now that we're back at a level with an altar, we're faced with a bit of a dilemma – normally, sacrificing at an altar only regains 1 point of luck, and we're down many more than that. We solve the conundrum by praying, manipulating "You feel that Thoth is displeased" after all of 13 wallwalks (we were struck by lightning, punished, and otherwise abused with all of the other results we tried); as a result, Thoth ends up angry with us (an independent axis from alignment and luck). The amusing side effect of this is that when we mollify him next turn, we regain all our luck back at once rather than just one point; it seems unlikely that this was intended as a strategy, but it is likely too risky to use in a non-TAS game anyway.

Prayer takes some time to take effect. Normally you're protected from monsters during this time, but with a non-responsive god (in this case due to negative luck), we're helpless and vulnerable. It doesn't matter in this case because there are no hostile monsters near anyway.

739-740 We use Ctrl+T to teleport to the altar and offer the stone giant, which is enough to mollify our god and reset our luck to 0 with an additional +3 bonus from the orb. After a massive slaughter we have finally reversed the effects acquired while gaining the infinite carry capacity glitch and we're ready to move on.
741-743 We drop all the statues we picked up almost 100 turns ago, then break them all with force bolt (which continues to be useful for its ability to break pretty much any inanimate object that can be broken), and pick up the 433 rocks the statues broke into, as well as the spellbooks that were in the statue. We're doing this now because the spellbooks will come in useful soon; the large amount of manipulation on this turn was so that the statues would produce a particularly large number of rocks. (We'll need a very large number of rocks much later on; 433 is not nearly enough, but it's a start.)
744 We put on the Eyes of the Overworld for the first time. These have the following effects: resistance to several magical effects even when merely carried (this is in general a negative for us, because many of these effects would be useful); ability to see three spaces through walls when worn (neutral because we can see things via memory watch, but helps for entertainment because it makes it easier to see what's going on); immunity to all forms of blindness when worn (essential to saving time later on, when we use blind polymorph forms but nonetheless need to see, and the reason we wished for them in the first place); immunity to being stunned due to the gaze of Archons when worn (incredibly tangential, but amusingly, actually becomes relevant at one point). Additionally, they can be invoked to view your own stats, but that would be a huge waste of time when we can see them via savestating, entering debug mode, checking them, and loadstating again.

However, we didn't put them on now for any of these reasons. Instead, we exploit the fact that they happen to be (very heavily and specifically enchanted) lenses, which means that we can use them to read spellbooks faster. We could have used ordinary lenses for this, but we had the Eyes handy, so they're more convenient.

Note that we can only use the Eyes at all because we've just fixed our alignment; they require 2 out of 3 of being a monk, being neutral, having nonnegative alignment to use. Because we don't satisfy all 3 conditions (we aren't a monk), they do some damage to us when we put them on.

745 Having improved our spell-learning ability with the Eyes, we follow up by obtaining an item with which to improve our spell-casting ability; we wish for a "blessed robe of a master assassin". This is another parser abuse; there's no such item as a "robe of a master assassin", but the game can parse "<item> of <monster name>", as in "tin of blue jelly", and as such accepts the wish. (The Master Assassin is a boss who would be fought by certain other characters, but does not appear if you play as a wizard.)
746 We wear the (actually perfectly ordinary) robe we just wished for. Robes reduce spell failure rates when worn; this is used later on, not only to make luck manipulation easier, but also because it brings the failure rate for some spells below 100% (thus making it possible rather than impossible to cast them).
747-753 We learn the "haste self" spell. We won't use it for a while, but we wanted the Orb of Fate timeout to have time to run down, and that spell takes just the right length of time to learn to let us use the Orb again.
754 After a huge amount of manipulation, we use the Orb of Fate to levelport to level 3. We haven't been here before, so this generates a new level. The Orb's timeout ends up at a mediocre 66, but we were manipulating something rather more important on this turn: this level contains a particularly large potion shop. The main reason we need potions is to, much later on, escape Gehennom and the Dungeons as quickly as possible after picking up the Amulet of Yendor; a cursed potion of gain level, in a terrible pun, gains you a dungeon level on the way up (rather than a character level), and works (75% of the time due to holding the Amulet) regardless of the properties of the level. Because there's no faster way to travel, we need a source of gain level potions; and because there are various ways to transmute potions into other potions, we need a large supply of potions generally to transform into them.

Because so much manipulation was required just to generate the level we wanted, we cannot manipulate a couple of other things we'd like; we don't end up inside the shop itself (in fact it isn't visible from our arrival point), and we don't trigger teleportitis to teleport there.

755 "Hello, wizard! Welcome to Sablja's liquor emporium!" We control-T teleport into the shop. As a 6 by 8 shop, it has 6 times 7 or 42 squares which sell items, and all but 2 of them are potions (the other two are mimics, one pretending successfully to be a potion, the other one whose disguise isn't nearly as good).
756 We read the scroll of create monster we picked up back in the Castle (a stone giant was planning to use it against us, but never got the chance, and we picked it up while picking up the corpse). Here's where we get to use it; some manipulation causes the scroll to create a hostile gelatinous cube (cyan 'b'). Gelatinous cubes are quite strange among monsters; not only do living cubes paralyze on touch (whether you touching them, or them touching you), but they also absorb items that they walk over. While organic materials get digested, gelatinous cubes cannot digest glass, so any potions it passes over will end up stuck in its body. Our strategy, therefore, is to speed up the raiding of the shop via allowing the cube to gather potions at the same time we are, halving the time it will take.
757 We teleport manually to the northeast corner of the shop (away from the cube). This not only starts to pick up the potions, but also helps manipulate the cube's movements. We couldn't trigger teleportitis last turn because it would be hard to manipulate at the same time as manipulating the created monster; and doing it manually lets us cause polymorphitis at the turn boundary. We also end up feeling hungry because of the nutrition spent in the manual teleport…
758-765 …but we don't stay hungry for long! We specify our natural form, "gnome", leading to another stat randomization, and get two benefits from it. One benfit is a gain in level (giving us intrinsic warning – which is redundant to the Orb of Fate's warning ability – and also increasing our max HP to over ten thousand, a truly staggering health total). The other is that it resets our nutrition level to midway, fixing our hunger and allowing us to do more manual teleports in the turns ahead.

The turn itself is spent starting to read our spellbook of polymorph. We're reasonably safe inside the shop, with Sablja guarding the entrance (because we owe him money). While we read, the gelatinous cube moves towards us, engulfing 4 potions; our character automatically stops reading when it gets near enough.

766 We manually teleport to the next corner of the shop, going round anti-clockwise; the gelatinous cube moves diagonally and engulfs another potion. We also pick up the potion in the corner while we're at it. (Because the gelatinous cube has a very strong tendency to move towards us and will move diagonally if necessary to keep moving towards us, there's no way to manipulate it to pick up the items in the far corners of the shop short of digging, so it's easiest to simply pick up those corner potions ourselves.)
767-790 We continue to read the spellbook of polymorph; it takes a long time to memorize, but we're making good use of the turns by getting the gelatinous cube to multitask for us. While we're busy reading, we spontaneously teleport around – twice – and eventually end with another polyself to natural form when the cube catches up with us. This stretch of book-reading went better than could be hoped, really; it required very little manipulation (none on turn 767 itself) to get a result as good as this, although it isn't quite perfect (the cube misses a couple of potions we'd want it to get).
791 We start picking up some potions by hand alongside the cube. Although it might look like the cube could attack us from there (which would paralyze us and make us lose a lot of time), it's rather slower than we are even in our natural form, so we can run round it due to gaining a turn over it just now.
792-800 We pick up potions alongside the cube (which moves one space for every two we get). This is mostly just a case of finding a pattern that both moves us over as many potions as possible, and misses ones that the cube can pick up behind us. (The white potion four spaces north of the closing square bracket, which is a badly-hidden mimic, is also a mimic.) For some added amusement, look at Sablja's compliments to us as we pick up the potions, ranging from "esteemed" up to "most renowned and sacred"; he presumably thinks he's going to get a lot of money from us. He's going to be rather disappointed…
801 Having no adjacent potions, we teleport up to one of the few remaining potions, encouraging the cube to go visit them as well.
802-803 We've almost finished learning to polymorph things; just a few pages left in the spellbook to read, and a couple of turns left to read them. At the end of turn 803, before the cube even reaches a potion, we finish memorizing the spell.
804-805 Only three potions left to pick up now, too (the white one is a mimic). We pick up two of them as the cube picks up one, again using our superior speed to run round it.
806 We drop all the potions we picked up; for ease of transport, we want to give them all to the cube. We use Escape to skip the many boring messages about potions getting dropped, so the message about the cube touching us (and failing to do anything further, like paralyzing us; the paralysis attack was luck-manipulated to have no effect) is skipped.
807 We walk next to the wall. This is both so that the cube can step onto and engulf the potions we just dropped, and because we're about to manipulate an unlikely event on the next turn.
808 Time to start off with the polymorph spell we just learned. The spell is a very high level – level 6 – meaning that even as an experienced level 17 wizard, we're going to have immense trouble casting it, due to having no skill with matter spells. This is why we're wearing the robe, which brings its failure rate from 100% down to 91%. Later on we need to be casting it without access to the robe, so while we're waiting for the cube to pick up the potions (which also happens on this turn), we cast the spell at a wall, just for the practice. (The spell has no effect, because walls cannot be polymorphed.)
809 More polymorph casting. Again, this is for the practice, but this time it's also for another purpose too; we cast the spell at the cube, and it changes from being a gelatinous cube with a huge number of potions engulfed in its body, to an elf mummy with a huge number of potions in its backpack. The reasoning behind this is that gelatinous cubes are acidic, and as such immune to being turned to stone, and we want to petrify it in the next few turns.
810 More polymorph practice. This time, just for variety, we cast it at the ceiling rather than a wall. Naturally, this has no interesting effect apart from the spell practice.
811 And one more cast, this time at ourself. The fourth cast of a level 6 spell is enough practice to be able to bring our matter skill up to basic, although we don't do that immediately because there's no need to. We choose to turn into a cockatrice; earlier on we used a cockatrice corpse to turn monsters into stone, this time we're going to do it directly. The elf mummy, being particularly mindless, decides to attack us anyway, and turns into stone as soon as it touches us. Meanwhile, our robe falls onto the floor, because as a cockatrice we're too small for it to fit.
813 [Cockatrices are sufficiently slow that we had to skip turn 812.]

We still need the robe, so (after rather more luck manipulation than is usually necessary – we were particularly unlucky on this turn) we pick it back up off the floor. (Cockatrices also have a very low carry capacity, but the antigold is sorting out that problem for us.) With a manipulated spontaneous polymorph, we turn into a wood nymph, a polymorph form useful because it has a theft attack, just like a succubus or incubus. (All three types of nymph are essentially identical for this purpose, so we picked the one with the shortest name to make the realtime marginally faster.)

As a note about the making of this run, we didn't continue past this point for many months, because we'd reached the end of our route plan up to that point. Instead, we spent our time exhaustively testing a wide range of endgame possibilities; we greatly improved our emulation platform in that time as well. As such, the run only continued when we'd finally decided what we wanted to do and what sort of setup would be needed in order to speed up the ascension run post-turn-2000. We also were willing to do things that were much more unlikely and hard to manipulate past this point, because we had the technology in place to manipluate it for us.

815 [We were still in cockatrice form on turn 814, so had to skip that one too.]

On this turn, we simply pick up the statue full of potions. We don't need the potions now, and they'd take up most of our 52 inventory slots if we left them all in separate slots, so carrying them around inside the statue is the most sensible option. (Containers are often used in NetHack to save on inventory slots in this fashion. However, it's very rare to use a statue for this purpose; they're heavy, and you cannot put items in them once they've been created, nor remove them without smashing or reanimating the statue.) At the start of the next turn, a manipulated teleport takes us to the shop entrance.

816 We close the door of the shop. Amazingly, this requires some luck manipulation to do; our character isn't particularly strong, nymphs aren't particularly large, and the door is bulky and prone to sticking. The reason we do this is that open doors aren't targetable by most spells (locking-based spells being the exception); the game assumes that casting a spell at an open doorway is intended to cast the spell through the doorway, rather than to hit the door. While this might be intended by most players in most cases, we genuinely want to hit the door, and so have to waste a turn closing it so that we can target it.
817 Were you were trying to guess what we were targeting the door with? It's our old favourite inanimate-object-destroying-spell, force bolt! Destroying the shop door is a little random-seeming and apparently illogical, but it has to do with how the game handles peaceful monsters (like Sablja). The game gives alignment penalties for attacking peaceful monsters; in most cases, this doesn't matter, but we happen to be on 0 alignment exactly, and the Orb of Fate won't work from negative alignment. In order to pull off a glitch much, much later in the game (over a thousand turns from now), we need an angry shopkeeper on dungeon level 1 (specifically, we need the combination of monster flags "follow across levels" and "speed > 24", and this is the easiest way we discovered to achieve that); we want to use Sablja for this, but peaceful shopkeepers won't follow through vertical teleports, so we need Sablja angry at us first.

Teleporting out of the shop would work eventually, but Sablja would give us some time to pay first (at least if we were still nearby); and so, the most time-efficient way to anger him without losing alignment is to destroy part of his shop, in this case the door.

Sablja's reaction is the intended "How dare you destroy my door!" (normally shopkeepers give you a chance to pay for the door, but we can't afford to do that by several hundred million zorkmids), followed up by attacking us with his wand of striking. (It ends up harmlessly bouncing off us, due to the Eyes of the Overworld in our inventory granting us protection from purely magical attacks.)

818 Now that Sablja is angry, we can attack him without alignment penalties (even though he was peaceful once). A nymph's attack is a theft attack that triggers twice per action. The item we need to steal is Sablja's wand of striking; but stealing from monsters always steals the item that was most recently added to their inventory first. Sablja hasn't picked up any items since he was generated, so the items we steal depend on the details of the monster generation algorithm; in this case, the first item we steal will always be his scroll of create monster, and the wand of striking the second. As such, we manipulate such that we will steal both the scroll and the wand in the same turn. (The scroll is far from useless, as it happens; even though we're forced to pick it up, we'll make good use of it later on.) A couple of seductive smiles (both of which are somewhat unlikely to work, incidentally), and Sablja hands over his

magical items. Then he comes to his senses again, and hits us four times, draining our nymph-form hitpoints and making us return to gnomish form. Angry shopkeepers do not mess around.

819 After quickly stopping to put skill points into matter (we'll be polymorphing things again soon), we drop the wand of striking we just stole; again, this is to make it a targetable object (items in inventory cannot be targeted by most spells, but items on the floor can). Sablja hits us twice in response. (If you're wondering about how Sablja's action timing works: he alternates between acting once per turn and twice per turn, and can hit us twice per action.)
820 We never got a chance to put our robe back on; however, with our newly skilled-up matter school, we can still just about cast polymorph (it's currently at 90% fail). We need a large number of manipulations both to make polymorph cast successfully, and to control what the wand polymorphs into; our intrinsic polymorph control lets us choose our own polymorph form, but doesn't let us control the polymorphs of other things.
821 We pick the polymorphed wand back up again. It's now a zinc wand; our character doesn't know what the wand is, but TAS tools (specifically, memory watch) give us that information (we manipulated it to be a wand of speed monster, which we're going to need shortly).
822 With the largest amount of manipulation we've needed so far in the run (around a second in realtime), we drag Sablja up to dungeon level 1 with us. (The Orb of Fate's timeout has just ended; it was 66 when we arrived on the level all the way back on turn 758, and we've spent 68 turns on the level.) Because there are a bunch of items we haven't paid for (a huge stack of potions, and a door), this summons the Keystone Kops, just like it did on dungeon level 2, but just like we did there, they're left behind on dungeon level 3, too far away to be relevant (monsters in NetHack cannot leave a level except at two times: the same time that the player leaves it, or on their own turn; and monsters don't get turns when there isn't a player on the level).

The manipulation itself was required to land next to a wall at the same time as keeping the Orb of Fate's timeout low; we'll be needing it again soon, and the manipulation gave us a particularly low timeout of 19. (Lower values become ever harder to manipulate; the distribution of timeouts is utterly bizarre and as such hard to describe, but it's particularly biased against unusually low values.)

823-824 At this point, we have to take some care with the random numbers we line up, because a timeout expires at the turn boundary between 824 and 825. The Wizard of Yendor's harrassment is going to continue for the rest of the game, given that we've disturbed him.

We manipulate the Wizard into cursing the Book of the Dead (the result we were hoping for; its blessed/cursed status affects what it does when read); at the same time, he also curses the Candelabrum of Invocation (something we could not reasonably manipulate away, but which will have no effect until much later, by which time we'll easily be able to fix curse-related issues), and sets the timeout to a reasonable value of 226 turns.

We're not entirely taking a break from our manipulation of Sablja, either. Our turns are spent practicing polymorph (randomizing our own stats in a mostly inconsequential way; we gain two points of Charisma, one of Dexterity, and lose one of Strength), and wearing the robe, both actions which improve our polymorphing ability.

825 Our time spent on dungeon level 1 is going to be heavily about manipulating movement energy values (basically much the same thing as manipulating subpixels in a platformer). Sablja has speed 18; as each action costs 12 movement energy, this is why he alternates between 1 and 2 actions per turn (and likewise, his movement energy reservoir at the start of the turn is alternating between 18 and 24).

Sablja's movement energy reservoir started at 18 at the start of this turn. We spend a heavily manipulated turn polymorphing him into a raven, one of the faster monsters in the game (ravens have a natural speed of 20); we need Sablja's speed to exceed 24 (for reasons that will be explained soon), and a high natural speed is needed because there are limits to how much we can artificially boost speed. The raven took the least manipulation out of the suitable polyforms.

Sablja spends 12 points with his action (bringing him down to 6), then gains 20 at the turn boundary, and is now at 26 movement points.

826 We start to read our cursed Book of the Dead. Reading the Book takes two actions, but we get knocked out of it after just one by Sablja's attack. In the process, we manipulate teleportitis to trigger, and move to a convenient distance from Sablja (who will catch up to us over the next few turns).

When making this turn, I seem to have been under the impression that spending one action reading the Book now would save one action later. It doesn't work out like that, though, so this was probably just a mistake, if a minor one (the time lost now will make no difference, as we have to wait for the Quest to open anyway).

Sablja is now at 22 movement points.

827 We use our wand of wishing to wish for a blessed figurine of an archon. Amusingly, we're on dungeon level 1, and this is a relatively common wish to make on dungeon level 1; an archon is typically considered the best monster in the game to use as an ally, and a blessed figurine has an 80% chance of turning into an allied monster when activated. Thus, this is considered standard strategy in pacifist play, which relies almost entirely on allied monsters to kill enemy monsters. We're not going to use it for its normal intended purpose, though.

Sablja is now at 30 movement points.

Turns 828-829 We read the Book of the Dead, completing the read this time. Because the Book is cursed, it summons undead; in this case, three zombies. We need it to summon monsters who will follow us between levels; the zombies' purpose will be to take up space on the Plane of Earth much later in the game.

Sablja is now at 22 movement points.

Turn 830 We use our blessed archon figurine. However, instead of hitting the 80% chance of an allied archon, we manipulate the 10% chance of a hostile archon. We're now surrounded by five monsters: three zombies, the hostile archon, and Sablja the raven (who has only just caught up to our new location, completing the set). The idea will be that, much later in the game, we'll drag all five of these monsters to the Plane of Earth with us (each of which will follow us between level changes; most are of species who naturally follow, ravens don't follow but shopkeepers do regardless of species, which is why we needed to polymorh Sablja rather than using a natural raven). Monsters only follow if they're adjacent, so we need them to surround a particular point on the map so that they can all be adjacent to us at once.

Sablja is now at 30 movement points, and the archon at 16 movement points.

Turns 831-832 Although our plan is to get monsters to follow us to the Plane of Earth much later in the game, five is actually too many. Thus, we need to kill or transform one of the monsters surrounding us. Sablja the raven, and the Archon, both have important roles of their own to play, so we need to leave them alone; the obvious monster to eliminate is one of the zombies.

Although we could kill a zombie, we need to waste 2 turns to get all the movement energies to line up. So we spend the time practicing polymorph on a zombie. Two turns' worth of polymorphing changes it into a red mold, a monster that will not follow and will have no influence on the rest of the run.

Sablja is now at 22 movement points, and the archon at 24 movement points.

Turns 833-834 We now get to put our zinc wand of speed monster to use. We spend two actions, zapping first the archon, and then Sablja. This increases the archon's speed from 16 to 22, and Sablja's from 20 to 27.

(In case you're wondering why we don't just zap ourself and get a ton of free actions, this is a tradeoff we made in order to keep the run entertaining; because we have to wait for the Quest to unlock anyway, we decided to not worry about action economy until near the end of the run when it was necessary. It makes more sense to use up most of our time preparing for the Quest unlock, then go straight to the Quest, than it does to finish all our preparation early and then have to waste a bunch of time all at once.)

Sablja is now at 33 movement points, and the archon at 32 movement points.

Turn 835 This is a pretty critical turn, at which our dungeon level 1 setup comes together. We spend it casting detect monsters; this is for the benefit of viewers, to allow them to see what is happening. At the turn boundary, we manipulate a teleport, and teleport to the far end of the level (any square not adjacent to a monster would do; I chose this one).

At this point, all our movement point manipulation has finally paid dividends. Sablja acted twice last turn (33-12*2 = 9 points left), and gained 27 at turn boundary; Sablja thus has 9+27 = 36 movement points. In other words, Sablja is about to get a three-action turn (something that's very rare in NetHack in general, and almost unheard of among monsters that follow from level to level). This is important because it means that Sablja will still have two actions left after following us to the Plane of Earth.

Meanwhile, the archon acted twice last turn (32-12*2 = 8 points left), and so at speed 22, now has 30 movement points left, meaning it's about to get a two-action turn. This means the archon will get to act once after following us to the Plane of Earth. One possible action for a hostile archon is to summon monsters; the four following monsters, plus the archon summons, will eventually give us exactly the number of monsters on Earth we need, with no cost of our own time (all the monster creation happens on monster turns).

Turn 836 Of course, we're not spending turn 836 on the Plane of Earth, so all this movement point manipulation might seem pointless. However, it's time to introduce a speed technique known as "monster charging". Newly created monsters (including monsters on newly created levels) normally have 0 movement points, so they won't act until the turn after you arrive on a level. However, if you leave a level, the current number of movement points for each monster will be saved, and those movement points will start to be spent the instant you arrive on it. Thus, if we leave the level right now, and never come back to it until the action before entering the Plane of Earth, the monsters will get to spend most of their actions there (one will be spent here on level 1 immediately after we arrive, but that's unavoidable).

We can think of these monsters as being "overcharged", because they're going to get many more actions than normal; a shopkeeper normally alternates betwen one and two actions per turn, three is far too many. Charging up the monsters, as seen over the preceding turns, requires both increasing their speed, and manipulating how many movement points they have on which turn (a concept that I think of as "movement phase", after the meaning of the word "phase" in signal processing). I'd love it if charged-up monsters were surrounded by little lightning bolt animations, but alas, NetHack's graphics is not up to the job.

Needing to leave the level right now, we have few choices for what we can do with the turn. Digging through the floor is a traditional method, but both dungeon levels 2 and 3 are in something of a mess due to our utter disregard for the normal use of shops. We can't teleport out with the Orb of Fate because it's still on cooldown (and will be for another 6 turns). Therefore, we leave using our last remaining cursed scroll of teleportation, and aim for the previously ungenerated level 7, spending a huge amount of manipulation to generate a particularly helpful level. (Why 7? Because the dungeon graph – which levels connect to which levels – is determined right at the start of the game, meaning that level 7 is predetermined to contain the branch to Sokoban.)

837-838 Over the next few turns, we're going to perform a tricky series of teleports. One of the squares we need to be standing on currently contains a door, which isn't normally a valid teleport destination. One possibility would be to teleport next to the door, open it, then move to that square (perhaps via turn boundary teleportitis), but that would be reasonably mundane and is much the same thing as we've been doing all through the run so far.

There's another option open to us, however: we can polymorph into something small enough to fit underneath a door, while dropping all our items (because otherwise the equipment wouldn't fit underneath the door). For the sake of variety, this is what we do. We need to unequip and drop all our equipment; we remove the Eyes of the Overworld manually, and the robe via turn boundary polymorph into a yellow light (which is amorphous and thus can squeeze under a door), then drop everything but the antigold and use the turn boundary to teleport onto a shop door (although it's impossible to see this on the map right now because yellow lights have no eyes; it'll be visible in future turns). The shopkeeper, Llanwrst, greets us.

839 We spend two keystrokes throwing away random numbers by walking into walls; note that as the walls were previously unseen, they become visible as a result of walking into them (and so I manipulated on two different walls to make this more obvious). For people who are surprised that walking into walls has side effects, this might help explain why such a major TAS trick as wallwalking ended up being possible (the action can't be cancelled altogether, it has to be aborted instead).

We attempt to open inventory, to show off a message that many players may not have seen ("Not carrying anything except gold"), and also to clarify what the situation is right now. (Yellow lights have zero carrying capacity; the only reason we can carry the gold is because it has negative weight.)

We drop the stack of negative gold underneath the door, and use turn boundary polymorphitis to show off an amusing programming oversight; we can change into arbitrary monster forms while still underneath the door, and nothing bad happens to either us or the door. We need to pick a form with hands and a nonzero carry capacity (the reason we changed form in the same place; note that right now, we have no hands and no carry capacity because we dropped our negative-weight item), so I chose the largest one available, "storm giant", to make fitting under the door more amusing.

840 Now it's time to go shopping. We're only moving two squares to the first item we want to buy, so it's possible to jump rather than teleporting. The first item we're buying is a wand of wishing we manipulated to generate on this level.
841 The next item we'll buy is a wand of teleportation. (Actually, we're going to use it even before it's been purchased – something shopkeepers are OK with so long as you eventually pay – but we're planning to use it outside the shop too.) It's adjacent, so we can just walk to it. (With as many movement options as we have available, it's quite rare for walking to be the best one; we last did it back on turn 807. Walking and running make up the bulk of most "normal" NetHack play, though. Note that running isn't normally any faster than walking (it simply saves on keystrokes by repeatedly walking until something happens), so it's even less useful in a TAS than walking is.)

Our character is unfamiliar with wands of teleportation (they haven't been relevant at any point of the run so far), so it shows up with its unidentified appearance, which this game is "jeweled wand". As usual, while making this TAS, we could use TAS tools to determine what items had what appearances. Memory watch would have worked, but there's an easier way; by this point, we'd implemented a tool, "Santa mode", that lets us force NetHack games into debug mode without needing to quit and resart them, so we could savestate, use Santa mode and the in-game debug commands to determine the appearance of a wand of teleportation, then loadstate again to revert the game back to exactly the state it was in before we entered debug mode. Thus, we get the ability to see what effect a debug command would have on the game if it were legal, without actually being able to use debug commands to affect the game, and the run itself never enters debug mode at any point (which would invalidate the whole point of the TAS).

842 And this turn shows off the power of luck manipulation in a TAS in a clearly visible way. On turn 836 (when this level was generated), we manipulated not just one wand of wishing in the shop, but two. The odds of this are pretty low: a wand shop can't be any larger than 20 squares, and each item in such a shop has about a 1 in 222 chance of being a wand of wishing, so the odds of this happening even given that such a shop generates are approximately (19*20/2) in (222*222), or around 0.4% (this formula is approximate, but should be accurate enough given how much larger 222 is than 1). The shop itself has a 3/7 chance of generating (given a suitable room), and has a 3% chance of being a wand shop, giving total odds of two wands of wishing on a level of 0.005% (actually rather worse, because there might not be a suitable room, and it might be smaller than 20 squares). Technically, the wands could generate outside a shop,

but that's even more unlikely. In other words, don't expect this to happen in your own games.

We walk to the wand of wishing, and manipulate a teleport at turn boundary, moving just a few squares (to the other end of the shop). It should be clear by now that our character has absolutely no trouble defeating or otherwise dealing with a shopkeeper if they want to. Instead, though, we're going to show off a more peaceful way to go shopping.

843 Time to show off some simple, if absurd, economics. Any items that are moved inside a shop, apart from the player dropping them there intentionally, are considered to belong to the shopkeeper (the shopkeeper will pay you for them if he can tell that you are responsible for them being added to the shop's stock, and they're something that that shopkeeper wants). We use the unpaid wand of teleport to teleport our stack of negative gold from underneath the door into the shop as a whole, meaning that the shopkeeper now owns it. (You can't influence where teleported items end up in NetHack normally; we used luck manipulation for the purpose.)
844 First, we change our options; specifically, we need to place more items on autopickup. We place gold on autopickup so that we can pick up the negative gold without losing time; also armor and gems, because we'll be needing those later on in the run and it's convenient to do it now while the option menu's open.

Then, we manually teleport onto the negative stack of gold. Shopkeepers normally charge you for gold you pick up in their shops, but if you have enough store credit, they'll just reduce your store credit instead (this is an exploit fix to prevent people repeatedly dropping and picking up the same stack of gold to overflow their debt, leaving themself with a large amount of credit, because dropping gold adds to your credit). Our credit of 0 zorkmids is sufficiently large to cover our purchase of -1073741824 zorkmids. We pick up a pair of old gloves while we're here (they happened to be on the same square, and we need autopickup for armour turned on because we're picking up our robe on the same turn), and trigger teleportitis at the turn boundary, teleporting to the items we dropped when we entered.

Teleporting out of a shop with unpaid items normally gets you in trouble, but your store credit can cover for them (in fact, the normal way to shop with teleportitis is to drop gold first and pick up the item second). So, as we leave, the shopkeeper cancels our credit to cover the debt (a little extreme considering the difference in magnitude), and we pick up all our old items, with the shopkeeper being entirely happy with the situation.

This sort of thing is why economists normally refuse to consider negative numbers.

845 We had to remove the Eyes of the Overworld for the raid on the shop, but there's no reason not to wear them right now (and their ability to see through walls is one that we like to keep up when possible because it makes the run easier to follow), so we put them back on immediately, and then teleportitis to our next destination, the stairs to Sokoban. Our character doesn't know where they are, but thanks to memory watch, we do.
846 We walk up the stairs into Sokoban. A small amount of manipulation is used to ensure a good layout.

The "Sokoban" branch is a NetHack-physics recreation of the famous crate-pushing puzzle game. The rules here are slightly different from elsewhere in NetHack: many diagonal moves involving boulders are prohibited, traps can't be escaped, and a wide range of actions (actions considered to be "cheating at Sokoban") will reduce your in-game Luck score (much the same way as the difficulty adjustment for playing on Friday 13 does). As in Sokoban, the goal is to push the boulders onto particular squares so that you can go to the next level.

Most importantly, though, teleportation doesn't work in Sokoban (you just remain in place), and the walls are particularly solid and can't be bypassed by any of the usual means. Additionally, jumping is one of the actions that causes a Luck score penalty. Therefore, most of our movement options are disabled, making walking less of a bad idea than normal.

847-848 The first two moves of the puzzle solution: we walk towards the nearest boulder.
849 And this is the first hint that we aren't planning to solve the puzzle the normal way. We bring out everyone's favourite inanimate object destroyer, the force bolt spell, and outright destroy one of the boulders.

You aren't supposed to do that, and so we incur a Luck penalty (without even a message; many players consider this to be unfair for unspoiled players).

850 [TODO: Explain what boulders look like on the map. I don't know whether they're 0 or ` with the settings we have.]

So if we aren't solving the puzzle, why are we here? This is the first hint for what we're planning to do instead. Sokoban is full of boulders, and we need plenty of rocks later in the run. So the idea is to raid Sokoban as a ready source of rock. Last turn, we manipulated the boulder to shatter into an unusually large number of usable rocks. This turn we walk over to them and pick them up.

851-852 Same idea as before. Smash a boulder, manipulate a bunch of rocks from it, then pick up the rocks.
853 We move further along the puzzle by jumping. There's a penalty for doing so, but as this is a TAS, we don't care. (It wouldn't have been particularly useful earlier in the level; we'd have got stuck on corners.) We've now incurred 3 points of luck penalties.
854 [TODO: Perhaps we could merge this use of the options menu with the previous one.]

And now for a technique that blew the mind of at least one NetHack player when I explained it to them. We open the options menu, and change the "packorder" option. This rarely used option is typically considered entirely cosmetic; it changes the order in which items are sorted in inventory. (We also turn the "confirm" option on at the same time, because we'll be needing it on soon and it'll save going into the options menu repeatedly; it won't have any effect right now.)

So why is it useful to change it in a TAS? There are two reasons. The immediately important one, though, is to help with luck manipulation. We'll be polymorphing items very soon, and the game generates random numbers for each item to determine what it changes into. With a normal understanding of statistics, it doesn't matter what order the game checks the items in during polymorph, because the situation is symmetrical; it's just as likely for your dice to roll an X then a Y as they are to roll a Y then an X. With a TAS, though, we can check to see which result happens with less manipulation, and then change the sequence in which items are stored in memory (using the packorder option) so that the right random numbers hit the right items. (The other reason won't become clear until later.)

With the items rearranged in memory, we can drop the items we're planning to polymorph: two rocks and an unlabelled (i.e. blank) scroll.

855-856 And now, we polymorph the items, and pick up the resulting items. The odds of this turn working out were very low: we're trying to polymorph two item stacks at once, each into a particular new item stack (rocks to valuable gems, and blank scroll to scroll of identify). Polymorphing a useless item into a useful one has reduced odds of working, and because we aren't wearing our robe right now, the polymorph spell only has 10% odds of working at all.

On top of all that, we only have limited room for manipulation. We've been watching the sequence of random numbers coming up for a while, and reasonably soon in the RNG sequence is a very rare sequence of numbers that we have a particular purpose in mind for. We need to be mostly done with the raid on Sokoban by then (for reasons that will become clear later), so we only have a limited supply of random numbers left. (In fact, we only just had enough RNG headroom to get this to work; if we'd needed even two more seeds for this manipulation, we'd have had to rearrange the next several turns to get all the random numbers affecting the right turns. I'd pretty much given up getting this strategy to work, but the second-last attempt was a nice surprise.)

857 We use our newly-polymorphed scroll of identify (it's unidentified itself, being given only a randomly generated level, but as usual that doesn't stop us), using it to identify our newly-polymorphed gems (and discovering them to be jacinths). Although while making the run, we knew what the gems were through memory watch, our character didn't know what they were. Giving up a known-valuable gem is considered to be more of a sacrifice by the game than giving up an unidentified gem is (by a factor of 2.5, for the purpose with which we use the gems, meaning we only need two gems and not 5).
858 This turn shows another way in which our Sokoban strategy deviates from normal play. We still have the wand of teleport that we used to teleport the antigold into the shop, so we can teleport around other items. In this case, we teleport the boulder to our south (although there's no immediate visual effect; this seems to be a graphical glitch in the game, because it goes away if I insert a "redraw" command). We can't see the square it ended up from where we're standing, but it's in the row of four pits (blue ^) near the bottom of the screen.
859 Just because the main reason we're here is to pick up rocks, that doesn't mean that we can't do other things too. This is a convenient time to pick up a pearl ring that generated on the ground (which was manipulated to generate along with the level), via jumping to its square. The ring is a ring of conflict, a magical effect that we'll need much later.
860-861 A couple more jumps later (bringing our total luck penalty to 6), we arrive next to the row of pits. The Eyes of the Overworld can see through boulders the same way they see through walls, so we can now see that that boulder we teleported has filled one of the four pits at the bottom of the map.
862 We push another boulder into a pit. (This particular boulder and pit generate right next to each other, presumably as a tutorial to let players know how Sokoban works mechanically.)
863-864 We teleport another boulder, this time the one to our north, and land it in the corridor to our west. Unlike the first one, it doesn't land in a pit; however, because it's right next to a pit, we can just push it in as we walk along the corridor. Then we move along to the next square.
865 This is another point at which we temporarily pause what we're doing to do something else. This time, we're using the scroll of create monster (that we stole from Sablja so that his wand of striking would become a valid steal). We manipulate it to produce a gray unicorn, which will be important later in the run for multiple reasons.
866 And here's the first reason. Throwing gems to unicorns adjusts your luck; if the unicorn shares your alignment (here, we have a neutral unicorn and a neutral character), the adjustment is always a boost. If your character knows the gem's identity for certain, this gives the largest possible boost (+5, cancelling out most of the luck penalties we've incurred so far).

Unicorns are programmed to try to avoid lining up with you and to teleport away if you throw a gem at them. The "no teleporting" restriction in Sokoban affects monsters as well as the player, though, so the unicorn can't do much to escape other than running (it moves twice as fast as we do). Interestingly, restrictions against teleporting don't affect items, and don't affect cases where a player teleports a monster (if we zapped the wand of teleport at the unicorn, it'd teleport despite the restrictions).

867 We teleport another boulder into a pit. This time, it's the boulder to our north-east, and the more distant remaining pit of what was originally the group of four.
868 We push the boulder that we teleported here earlier into the last remaining pit. Now we can reach the bottom-left corner of the Sokoban level.
869 We jump over to that corner. It's now possible to see that there are two scrolls here. These are scrolls of earth, which generate boulders when used. The intended use is to fix mistakes made solving Sokoban, but the main reason we want them is to generate boulders which can be broken into rocks. (We won't be using them for this purpose immediately; we won't need the rocks we're collecting until much later, and breaking boulders is better done outside Sokoban due to luck penalties.)
870-876 We spend three moves and four jumps backtracking out of Sokoban; we now have most of what we came for. We're back up to 6 points of Luck penalties for "cheating" here. (Strangely, although we've been cheating like mad with our wand of teleport, the penalties given have mostly been for fast movement, which doesn't even help solve the puzzle.)
877 We push a boulder northwards, thus blocking the unicorn against a wall. We didn't even have to manipulate the unicorn to move it back towards the entrance of the level (things just work out really well sometimes). In its current location, the unicorn can't escape our line of fire; there are no squares within two spaces of its position that aren't adjacent to us. It thus decides to stay put instead (and will do as long as we don't move and it's still trying to escape from us); this is actually the result of an AI bug that I discovered in February 2015, which causes the square to our northeast to act as if it's more favoured for the unicorn than the square to our southeast due to incorrect handling of ties between squares in the monster AI code.
878 We throw the other jacinth stone to the unicorn, thus cancelling out another 5 points of Luck penalty (putting us back to -1; because we were at +0 before entering Sokoban, and -1 is where your Luck starts on Friday 13, we're now back to the same Luck status as at the start of the game).
879 It's now time to show off another luck manipulation technique. So far, when we wanted to discard random numbers, we've nearly always been walking into walls; in situations where there were no available wall, we've been doing things in a different order so that different random numbers hit different actions (e.g. when we were practicing the detect monster spell while in xorn form). Right now, though, we're just a few seeds before a sequence of random numbers that give us a very low-probability event, and we don't have an adjacent wall (and we can't use the boulder like a wall because giants are large enough to step over boulders).

The solution is to repeatedly declare attacks on the gray unicorn, then cancel them. We turned on the "confirm" option, meaning that we'll be given a chance to cancel an attack on a peaceful monster; and declaring the attack uses up an RNG seed the same way that walking into a wall does. Thus, we need only declare and cancel attacks on the unicorn 11 times (the number of seeds we needed to waste), and the RNG is in exactly the right place for us, taking no further in-game time. (Wallwalking manipulation is better than attack-cancel manipulation because it's much faster in realtime and usually has no visible effect; but when you don't have a wall, you don't have a wall.)

We'd been keeping an eye on this RNG location for literally months, at this point, planning things so that we'd have a spare turn (we do) and a sufficiently high Luck score (-1 is enough) when the RNG sequence in question came up. When planning for very highly unlikely events, you can't manipulate them just by walking into walls; it'd take several minutes of nothing apparently happening, which tends to bore viewers and makes for a bad run. Instead, the only real option is to work out when in the RNG sequence the event will happen, and plan your route around it.

As for what the unlikely event is? Well, we have plenty of wands of wishing at this point, so we zap one of them. Our wish is for an empty chest (I decided to name it Bob, in honour of an infamous missile tank from Metroid Fusion). The wish parser recognises "empty" only for tins, not for chests, and so despite the apparent wording of the wish, the chest comes with contents. In particular, among its contents is another wand of wishing. In other words, we've managed to violate the fundamental law of wish conservation in fiction, by successfully wishing for more wishes. (And this would completely break the game, were it not for the fact that we've already completely broken the game). The odds of this happening are not at all good (the wand of wishing has to be generated completely at random, which is a 0.03% chance for each item in the chest), and they're not helped by the fact that generating contents for a chest has notable amounts of RNG jitter (meaning that generating a wand of wishing in a chest takes longer to manipulate than its probability would suggest).

There's no need to actually open up the chest to look at the wand right now (we have plenty of wands of wishing in main inventory). Part of the reason I named the chest is to make it easier to recognise it as the same chest when we finally use it.

880 Although the unicorn has served an important purpose for us by boosting our Luck score (the previous turn wouldn't have worked with a much lower Luck score, because low Luck causes wands of wishing to fail), that doesn't mean its job is done yet. We'll be using the unicorn later on in the run, too. In order to navigate it out of Sokoban, we'll need it to follow us down the stairs, and because unicorns don't naturally use stairs, we charm it so that it follows us. It refunds our jacinths in the process; we'll be able to use them later on to boost Luck again (although the unicorn would need to be untamed first).

Also of note is the wood golem (brown apostrophe) in the middle top area of the level (near the greater-than sign that represents the stairs down). It moves to the west, apparently inexplicably (given the monster AI, it should be seeking us out by following our tracks, and it was adjacent to a square we've been on recently enough that the tracks are still fresh). The reason for its behaviour is due to an incorrect optimization in the monster tracking code, whose main effect is to make monsters move in an apparently unpredictable way (it's technically predictable and deterministic, but sufficiently complex that predicting it is a pain) that's manipulated based on the precise details of your own movements. It's a good thing that the golem's moving westbound; otherwise, it would get in our way.

881-882 We move around a little to manipulate the unicorn's movement. The pet AI is different from the hostile monster AI; in particular, it has a rather larger random factor, so luck-manipulating it is rather easier. We take the opportunity to pick up the jacinths while we're here. The unicorn picks up a cream pie (this is irrelevant to the run, but mildly amusing, so once it had happened I saw no reason to manipulate it out).
883-884 Despite all the excitement with chests and wishes and unicorns, it's important not to lose sight of the reason we came here. We smash another boulder and loot the resulting rocks (as usual, the boulder's luck-manipulated to produce an unusually large number of usable rocks).
885-888 This is just leaving Sokoban via the most direct available path (including one jump). The unicorn has no trouble keeping up, although it needs a minor amount of manipulation to persuade it to actually do so.

Rerecording Environment

The primary goal of this project is to provide a rerecording environment suitable for use with any application or game that can save its own state inside of a virtual machine. The environment was specifically designed with NetHack in mind but may be suitable for other projects. This is very much a purpose-built environment so any reuse should be done with that in mind. The document that follows generally describes how things were designed for the initial NetHack project but should provide enough background for other uses as well.

The entire communication chain from inside to outside the VM and finally on to the target DOS platform is very complicated but functional; the overall picture looks something like this (with our actual implementation listed in parentheses):

Guest VM (KVM JeOS Ubuntu 10.04 based guest) running target application (NetHack)

Recording method (tee copying input to a file inside the VM)

Host-to-guest interface (screen to /dev/pts VM serial interface)

Host virtual machine CLI interface (qemu control channel)

VM control script environment (Python pexpect)

Detachable environment (tmux)

Guest VM: Various virtual machine environments provide different levels of support for live snapshots of a guest operating system and most environments provide a command line tool for taking new snapshots and restoring to saved snapshots. This project uses KVM due to faster load times. KVM can restore environments even faster and has some convienent capabilities and thus is the preferred platform; VirtualBox support is deprecated at this point.

Because the size of the guest VM affects the restore speed it is best to create a guest VM with a very small memory and hard drive footprint. The VM created for this project started as a minimal installation with 64 MB of RAM and a ~500 MB HD along with a serial interface that allows logins (more on this below). The actual OS is called JeOS based on Ubuntu 10.04 with a read-only filesystem and NetHack running under /dev/shm so only the state of memory needs to be saved.

Target application: The copy of NetHack running on the VM uses the environment variable RANDOMSEED for setting the initial RNG value and behaves identically to the DOS version of NetHack. The reason for doing this and the method used is complicated but the goal is to ensure that the input fed into the modified version of NetHack in the Linux VM synchronizes with the DOS version of NetHack. It has been modified to display internal game information such as memory locations as well as a Santa mode accessed with X. The DOS defaults.nh file is also loaded, although for ease of use while in Linux the options are changed in-game later. Finally, the user is set to the name "Wizard" to allow the use of NetHack's wizard mode as needed.

Rerecording method: NetHack itself is incredibly sync stable. Because of this, all that is required is recording the keys pressed with no timing information required. This makes it possible to use tee to record the keystrokes sent to the VM guest from within the guest itself. The advantage is if the guest's state is rolled back, so is the recorded input. This is an impractical solution for virtually anything except NetHack but it gets the job done.

VM host-to-guest interface: KVM uses a simple numbered /dev/pts which can be connected to with screen.

Host virtual machine CLI interface: KVM uses a control channel which is put on a pts and connected to using screen.

VM control script environment: The VM control scripts are based on Python along with pexpect. The host OS directory structure is as follows:

  • nethack-3.4.3 is is a modified version of NetHack with specific adjustments for rerecording and to include changes to allow the Linux version of the game to use the DOS RNG system.
  • recordings is is where any output files created in the environment are synchronized to.
  • scripts is is where most of the activity happens. A variety of purpose-built scripts reside in this folder and are described in detail below.

Detachable environment: In order to allow scripts to run unattended (and to allow multiple users to see the input and interact at the same time) we opted to use tmux at all times. We chose tmux because we're already using screen to connect to the PTY interface and we were unable to run screen nested within screen in that scenario. The tmux shell generally has only one or two windows inside of it with the tmux status bar disabled.

Target platform: The jpc-rr emulator is a Java-based i386 emulator that can run a DOS environment and provides rerecording functionality. Unfortunately, it is very slow even on modern hardware and is unsuitable for the extensive amount of luck manipulation required for a NetHack Tool Assisted Speedrun. It does provide an embedded lua scripting environment and several other handy features, however.

Target application: Inside of jpc-rr is a disk image with the 3.4.3 release of NetHack in its natural, unaltered form. The input for the DOS version uses a single letter character name and uses a different options menu layout than what Linux uses.

Target platform scripting environment: Because jpc-rr has lua support it is possible to use a lua keyspam script to read the text file and send the characters to the emulator as fast as the BIOS can accept them.

Final video output: Attempting to get a watchable video out of jpc-rr turned out to be a very difficult problem because we're spamming the input at over 750 characters a second. The h.264 / .mkv file creation required customizations to jpc-rr by the author (Ilari).

Hardware verification: We (mostly dwangoAC) intend to eventually play this back on a real physical 386 or 486 with a VGA video card using an adapter with TASBot to pretend to be a PS/2 keyboard with the intent of doing so at a live charity event.

Scripts: The majority of the work outside of building the actual environment was the development of scripts. The primary script that everything is based on is expectKvm.py which handles starting the VM, connecting to it, saving and restoring the state, handling user input to control the script, and recording statistics. It reads a conf.yaml file for configuration settings such as the name of the virtual machine and the keystrokes to watch for for interactive control of the script. Statistics are saved to stats.yaml and record manual and scripted rerecords as well as the output of automated script attempts. The snapshot names are stored in a separate savestates.yaml file to reduce the size of the file that must be saved on each update. The script can be run on its own (which increments manual rerecord counts) or it can be called by other scripts and increment scripted rerecord counts. If expectKvm.py is run on its own it restores the most recent snapshot state and connects screen to the serial interface of the VM.

To allow automation the VM's state is saved as a snapshot and scripts are created using Python and the pexpect module to expect a given state, provide input and make a decision of success or failure based on the response. As an example, in NetHack it's handy to trigger polymprohing which happens 1% of the time when wearing a ring of polymorph. The script might walk against a wall a given number of times (which advances the RNG but does nothing else) followed by doing something that uses a turn and checks to see if we've polymorphed. If polymorph isn't triggered the VM's state is restored to the most recent snapshot, the number of times to walk into the wall and advance the RNG is incremented and the test is performed again. When the luck manipulation attempt is successful based on seeing the polymorph prompt the result is logged and the script stops. This example script is relatively simple but scripts can be incredibly complicated such as attempting to not teleport while polymorphing and not taking damage from a nearby enemy.

Outside of VM manipulation scripts there are a number of utility scripts including runWipFaster.py which plays back a file of input back into the VM which is occasionally required when changes are made inside of the guest environment (such as changes to the NetHack code or hex edits to parts earlier in the run).


In VM Setup: These are the commands to start from scratch:

export HOME=/dev/shm
cd ~
cp -R /home/user/build/ .
cp /home/user/.tmux.conf .
cp /home/user/vtdefaults.nh .
export 'TZ=UTC+0'
export NETHACKOPTIONS='@/dev/shm/vtdefaults.nh'
export RANDOMSEED=1447373582
rm build/playfield/record && touch build/playfield/record
export LD_PRELOAD=`readlink -f nobuffer.so`
tmux
stty raw -echo icrnl onlcr opost; tee ~/nethack.nttrec | build/nethack -u wizard; reset

If you're making filesystem changes and you're running from expectKvm.py inside Nethack, perform these steps as well (the example below is for updating the nethack executable, replace the example IP):

#quit nnnnnnn
sudo mount -o remount,rw /
scp tas@192.168.254.210:build/playfield/nethack /home/user/build/playfield
sudo reboot

Usage and controls

After the environment has been setup with a working guest OS and a snapshot has been taken of a given state the next step is to run ./expectKvm.py in the /scripts folder. Once expectKvm has restored the snapshot and connected to the VM it's possible to save or restore the snapshot state on the fly. The control keys are defined in conf.yaml and by default are set to Ctrl+U to save a snapshot and Ctrl+O to restore the most recent snapshot along with Ctrl+E which brings up a small menu to navigate between savestates. The guest OS can be exited by hitting Ctrl+C twice to exit the script. When expectKvm is called from a script the script can be paused at the end of an attempt by touching a file named block in the /scripts directory. This pauses execution to allow verification that the script is executing properly; the script can be resumed by pressing Ctrl+] at which point the block file will be removed. Alternately, pressing Ctrl+C by default will behave the same way as manually creating a block file. A permablock file can also be created which will not be removed.

When in manual mode, input is saved every time a new state is loaded; pressing the restoreLastStateKey gets back to that state by sending the previously sent input, and pressing it again automatically duplicates the first character which is useful in some contexts and completely useless in others. As a special case, if the current unsaved input starts with #n, split the string and send the second whitespace-deliniated text * the third whitespace-deliniated text, such as #n 7 3 to send 777 or #n Zc 5 to send ZcZcZcZcZc.

Resources

See also