Data Insights into Simulations of Card Games

Joseph Pajot
Joseph Pajot
Altair Employee
edited December 2021 in Other Discussion & Knowledge

Altair’s data science software can learn from virtual physics simulations, but it is equally fun to apply these to tools to casual pursuits.

I was recently speaking with someone who was taking a trip to the famous American gambling city of Las Vegas.  The conversation made me recall a trip I took there years ago.  During that trip I watched many people lose their money at a game called 3 card poker.  The deceptively simple game has only a few choices for the player to make, such as the ante bet size and a midgame decision to fold or stay.  Because I am a nerd, I was fascinated by finding the game’s optimal strategy. 

Rather than search for an answer on the internet, I returned from my trip and I wrote a program to simulate the game.  The program starts “a game” with a given set of money, plays hand after hand using a user supplied set of rules, and continues to play until it eventually loses all the money.  This program is a simulation of a gambler using his “system” to sit at the table and play until he goes broke.  With this code in hand, I can use software like Altair HyperStudy to repeatedly rerun the gambling simulation and subsequently mine the resulting data in order to find the ideal strategy.  Inputs to the program cover all facets of the simulated games, including things like wager amounts, replication size, and folding logic.  For example, folding if the best card isn’t at least a Queen, and the second best card isn’t at least a 6, and the third best card isn’t at least a 4:

image

For outputs, it tracks quantities like the median or average number of hands until running out of money, or the median or mean “high water mark” of the money (before you lose it all).  Here is a plot of these response metrics plotted versus the number of games.

image

As observed in the chart, all the metrics are noisy when only a few games are played, yet the values settle down as more games are played. Furthermore, you can see the medians converge more quickly than the averages – which makes sense as averages are much more sensitive to outliers (known to gamblers around the world as “hot streaks”).

Finally, a bubble plot can be used to visualize the strategy that will result in the highest median number of hands – this serves as a proxy metric for “how to make your money last into the night”.

image

The size of the scatter point is proportional to the median numbers of games played until going bust using that betting strategy.  The data from these simulations indicates the optimal strategy comes of folding unless having at least a Jack as the high card.

At Altair, we tend to use the word simulation to mean a physics-based solver such as a finite element or fluid dynamics solution.  However, the concept of simulation is much more general, yet the tools used to perform design exploration translate to non-physics simulations – such as this game example.  Learning from these simulations is an important piece of artificial intelligence, for example in reinforcement learning applications.  Share some of your ideas for creatively using simulation data to gain insight in the comments below.