
NetHack beaten in 7 minutes 15 seconds real time - User23
https://pellsson.github.io/
======
schoen
When I saw the previous submission of this as
[https://news.ycombinator.com/item?id=18853508](https://news.ycombinator.com/item?id=18853508)
(which describes it as a "tool-assisted speedrun" of NetHack on the online
server nethack.alt.org), I thought "wait, you can't have a tool-assisted
speedrun of a nondeterministic game with hidden information...!" (particularly
on an online server where you can't roll back history).

Then I read the article and saw that this project went to absolutely insane
lengths to work around the "nondeterministic" and "hidden information" parts.

~~~
merlincorey
They had to do quite a lot of source diving to achieve this.

The bumping into a wall to advance the RNG state without changing the game
time is a really neat trick that I would otherwise have been completely
unaware of, and I have played Nethack for many years and done some source
diving myself.

Truly a great feat of engineering here.

~~~
malux85
This reminds me of something I read on reinforcement learning playing Atari /
video games ... often you see the Deep net (I think the game in question was a
tank game) just spazzing out on the controller when there’s no enemy, the tank
was spinning on the spot while waiting for a door to open for example.

Initially thought just to probably be some numerical instability when the next
actions are all equally likely (I.e. there’s nothing for it to do) but what
was actually happening is the pseudo RNG was partially fed by controller
input, and certain patterns of controller input would make random rewards more
likely to spawn.

I always thought it was cool how these exploits get discovered by the deep
nets

~~~
zawerf
Do you have a source on this?

I was under the impression that machine learning is only good at learning
things that can be approximated by continuous functions.

A RNG is almost the complete opposite of that. It's everywhere discontinuous!

~~~
dklsafhjskljfl
Old games put the P in PRNG. Often, the technical limitations caused them to
very roughly approximate randomness, for example a function that used the last
n button presses plus the countdown timer as a seed. If your game has to run
in under a kilobyte of memory, that n value might be a byte, or less (such as
four bits, 2^4)

Some games were worse, far worse. Doom used a list of 256 random numbers that
it looped through.

Pokemon is another game where the RNG function is extensively mapped, and even
used in combination with bugs to generate Mew events, something that should
never ever happen.

You see a lot of TAS of old games, especially popular ones, that abuse the RNG
generator where feasible.

------
beefhash
This isn't the first time RNG manipulation in NetHack happened. In 2009, Adeon
released a set of RNG manipulation tools for NetHack 3.4.3
(nethack_rng_tools-0.2.3.tar.bz2 -- I can't find that filename anymore, so I
put up a mirror[1]). This allowed determining the RNG seed from a _running_
game. However, he also made a patch to use a cryptographically secure PRNG[2].
I'm not sure if nethack.alt.org (NAO) ran that patch. If they did, I'm not
sure why they kept random() for 3.6.1 that was apparently run by SWAGGINZZZ.

[1] Since it had license headers, this is probably okay.
[https://xorhash.bitbucket.io/nh/nethack_rng_tools-0.2.3.tar....](https://xorhash.bitbucket.io/nh/nethack_rng_tools-0.2.3.tar.bz2)

[2] [https://bilious.alt.org/?349](https://bilious.alt.org/?349)

------
fzeroracer
RNG manipulations are among some of my favorite speedruns just because of the
absurd lengths players will go to align absolutely everything perfectly. For
example, Dragon Warrior at AGDQ last year was an absolute treat to watch [1]

[1]
[https://www.youtube.com/watch?v=Bgh30BiWG58](https://www.youtube.com/watch?v=Bgh30BiWG58)

~~~
skibz
Remarkable. So is this player performing all of these movements that change
the RNG behaviour from (muscle) memory?

~~~
TremendousJudge
Yeah, pretty much. Speedrunning takes all the obsessive practicing of
classical piano concert performance and applies it to video games. It's insane

------
hannofcart
The best thing that nethack did for me was letting me ingrain the hjkl muscle
memory. This in turn helped me thrive in vim.

Thriving in the dungeons though... that's something that's always been
elusive.

~~~
linuxlizard
I hacked the source slightly so I don't take any damage in combat. Is a simple
one line change so it's a cheat but a tiny cheat. I _still_ cannot get past
level 10-12 or so. (Wow, I suck.)

------
dmix
Had to look up this abbreviation:

c!oGL = cursed potion of gain level

[https://nethackwiki.com/wiki/Abbreviations](https://nethackwiki.com/wiki/Abbreviations)

~~~
schoen
For non-NetHack players, this is a joke that results in a useful strategy. The
potion of gain level normally causes you to get an experience level. But if
the potion is cursed, the universe instead misinterprets the magical effect
and you gain a _dungeon_ level instead of an _experience_ level—that is, "You
rise up, through the ceiling".

This is generally very disappointing because an opportunity for your character
to become more powerful was effectively squandered due to the curse. But
magically moving upward quickly through the dungeon _can_ be very useful if
you need to escape from a dangerous monster quickly—or at the end of the game
when you need to escape from the dungeon as a whole. The latter is what this
speedrun used in order to avoid having to walk through the dungeon and take
the stairs.

Most normal characters wouldn't be close to having enough potions of this kind
to get entirely out of the dungeon by this means (also because of a certain
complicating factor that prevents characters who can't control the RNG from
knowing in advance exactly how many they'll need!). Although it's been done
before by different forms of grinding, this is a whole other matter because
the potions were obtained almost instantly with a preposterously lucky series
of wishes.

~~~
dmix
Thanks for the write up, that makes parts of the article make more sense.

------
ourmandave
_Blindly jumping to the altar and one-shotting the priest does of course take
A LOT of attempts, but modern CPUs are pretty fast and NetHack is a pretty
low-end game._

I can't help thinking of Phil in _Groundhog Day_ coming up with new challenges
as he spends eternity in Punxsutawney PA.

------
tibbon
Maybe I'm reading too far into this, but I think there's a greater lesson to
be learned from this.

This game's been around for 30 years, and is still under development. Some
would assume that security patches on any 30 year old piece of software would
have found nearly every bug or account for unexpected usages.

There's also a _big_ assumption that random states on remote systems can't be
determined. Our assumptions around what's "good enough" keep getting broken.
32-bit states, MD5, SHA-1, etc... Now clearly (until quantum computers go
mainstream) some problem spaces are just too big to reasonably brute force or
find collisions.

Could/will we find critical bugs that allow us to do similar types of attacks
for modern computing systems that aren't games?

------
XCabbage
Huh. Given that the first 6 minutes (out of 7:15 total) were spent with a
HUMAN player fumbling around looking for a fountain, presumably writing an AI
capable of doing that step would get the ascension time down to just over a
minute. I wonder why they didn't do so?

------
MaupitiBlue
I’ve been trying to reach the amulet for 30 years.

~~~
remote_phone
I’ve been playing since 1987 with the IBM PC version called Hack. My friend’s
floppy disk got damaged so he couldn’t use a scroll of identify because it
crashed the game, but he was still able to finish the game without it. For
Hack all you needed to do was find the Amulet of Yendor under a boulder and
bring it to the top.

I’ve never ascended on Nethack though despite all my time invested. I’m
probably playing it wrong but I don’t care it’s still fun as hell.

~~~
jandrese
That sounds closer to Rogue than Nethack.

~~~
remote_phone
No it was called Hack. This is around 1985 or 1986.

------
xyproto
Just waiting for AlphaNethackZero to beat this record.

------
DataWraith
> Turns out, every function in NetHack seems to find a way to call random(),
> causing the RNG state to drift.

I recently stumbled across the concept of _splittable RNGs_ , which works
around this very problem.

Once seeded, you can either "hand in" the generator to get a random number, or
you can split it into two (or more) new generators that themselves can be
handed in or split.

From a single seed generator, you would split off multiple generators for
things like map generation and monster behavior, which then split their
generators in turn to generate the level or move monsters.

As a consequence, if you change some monster behavior that uses the RNG, that
does not cause the level generation to change, because that was split off
earlier and is thus on an independent chain of random numbers.

~~~
HelloNurse
Splitting the PRNG would provide resistance to tampering by walking into walls
and the like, but it would also reduce the avalanche effect of _code changes_
, hiding inaccurate probability distributions (e.g. if a polymorph potion
turns you into a yeti the next spawned monster is likely to have low hit
points) that would cease to change drastically as PRNG calls are added or
removed anywhere.

------
octernion
this seems like the plot of "edge of tomorrow," [1] but in nethack form.

so neat -- i love that the RNG space fits into 100GB (all nethack games that
ever will be).

[1]
[https://en.wikipedia.org/wiki/Edge_of_Tomorrow](https://en.wikipedia.org/wiki/Edge_of_Tomorrow)

~~~
schoen
The original article points out that it's all possible "Tou Hum Fem Neu"
(female neutral human tourists). You have lots of other choices when you start
a NetHack game. :-)

~~~
octernion
oh gosh, i didn't realize that. looks like there are around 38 combinations; i
wonder what the table space looks like for the other ones!

~~~
jandrese
The problem with the other classes is that their starting equipment is less
random, so it's more difficult to figure out which seed you are on. You would
have to include more of the generated map in the database to figure out which
seed you are on.

And of course this would all be shot to hell if Nethack went to a 64 bit seed.

~~~
octernion
yeah, i wonder how much of the game information you would have to include to
make it unique.

that being said, wouldn't map information be sufficient for the remainder of
the classes? so using starting equipment is really just an optimization
available for this class?

~~~
jandrese
The problem with using the map is that you can't see most of it when you first
load the game. So you have to play more (and build up more state) before you
get to a completely unique solution. Being able to use the starting equipment
makes it much simpler.

------
njn
haha, nice.
[https://alt.org/nethack/fastasc.html](https://alt.org/nethack/fastasc.html)

~~~
orbital-decay
An ascension in -2147483648 turns by Khaos is another thing to note in the
table. Did he really wait for 2 billion turns before ascending to overflow
that counter?!

~~~
IncRnd
[https://nethackwiki.com/wiki/1-turn_ascension](https://nethackwiki.com/wiki/1-turn_ascension)

Check out the information at the very end of this page.

~~~
minikomi
> paste it into NetHack's terminal, and wait approximately 19 days.

Thanks for the laugh

~~~
kazinator
> If NetHack is compiled for a 64-bit platform, the "long" type will not wrap
> around until it gets to 9,223,372,036,854,775,808. The above trick still
> works in principle, but will take a few hundred million years to complete.

Another laugh.

------
fb03
How can you achieve a +100 Magicbane without Wizard-mode? Damn.

I didn't watch the TTYREC but I am seriously puzzled by that. Anyone has
insight into this?

~~~
aetimmes
Scroll of enchant weapon above +6 has a 2/3 chance of vaporizing the weapon
and then a 1/N chance of actually increasing the enchantment by +1, so if you
can manipulate RNG you can make sure that you always get the no-vaporize +1
result.

------
ngcc_hk
Is this just ai job for the 3000 if logic. Seems there is a feedback loop for
the core trial and error logic

------
XCabbage
Something else that's not obvious to me: why does the fountain have to be next
to a wall?

~~~
Jolter
They describe that in the article. To be able to bump into the wall and
advance the RNG one step at a time without passing in-game time. Presumably
that's to ensure that the next Wish will be successful.

~~~
XCabbage
D'oh. Not sure how I missed/forgot that. Thanks.

------
haolez
NetHack can be very fun, if you invest some time. I recommend to start with a
GUI version.

~~~
kibwen
Alternatively, for a roguelike cut from the same mold as Nethack but with a
very different philosophical bent, I recommend Dungeon Crawl Stone Soup, which
can be played either locally, online in the classic SSH fashion, or via a web
browser with a nice graphical UI (e.g.
[http://crawl.akrasiac.org:8080/#lobby](http://crawl.akrasiac.org:8080/#lobby)
, click on any name there to observe other players in action).

~~~
erikb
I think it's the very best dungeon crawler when it comes to comfort of use and
startability for new players.

And I would suggest it not just for gamers but for programmers as well. There
is a lot one can learn about user interfaces, shells, coding, architecture,
data management (items, races etc are all data) with the additional motivation
to learn it while playing.

~~~
floatboth
> for programmers as well

[https://twitter.com/crawlcode](https://twitter.com/crawlcode) :)

------
Jolter
Looks like the TTYrec is missing. Did NAO remove it?

~~~
Roujo
Looks like the URL is mangled by being repeated, that's odd. It seems to work
when I de-dupe it, though. ^^

[https://alt.org/nethack/trd/?file=https://alt.org/nethack/us...](https://alt.org/nethack/trd/?file=https://alt.org/nethack/userdata/S/SWAGGINZZZ/ttyrec/2019-01-05.23:56:16.ttyrec#)

~~~
dlgeek
That only has 3 frames...that can't be right..?

~~~
Liskni_si
Try Firefox. Doesn't work in Chrome for me either.

