Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!news.ecn.bgu.edu!psuvax1!news.math.psu.edu!chi-news.cic.net!newsxfer.itd.umich.edu!news.mathworks.com!news.kei.com!nntp.coast.net!torn!watserv3.uwaterloo.ca!undergrad.math.uwaterloo.ca!eadengle
From: eadengle@dino.uwaterloo.ca (Ed "Cynwrig" Dengler)
Subject: Re: Card Game Project
Sender: news@undergrad.math.uwaterloo.ca (news spool owner)
Message-ID: <DJ52GF.LtA@undergrad.math.uwaterloo.ca>
Date: Wed, 6 Dec 1995 00:24:15 GMT
References: <4908q6$f11@medici.trl.OZ.AU> <7f3_9511260100@rtbbs.iaf.nl> <30BF4D3F.5B70@mailhost.gg.caltech.edu> <49uv6i$m53@elektron.et.tudelft.nl>
Nntp-Posting-Host: dino.uwaterloo.ca
Organization: University of Waterloo
Lines: 92

In article <49uv6i$m53@elektron.et.tudelft.nl>,
Melle Koning  <4921284@hsu1.> wrote:
>Preston Pfarner <presto@mailhost.gg.caltech.edu> wrote:
>>melle@rtbbs.iaf.nl (Melle Koning) writes:
>>: A shuffle _by hand_ is indeed *very* imperfect. However it is > mathematicly proven that there is a handshuffle that counts as > 'perfect'. It is like this 
>>: 
>>: Repeat seven times:
>>:    devide deck in two halfs.
>>:    put the decks next to each other
>>:    make one deck from the two decks by pushing them into each other.
>
>>One interesting point is that if you follow this algorithm exactly, but with
>>the substitution of "eight" for "seven", something entirely different happens.
>>The final ordering is _the_same_ as the original ordering.  If you're into
>>group theory, that's because the "shuffle" operator is of order 8 in the group
>>of card orderings.
>
>Nope.
>
>7 gives a perfect shuflle. It now doesn't matter if you shuffle more than 
>7 times. 8/9/10... whatever more shuffles still give the cards prefect 
>randomness.
>

7 does not give a perfect shuffle.  Any algorithm which you can follow
_exactly_ means that you will not get a perfect shuffle.  A perfect
shuffle _requires_ some form of randomness.  For example, if you use the
shuffle as described you get the following decks for each shuffle:

Deck 1: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Deck 2: aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ
Deck 3: anANboBOcpCPdqDQerERfsFSgtGThuHUivIVjwJWkxKXlyLYmzMZ
Deck 4: aGnTAhNubHoUBiOvcIpVCjPwdJqWDkQxeKrXElRyfLsYFmSzgMtZ
Deck 5: aqGWnDTkAQhxNeuKbrHXoEUlBRiyOfvLcsIYpFVmCSjzPgwMdtJZ
Deck 6: aiqyGOWfnvDLTcksAIQYhpxFNVemuCKSbjrzHPXgowEMUdltBJRZ
Deck 7: aeimquyCGKOSWbfjnrvzDHLPTXcgkoswAEIMQUYdhlptxBFJNRVZ
Deck 8: acegikmoqsuwyACEGIKMOQSUWYbdfhjlnprtvxzBDFHJLNPRTVXZ
Deck 9: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

Noticed that we have created an 8-cycle with the cards.  The reason
that this shuffle works well _in general_ is because when you do
the "split the deck in two haves" and "make one deck from two" both of
these introduce randomness.  In the first case, you will probably split
the deck into two piles, one of which will contain 26 +- up to 10 cards.
In the second case, as you "riffle" the cards together, you invariably
will "clump" cards by interleaving them 1-4 cards at a time from each
smalleer deck.  The analysis done was to show that performing this
form of shuffling _with_ the randomness is a firly good shuffle.

>>
>>After doing this 7 times instead of 8, you are left one shuffle away from
>>restoring your pre-shuffled state.  Your cards are not random at all, but are
>>in some order that is dependent on the pre-shuffled order.
>
>Nononono... if you do it SIX times, your cards are in some dependency of 
>the previous state. With seven, the barrier is broken, and you can't get 
>them back in a previous state by simple doing one shuffle more...

As you can see from above, it doesn't matter how many times you do
this, each new deck is dependent on the deck before.

>
>  This makes it
>>sound like a bad method, but it isn't for some contexts.
>>
>>One reason that this works for humans is that we can't follow the instructions
>>well.  When was the last time that you managed to do a single shuffle 
>>(as above) none of the cards got clumped?  I mean that you're really taking a
>>random number of cards from each half-deck each time.  This, then, is a very
>>different operator than the "perfect shuffle".  It will result in a random 
>>configuration.  It's hard to say how good the randomness is, but it works for
>>card games with humans.
>>
>>What it comes down to is that the algorithm above describes a good method for
>>humans to shuffle a deck, but definitely not a good way for computers to do so.
>
>No, the algorithm of seven shuffles is REALLY good. 
>
>Nevertheless, for computers there are easier shuffling methods like Court 
>has already described.
>
>Ciao,
>Melle
>

For computers, we can create a shuffle that is as good as the pseudo-random
number generator.  These shuffles will in general be better than a
human-generated algorithm, though the human-generated method is
"good enough" for play.

Ed

