Poker Simulator in Python

akarsh mallya
19 min readApr 3, 2023

Designing a poker simulator in python is a great way to get some practice and experience in various aspects of the python language and have fun doing it.

Through this exercise you will gain an understanding of classes, dictionaries, list and dictionary comprehension, writing to csv files, and Poker of course.

Let’s start with the objective: Our objective is to write a program that will simulate a game of Texas hold’em poker between a specified number of players. Through this simulation we will try to learn what starting hands in Poker give us the best chance of winning a round. Of course, if you just want to learn poker strategy you can go somewhere else and get these answers. The goal here is to write our own program to figure it out.

In this article I will explain how I approached this problem, and the various stages and steps in development. When I thought about this problem, the logical starting point for me was with the Card.

Card

The card is the fundamental unit of poker. Without the concept of a Card you don’t have anything. So, the first step was to create a class named Card.

class Card:
static_suites = ["Heart", "Club", "Diamond", "Spade"]
static_cardvalues = [str(n) for n in range(2, 10)] + ["T", "J", "Q", "K", "A"]

def __init__(self, suite…

--

--