Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $deck = @(
- '♥A','♥2','♥3','♥4','♥5','♥6','♥7','♥8','♥9','♥10','♥J','♥Q','♥K',
- '♣A','♣2','♣3','♣4','♣5','♣6','♣7','♣8','♣9','♣10','♣J','♣Q','♣K',
- '♦A','♦2','♦3','♦4','♦5','♦6','♦7','♦8','♦9','♦10','♦J','♦Q','♦K',
- '♠A','♠2','♠3','♠4','♠5','♠6','♠7','♠8','♠9','♠10','♠J','♠Q','♠K'
- )
- Function Cut-Deck($Deck) {
- $splitAt = Get-Random -Minimum 19 -Maximum 34 # So split between index 19 and 33 of the deck.
- [pscustomobject]@{
- LeftHand = [System.Collections.Generic.Stack[object]]$Deck[0..($splitAt - 1)]
- RightHand = [System.Collections.Generic.Stack[object]]$Deck[$splitAt..51]
- }
- }
- Function Shuffle-Deck($TwoPiles) {
- $singlePile = New-Object 'System.Collections.Generic.List[object]'(52)
- while ($TwoPiles.LeftHand.Count -gt 0 -or $TwoPiles.RightHand.Count -gt 0) {
- if ($TwoPiles.LeftHand.Count -gt 0) {
- $singlePile.Add($TwoPiles.LeftHand.Pop()) # release bottom card
- if ($TwoPiles.LeftHand.Count -gt 0 -and -not (Get-Random -Maximum 6)) { # ~17% chance of occurring -
- # my left hand isn't what it used to be...
- # My hands are a little unsteady... one extra card was let go.
- $singlePile.Add($TwoPiles.LeftHand.Pop())
- }
- }
- if ($TwoPiles.RightHand.Count -gt 0) {
- $singlePile.Add($TwoPiles.RightHand.Pop()) # release bottom card
- if ($TwoPiles.RightHand.Count -gt 0 -and -not (Get-Random -Maximum 10)) { # 10% chance of occurring.
- # My hands are a little unsteady... one extra card was let go.
- $singlePile.Add($TwoPiles.RightHand.Pop())
- }
- }
- }
- return $singlePile
- }
- $numberOfShuffles = 4
- for ($i = 0; $i -lt $numberOfShuffles; $i++) {
- $splitDeck = Cut-Deck -Deck $deck
- $deck = Shuffle-Deck -TwoPiles $splitDeck
- }
- $deck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement