Dealer probs
The way I did it; so I have the data available for all my programs that need it, is go through ALL the possibilities of hands with scores of 17 or greater. There are a GREAT many redundancies; so in creating my file "all_dlr.dat," once I had the score total, I sorted the cards within in the hand, then did a binary search of hands already processed, and put the data in a record:
struct dlr_dat{
char cards[14];
char score;
char ways; } burp;
I finally arrived at dividing the file into ten sections, divided by headers containing the dealer's up-card and the number of different hands in the segment, so I could easily step through the file to locate the data for each different up-card. You could also sort each segment by the dealer score if that would help the speed and efficiency of your app.
I purposely made cards[] larger than necessary so I could use the first null to indicate the end of the cards in the hand. For example:
prob = 1.0;
ptr = &burp.cards;
while ( card = *ptr++ )
{...if ( !cards_left[card] )
........return 0.0;
....else
........prob *= cards_left[card]-- / cards_left[0]--;
}
return prob;
where elements 1 through 10 of the 11-element "cards_left" array hold the counts of each of the cards remaining and element zero contains the total number of cards remaining.
"Score" is obvious.
"Ways" saves a LOT of processing. For example, there are 6 ways to arrange the cards in a hand of 34X. Once you have determined the probability of getting that hand, you just multiply that by "ways" and save 5/6ths of the processing time. (NB, if you separate by upcard, then there would only be two ways for the hand for each of the upcards -- a fact you must take into account when writing the program which creates the file in the first place.)