If divident negative, then remainder is negative too.

RNG values need to be always positive.
Solution: Transposing positively by divisor. In all the two places it may happen.
This commit is contained in:
NHOrus 2017-09-11 21:20:46 +03:00
parent 4e4c2e0198
commit 076bb8908b
2 changed files with 9 additions and 2 deletions

View file

@ -145,6 +145,11 @@ bool is_valid(struct game_t* valgame)
valgame->lcg_x %= LCG_M;
}
/* Check for RNG underflow. Transpose */
if (valgame->lcg_x < LCG_M) {
valgame->lcg_x = LCG_M + (valgame->lcg_x % LCG_M);
}
/* Bounds check for locations */
if ( valgame->chloc < -1 || valgame->chloc > NLOCATIONS ||
valgame->chloc2 < -1 || valgame->chloc2 > NLOCATIONS ||