Public/Invoke-Roulette.ps1
function Invoke-Roulette { param ( [switch]$Show ) begin { $a, $b, $c, $d = 0, 0, 0, 0 } process { do { if((random)%6 -eq 0) { if($Show) { 'bang' } $b++ if($c -gt $d) { $d = $c } $c = 0 $a++ } else { if($Show) { 'click' } $c++ $a++ } } until($a -eq 1000) } end { 'Longest winning streak was {0}.' -f $d 'Number of losses was {0:P4}' -f ($b/$a) 'Standard loss is {0:P4}' -f (1/6) } } |