Level distribution of NetHack 3.4.3 and UnNetHack

In 2014 I ran some tests on the level compiler in UnNetHack. The level compiler is different from the one in NetHack 3.4.3. It’s an extended version of this patch by Pasi Kallinen. Pasi added this to SporkHack and after I took it from there and added it to UnNetHack, Pasi himself updated and extended it for the UnNetHack code. Since 3.6 it has also been incorporated into NetHack itself.

I wanted to stress-test this level generation code to find bugs and as a by-product of this process, generate some statistics on how dungeons in UnNetHack look like. I added some hacks so that starting a game would run automatically through the whole dungeon and record the dungeon layout on file. Any error or warning from the code would also generate a core dump and as the random seed got logged, I could easily debug any issue that cropped up.

The code was simple enough to apply to Vanilla as well, so I ran some tests on Vanilla as well. At the time of testing, this was still 3.4.3. I will have to rerun the stress test with the current version of NetHack, especially now that we have changed the level files format to Lua.

In UnNetHack, several issues were identified and fixed. For example an endless loop in place_random_engraving() or the level compiler crashing in the ice room vault while placing a trap.

The only bug I found with NetHack 3.4.3 was that if you get the Frontier Town version of mine town, on the right side there might be not enough space for downstairs placement. To my knowledge, this hasn’t happened ever to a player but it also is not a game breaker. You can always dig down and use the upstairs to come back up. The game will place you at a random position if the target level has no downstairs.

For both Vanilla and UnNetHack, I produced each 1 million dungeons. The big room came up 40.04% in Vanilla and 40.07% in UnNetHack which is close enough to the theoretical 40% that one would expect. Fort Ludios was 74.80% in Vanilla which is slightly lower than the 74.9% that have been calculated more than 15 years ago by Robert R. Schneck.
https://groups.google.com/forum/#!msg/rec.games.roguelike.nethack/tzlaN5uzKw8/fHPrsgfRQ8gJ

We don’t have his code, so I can’t reproduce his findings and I don’t know if the difference was caused by him not using 3.4.3 (although unlikely, I think nothing changed in the level generation code between previous 3.4 versions and 3.4.3), some error in his or my code changes, or maybe even just by using different random number generators. But the difference does not seem to be significant enough to worry about.

In UnNetHack, Fort Ludios came up 93.51%, this is due to a change in the portal placement code so that it would appear more often. The nymph level was in 45% of all generated dungeons.

I made two charts that visualize the data for NetHack 3.4.3 and UnNetHack.

I left out some levels because they are dependant on each other and only clutter up the chart. For example, Sokoban is always directly below Oracle, fakewiz1 and fakewiz2 have the same probabilities, or the wizard’s tower levels.

https://bhaak.net/nethack/levels/vanilla.html
https://bhaak.net/nethack/levels/unnethack.html

I was surprised to see that the new UnNetHack levels don’t influence the placement of the Vanilla levels. Fort Ludios is the only exception but we deliberately tweaked its placement so this was to be expected.

The code for both Vanilla and UnNetHack are in branches in the normal UnNetHack git repository:
https://github.com/unnethack/unnethack/tree/level_statistics
https://github.com/unnethack/unnethack/tree/nethack_level_statistics

The raw data, including the levels I removed for the charts:
https://bhaak.net/nethack/levels/nethack_levels.txt
https://bhaak.net/nethack/levels/unnethack_levels.txt

~ by bhaak on 29. January 2020.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: