#ifndef WH_DICE_H_15c972e3_ #define WH_DICE_H_15c972e3_ #include "structs.h" /* * APIs exported by dice.c. These give the rest of the game convenient * access to randomness. */ /* * Set and get the randomness seed. This is useful for debugging, to * reproduce a particular game exactly. */ extern unsigned long int get_dice_seed(void); extern void set_dice_seed(unsigned long int); /* * Three ways of getting random numbers. * * onein(N) returns true with probability 1/N, false with (N-1)/N. * * rnd(N) returns a random integer in [0..N). * * roll(dice) rolls dice based on a descriptive string, as in "d8" or * "4d3+7" or "d10+d12-1". */ extern int onein(int); extern int rnd(int); extern int roll(const char *); /* * Return a random value in the range [0..1) tick. */ extern TIME subtick(void); /* * Initialize randomness. Called once at startup. */ extern void initrandom(void); #endif