Thread Rating:

dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 7th, 2015 at 7:55:06 AM permalink
Hi,
I am designing a Blackjack AI such that it would try to play optimally each hand against the dealer.

When I'm having a hard score the algorithm is easy: as long as my risk of busting is lower than the dealer's risk of busting (based on its visible card) I will hit, otherwise stand.

My problem is when I have a soft score. If both scores are under 21, I will have two probabilities of busting based on each version. I do not know however which score should I keep track of.

For example, if I have a soft 21, even though I have a 0% risk of busting the lower score on my next hit, it is better to stand since 21 is a very good score.

On the other hand, if I have a soft 15, it might be better to hit against a dealer's 2, even though the risk of the higher score going over 21 is larger than the risk of the dealer going bust with a 2 showing.

Could you please tell me if there is another parameter that should be considered regarding the soft scores (preferably easy to calculate)? If so, how should I use it on top of the bust probabilities?

N.B. The only two actions I am able to do are hitting and standing. I am not using any other actions such as doubling down, splitting or surrendering or changing my bet.
Dalex64
Dalex64
  • Threads: 1
  • Posts: 1067
Joined: Feb 10, 2013
May 7th, 2015 at 8:47:29 AM permalink
Lots of people have done lots of work on this before, and have made the results of their work available to the public for viewing.

In particular, I suggest you look at the Wizard of Odds Blackjack pages and appendices.

https://wizardofodds.com/games/blackjack/

https://wizardofodds.com/games/blackjack/appendix/1/
dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 7th, 2015 at 9:12:23 AM permalink
I looked over those articles, but they don't provide a clear justification on the actions regarding soft scores.

The general idea when playing is to hit if there is a lower chance of busting on the next card than it is for the dealer to bust in general.

When confronted with a soft score, there are two player scores that need to be taken into consideration, each with a different chance of busting in the next hand, but also with a different chance of winning should the player decide to focus on either one of them.

I was just wandering what parameters are taken into account when deciding on hitting on soft scores.

For example, why would a player hit on a soft 17, but stand on a hard 17, and why would a player stand on both hard and soft 18?
Donuts
Donuts
  • Threads: 24
  • Posts: 171
Joined: Oct 17, 2014
May 7th, 2015 at 9:33:32 AM permalink
Are you asking about how to code parameters for soft hands or how basic strategy was calculated for soft hands?
Romes
Romes
  • Threads: 29
  • Posts: 5602
Joined: Jul 22, 2014
May 7th, 2015 at 9:38:14 AM permalink
Quote: dvorak

... The general idea when playing is to hit if there is a lower chance of busting on the next card than it is for the dealer to bust in general...

I was just wandering what parameters are taken into account when deciding on hitting on soft scores...

For example, why would a player hit on a soft 17, but stand on a hard 17, and why would a player stand on both hard and soft 18?


No. In general, the idea is to make the best play available that has the most expected value return. What mathematicians did originally, and we still use today, is they took all of our available options (hit, stand, double, split, surrender) and they calculated the expected value of each of these plays for a particular hand over hundreds of millions of trials. These decisions all converged to a specific expected value. Thus, they took the highest one because that would be the best possible play, and that's how "basic strategy" was born.

Secondly, for your soft 17 question... 17 is not a good hand. You can only win when the dealer busts. However, you can't hit hard 17 because your expected value from standing is greater than your expected value of hitting (since you'll bust so frequently). DO NOTE... BOTH expected values from hard 17 are negative. Standing is LESS negative though, which is why it's the best play. Thus, if you have a soft 17, where you can not bust, it's a better play to try to improve your hand to something with positive expectation (19, 20, 21). If you hit your soft 17 and end up with something like a hard 13, you're still hitting twice and giving yourself 2 more cards/chances to improve from the measly 17.

Lastly, a player only stands on soft 17 to a dealer 7 or 8 (and 2 in a S17 game). This is one of the reasons A-7 is my favorite hand, it always has 'action' =P. Again, using the same process previously described, simulating millions of hands, it was proven that it's better to hit your A-7 than it is to stand on it against a dealer A-10-9. The average hand in blackjack is approximately 18.25. Some say 18.5, etc, but the point is, it's OVER 18... thus 18 is actually a LOSING hand! Most people don't realize this, so when they have A-7 they're like "why would I hit 18?!?!" when in fact it's very smart to hit it when you're up against a A-10-9, and even to double it when you're against a 2-6 (H17 game).

If you want to learn a LOT more about blackjack basics and an intro in to card counting, how it works, why it works, etc... Check out my A to Z Counting Cards in Blackjack thread.
Playing it correctly means you've already won.
dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 7th, 2015 at 9:40:06 AM permalink
I would like to know how the basic strategy was calculated for soft hands.

I can code the parameters on my own, but I don't know where to look for them.
I hope they are not something generic like 'they are like that because they showed the best results in testing'.
Romes
Romes
  • Threads: 29
  • Posts: 5602
Joined: Jul 22, 2014
May 7th, 2015 at 9:42:27 AM permalink
Quote: dvorak

I would like to know how the basic strategy was calculated for soft hands.

I can code the parameters on my own, but I don't know where to look for them.
I hope they are not something generic like 'they are like that because they showed the best results in testing'.


That's how all of basic strategy was developed. It wasn't testing. It was mathematically proven by trials in the magnitude of hundreds of millions.

You can do the actual math if you'd like... Get A-7 out of a deck, put a dealer 10 up and play out 100,000,000 hands and record your results when you stand. Then play another 100,000,000 hands and record your results when you hit. Then do the same thing for surrender, double, etc (all of your possible decisions). Then record your findings after you're all said and done and report back to us. In 1,000 years you'll let us know that basic strategy is correct =).

EDIT: If you want just math formulas, etc, look up the article from the American Math Society by the 4 horseman (Roger Baldwin, Wilbert Cantey, Herbert Maisel, and James McDermott). They did all the math by hand before computers were able to be leveraged in high volume simulations.
Playing it correctly means you've already won.
dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 7th, 2015 at 9:48:29 AM permalink
Quote: Romes

...What mathematicians did originally, and we still use today, is they took all of our available options (hit, stand, double, split, surrender) and they calculated the expected value of each of these plays for a particular hand over hundreds of millions of trials.



I agree with your point of view, except that my program intends to make decisions based on the remaining cards in the deck. I would like to be able to deduce the optimal decision based on the remaining deck structure instead of what was indicated in other trials.

I don't want to modify my bet based on the upcoming card likelihood, but I want to make the best decision with constant betting based on the remaining structure of the shoe.
Romes
Romes
  • Threads: 29
  • Posts: 5602
Joined: Jul 22, 2014
May 7th, 2015 at 9:57:09 AM permalink
Quote: dvorak

I agree with your point of view, except that my program intends to make decisions based on the remaining cards in the deck. I would like to be able to deduce the optimal decision based on the remaining deck structure instead of what was indicated in other trials.

I don't want to modify my bet based on the upcoming card likelihood, but I want to make the best decision with constant betting based on the remaining structure of the shoe.


I understand what you're saying, and doing. Sounds like you're trying to program a blackjack computer, like the ones previously used and now banned under the device law. You want optimal play for the exact given cards remaining, which by the way isn't "that" much more profitable than say a counting team. When doing this though you're dramatically increasing the amount of work, calculations etc...

You need to do something similar still. Write a program that knows all of the remaining cards. These are your inputs to your "decision" function. Pass the remaining deck of cards to this function. This function must then run simulations on that deck to find the best expected value return (similar to the previously explained). After this function runs it's simulations (and compares the EV's of your different decisions) you'll have your answer. The key difference here is you're not running simulations with random decks/etc, you're running them with your SPECIFIC deck. This is what you want. Do you have any idea how many math calculations you'd have to do NOT using a simulation? You'd have to know every possible scenario and every possible outcome at ANY given time. Hell, just for one deck that's BILLIONS if not TRILLIONS of combinations, for EVERY SINGLE ONE you'd need to know it's specific result. It's more/less impossible, which is why simulations are key.
Playing it correctly means you've already won.
dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 7th, 2015 at 10:15:34 AM permalink
I don't intend to create a program for illicit use or profit. I only want to research the advantage that optimal play knowing the remaining deck structure has over basic strategy.

Moreover, I don't think that simulating every possible hand is the only way to calculate certain probabilities.
For example, finding the chance a player will bust if he/she hits would just requires an iteration over the all the possible ranks (10 in total) and tallying up the ones that would cause the player to go over 21. For instance, given the following remaining deck structure (for 1 deck):

A 2 3 4 5 6 7 8 9 10
4 4 4 4 4 2 3 4 4 16

If the player has a 6 and a 7 while the dealer shows a 6 (and no other players are present), the only cards that could bust the player are 10 and 9. Since there are 20 of them and 49 cards remaining, the chance of the player busting on its next hit is 20/49=40.8%.

The probability of the dealer busting in general can also be calculated over another few iterations over the ranks, and the result is accurate.

Those probabilities will influence the player decision and they do not require simulations to be run.

I was hoping I could find a paper that discusses those decisions and provides a justification for all of them. Or in particular, some way to treat the soft scores.
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6271
Joined: Jun 22, 2011
May 7th, 2015 at 10:18:16 AM permalink
Quote: dvorak

I would like to know how the basic strategy was calculated for soft hands.


Here is a post I made earlier about how I calculated basic strategy.

The key to basic strategy is not in determining "whether it is more likely that the player or the dealer will bust" (among other things, you have to remember that if both players bust, the dealer wins), but "whether the player is more likely to win by hitting or by standing."

For soft hands, you need to figure out the strategy for hard 12-21 first.
You then start with "soft 21" and work down to "soft 12".
Let's say you have Soft 17, and you hit.
1/13 of the time, your next card is an Ace; your probability of winning is P(S18) (i.e. the probability of winning with a Soft 18, which you have already calculated; this is why you have to start with Soft 21 and work down to Soft 12 instead of the other way around)
1/13 of the time, your next card is a 2; your probability of winning is P(S19)
1/13 of the time, your next card is a 3; your probability of winning is P(S20)
1/13 of the time, your next card is a 4; your probability of winning is P(S21)
1/13 of the time, your next card is a 5; your probability of winning is P(H12) (i.e. the probability of winning with a Hard 12 - again, you have already calculated this)
1/13 of the time, your next card is a 6; your probability of winning is P(H13)
1/13 of the time, your next card is a 7; your probability of winning is P(H14)
1/13 of the time, your next card is a 8; your probability of winning is P(H15)
1/13 of the time, your next card is a 9; your probability of winning is P(H16)
4/13 of the time, your next card is a 10-value card; your probability of winning is P(H17)
Add these 10 values up (i.e. 1/13 x P(S18) + 1/13 x P(S/19) + ... + 4/13 x P(H17)); this is the probability of winning if you hit a soft 17. Compare this to the probability of winning if you stand on 17; set P(S17) equal to the higher of the two - if the stand probability is higher, you stand on soft 17, and if the hit probability is higher, you hit.
(See my linked post for how to determine the probability of winning if you stand on a number.)
Romes
Romes
  • Threads: 29
  • Posts: 5602
Joined: Jul 22, 2014
May 7th, 2015 at 11:07:04 AM permalink
I definitely wasn't implying you were doing anything illegal. The scenario you gave above is literally how the shoe computers calculated plays though. They took inputs from the player and thus knew the composition of every remaining card in the deck(s). With this information it was able to calculate which of the best playing decisions was to be made (hit, stand, surrender, double, split).

There's plenty of documentation on how they performed vs counting vs basic strategy, etc.
Playing it correctly means you've already won.
MangoJ
MangoJ
  • Threads: 10
  • Posts: 905
Joined: Mar 12, 2011
May 7th, 2015 at 5:51:50 PM permalink
Quote: dvorak

Hi,
I am designing a Blackjack AI such that it would try to play optimally each hand against the dealer.

When I'm having a hard score the algorithm is easy: as long as my risk of busting is lower than the dealer's risk of busting (based on its visible card) I will hit, otherwise stand.


For a start, it is an algorithm. But it won't play optimally. Are you sure you didn't miss anything important from the game ?
teliot
teliot
  • Threads: 43
  • Posts: 2871
Joined: Oct 19, 2009
May 8th, 2015 at 9:03:37 AM permalink
I followed the article "Algorithms for Computation of Blackjack Strategies" by David Heath when I built my infinite deck model for blackjack. It is very easy to use this article to write the code or build a spread sheet.

Click here to download article

The file is a bit large (sorry), but it will tell you everything you need to know for the infinite deck case.
Climate Casino: https://climatecasino.net/climate-casino/
dvorak
dvorak
  • Threads: 1
  • Posts: 6
Joined: May 7, 2015
May 9th, 2015 at 4:52:00 PM permalink
ThatDonGuy, thank you for the informative response. This was the kind of answer I was looking for.

I thought that I should make the decision if the probability of busting on a hit was lower than the dealer's in general because I've seen this justification on this page.
  • Jump to: