diff options
author | elliptic <hyperelliptical@gmail.com> | 2013-08-26 20:11:01 -0400 |
---|---|---|
committer | elliptic <hyperelliptical@gmail.com> | 2013-08-26 20:11:01 -0400 |
commit | 44efbc97f7b172a61e09fa0c054832add0692a27 (patch) | |
tree | e51c864f9499a0f0ddb29b0680c1a32d0705898b /crawl-ref/source/random.cc | |
parent | 04e3a93a1fb0f08d580a007a149094fef39430b8 (diff) | |
download | crawl-ref-44efbc97f7b172a61e09fa0c054832add0692a27.tar.gz crawl-ref-44efbc97f7b172a61e09fa0c054832add0692a27.zip |
Increase enchantment on weapon randarts.
It was generally agreed that weapon randarts are a bit weaker than non-weapon
randarts on average. This commit buffs them by increasing their accuracy and
damage enchantment by about 3 each on average (while maintaining the same
[-6,+12] range of possibilities).
Diffstat (limited to 'crawl-ref/source/random.cc')
-rw-r--r-- | crawl-ref/source/random.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crawl-ref/source/random.cc b/crawl-ref/source/random.cc index f17e4716b5..669cb7dd0b 100644 --- a/crawl-ref/source/random.cc +++ b/crawl-ref/source/random.cc @@ -206,6 +206,19 @@ int random2avg(int max, int rolls) return (sum / rolls); } +// biased_random2() takes values in the same range [0, max) as random2() but +// with mean value (max - 1)/(n + 1) biased towards the bottom end. +// This can be thought of as the smallest of n _distinct_ random integers +// chosen in [0, max + n - 1). +// Never use with n < 2. +int biased_random2(int max, int n) +{ + for (int i = 0; i < max; i++) + if (x_chance_in_y(n, n + max - 1 - i)) + return i; + return 0; +} + // originally designed to randomise evasion - // values are slightly lowered near (max) and // approach an upper limit somewhere near (limit/2) |