Re: Card dealing and random repetition
- From: Simaldeff Blaldieri <simaldeff@xxxxxxxxx>
- Date: Sun, 26 Mar 2006 19:17:44 +0200
I though about something while reading your post.
Have you ever seen someone shuffle a deck? it's quite interesting, and inspiring for an 'elegant' way to simulate a shuffle.
example 1 : Poker dealer "show off"
The dealer divide the deck in two parts, trying to make them equally big (but I estimate the error margin being between 1 to 5 cards from the count of 26 cards per half-deck). Then he shuffle them trying to alternate 1 card from the right-half-deck and one from the left-half-deck (here there is a slight probability of 2 card staying stuck together and not being separated during the shuffle, the probability of 3 staying unseparated is even slighter and 4 cards is nearly impossible if the dealer is good at this) by bending the cards and releasing each deck next to each other.Then repeat 1 to 3 time and then deal.
SO doesn't it look simple to emulate in a program?
Take your array of 52 cards.
Divide it in 2 sub arrays, with a random error of 1 to 5 cards difference.
Shuffle : adding a random probability of the next card on the array being picked instead of the next of the other array. This probability go decreasing if this already happened in the previous card.
Repeat it as much as you want.
I think this method looks funnier. Could it have any utility? It's a direct emulation of the real-world card shuffling.
Schraalhans Keukenmeester ha scritto:
Most rand() implementations, even the more sophisticated PRNG's.
are limited to 32 or 64 bits at best. Given the fact that they will always produce identical series given the same seed, it follows the randomizer repeats itself after max. 2^32 cq 2^64 numbers.
If you shuffle a deck of 52 cards, there are 52! different decks to end up with, or 8.0658175170943878571660636856404e+67 different possibilities.
(I did an experiment, not exhaustively, but I manually shuffled a deck of cards, created an array with the same card order and shuffled a deck continuously and kept track of how many cards in the shuffled deck matched the order in the 'test' array. To my shock & horror after more than a 100 billion shuffles I had only the first three cards matching. Quite bizarre! Note: I may have had more matches, but I only count rom the top, and quit when the first non-matching card is found)
I know several poker/bj-sites brag about using true random seeds each run, I still think that if there are 'just' 2^64 (18446744073709551616) possibilities there are no more than that number of ways the resulting deck is shuffled. Or am I wrong?
I'd say, only if you (RANDOMLY) reseed the randomizer between each card picked there is a chance you will eventually exhaust the possibilities.
How would one get around this problem without resorting to a true random source?
Your help/insight is very welcome.
- Follow-Ups:
- Re: Card dealing and random repetition
- From: Gerry Quinn
- Re: Card dealing and random repetition
- Prev by Date: C ++ help!
- Next by Date: Re: C ++ help!
- Previous by thread: C ++ help!
- Next by thread: Re: Card dealing and random repetition
- Index(es):
Relevant Pages
|