How to really shuffle a deck of cards

后端 未结 5 2167
孤独总比滥情好
孤独总比滥情好 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:03

    You may only be able to get 248 different hands from a specific starting arrangement but there's no requirement that you start at the same arrangement each time.

    Presumably, after the deck is finished (poker hands, blackjack and so on), it will be in an indeterminate order, and any one of those rearrangements will be suitable.

    And, if you're worried about the fact that you start from a fixed arrangement each time you start your program, just persist the order when exiting and reload it next time.

    In any case, 248 is still a huge number of possibilities (some 280,000,000,000,000), more than adequate for a card game, more so when you come to a realisation that it's limiting shuffles rather than arrangements. Unless you're a serious statistician or cryptographer, what you have should be fine.

提交回复
热议问题