fixed random dice rolling bug (uneven distribution of 1s)

This commit is contained in:
TLINDEN
2015-08-02 21:19:29 +02:00
parent 3ee9296066
commit 396b832327
3 changed files with 2 additions and 20 deletions

View File

@@ -89,11 +89,12 @@ unsigned char *toss(int count, int dicenum) {
for(i=0; i<RLEN; i++) {
onedice = rand[i];
onedice &= 7; /* only use the last 3 bits, 0-7 */
onedice %= 6; /* 6 is the max */
if(onedice >= 1 && onedice <= 6) {
tosses[pos] = onedice;
pos++;
}
else
continue;
if(pos == count)
break;
}