phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
October 31st, 2019 at 7:57:10 AM permalink
I'm interested in understanding the mathematics behind how the odds for the Blackjack sidebet 21+3 have been calculated.

For those who are unaware, 21+3 uses the player's first two cards and the dealer's first card to ascertain whether a win has occurred.

The odds as per the Wizard of Odds page for 8-decks are listed as:

Type Payout Total Chance Return
Suited three of a kind 100 2,912 0.000244 0.024446
Straight flush 40 24,576 0.002063 0.082524
Three of a kind 25 61,568 0.005169 0.129213
Straight 10 368,640 0.030947 0.309465
Flush 5 700,928 0.058841 0.294207
Loser -1 10,753,536 0.902736 -0.902736


I'd like to understand how to calculate these programatically, although just understanding the mathematical process behind the calculation is probably enough.

The original page is here.

Kind Regards,
Phoenix
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
Thanked by
phoenixqueueMrCasinoGames
October 31st, 2019 at 8:08:16 AM permalink
The page you refere to is https://wizardofodds.com/games/blackjack/side-bets/21plus3/

You have to work out all the permuations, and discount ones already done.

Consider "Version 6" with 8 decks.

Suited three of a kind can be any of 52 cards, there are 8 or each card (e.g. 7 of diamonds).
The second card has to be the same (now there are only 7 left),
The third card has to be the same (now there are only 6 left).
So permutations are 52* (8*7*6/6) = 2912.

Straight flush
There are 4 suits and 12 ways to get a straight A23, 234, ... QKA (i.e. A thru Q can have a straight)
For each one there are 8 ways to get each card.
So permutations are 48 * 8 * 8 * 8 = 24,576.

Use similar logic for other hands (for trips subtract suited trips and straights subtract SF).
phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
October 31st, 2019 at 8:13:47 AM permalink
Thank you, that is a great explanation and I am going to get coding on putting this in action.

As a variation on the above, how would the outcomes be calculated in the event of a partial deck?

For example, if 30 random cards had been dealt and discarded (so 386 remain), how would I apply the same to calculate the updated probabilities in the case of Suited Three of a Kind (for example)?
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
Thanked by
phoenixqueueMrCasinoGames
October 31st, 2019 at 8:25:45 AM permalink
One way is to develop a spreadsheet. I know some people (e.g. miplet) use the makeup of the deck and work from there (adding each possible hand, e.g. 3 suited would be sum of N N-1 N-2 for each card).

If the cards are 30 random then it doesn't make any difference.

If the cards are specific (i.e. you know which they are) then if the above doesn't work it's probably best to do a simulation. If you're getting into developing a method to count cards and detect when the bet might be positive, then that probably gets complicated. There's a lot of code to develop, creating random shoes and you'll then code what the spreadsheet would hae done.
phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
October 31st, 2019 at 8:32:25 AM permalink
Thanks once again for your answer.

I believe I misled you when I said "30 random" cards. I mean 30 cards that I am aware of but they are randomly taken from the 8-decks.

So I'd like to programatically calculate how the odds differ dependent upon the remaining 386 cards.

Of course, a forum may be the wrong place to try to glean such information, but if you happened to know of any useful guides to get me started I would appreciate it. I'm a programmer by trade so not afraid to get my hands dirty :)

Thanks,
PQ
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
Thanked by
phoenixqueue
October 31st, 2019 at 8:49:12 AM permalink
There are two scenarios I see.

(i) Let's assume you are playing Blackjack online and can record the first 30 cards. The aim is to detect when a sidebet becomes in the player's advantage.

In this case create a spreadsheet where you can enter the cards gone, calculate the deck left, and work through all the hands that can be made from the modified deck.

(ii) Let's assume you want to develop a counting method that can be used in a live casino and detect an advantage.
(That's what I assumed when writing the last paragraph.)

It would take ages to analyse every combination of 30 cards, which is why you need to develop a method of running simulations and look for patterns. I'm guessing it would be based on having a large number of one suit having gone, or perhaps a large number of specific ranks.

You need to develop a method of "counting", something you might use at the table. You have to work out what things you want to count, this means looking at "Effect of Removal" etc. Then you also need to develop a good random number generator and method to shuffle the cards. Then you need to collate the results based on the counts.

btw Some people have the expertise to work through all the combinations of cards, especially when looking at poker games, but I've never done that for more than this many cards. Typically you have to narrow down the numbers (e.g. see that a deck missing As As As is the same as Ah Ah Ah.)


This is the right forum but I'm not aware of any books/guides that tell you exactly how to do all this. Personally I just learnt, looked up various algorithms etc. There are some ideas by others of how to categorise poker hands rather than running every combination.
phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
November 1st, 2019 at 1:26:25 AM permalink
Thank you once again for your detailed and useful response.

I've written some code already to calculate the chance of a Suited Three of a Kind, but it's returning exactly twice as many outcomes as per the formula you pointed out.

I'm struggling a little with the logic behind calculating this.

For any card in an 8-deck stack, you stated that the permutations are:


52 * (8 * 7 * 6 / 6) = 2912


Where does the final /6 come from to make this 2912 instead of 17,472?

My faulty logic has me at this juncture:


I have a card (ex: Ace of Diamonds)

How many other cards match my card? (answer: 7 out of 415)

How many other cards match that card? (answer: 6 out of 408)

Therefore, the chance of a Ace of Diamonds Suited Three of a Kind is:
7 * 6 = 42
The chance of NOT an Ace of Diamonds Suited Three of a Kind is:
7 * 408 + 408 = 3,264


However, my code is wrong. The answer should be 56 'chances' and I don't know how many 'not chances'.

I'm sure I'm being quite dim here and I apologise for it. I'd appreciate your continued insights into how I am not calculating this correctly.
charliepatrick
charliepatrick
  • Threads: 39
  • Posts: 3017
Joined: Jun 17, 2011
Thanked by
phoenixqueue
November 1st, 2019 at 1:53:49 AM permalink
Consider the eight decks but you number every card; so deck 1's Ace of Diamonds is 1Ad, etc.

Then you have three Ace of Diamonds with any combination of {1Ad, 2Ad, ... 8 Ad}; The ways of doing this are (8*7*6)/6. This is because 1Ad 2Ad 3Ad is the same combination as 2Ad 1Ad 3Ad etc. Usually you divide by 6 as you don't care which order the cards come in, and this eventually should give a total for all hands of (416*415*414)/6.

btw when you said P(2nd card == 1st card) then it's 7/415, but P(3rd card == 2nd card) = 6/414.
phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
November 1st, 2019 at 1:54:23 AM permalink
I think I've made some progress since I posted this.

For an 8-deck game:

The chance is:


Chance of any card matching 1st card:
7 out of 415
7/415 = ~0.01686747

Chance of any card matching 2nd card:
6 out of 414
6/414 = ~0.014492754

Therefore, chance is:
~0.01686747 * ~0.014492754 = ~0.000244456


So I can now successfully calculate the correct odds.

However, to put it into context I need to find out how many combinations of cards there are. This is what I am stuck on now(!)


Combinations of cards:
416 * 415 * 414 = 71,471,960

Giving the number of chances of the hand of:
71,471,960 * ~0.000244456 = 17,472


However, the correct answer is 11,912,160 and 2,912 combinations. This is the answer I have divided by 6. Why is it divided by 6?

The same calculation with 6 decks gives me a chance of ~0.000207447 and 30,079,920 combinations (giving 6,240 chances), but it should be 5,013,320 (giving 1,040 chances). It should be exactly divided by 6 again, but why?
phoenixqueue
phoenixqueue
  • Threads: 1
  • Posts: 6
Joined: Oct 31, 2019
November 1st, 2019 at 1:56:47 AM permalink
I posted the above whilst you were posting your original reply. Thank you for the clarification regarding that. Of course, for 3 cards there are 6 permutations as order doesn't matter - I was being a bit slow then!

Thank you for clarifying this and all your help. I'm going to get back to my program now and get this finished off.

I really appreciate your time and effort helping me with this.
  • Jump to: