Fix off by one error inf shuffle_deck()
This commit is contained in:
parent
1aa7e560f1
commit
5cd663b589
@ -153,8 +153,8 @@ static void shuffle_deck(struct deck *deck) {
|
||||
card[i] = stack_pop(&(deck->stock));
|
||||
}
|
||||
srand(time(NULL));
|
||||
for (int i = 0; i < NUMBER_OF_CARDS - 1; i++) {
|
||||
random = i + (rand() % (NUMBER_OF_CARDS) - i);
|
||||
for (int i = 0; i < NUMBER_OF_CARDS; i++) {
|
||||
random = rand() % (NUMBER_OF_CARDS);
|
||||
tmp = *card[i];
|
||||
*card[i] = (*card[random]);
|
||||
*card[random] = tmp;
|
||||
|
Loading…
Reference in New Issue
Block a user