X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=init.c;h=fdde548f879c5e83db88d0f60ae478a5dfa89c94;hb=065caace647f86770df0d7bb9f1a3a1ffdd0f188;hp=4d05e0fa03c6b4ff02f2f1541c0c61ab228a3ef9;hpb=0a87fc9f78c40354068749f93cbbed80e217cd88;p=open-adventure.git diff --git a/init.c b/init.c index 4d05e0f..fdde548 100644 --- a/init.c +++ b/init.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "advent.h" @@ -9,11 +10,20 @@ * Initialisation */ -void initialise(void) +long initialise(void) { if (oldstyle) printf("Initialising...\n"); + /* Initialize our LCG PRNG with parameters tested against + * Knuth vol. 2. by the original authors */ + game.lcg_a = 1093; + game.lcg_c = 221587; + game.lcg_m = 1048576; + srand(time(NULL)); + long seedval = (long)rand(); + set_seed(seedval); + for (int i = 1; i <= NOBJECTS; i++) { game.place[i] = LOC_NOWHERE; } @@ -57,4 +67,6 @@ void initialise(void) } } game.conds = setbit(11); + + return seedval; }