– By Jim Peschke
At some point in their career, every Advantage Player will need to analyze a proposition. It might be a curious casino promotion like a buy-one-get-one-free Keno ticket at Las Vegas Club or blackjacks paying 3:1 on New Year’s Eve at Terrible’s in Las Vegas. It might take the form of a new side bet like the Dragon 7 Baccarat bet at Barona or the Slingo Bonus bet in Atlantic City. It might be a brand new game like Lunar Poker at Pechanga or a Super Pan 9 tournament at Hawaiian Gardens. It might even be an unexpected error by the casino like not requiring the Super Bonus bet at Crazy 4 Poker at Hollywood Casino in Columbus or using unshuffled cards at Taj Mahal and Golden Nugget in Atlantic City. Or maybe your usual “numbers guy” can’t be reached because he is desperately playing Baccalette at Sam’s Town.
Whatever the reason, you’ll find yourself needing to figure it out on your own. It can feel overwhelming if your math skills are a little rusty or you don’t know where to start. This book gives an overview of some tools, techniques, shortcuts, and optimizations that will show the reader how to think about casino games in a mathematical way. In the author’s words, it is designed to develop the reader’s “intellectual infrastructure” and give them a solid foundation of computer code that will allow them to understand and analyze casino games. It assumes the reader is familiar with simple math and is at least somewhat fluent in C++ or other similar programming languages, but just a basic understanding of both is enough. As the author says:
“It is the dirty little secret of game analysts; numerical characterization of casino games rarely requires more than basic high-school mathematics…In most cases, clever application of simple math and the brute force of modern computers make the difference between success and failure.”
About the Author
Jim Peschke received a Bachelor of Science degree in Nuclear Engineering from Rensselaer Polytechnic Institute and continued his studies in plasma physics and thermonuclear fusion at the University of Wisconsin, Madison. He currently works as a lead electrical engineer for a research and development company in southern New Hampshire.
The first two chapters cover the usual topics: dice probabilities, combinatorics, and Gaussian distributions. We are shown the strengths and weaknesses of each approach, including real-world limitations such as computer runtimes and storage size. For example, a program that counts every possible combination of two dice will be very straightforward and fast, but adding more dice can cause the runtime to become longer than the lifespan of some casino games. The knee-jerk reaction is to use combinatorics to calculate the number of each occurrence instead of counting them all one by one, but the factorials involved can become overwhelming and can easily overflow a 64-bit integer. So we consider using the Gaussian distribution to estimate the frequencies, but that may not be acceptable since it does not produce integer exact results. Several other methods are suggested including mathematical convolution, methods of grouping results to reduce the number of outcomes counted, and hybrid methods that use more than one of the approaches above. This may all sound very confusing, but the book carefully explains each method and includes the corresponding C++ code to help demonstrate the concepts. More importantly, it shows that there are many different ways to approach a problem once you learn how to simplify the goal.
Chapter 3 refreshes our memory on permutations and poker hand probabilities. We are shown the usual methods for calculating each hand in a 5-card draw poker game and determining the EV for a given payout schedule. There are also a few short examples of live hand analysis for video poker, which can come in handy if you find a game with unexpected payouts, rules, or bonuses…or you just forget how to play a certain hand and need to figure it out on the fly.
Chapter 4 teaches us how to think about representing a deck of cards in a computer model. A computer doesn’t know what a playing card is. It doesn’t know that hearts and diamonds are both red but are different suits. It doesn’t know that a King is higher than a Nine. And, in many cases, it doesn’t need to know all of that. As humans, we know that every card has a rank and a suit, but a Baccarat program doesn’t need to know either of those things. It only needs to know the card’s value between 0 and 9. Similarly, a Blackjack program will need to know that aces can be valued at either 11 or 1 but the suits are still irrelevant. A side bet may need to know the suit of every card but only the rank of the ten-valued cards (Ten through King). Our computer programs only need to describe the deck with as much detail as is required for the game we are analyzing. This can allow us to make massive simplifications for many casino games. In particular, we can cut down on the number of calculations and speed up our ability to loop through the entire deck. In this chapter we look at a model for poker games, which is probably one of the more complicated models. A poker program will need to know the rank and suit of every card as well as several special combinations like straights and flushes. We also need to be able to loop through the deck quickly so we want the cards to be contiguous. The model used in this book does a very good job of storing the data in a way that is easy to evaluate and compact enough to not burden consumer level computers. By the end of this chapter we have the tools to loop through any deck of cards (including modified decks) and evaluate any initial hand.
In chapter 5 we begin to generate a playing strategy for a video poker type game. We explore methods for ranking each hand and comparing the EVs of every possible action that the player may consider. This is where the majority of the number crunching happens, and this is the spot where amateur software often becomes a proverbial sausage factory. While even the most elegant methods and efficient code are going to be fairly dense, this chapter has a lot of advice that will keep the reader’s hands out of the meat grinder. The process isn’t always pretty to look at, but safety and relative efficiency will produce the tastiest results.
By the end of this chapter the reader will know how to find the computer-perfect playing strategy for many variations of video poker. Unfortunately there is no advice on how to distill this down to a human-readable strategy, so the reader may need to organize the results into a strategy that they can remember.
Chapter 6 teaches us some good optimization methods for poker style games. Like many card games, the math behind poker involves a lot of double-counting. For example, the same hand will be counted anywhere from 4 to 24 times simply by changing the suits of the cards. The relative value of the hand does not change and all of the outcomes are identical, so the calculations end up being redundant. This chapter introduces techniques such as suit substitution and combinatorial expansion which can speed up the execution time of a program at the one-time cost of development and debugging time. We also get some good advice on when to avoid optimizations and some of the potential pitfalls. There is obviously a cost-benefit consideration involved with optimizing a program that already works. This chapter can help you decide if the extra effort is worthwhile. It also gives examples of techniques that are effective and some that are not worth pursuing.
Now that we have the knowledge and tools to analyze video poker style games, we get thrown a curveball. The game of Multi-Strike Poker is a more complicated version of video poker that has several unique twists. The main difference is that the player can make additional bets on potential subsequent tiers. If the player receives a payout on the initial hand, a second hand is randomly dealt with all payouts being doubled. If that hand pays out then a hand with 4X odds is played, then finally a hand of 8X odds is played. There is also a random “free ride” bonus that complicates matters. This is the final chapter on video poker and it really feels like a master class. This is a very tricky game to analyze and it requires a lot of thought and several consecutive stages of calculations. This is, at least in my opinion, the most complicated chapter of the book. Don’t get frustrated that we’re dealing with this kind of stuff and we’re only halfway through the book. We are simply reaching the pinnacle of this topic. It gets easier from here.
Although the strategy for the final 8X hand is the same as a standard video poker game, the strategy for the lower levels can change significantly. Our goal in the first few rounds is to give ourselves the highest probability of scoring a payout, no matter how small it is, in order to progress to the higher rounds with bigger payouts. We are playing it safe in the beginning and becoming more aggressive as the stakes become higher.
With a complicated game like this we will need to work in stages. We already know the strategy for the final 8X hand so at least we have a good start. We cannot calculate the strategy for the initial hand yet because it is dependent on the values of the 2X and 4X hands, so we will need to work backwards. We can use the value of the 8X hand to calculate the EVs and strategy of the 4X hand, then use those to analyze the 2X hand, and so on.
To be honest, just describing the process is already making me cringe in my seat. Luckily, computers are exceptionally good at complex repetitive tasks such as this. When given adequate instructions, they will merrily flip their bits millions of times every second for as long as you feed them power. But in order to provide those instructions we will need to learn a few new things. Now that we are dealing with several interrelated playing strategies and four times the calculations we will need to update our data structures, storage requirements, and looping methods. There is a lot of work to do, but this chapter guides us through the process and gives some tricks to avoid the days-long runtimes that we might expect.
Chapter 8 turns our attention to an often neglected topic: practice software. After all, what’s the point of doing all of this math, writing all this code and creating these playing strategies if we aren’t able to use them in real-world play? We certainly don’t want to be playing for real money until we know we are playing properly. The machines at the casino are not going to tell us when we make a mistake, and asking a casino employee for playing advice is utterly useless and probably misleading. And even once we learn to play our strategy correctly we will want to play as fast as possible in order to maximize our win rate. All of this can be accomplished through practice software.
Although most common casino games have practice programs already available, they may not be able to handle unusual payout tables, side bets or bonus hands. Most new games will not even have a published playing strategy let alone practice software. If you want something done right you need to do it yourself.
Writing practice software also allows us to customize it for our purposes. If we are a beginner we will want to see the correct play for each hand so that we can learn the complete strategy. As we get better we will want to play without any help except for notification if we make a mistake. Once we get very good we may want to focus on specific difficult hands that we have trouble with or that may not come up very often. Chapter 8 shows us how to design a program that has all of these features.
We expand our investigation of poker style games in chapter 9 by examining the game of Caribbean Stud. This has many of the same elements we have already studied but it adds a few new twists. In the previous video poker style games, the player’s payout was based solely on the rank of their final hand. In this game, the player’s hand is being compared to the dealer’s hand to determine the winner. This game also uses two rounds of betting. The player makes an initial ante bet before seeing any cards, then must decide whether to fold their hand and lose the ante or make an additional raise (twice the ante) to play their hand against the dealer. There is also the issue of dealer hand qualification. If the dealer’s hand is worse than Ace/King then the hand does not “qualify” and the player’s ante bet is paid regardless of what they hold. When the dealer holds Ace/King or better, it is compared to the player’s hand and both the ante and raise bets are settled based on the stronger hand. These kinds of rules are very common in live poker variants such as Three Card Poker and Crazy 4 Poker, so this chapter will open up a whole new range of carnival games that may be exploitable.
This chapter is very much a departure from the previous ones. Now that we have a solid understanding of poker based games, we veer into the arena of tournament play. This discussion is unique in the fact that it doesn’t cover specific tournament betting or playing strategies the way a book like Casino Tournament Strategy by Stanford Wong does. Instead it focuses on a specific tournament format where the player wants to achieve a specific win target based on the number of other players in the tournament. The math is very interesting but I honestly don’t know how much of an advantage it would give or how common this tournament format is. In my experience, players are not generally ranked by their cumulative totals or anything other than their current chip count. But tournament rules can (and do!) vary in every conceivable way, and clearly these types of tournaments exist so there is value in being able to estimate a goal that will put you in a winning position.
In this chapter we look at ways of revising our playing strategy after the cards are dealt. In live card games we are sometimes able to see the cards from other players’ hands if they flash them (either purposely or inadvertently) or when they fold a hand. Other times we can make assumptions about their cards based on their play. In its weakest form it may be an assumption that a blackjack player taking several hits is holding small cards, or that someone folding a Caribbean Stud hand did not have any matching ranks. In extreme cases, a team of players can take every seat at a table and play with the collective knowledge of almost every card except the dealer’s hole cards.
In a pleasant (and practical) departure, this chapter uses the Monte Carlo simulation technique instead of brute force combinatorics. With this method, the computer plays billions of randomly dealt hands and combines the outcomes in order to estimate the final result instead of painstakingly iterating through every single hand and every associated payout. The Monte Carlo method is usually much simpler and will give acceptable results with enough trials. Another benefit is that it allows you to establish specific playing conditions like the number of other players at the table or a particular shuffling style. It is a very valuable tool, but there are some pitfalls that need to be avoided. For example, a high quality random number generator is essential. Anything else can give skewed and inaccurate results. The book recommends the standard arc4random() function, but ultimately uses the weaker random() function in order avoid multi-thread locking. I wouldn’t recommend using either of these for game simulations. RNGs like the Mersenne Twister or MarZam II are much better choices.
And the book wouldn’t be complete if it didn’t include the Cactus Kev evaluation scheme, complete with the Senzee hashing function and everything!
All of the games we have looked at so far have been 5-card poker games. When analyzing 7-card poker games like Texas Hold ‘Em the sheer number of computations can become unwieldy. While multithreaded CPUs can mitigate this somewhat through parallel processing, an extension of this concept is grid computing. This chapter explains how to use a program called Xgrid to share resources between several computers. Using this method we can have several computers working together simultaneously to crunch the numbers faster. This works great for generating large lookup tables, manual combinatoric calculations, and other tasks where several computers can work independently. We also get advice on appropriate data storage methods and a primer on using hash functions.
This chapter is a very short collection of “final thoughts” from the author.
While there is great value in having a knowledgeable instructor guide you through a difficult process and explain the details of each method, sometimes you just want the work to be done for you. For those people, Appendix A is your silver bullet. It is a listing of the complete source code for every program in the book. Just cram it into your C++ compiler and you will have all the tools and lookup tables used in the book. Of course, you’ll need to understand them in order to modify them for new games and opportunities.
This book is an excellent resource for people who want to develop their own game analysis, simulation, or practice software. While my review has been from an Advantage Player’s point of view, this book will also be useful to casino game designers, casino employees who are interested in game protection, and anyone who wants to better understand the math behind games of chance. The mathematical methods and programming techniques are fairly simple and easy to understand, but also very powerful. It includes the complete source code for every program in the book and all of the “heavy lifting” has already been done.
Amateur programmers (and even experienced coders who are feeling extremely rushed) tend to begin writing their code with the intent of optimizing it after its functionality has been verified. Although this has the benefit of allowing them to optimize only on the sections which require attention, it often leads to the realization that a different approach would have avoided the problems completely. I am not comfortable admitting how many hours I have spent stubbornly trying to smooth over a burl in my code instead of starting from scratch with a better method. This book not only shows you the methods that work, but it also shows a few methods that aren’t worth trying so that the reader doesn’t get stuck down a path that leads to an inferior method or a dead end. Having all of the source code also saves countless hours of designing and debugging. The code base alone is worth the price of the book.
A nice aspect of this book is that many chapters build on the previous ones. Each chapter adds a new piece to the puzzle and opens the door to more casino games and new opportunities. There is an enormous amount of ground to cover and the book is organized in a way that each chapter fully covers a new topic. The reader will be able to immediately apply that new knowledge to any game that has a similar format. With this book you feel a sense of accomplishment after finishing a chapter.
Many casino games and side bets are simple enough that the correct strategy can be calculated and learned within a few hours at the kitchen table. Sometimes a game or casino promotion involves nothing more than learning an additional bonus payout or keeping your eyes peeled for specific card combinations. These kinds of opportunities are the easiest to play, but also the most obvious and easy to analyze. You will probably find yourself competing for seats with other players and you run the risk of exposing the play to all but the most clueless casino employees. For example, the famous “Free Ride” option at the Klondike Casino only lasted about 8 hours once every seat was filled with people betting the table max. Many players couldn’t even buy a seat in the small casino, and management quickly realized that something was happening and cancelled the option. The maximum bets on these simple side bets and promotions are often low, as is the hourly win rate. The strongest games will be the ones that allow you to get plenty of money on the table while the casino and other players are completely oblivious. If you want to have access to the best games, you’ll need a good numbers guy. If you want access to the best games and not have to share them or have them get leaked, that guy needs to be you. This book shows you how to get started.