Nanno

Poker

My own network-based Poker game (In-Progress)

Here I will talk more about my own network based poker game that is still in progress (coded in Python).


First of all, what is poker? I coded the Texas Hold-em Variant, cards: 4 colors, 2-10, J, Q, K, A. If you already know that, just skip this section: In simplified terms, poker is a game in which you bet that your cards are better than the cards of your opponents. You can also bluff and trick your opponent into thinking your cards are good when they aren't. You get two cards in your hand, and slowly, over time, 5 cards will appear in the middle, which you can also use to make, for example, a pair (Which could be made of two aces or two 5s). For a better understanding of how exactly the card ranking system works, I recommend that you take some time to to understand the picture below.

Ranking Cards Poker


Source: https://commons.wikimedia.org/wiki/File:Poker_Hand_Rankings_Chart.jpg


I started by creating some basic deal functions that should deal the cards in the middle and give all players their 2 starting cards. For this I had to declare all cards, so that I can later also keep track of which cards are already used.



Variable Declare Cards


Then it was time for the real game: I had to create a function that understands who has the best cards. To achieve this, I had several functions that took a very long time to optimize and work with every single case (just so you know how long everything took, this project started in DECEMBER of 2023). For example, for the "One Pair" determine function, I count every single card and see if that number has a duplicate. So if a player gets a Hearts/10 (my real notation, by the way) and a Clubs/10, a dictionary would keep track of how many 10s the player has, and then know that the player got 2 10s, which means a 10 "One Pair". So far, not much time has passed, and I haven't ran into any problems yet.



I will save you the headache of understanding every single case, but just to give you another example, I will show you how I implemented the Straight. This was by far the most difficult one, because I had to count when there were 5 consecutive cards in the 7 cards given. I started by coding the number 14 for an Ace, 13 for a King, 12 for a Queen, and 11 for a Jack, so that I did not have the annoying letters. I also removed the colors, so I no longer had Clubs/A, or Hearts/10. I had 14 and 10. Then I removed the double cards from the list, because they do not matter for a straight. Now I sorted the list from lowest to highest. Below is a picture which contains the code of the previous, and the next part. (If you're a poker expert, I also implemented the low straight with Ace, 2, 3, 4, 5)



Poker Straight


Now I had a list, for example 2, 2, 2, 2, 2, 3, 3. Now the same as with the One Pair: I counted all the numbers, and if there was a number that appeared 5-7 times, then I had a straight! By the way, this was very hard to figure out, even if it seems logical to you now, it was very hard.

What's still missing:

I still didn’t build any kind of betting system, nor did I started coding the GUI or even touch netcoding, because I just did not have the time for it. But especially in the summer holidays I want to improve this poker game even more, but I don’t think that I can finish it until September 2024, but I’m off for the challenge!

Edit: Now it's December, 2024... Haven't made any progress since last time 😅 Next goal: March 2025

Enlarged Image