Here I'll talk more about my own network-based poker game, still in progress and coded in Python.

What is Texas Hold'em?

I coded the Texas Hold'em variant: 4 suits, cards 2–10, J, Q, K, A. In simplified terms, poker is a game where you bet that your cards are better than your opponents' cards. You can also bluff and trick opponents into thinking your hand is strong when it isn't. Each player gets two cards, and over time five community cards appear in the middle — you can combine any of these to form your best hand.

For a better understanding of the card ranking system, take a look at the chart below.

Poker Hand Rankings

Source: Wikimedia Commons

Declaring the Cards

I started by creating deal functions to distribute the community cards and give each player their two starting cards. To do this properly I had to declare all 52 cards upfront so I could track which ones were already in play.

Variable declarations for cards

Determining the Best Hand

Then came the real challenge: a function that correctly identifies who holds the best hand. I needed separate routines for every possible hand rank, and each one took significant time to get right — this project started in December 2023.

For "One Pair", for example, I count every card value and flag any value that appears at least twice. So if a player holds Hearts/10 and Clubs/10, a dictionary records two tens and the hand is classified as a pair of tens.

The Straight was by far the hardest case. I needed to detect five consecutive cards within the seven available. My approach: replace face cards with numbers (A=14, K=13, Q=12, J=11), strip suits, remove duplicates, sort ascending, then check for five consecutive values. I also handle the low straight (A-2-3-4-5). The picture below shows this implementation.

Straight detection implementation

After removing duplicates I'm left with a sorted list, e.g. 2, 3, 4, 5, 6. I then count the difference between each adjacent pair — if I accumulate five consecutive +1 steps, it's a straight. Took a while to arrive at this, even if it reads simply now.

TODO / What's still missing

A betting system, a GUI, and network code are all still on the list. Time has been the main constraint — but the hand-ranking engine is solid and ready to build on top of.