4 * Copyright (c) 1997 Ben Harrison, and others
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
12 #ifndef INCLUDED_Z_RAND_H
13 #define INCLUDED_Z_RAND_H
19 /**** Available constants ****/
23 * Random Number Generator -- Degree of "complex" RNG -- see "misc.c"
24 * This value is hard-coded at 63 for a wide variety of reasons.
31 /**** Available macros ****/
35 * Generates a random long integer X where O<=X<M.
36 * The integer X falls along a uniform distribution.
37 * For example, if M is 100, you get "percentile dice"
43 * Generates a random long integer X where A<=X<=B
44 * The integer X falls along a uniform distribution.
45 * Note: rand_range(0,N-1) == randint0(N)
47 #define rand_range(A,B) \
48 ((A) + (randint0(1+(B)-(A))))
51 * Generate a random long integer X where A-D<=X<=A+D
52 * The integer X falls along a uniform distribution.
53 * Note: rand_spread(A,D) == rand_range(A-D,A+D)
55 #define rand_spread(A,D) \
56 ((A) + (randint0(1+(D)+(D))) - (D))
60 * Generate a random long integer X where 1<=X<=M
61 * Also, "correctly" handle the case of M<=1
68 * Evaluate to TRUE "P" percent of the time
78 * Evaluate to TRUE "S" percent of the time
80 #define saving_throw(S) \
84 /**** Available Variables ****/
86 extern bool Rand_quick;
87 extern u32b Rand_value;
88 extern u16b Rand_place;
89 extern u32b Rand_state[RAND_DEG];
92 /**** Available Functions ****/
94 extern void Rand_state_init(u32b seed);
95 extern s32b Rand_div(u32b m);
96 extern s16b randnor(int mean, int stand);
97 extern s16b damroll(int num, int sides);
98 extern s16b maxroll(int num, int sides);