[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Shufflebug



On Tue, Jul 18, 2000 at 03:36:53PM -0400, Bernie Cosell wrote:
> 
> Not quite: for bridge, you only have to randomize the position *mod*4 
> -- this is actually a lesser constraint than having to have a shuffle 
> that can generate all 52! [or whatever it is] shuffles with equal 
> probability.  That is, you don't care that card A's *position* is 
> indpendent of its position in the pre-shuffled deck, but rather that 
> *the*hand*that*gets*it* is independent of that...  alas, I can't 
> offhand come up with an algorithm that I can defend that just makes a 
> "random deal" [rather than a randomly shuffled deck] but my intution 
> says we ought to be able to come up with one...


That's easy. With C(n,k) the "choose" function, (the number of ways to pick
k items from a set of n), the number of different bridge hands is:

    C(52,13) * C(39,13) * C(26,13) * C(13,13)

which evaluates to 52!/((13!)**4), and that gives us:

    perl -we '$"="*";@a=(1..52);@b=(1..13);print`echo "@a/(@b)^4"|bc`'
    53644737765488792839237440000

And 2^95 < 53644737765488792839237440000 < 2^96.

But does that help us anything? In fact, this might be worse. The 2^32
different shuffles don't have to result in 2^32 different bridge hands.
In fact, it would not be impossible to have a shuffling algorithm, that
would be fair if the rand() would be truely random, that does generate
2^32 different shuffles, but always results in the same bridge hands...



Abigail

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe