diff options
author | Adam Borowski <kilobyte@angband.pl> | 2013-06-26 19:25:51 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2013-06-26 19:25:51 +0200 |
commit | afa23c35285b32f5768c224001b11e0be08d886c (patch) | |
tree | e05aadac8eb66fd5ff13a1103cd090135f4dd03c /crawl-ref/source/random-pick.h | |
parent | de8e8e0bc01e85ea6c1f5c3a9b9f243371f7bf1e (diff) | |
download | crawl-ref-afa23c35285b32f5768c224001b11e0be08d886c.tar.gz crawl-ref-afa23c35285b32f5768c224001b11e0be08d886c.zip |
Scale the calculations in mon-pick by 2520.
The algorithm was designed with values based at 10000 in mind so numbers
small enough to zero off were not a concern, they could be avoided by scaling
up the data in other users of that code, but it's probably better to get rid
of gotchas rather than to document them.
Diffstat (limited to 'crawl-ref/source/random-pick.h')
-rw-r--r-- | crawl-ref/source/random-pick.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crawl-ref/source/random-pick.h b/crawl-ref/source/random-pick.h index 028f03c081..3ebdb3447e 100644 --- a/crawl-ref/source/random-pick.h +++ b/crawl-ref/source/random-pick.h @@ -60,7 +60,9 @@ T random_picker<T, max>::pick(const random_pick_entry<T> *weights, int level, if (veto(pop->value)) continue; - int rar = rarity_at(pop, level); + // 2520 is divisible by any number 1..10, and provides enough scale + // to make round-off errors even for degenerate distributions ok. + int rar = rarity_at(pop, level) * 2520; ASSERTM(rar > 0, "Rarity %d: %d at level %d", rar, pop->value, level); valid[nvalid].value = pop->value; |