railer Joined: Mar 2, 2012
• Posts: 18
August 14th, 2019 at 11:37:43 AM permalink
I'm working on a CA engine for Baccarat. It seems the easiest way to go about it is to:

1) enumerate every possible Baccarat hand
2) calculate the probability of that hand given the deck composition
3) calculate the result of each hand * the probability of it occurring
4) Sum the results

My challenge is actually enumerating every hand. The cool thing about Baccarat is that the whole universe of hands can be expressed as all 6 card subsets, even though most hands will not use 6 cards. The cards are valued 0-9 so there's 10^6 possible hands in a six-deck game, minus the hands that don't use 6 or 5 cards. Eliot Jacobson states that the total number of individual hands is 302,500 ....I got a different number 339400. He actually posted an excel sheet with every combination, but he stopped maintaining his site and the sheet is no longer available. Can anybody help me with the total number of hands or does anyone have access to Jacobson's sheet?

-Thanks!
Wizard Joined: Oct 14, 2009
• Posts: 23607
August 14th, 2019 at 11:42:29 AM permalink
I use a simple looping program for baccarat. You don't need to worry about the suits, just keep track of the 10 different point values in a deck (0 to 9).
It's not whether you win or lose; it's whether or not you had a good bet.
miplet Joined: Dec 1, 2009
• Posts: 1981
Thanks for this post from: August 14th, 2019 at 11:45:29 AM permalink
I have my spreadsheet at http://miplet.net/baccarat/ .
�Man Babes� #AxelFabulous
DogHand Joined: Sep 24, 2011
• Posts: 458
Thanks for this post from: August 14th, 2019 at 2:05:46 PM permalink
railer,

Because the order of each side's first two cards doesn't matter, each side has 10*11/2=55 possibilities for its first two cards: 00, 01, 02, ..., 09, 11, 12, 13, ..., 19, 22, 23, ..., 29, 33, 34, etc., using 1 for A and 0 for X.

Thus, for the first four cards we have 55*55=3025 combinations.

The next two cards have 10*10=100 combinations.

Thus, the total is 302,500 as EJ claims.

Hope this helps!

Dog Hand
7craps Joined: Jan 23, 2010
• Posts: 1977
August 14th, 2019 at 2:58:32 PM permalink
Quote: railer

Eliot Jacobson states that the total number of individual hands is 302,500 ....I got a different number 339400. Can anybody help me with the total number of hands or does anyone have access to Jacobson's sheet?

for Banker, combinations with repetition is 11!/(2!*9!) = 55
https://www.mathsisfun.com/combinatorics/combinations-permutations-calculator.html
`Types to choose from? 10Number Chosen? 2Is Order important? NoIs Repetition allowed? YesCombinations: 55`

55^2 * 10^2 = 302,500

but miplet listed his

and
each hand (302,500) is not equal probable as you pointed out (I think)

"My challenge is actually enumerating every hand."
yes, some like to reinvent the wheel themselves

How do you actually want to do that?
One could do this by hand, if time is not a deciding factor.
winsome johnny (not Win some johnny)
railer Joined: Mar 2, 2012
• Posts: 18
August 14th, 2019 at 3:25:36 PM permalink
Thank You!

Miplet: Great Spreadsheet. I did one almost exactly the same. Like you, I eliminated hands where the first two cards dealt to Player/Banker are reversed. Using this method, arrived at 103,411 unique hands, same as your result.

Doghand: Ahhhhh! I see where EJ gets that number from, and this is what was confusing. So, 302,500 is the number of possible 6 card subsets after eliminating the redundant first two card combinations. This answer isn't really complete, however, because many of these combinations aren't actual Baccarat Hands (ie. 095 vs. 123 wouldn't happen on a Bac. table). Also, Just as a general probability question...I understand how to calculate the 55 combinations of each side (10+9+8...+1), but how do you generalize that expression mathematically as 11*10/2 ?
Last edited by: railer on Aug 14, 2019
railer Joined: Mar 2, 2012
• Posts: 18
August 14th, 2019 at 3:46:42 PM permalink
Quote:

"My challenge is actually enumerating every hand."
yes, some like to reinvent the wheel themselves

How do you actually want to do that?
One could do this by hand, if time is not a deciding factor.?

Dig it. Excel Row() Function down to 999,999---> multiply each number by .000001 (make sure numbers are formatted to 6 digits)----->text to columns and separate all the digits---->add 000000 by hand. You've got all 1M 6-card baccarat hands.

Now, use a series of IF() Functions with the rules of Baccarat to determine your 4,5,and 6 card hands----->Use Sort Functions to sort for 4 and 5-card hands and eliminate cards that won't appear (replacing blank spaces with a *)---->Use Concatenate() Function to bring each 6 cell hand together again. Now, you have a million hands with duplicates.

Highlight the row of hands and press the awesome "Remove Duplicates" function embedded in Excel. You're done. 90 mins tops.
DogHand Joined: Sep 24, 2011
• Posts: 458
August 16th, 2019 at 8:59:42 PM permalink
Quote: railer

<snip>Doghand: Ahhhhh! I see where EJ gets that number from, and this is what was confusing. So, 302,500 is the number of possible 6 card subsets after eliminating the redundant first two card combinations. This answer isn't really complete, however, because many of these combinations aren't actual Baccarat Hands (ie. 095 vs. 123 wouldn't happen on a Bac. table).

railer,

That's true. The spreadsheet also has to calculate the probability of each of the 302,500 combinations (based on the specified shoe composition), as well as the baccarat value of each. For the six-card subset you mentioned, the spreadsheet would score this as 9 vs. 3, with each side using 2 cards... at least that's how my spreadsheet does it.

Quote: railer

<snip>Also, Just as a general probability question...I understand how to calculate the 55 combinations of each side (10+9+8...+1), but how do you generalize that expression mathematically as 11*10/2 ?

railer,

The sum of the integers from 1 to n is equal to n*(n+1)/2, so for n=10, we get 10*11/2 = 55.

Hope this helps!

Dog Hand
railer Joined: Mar 2, 2012
• Posts: 18
August 16th, 2019 at 10:17:21 PM permalink
Thanks, DogHand!
Oli Joined: Oct 7, 2019 `# https:// colab DOT research DOT google DOT com/drive/1s5JQYFGF0W7C-jULaIkkh4TUsMha7GF6 import itertoolscard_values = [1,2,3,4,5,6,7,8,9,10]unique_hands = duct(card_values, repeat=6)# print(len(list(unique_hands)))def bacc_add(n1, n2):  return (n1 + n2) % 10def compute_outcome(hand):  [c1,c2,c3,c4,c5,c6] = hand  banker_total = bacc_add(c1, c2)  player_total = bacc_add(c3, c4)    if (player_total == 6 or player_total == 7):    if (banker_total <= 5):      banker_total = bacc_add(banker_total, c5)  elif (player_total <= 5 and banker_total < 8):    player_total = bacc_add(player_total, c5)    if (banker_total <= 2):      banker_total = bacc_add(banker_total, c6)    elif (banker_total == 3 and c5 != 8):      banker_total = bacc_add(banker_total, c6)    elif (banker_total == 4 and c5 in [2, 3, 4, 5, 6, 7]):      banker_total = bacc_add(banker_total, c6)    elif (banker_total == 5 and c5 in [4, 5, 6, 7]):      banker_total = bacc_add(banker_total, c6)    elif (banker_total == 6 and c5 in [6, 7]):      banker_total = bacc_add(banker_total, c6)    if (banker_total > player_total):    return 'banker'  elif (player_total > banker_total):    return 'player'  return 'tie'  example_hand = (5, 1, 3, 2, 2, 6)compute_outcome(example_hand)n_suites = 4def count_hands(hand, n_decks = 8):  normal_count = n_suites * n_decks  # number of cards in shoe for each type of card  card_counts = {      '1': normal_count,      '2': normal_count,      '3': normal_count,      '4': normal_count,      '5': normal_count,      '6': normal_count,      '7': normal_count,      '8': normal_count,      '9': normal_count,      '10': normal_count * len(['10', 'J', 'Q', 'K'])  }  # count possible ways to form hand from shoe  count = 1  for c in hand:    count = count * card_counts[str(c)]    # "remove card from shoe"    card_counts[str(c)] -= 1  return countexample_hand = (5, 1, 3, 2, 2, 6)count_hands(example_hand)counts = { 'tie':0, 'banker':0, 'player':0 }for hand in unique_hands:  outcome = compute_outcome(hand)  count = count_hands(hand)  counts[outcome] += countprint(counts)tie = counts['tie']banker = counts['banker']player = counts['player']total_count = tie + banker + playerprint('total count', total_count)print('probabilities:')print('tie:', tie / total_count)print('banker:', banker / total_count)print('player:', player / total_count)`