/* vi: set ts=2: * +-------------------+ Christian Schlittchen * | | Enno Rehling * | Eressea PBEM host | Katja Zedel * | (c) 1998 - 2005 | * | | This program may not be used, modified or distributed * +-------------------+ without prior permission by the authors of Eressea. * */ #ifndef UTIL_RNG_H #define UTIL_RNG_H #ifdef __cplusplus extern "C" { #endif #define RNG_MT #ifdef RNG_MT /* initializes mt[N] with a seed */ extern void init_genrand(unsigned long s); /* generates a random number on [0,0xffffffff]-interval */ extern unsigned long genrand_int32(void); /* generates a random number on [0,1)-real-interval */ extern double genrand_real2(void); /* generates a random number on [0,0x7fffffff]-interval */ long genrand_int31(void); # define rng_init(seed) init_genrand(seed) # define rng_int genrand_int31 # define rng_double genrand_real2 # define RNG_RAND_MAX 0x7fffffff #else # include # define rng_init(seed) srand(seed) # define rng_int rand() # define rng_double ((rand()%RAND_MAX)/(double)RAND_MAX) # define RNG_RAND_MAX RAND_MAX #endif #ifdef __cplusplus } #endif #endif