PatR
cbdda9dc9d
adopt github pull request #286 - rndmonst()
...
Eliminate the cache that was supporting rndmonst() and pick a random
monster in a single pass through mons[] via "weighted reservoir
sampling", a term I'm not familiar with.
It had a couple of bugs: if the first monster examined happened to
be given a weighting of 0, rn2() would divide by 0. I didn't try
to figure out how to trigger that. But the second one was easy to
trigger: if all eligible monsters were extinct or genocided, it
would issue a warning even though the situation isn't impossible.
Aside from fixing those, the rest is mostly as-is. I included a bit
of formatting in decl.c, moved some declarations to not require C99,
and changed a couple of macros to not hide and duplicate a call to
level_difficulty().
Fixes #286
2020-02-22 17:40:55 -08:00
..
2018-11-11 10:29:52 -05:00
2019-11-27 09:53:40 -08:00
2019-11-06 18:43:20 +02:00
2015-05-25 09:21:31 +09:00
2018-04-25 15:00:13 -04:00
2019-11-22 22:35:48 -05:00
2018-12-25 16:26:27 -08:00
2015-05-25 09:21:31 +09:00
2015-05-25 09:21:15 +09:00
2020-02-20 01:22:27 -05:00
2015-10-17 13:15:46 +03:00
2019-04-19 12:42:35 -07:00
2020-01-29 09:56:43 -05:00
2020-02-12 14:35:37 -08:00
2018-04-25 15:00:13 -04:00
2020-02-22 17:40:55 -08:00
2015-05-25 09:21:31 +09:00
2019-11-06 18:45:10 +02:00
2020-02-08 00:48:03 -05:00
2019-05-12 14:51:26 -04:00
2020-02-01 18:31:39 +02:00
2018-04-25 15:00:13 -04:00
2020-02-22 17:40:55 -08:00
2020-02-13 15:38:59 -08:00
2020-01-29 10:29:37 -05:00
2018-12-15 19:31:42 -05:00
2015-05-25 09:21:15 +09:00
2020-01-14 11:35:06 -05:00
2020-02-08 00:48:03 -05:00
2019-03-06 11:37:52 -08:00
2019-01-28 10:02:08 +01:00
2018-04-25 16:54:50 -04:00
2015-05-25 09:21:15 +09:00
2018-04-25 15:00:13 -04:00
2018-04-25 15:00:13 -04:00
2018-04-25 15:00:13 -04:00
2018-04-25 15:00:13 -04:00
2015-10-17 13:15:46 +03:00
2019-05-11 11:10:00 +03:00
2020-02-20 20:12:51 -05:00
2018-04-25 16:54:50 -04:00
2019-11-27 01:27:11 -05:00
2018-04-25 15:00:13 -04:00
2018-12-25 09:34:24 -08:00
2019-06-18 21:50:51 -04:00
2015-05-25 09:21:31 +09:00
2020-02-06 12:09:24 -05:00
2020-02-18 13:33:00 -08:00
2020-02-22 17:40:55 -08:00
2019-01-13 17:19:39 -08:00
2015-05-25 09:21:31 +09:00
2020-02-13 21:24:24 -05:00
2020-01-26 02:58:18 -08:00
2020-01-12 22:02:36 -08:00
2019-01-28 10:02:09 +01:00
2020-02-12 14:35:37 -08:00
2019-11-02 22:53:46 -04:00
2018-10-21 08:45:55 -04:00
2019-10-08 13:26:39 -07:00
2015-05-25 09:21:31 +09:00
2015-05-25 09:21:31 +09:00
2015-10-17 18:47:31 +03:00
2020-02-08 00:48:03 -05:00
2019-01-11 17:18:48 -08:00
2020-02-21 18:16:14 +02:00
2018-12-24 16:43:50 -08:00
2019-12-18 07:38:59 -05:00
2019-11-29 17:40:58 -05:00
2018-04-25 15:00:13 -04:00
2018-04-25 16:54:50 -04:00
2020-01-27 09:54:58 +02:00
2019-07-27 16:12:24 -07:00
2018-04-25 15:00:13 -04:00
2019-04-15 13:48:27 -07:00
2020-02-20 20:12:51 -05:00
2019-01-12 01:09:17 -05:00
2019-07-14 23:36:56 -07:00
2019-06-08 09:38:27 -04:00
2020-01-20 21:33:20 -05:00
2019-01-28 10:02:09 +01:00
2015-05-25 09:21:31 +09:00
2020-02-20 20:12:51 -05:00
2020-02-20 20:12:51 -05:00
2015-05-25 09:21:31 +09:00
2020-02-20 20:12:51 -05:00
2020-02-20 20:12:51 -05:00
2020-02-20 20:12:51 -05:00
2020-02-20 20:12:51 -05:00
2015-05-25 09:21:31 +09:00
2015-05-25 09:21:31 +09:00
2020-02-12 14:35:37 -08:00
2020-01-21 17:03:54 -08:00