]> granicus.if.org Git - nethack/commit
fix #H2204 - mkclass() mon selection distribution
authorPatR <rankin@nethack.org>
Sun, 16 Dec 2018 22:21:30 +0000 (14:21 -0800)
committerPatR <rankin@nethack.org>
Sun, 16 Dec 2018 22:21:30 +0000 (14:21 -0800)
commit0fe6a731dff521a7dd1c1a9f3c36d5438d24c22e
treea849d033e2a285b70ac1a004d1aaebb6e793ad7a
parent42d9af1b233ed0092caaa7f52f6fe85bafafda31
fix #H2204 - mkclass() mon selection distribution

That #H number isn't a typo.  This finally fixes--at least improves--
something reported eight years ago.  The monster types chosen by
mkclass() could be way off in some circumstances.  Cited example was
repeated same-race sacrifice by chaotic hero on dungeon level 20; it
produced about twice as many incubi as succubi even though they're
the same as far as difficulty goes.  (No changes in the intervening
years had any discernable effect; that was still reproducible.)
The report also mentioned that ndemon() threw away the result from
mkclass() and retried quite often and suggested that mkclass() be
taught to filter by alignment when caller cared about that.

This seems to even things out, although it also made harder monsters
chosen more often.  A test program generated these numbers when
picking a chaotic demon 10000 times (level 1 hero on dungeon level 20,
so not realistic; actually probably level 0 hero since the program
didn't initialize struct u.)  Third column is the number of times the
monster type was chosen with the old mkclass(), fourth is same for
the new one.
    mkclass() calls    27315 10000
286 succubus            2800  3309
288 incubus             5552  3262
291 marilith             973   780
292 vrock                477  1617
293 hezrou               150   626
294 bone devil            46   247
295 ice devil              2   107
296 nalfeshnee             0    23
297 pit fiend              0    15
298 sandestin              0     4
299 balrog                 0    10
Note that vrock has generation frequency 2 and marilith only 1, so
getting twice as many vrocks as mariliths should be expected.

I temporarily changed ndemon() to ask for lawful demons instead of
chaotic ones and got this.
    mkclass() calls    15762 10000
287 horned devil        3197  3375
289 erinys              4991  3339
290 barbed devil        1812  3286

I also ran it for dragons with any alignment (so the outcome was
never thrown away; 10000 calls were needed for 10000 picks) instead
of demons of specific alignment and am suspicious of the outcome.
    mkclass() calls    10000 10000
140 baby yellow dragon  1124     0
141 gray dragon         1096  1096
142 silver dragon       1073  1099
143 red dragon          1061  1126
144 white dragon        1077  1128
145 orange dragon       1141  1118
146 black dragon        1154  1049
147 blue dragon         1137  1123
148 green dragon        1137  1154
149 yellow dragon          0  1107
There may be a flaw in the test program.  Or else old mkclass() was
not very good at picking dragons.
doc/fixes36.2
include/extern.h
src/makemon.c
src/minion.c