X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;f=random.c;h=51f6774b70503b853642dac80b979698461e49ad;hb=4dc55f36080bc8cc78c07efe25bf3f222c3d0a9a;hp=3fbf912d64b4f9cfca5e478f9625f4864a978635;hpb=cdf203b95bccd0e7e01e83800ad8435f4a2da8c3;p=physik%2Fmorpheus.git diff --git a/random.c b/random.c index 3fbf912..51f6774 100644 --- a/random.c +++ b/random.c @@ -10,7 +10,7 @@ #include "defines.h" /* global and extern variables */ -extern u32 sum_z_cells; +extern u32 gr; extern int random_fd; /* return random integer between 0 - max-1 */ @@ -27,10 +27,12 @@ u32 rand_get(u32 max) } /* get z value (linear growth of probability with depths) */ -u32 rand_get_lgp(int slope_nel,int start_nel) { +u32 rand_get_lgp(int slope_nel,int start_nel,u32 z_max) +{ int z; - u32 i; - z=rand_get(sum_z_cells)+1; /* +1 as rand_get returns values 0...max-1 */ + u32 i,weighted_sum_z; + weighted_sum_z=z_max*start_nel+slope_nel*gr; + z=rand_get(weighted_sum_z)+1; /* +1 as rand_get returns values 0...max-1 */ for(i=1;;i++) { z-=(start_nel+i*slope_nel); if(z<=0) break;