Maximum Tinkering
Published in

Maximum Tinkering

Augmenting Thinking

with Monte Carlo Simulations and Poker

Photo by Rob Schreckhise on Unsplash

One of the things I’m interested in exploring is how to use computers to augment my thinking. What I mean by that personally is how can I leverage what a computer does much better than me (scalable, fast, and accurate calculations that can run in parallel 24/7) to help me make better decisions and understand the world more accurately.

One technique that matches this criteria that I have repeatedly come across in varying fields such as biology and finance is called Monte Carlo simulation. If you’re not familiar with Monte Carlo simulation, the basic idea is that you create a program that simulates something — like a game, investment portfolio, or how certain molecules might interact with each other — and then you run that program over and over again, keeping track of the results of each simulation. The results of these simulations can then be used to analyze the probabilities of certain outcomes of the event you were simulating. It’s particularly useful when trying to understand complex outcomes, outcomes that depend on the interaction of many different variables and where calculating precise probabilities is difficult or impossible to do.

By using Monte Carlo simulations, one can get a better understanding of the range of possible outcomes without having to actually experience each personally. It is also a great method for understanding probabilities and thinking more probabilistically.

But instead of just reading about it, I wanted to learn how to implement it so I could then use it to improve my own thinking when needed. In order to do so, I had to look for a problem that had a large field of potential outcomes that were difficult or imprecise to calculate. In addition, I wanted to pick a problem that was interesting to me personally because I find this to be the best way to learn. That’s why I decided to build a Monte Carlo simulation for poker¹.

Why poker

In my opinion, poker is one of the best kinds of games to play because it so closely resembles the real world — involving elements of psychology, probability, and risk taking. And even though many would have you believe that the part of reading others is the name of the game, the best players understand that one of the most important elements is understanding probability.

In addition, despite there being a number of different sources to look up many of the probabilities associated with poker, it is still challenging to understand what these probabilities mean and how to use them in the course of a game. Just because you know you have a little less than 6% chance of having any pocket pair, what does that mean for how you should think about the outcome of that particular hand? That pocket pair doesn’t exist in isolation, you are playing against other players. How many others are sitting at the table? What hands may they have?

There are so many different scenarios to think about that it’s quite difficult for your average poker player to get an intuitive feel for the probabilities of the game and how they may assist in making certain in-the-moment decisions. Professional players have the advantage of playing millions of hands over their lifetime. Because of this, they get a better feel for how the probability of the game works. Something as rare as a Royal Flush can happen a number of times if you play enough games.

This is what makes poker an ideal game for Monte Carlo simulation. Even if you’re an amateur player who plays the game every so often, you can still develop more of a probabilistic understanding of the game by letting a computer play the game for you millions of times, without having to do it yourself.

Of course this is an imperfect model of the real game and cannot account for the human and psychology factors. But this method isn’t meant to model the game exactly, instead its purpose is to help get a more intuitive grasp of the probabilities of poker.

Gameplay setup

Because of the vast amount of possible scenarios that can happen in any one poker hand — let alone game — it would be quite challenging to try and simulate everything. So to reduce the scope a bit and make the simulation of the game easier, I made a few assumptions.

The first assumption is that there is no betting or money involved in the game. Money and betting shouldn’t have any effect on probabilities, outside of eliminating the players involved, which is addressed in my next assumption.

The next assumption I made was that in each of the simulated games, no players would fold their hands and all would play through until the end².

I believe this assumption was a logical choice to make. Because this simulation is meant to help with the understanding of the probabilities of poker, one should understand the game at its most basic level. Afterall, no one is forced to fold their hands because of the game’s rules, players choose to do that on their own. When any player folds their hand, you can never find out how things would have played out had everyone stayed in. And players fold their hands for a variety of reasons, some logical and some not so much. So not only does it help reduce the scope of the simulated game, it also allows one to see what would’ve happened in each game had everyone not folded their cards.

The only other assumption about the actual gameplay that I made was that a draw would be considered a win. The reason I made this choice is because in a certain way, a draw is a win in poker. When two or more players draw and have equal hands, they end up splitting the pot evenly. Depending on how many players began the game, this means that even though the players had to split the pot rather than take it all themselves, they could end up with more money then they started with³.

Analysis

To generate the results below, I ran 10,000 simulations⁴ of a poker game with varying amounts of players⁵, where all players were dealt two random cards from a deck of 52 possible ones, and the rest of the game followed standard Texas Hold’em rules.

The main questions I wanted to answer for my analysis were:

  • What is the winning percentage of every possible pocket combination across games of varying sizes?
  • What is the frequency of particular pocket cards? For example, how likely are you to get suited connectors as a pocket pair?
  • Of the winning hands, what type of hands were they? (i.e. straights, flushes, pairs, three-of-a-kind, etc.)

Many of the results are obvious to anyone who understands the game of poker — like that Aces are good (duh) — but some are pretty interesting. For example, everyone loves a good pocket pair, but some pocket pairs have notably worse winning percentages than a non-pair combination with a face card. Another interesting result is that the pocket combination of 2/3 off-suit can be just as bad as the notorious 2/7 off-suit. This again demonstrates the power of higher cards.

Winning percentage for all possible pocket combinations

Other interesting results include how pocket cards perform across games of varying sizes. For instance, only in larger games of 6+ players, do suited and connected cards have similar, if not better, odds of winning than face cards. However, as the game size decreases, the value of having a face card increases.

Winning percentages for different types of pocket cards

It’s also interesting to look at what kinds of card combinations win across game sizes. For example, in a game with 9 players, assuming all players play all the way through, a high card never wins. Yet, in a game of only 2 players, a high card wins around 6% of the time. The takeaway here is that you should be aware that a rare winning hand like four-of-a-kind is much more likely to happen with a lot more players in the game — because the chances someone has those cards are higher — but in games with only a few players, having even a pair can give you great odds.

Winning percentages of the various winning hand types by game size

Finally, perhaps something that’s more intuitive to others but that I didn’t know before this analysis is that two-pairs is a quite common winning hand across games of all sizes. It roughly accounted for 30% of all wins for each of the different game sizes.

You can find the full results here and the code used to produce the results here.

Please feel free to let me know if I have made any mistakes or if there are any other improvements or changes that you would make.

Thanks for reading!

¹ The Texas Hold’em version.

² Even though I did the analysis with the assumption no players folded in the game, I still setup the simulation to accept an additional argument for the number of players who folded. The reason for this was my own curiosity and usage of the simulation. For example, if I was playing a hand of poker with 7 other players and 2 players folded, what would the results look like?

³ The only time this isn’t true is if every player who has put money in the hand has an equal hand, a pretty rare scenario, especially with lots of players at the table.

⁴ You could obviously run a lot more simulations but the results wouldn’t be that different. Plus, I didn’t have the resources to run this for days on end.

⁵ Game sizes of players between 2 and 9. This is a pretty standard range for poker games. Tables usually don’t have more than 9 players at a time and they can be as small as 1-on-1 or what’s called in the poker world “heads-up”.

--

--

--

The blog of Alex Meyer.

Recommended from Medium

My First Data Science Project

Short guide: using Nordigen on top of Truelayer data

You make the world better| TimeBank service system without spending and depositing money/debt…

Data Science With No Data

Starbucks Capstone Challenge

You can Timely Deliver your Machine Learning Projects if you follow these rules

Learning Tableau Through DataCamp — Part 1

4YearElect U.S. — The development of a diverse country

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex Meyer

Alex Meyer

Attempting to put my dent in the universe.

More from Medium

Day 01 — Science and meaning

Mythbusters Part 1: The Science Behind Lightning

Are we a minuscule part of intelligent life in the universe?

Gautama Buddha statue

A Stream of Consciousness