2 #include "object-boost.h"
5 * @brief 上質以上のオブジェクトに与えるための各種ボーナスを正規乱数も加えて算出する。
6 * Help determine an "enchantment bonus" for an object.
8 * @param level ボーナス値に加味する基準生成階
11 * To avoid floating point but still provide a smooth distribution of bonuses,\n
12 * we simply round the results of division in such a way as to "average" the\n
13 * correct floating point value.\n
15 * This function has been changed. It uses "randnor()" to choose values from\n
16 * a normal distribution, whose mean moves from zero towards the max as the\n
17 * level increases, and whose standard deviation is equal to 1/4 of the max,\n
18 * and whose values are forced to lie between zero and the max, inclusive.\n
20 * Since the "level" rarely passes 100 before Morgoth is dead, it is very\n
21 * rare to get the "full" enchantment on an object, even a deep levels.\n
23 * It is always possible (albeit unlikely) to get the "full" enchantment.\n
25 * A sample distribution of values from "m_bonus(10, N)" is shown below:\n
27 * N 0 1 2 3 4 5 6 7 8 9 10\n
28 * --- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----\n
29 * 0 66.37 13.01 9.73 5.47 2.89 1.31 0.72 0.26 0.12 0.09 0.03\n
30 * 8 46.85 24.66 12.13 8.13 4.20 2.30 1.05 0.36 0.19 0.08 0.05\n
31 * 16 30.12 27.62 18.52 10.52 6.34 3.52 1.95 0.90 0.31 0.15 0.05\n
32 * 24 22.44 15.62 30.14 12.92 8.55 5.30 2.39 1.63 0.62 0.28 0.11\n
33 * 32 16.23 11.43 23.01 22.31 11.19 7.18 4.46 2.13 1.20 0.45 0.41\n
34 * 40 10.76 8.91 12.80 29.51 16.00 9.69 5.90 3.43 1.47 0.88 0.65\n
35 * 48 7.28 6.81 10.51 18.27 27.57 11.76 7.85 4.99 2.80 1.22 0.94\n
36 * 56 4.41 4.73 8.52 11.96 24.94 19.78 11.06 7.18 3.68 1.96 1.78\n
37 * 64 2.81 3.07 5.65 9.17 13.01 31.57 13.70 9.30 6.04 3.04 2.64\n
38 * 72 1.87 1.99 3.68 7.15 10.56 20.24 25.78 12.17 7.52 4.42 4.62\n
39 * 80 1.02 1.23 2.78 4.75 8.37 12.04 27.61 18.07 10.28 6.52 7.33\n
40 * 88 0.70 0.57 1.56 3.12 6.34 10.06 15.76 30.46 12.58 8.47 10.38\n
41 * 96 0.27 0.60 1.25 2.28 4.30 7.60 10.77 22.52 22.51 11.37 16.53\n
42 * 104 0.22 0.42 0.77 1.36 2.62 5.33 8.93 13.05 29.54 15.23 22.53\n
43 * 112 0.15 0.20 0.56 0.87 2.00 3.83 6.86 10.06 17.89 27.31 30.27\n
44 * 120 0.03 0.11 0.31 0.46 1.31 2.48 4.60 7.78 11.67 25.53 45.72\n
45 * 128 0.02 0.01 0.13 0.33 0.83 1.41 3.24 6.17 9.57 14.22 64.07\n
47 int m_bonus(int max, DEPTH level)
49 int bonus, stand, extra, value;
52 /* Paranoia -- enforce maximal "level" */
53 if (level > MAX_DEPTH - 1) level = MAX_DEPTH - 1;
56 /* The "bonus" moves towards the max */
57 bonus = ((max * level) / MAX_DEPTH);
59 /* Hack -- determine fraction of error */
60 extra = ((max * level) % MAX_DEPTH);
62 /* Hack -- simulate floating point computations */
63 if (randint0(MAX_DEPTH) < extra) bonus++;
66 /* The "stand" is equal to one quarter of the max */
69 /* Hack -- determine fraction of error */
72 /* Hack -- simulate floating point computations */
73 if (randint0(4) < extra) stand++;
76 /* Choose an "interesting" value */
77 value = randnor(bonus, stand);
79 /* Enforce the minimum value */
80 if (value < 0) return (0);
82 /* Enforce the maximum value */
83 if (value > max) return (max);