Hi all. I have a sort-of computer sciencey question, I have no formal training in it, I’m half-remembering stuff from a book by David Mackay on Information Theory that I don’t have to hand at the moment.
I have a file consisting of lots of random bits. I want to simulate dealing lots of Bridge hands, that is, 4 players each getting 13 cards from a standard jokerless pack of playing cards.
Here’s what’s going through my head. The total number of distinct hands (distribution of all the cards amongst four players, where it matters who gets which bunch of 13, but not what order the cards come to an individual player) is 52C13 * 39C13 * 26C13 =~ 5.36e28 (hope the crude ASCII notation is clear). Therefore it should be possible to encode such a hand in 96 bits ( log2 5.36e28 =~ 95.43 ). My two sticking points are:
How does one actually go about mapping the 96-bit sequences onto the hands? I.e. turning ‘1011010101101000…’ into ‘South: Spades AJ95 Hearts 72…’
How does one use the leftover 0.56… of a bit? It suggests to me that slightly half of all possible 96-bit sequences would not correspond to a meaningful hand. Do I just have to discard such sequences and reach for the next 96 bits? Or is there a way of extracting some of that information and then getting the next (say) 8 bits in the file and constructing a hand from that? Bear in mind that I want all hands to be equally probable.