mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
the man page says it is impossible to cheat, but since the shuffle is
lopsided, a sharp counter can detect uneven permutations. fix this by using knuth shuffle. ok mlarkin pjanzen
This commit is contained in:
parent
e3490c9c4a
commit
a8ed32d4ad
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: canfield.c,v 1.13 2013/08/29 20:22:11 naddy Exp $ */
|
||||
/* $OpenBSD: canfield.c,v 1.14 2014/11/03 19:18:16 tedu Exp $ */
|
||||
/* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */
|
||||
|
||||
/*
|
||||
@ -533,8 +533,8 @@ shuffle(struct cardtype *deck[])
|
||||
deck[i]->visible = FALSE;
|
||||
deck[i]->paid = FALSE;
|
||||
}
|
||||
for (i = decksize-1; i>=0; i--) {
|
||||
j = arc4random_uniform(decksize);
|
||||
for (i = decksize - 1; i > 0; i--) {
|
||||
j = arc4random_uniform(i + 1);
|
||||
if (i != j) {
|
||||
temp = deck[i];
|
||||
deck[i] = deck[j];
|
||||
|
Loading…
Reference in New Issue
Block a user