mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-25 20:34:18 -08:00
Implemented Fisher–Yates shuffle. Assumes RNG function is in form getNumber(min,max), with min and max inclusive (Did not find documentation on function)
This commit is contained in:
@@ -45,7 +45,7 @@ void Server_CardZone::shuffle()
|
||||
{
|
||||
for (int i = cards.size() - 1; i > 0; i--){
|
||||
int j = rng->getNumber(0, i);//Assuming i is inclusive, i + 1 if exclusive (end result should be a number between 0 and i [0 and i included])
|
||||
cards.swap(j,i)
|
||||
cards.swap(j,i);
|
||||
}
|
||||
playersWithWritePermission.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user