X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/move_up?a=blobdiff_plain;f=roguelike.c;h=c91c407360c100d71921f82ab39631b1d676197e;hb=66bc25319591a8e1b4688285c4a441faa1d78437;hp=7b2d159f878b5ea3fa4e5278d5295f5488abbd55;hpb=67396848cb5e3e55385a466d7a24a4f68d0a6c9c;p=plomrogue diff --git a/roguelike.c b/roguelike.c index 7b2d159..c91c407 100644 --- a/roguelike.c +++ b/roguelike.c @@ -8,13 +8,12 @@ #include "roguelike.h" #include "keybindings.h" -static uint32_t seed = 0; - uint16_t rrand() { // Pseudo-random number generator (LGC algorithm). Use instead of rand() to ensure portable predictability. uint32_t a = 1103515245; // Values for a and b as recommended by POSIX.1-2001 (see man page rand(3)). uint16_t b = 12345; uint32_t mod = 2147483648; + static uint32_t seed = 0; seed = ((seed * a) + b) % mod; return (seed / 65536); } // Ignore least significant 16 bits (they are less random).