mirror of
https://codeberg.org/scip/diceware.git
synced 2025-12-17 10:50:57 +01:00
fixed random dice rolling bug (uneven distribution of 1s)
This commit is contained in:
@@ -182,13 +182,6 @@ The program only uses words which contain 7bit \s-1ASCII\s0 letters
|
|||||||
<https://xkcd.com/936/>.
|
<https://xkcd.com/936/>.
|
||||||
.SH "BUGS"
|
.SH "BUGS"
|
||||||
.IX Header "BUGS"
|
.IX Header "BUGS"
|
||||||
.IP "\(bu" 4
|
|
||||||
Program rolled dices are using a pseudo random device, thanks
|
|
||||||
to some yet unknown reason the digits of dice rolls are unevenly
|
|
||||||
distributed, in fact there are 20% as much 1s as other digits.
|
|
||||||
.Sp
|
|
||||||
Use the option b<\-t> with physical dices to mitigate this.
|
|
||||||
.PP
|
|
||||||
In order to report a bug, unexpected behavior, feature requests
|
In order to report a bug, unexpected behavior, feature requests
|
||||||
or to submit a patch, please open an issue on github:
|
or to submit a patch, please open an issue on github:
|
||||||
<https://github.com/TLINDEN/diceware/issues>.
|
<https://github.com/TLINDEN/diceware/issues>.
|
||||||
|
|||||||
@@ -46,18 +46,6 @@ L<https://xkcd.com/936/>.
|
|||||||
|
|
||||||
=head1 BUGS
|
=head1 BUGS
|
||||||
|
|
||||||
=over
|
|
||||||
|
|
||||||
=item *
|
|
||||||
|
|
||||||
Program rolled dices are using a pseudo random device, thanks
|
|
||||||
to some yet unknown reason the digits of dice rolls are unevenly
|
|
||||||
distributed, in fact there are 20% as much 1s as other digits.
|
|
||||||
|
|
||||||
Use the option b<-t> with physical dices to mitigate this.
|
|
||||||
|
|
||||||
=back
|
|
||||||
|
|
||||||
In order to report a bug, unexpected behavior, feature requests
|
In order to report a bug, unexpected behavior, feature requests
|
||||||
or to submit a patch, please open an issue on github:
|
or to submit a patch, please open an issue on github:
|
||||||
L<https://github.com/TLINDEN/diceware/issues>.
|
L<https://github.com/TLINDEN/diceware/issues>.
|
||||||
|
|||||||
@@ -89,11 +89,12 @@ unsigned char *toss(int count, int dicenum) {
|
|||||||
for(i=0; i<RLEN; i++) {
|
for(i=0; i<RLEN; i++) {
|
||||||
onedice = rand[i];
|
onedice = rand[i];
|
||||||
onedice &= 7; /* only use the last 3 bits, 0-7 */
|
onedice &= 7; /* only use the last 3 bits, 0-7 */
|
||||||
onedice %= 6; /* 6 is the max */
|
|
||||||
if(onedice >= 1 && onedice <= 6) {
|
if(onedice >= 1 && onedice <= 6) {
|
||||||
tosses[pos] = onedice;
|
tosses[pos] = onedice;
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
continue;
|
||||||
if(pos == count)
|
if(pos == count)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user