The documentation for the Powershell Get-Random cmdlet suggests that the seed is the system tick count but ,if the following test is performed ,the value of $rand1 is not replicated in the output of the for() loop and so appears to be independent of the TickCount. Why is this?
// generate a random int32 - should automatically use the tickcount as seed?
$tick1 = ([Environment]::TickCount)
$rand1 = Get-Random
Write-Host $rand1
$tick2 = ([Environment]::TickCount)
// generate seeded randoms with all possible values used to generate $rand1
for ($i = $tick1; $i -le $tick2; $i++){
$rand2 = Get-Random -SetSeed $i
Write-Host $rand2
}
Aucun commentaire:
Enregistrer un commentaire