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:
parent
2ad09399f4
commit
1d3667f37d
1 changed files with 1 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue