How to really shuffle a deck of cards

后端 未结 5 2169
孤独总比滥情好
孤独总比滥情好 2021-02-04 08:16

When I need to shuffle a deck of poker cards in Java/Android, I use Collections.shuffle(List list), of course. I\'ve ever been doing this and the results s

5条回答
  •  离开以前
    2021-02-04 09:07

    How to really shuffle a deck?

    There are several shuffling techniques.

    Either (Stripping/Overhand):

    Cut the deck in two
        Add a small (pseudorandom) amount of one half to the front of the front of the other
        Add a small (pseudorandom) amount of one half to the front of the back of the other
    Do this until one hand is empty
    Repeat
    

    Or (Riffle):

    Cut the deck in two
        Set down a small (pseudorandom) portion of one half
        Set down a small (pseudorandom) portion of the other
    Do this until both hands are empty, and you have a new deck
    Repeat
    

    And there are more on top of this, as detailed in my link above.


    Regardless, there are so many combinations that even the perfect shuffling algorithm would take a machine exploring 2*10^50 unique permutations per second to finish exploring every permutation in the time the universe has existed. Modern computers are only predicted to hit 1 ExaFLOPs (1*10^18 floating point operations per second) by 2019.

    No human shuffler will explore that range of possibilities either, and you are, I believe (at the most basic level) simulating a human shuffling, correct? Would you find it likely that a croupier could shuffle an incrementally ordered deck into decreasing order in one shuffle? To split the deck with even ranks before odd, in one shuffle?

    I don't find it unacceptable to limit yourself to a (albeit extremely) small subsection of that phase space (2^48 possible random numbers) in each shuffle, so long as you don't continuously seed the same way etc.

    There are exactly 52 factorial (expressed in shorthand as 52!) possible orderings of the cards in a 52-card deck. This is approximately 8×1067 possible orderings or specifically: 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000.
    The magnitude of this number means that it is exceedingly improbable that two randomly selected, truly randomized decks, will ever, even in the history of the Universe, be the same. However, while the exact sequence of all cards in a randomized deck is unpredictable, it may be possible to make some probabilistic predictions about a deck that is not sufficiently randomized.
    ~Wikipedia

    Also, it's worth noting that Bayer & Diaconis in 1992 proved it only takes 7 good shuffles to properly randomize a deck, here is the section on it from wikipedia which has plenty links to papers discussing this.

提交回复
热议问题