I developed a card deck to play board game on Visio, but my friends and I have the "feeling" the cards are not well shuffled.
The code I am using is the following (I simplified but I am using the same algorithm for the verso of the cards which contains numbers, if needed I can add it):
# Actions
$CONFIG_ACTIONS = @{
"pool"=9
"interim"=9
"bis"=9
"parc"=18
"sell"=18
"barrier"=18
}
$unshuffeledListAction = [System.Collections.ArrayList]@()
foreach ($actionToAdd in $CONFIG_ACTIONS.Keys) {
[int]$howManyTime = $($CONFIG_ACTIONS[$actionToAdd])
for($i=0;$i -lt $howManyTime;$i++) {
$unshuffeledListAction.Add($actionToAdd) | out-null
}
}
# Request random number between 0 and 65535
$requestURI = "https://qrng.anu.edu.au/API/jsonI.php?length=1&type=uint16"
# Randomize Cards: Try WebService
Try {
$random = $(Invoke-RestMethod -Uri $requestURI -Method GET).data
$shuffeledListActions = $unshuffeledListAction | Get-Random -Count $unshuffeledListAction.Count -SetSeed ($random[0])
} Catch {
Write-warning "Failed to called QRNG@ANU JSON API switching to local pseudo-random"
$shuffeledListActions = $unshuffeledListAction | Get-Random -Count $unshuffeledListAction.Count
}
I have no special needs on security as this is for personal use without sensitive information, so I am OK to work with WebServices and I already made a try.
My first shuffle attempt was simply:
$shuffeledListActions = $unshuffeledListAction | Get-Random -Count $unshuffeledListAction.Count
Can it be improved? Is the second attempt with calling a quantum random number generator service better?