Angband
z-rand.h
Go to the documentation of this file.
1 
22 #ifndef INCLUDED_Z_RAND_H
23 #define INCLUDED_Z_RAND_H
24 
25 #include "h-basic.h"
26 
32 #define MAX_RAND_DEPTH 128
33 
40 typedef struct random {
41  int base;
42  int dice;
43  int sides;
44  int m_bonus;
45 } random_value;
46 
50 #define RAND_DEG 32
51 
55 typedef enum {
61 } aspect;
62 
63 
69 #define randint0(M) ((s32b) Rand_div(M))
70 
71 
77 #define randint1(M) ((s32b) Rand_div(M) + 1)
78 
85 #define rand_spread(A, D) ((A) + (randint0(1 + (D) + (D))) - (D))
86 
90 #define one_in_(x) (!randint0(x))
91 
95 extern bool Rand_quick;
96 
100 extern u32b Rand_value;
101 
105 extern u32b state_i;
106 extern u32b STATE[RAND_DEG];
107 extern u32b z0;
108 extern u32b z1;
109 extern u32b z2;
110 
111 
115 void Rand_state_init(u32b seed);
116 
120 void Rand_init(void);
121 
127 u32b Rand_div(u32b m);
128 
133 s16b Rand_normal(int mean, int stand);
134 
141 int Rand_sample(int mean, int upper, int lower, int stand_u, int stand_l);
142 
149 
153 int damroll(int num, int sides);
154 
158 int damcalc(int num, int sides, aspect dam_aspect);
159 
166 int rand_range(int A, int B);
167 
172 s16b m_bonus(int max, int level);
173 
177 s16b m_bonus_calc(int max, int level, aspect bonus_aspect);
178 
182 int randcalc(random_value v, int level, aspect rand_aspect);
183 
187 bool randcalc_valid(random_value v, int test);
188 
193 
194 extern void rand_fix(u32b val);
195 
196 #endif /* INCLUDED_Z_RAND_H */
int sides
Definition: z-rand.h:43
int randcalc(random_value v, int level, aspect rand_aspect)
Calculation helper function for random_value structs.
Definition: z-rand.c:498
Use the roguelike command false Show damage player deals to false Always pickup false Show flavors in object false Highlight player with cursor between false Show walls as solid false false Center map false Automatically clear more false Allow mouse clicks to move the true false false false false false Generate a random artifact false Force player false Restrict creation of false Lose artifacts when leaving level
Definition: list-options.h:86
int dice
Definition: z-rand.h:42
uint32_t u32b
Definition: h-basic.h:172
u32b Rand_value
The state used by the "quick" RNG.
Definition: z-rand.c:93
u32b state_i
The state used by the "complex" RNG.
Definition: z-rand.c:53
int mean(int *nums, int size)
Arithmetic mean of the first 'size' entries of the array 'nums'.
Definition: z-util.c:437
u32b z2
Definition: z-rand.c:58
s16b Rand_normal(int mean, int stand)
Generate a signed random integer within stand standard deviations of mean, following a normal distrib...
Definition: z-rand.c:283
Definition: z-rand.h:58
int base
Definition: z-rand.h:41
int damroll(int num, int sides)
Emulate a number num of dice rolls of dice with sides sides.
Definition: z-rand.c:352
Definition: z-rand.h:56
Definition: z-rand.h:59
u32b Rand_div(u32b m)
Generates a random unsigned long integer X where "0 <= X < M" holds.
Definition: z-rand.c:164
int rand_range(int A, int B)
Generates a random signed long integer X where "A <= X <= B" Note that "rand_range(0, N-1)" == "randint0(N)".
Definition: z-rand.c:390
The lowest level header.
void Rand_init(void)
Initialise the RNG.
Definition: z-rand.c:128
int Rand_sample(int mean, int upper, int lower, int stand_u, int stand_l)
Generate a signed random integer following a normal distribution, where upper and lower are approxima...
Definition: z-rand.c:331
int num
Definition: libpng12/png.h:1527
int damcalc(int num, int sides, aspect dam_aspect)
Calculation helper function for damroll.
Definition: z-rand.c:369
bool randcalc_valid(random_value v, int test)
Test to see if a value is within a random_value&#39;s range.
Definition: z-rand.c:516
int16_t s16b
Definition: h-basic.h:170
#define RAND_DEG
The number of 32-bit integers worth of seed state.
Definition: z-rand.h:50
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:40
u32b Rand_simple(u32b m)
Generate a semi-random number from 0 to m-1, in a way that doesn&#39;t affect gameplay.
Definition: z-rand.c:546
u32b STATE[RAND_DEG]
Definition: z-rand.c:54
Definition: unit-test-types.h:10
int m_bonus
Definition: z-rand.h:44
bool randcalc_varies(random_value v)
Test to see if a random_value actually varies.
Definition: z-rand.c:529
aspect
Random aspects used by damcalc, m_bonus_calc, and ranvals.
Definition: z-rand.h:55
Definition: z-rand.h:60
s16b m_bonus_calc(int max, int level, aspect bonus_aspect)
Calculation helper function for m_bonus.
Definition: z-rand.c:480
u32b z0
Definition: z-rand.c:58
bool Rand_quick
Whether we are currently using the "quick" method or not.
Definition: z-rand.c:88
u32b z1
Definition: z-rand.c:58
void rand_fix(u32b val)
Definition: z-rand.c:534
void Rand_state_init(u32b seed)
Initialise the RNG state with the given seed.
Definition: z-rand.c:101
struct random random_value
A struct representing a strategy for making a dice roll.
Definition: z-rand.h:57