4/6/2022

Nodejs Poker Holdem

25

What’s up, guys. 🤜🏾

Wisdom Begins with Wonder - Socrates. Alton is an educator, poker coach, self-published & best-selling author, and full-time IT and Business professional. He is also the founder of MicroGrinder Poker School, an online poker school dedicated to micro stakes poker players, where he provides a wide array of free and low-cost poker resources and poker training, included poker strategy articles. Node Js Poker Holdem new members to try out their gaming facilities. However, there is no assurance that you would be able to withdraw your winnings from no deposit bonus games.

Now that the Flash game Blasteroids has been converted to HTML5, the next game I’m working on is a multiplayer Poker game.

HTML5 & Node.js Projects for $1500 - $3000. I want Poker Game(HTML5). If you can show me this game within a month, please contact me. You should tell me the game rules you think. I'm building a poker Hold'em hand evaluator. Ultimately my goal after building the evaluator is to build a client on the browser but that's far from now. What I've done so far is a hand analyzer that check checks hand strength but I'm unsure of the architecture I've chosen. A deck of French playing cards, as it is used in Texas Hold’em, contains 52 different cards; in a heads-up game two players are playing against each other. Both of them get two private cards dealt pre-flop face down.

Now, this won’t be a conversion, but a game originally built using Phaser 3, JavaScript, and Phaser Editor.

Building this game will be a bit of a challenge for me for these two reasons:

One, this will be my first attempt at developing a complete multiplayer, turn-based game.

An MP game is much more challenging to build than a single-player one, believe you-me. I once tried making a real-time MP in the past using PlayerIO, but… let’s just say that didn’t pan out so well.

And two, I’m learning a bit about the JavaScript ecosystem. I took previous course on Zenva called MMORPG Academy. The course showed you how to make a simple multiplayer MMO game using Phaser, Express and SocketIO. It also introduced me to the following tools, which I will also be using for this game.

Technology Used

Node.js

Node.js is a server-side platform built on Google Chrome’s V8 JavaScript Engine. It can be used for developing server-side and networking applications. I’ll use it as part of the back-end for this game.

npm

npm is a very large software repository. It’s a package manager for JavaScript, and you can use it to download and install many third-party packages into your projects. It comes with Node.js, and it can be used to install most of the tools listed below.

Express

This is a web framework that allows your web application to handle requests that are sent to a specific URL. Both Node.js and Express will be used together to create the web server.

Socket.IO

This is what will allow communication between the the player client app and the server web app.

webpack

Among many other things, webpack can bundle all your modular JavaScript code and packages together into a single file that can be understood by your web browser.

Babel

It’s much more convenient to write JS code in the latest/modern version. However, older versions of web browsers can’t understand these versions. This is where Babel comes in. It can transpile your modern code to earlier versions that can be understood those older browsers, increasing the available of your web apps to more people.

ESLint

This tool examines your code for syntactical errors, or other issues where the code may not adhere to a certain standard or set of styling rules. Essentially, “linting”, helps you write cleaner code.

Some other tools not discussed in the Zenva course that I will be using in Poker are:

TypeScript

I much prefer Typescript over JavaScript. Typescript allows you extra features, and for me, that means static typing and support for interfaces. Of course, I’m sure I’ll learn more as I dive deeper into Typescript.

Note: My plan is to write the code using TypeScript (which both Phaser and Phaser Editor also support), use Babel (with Typescript support) to transpile the code, and bundle it all together in a single JavaScript file using webpack. This is for the client-side portion of the game. The back-end server-side code will not be run in a web-browser, so it will not use this process.

Poker Game Multiplayer Development Plan

First thing’s first: the game’s design, and layout will need to be created. While I’m not a game designer (my service currently only includes programming), this version of Texas Holdem Poker I’ll be making will have a relatively simple enough mechanic. Nothing fancy here. And the game is mainly to add to my portfolio.

I’ll need to find some assets (graphics and sounds). I’ll use the same assets I used from my Thunderjack! game.

Because this is a multi-player game using a client-server model, where the server has the authority and maintains the game’s state.

The client apps (what the players will use) act as visual agents, showing the state of the game server. They also accept input (keyboard, mouse, touch, etc.) from each player, send them to the server, then the server with validate that input. The validation is to make sure the state stays clean, and to prevent cheating.

Because this will be a turn-based game and not a real-time game, it doesn’t need to rely heavily on advanced concepts like client-side prediction or entity interpolation and prediction.

Next, there are the rules of Poker. Because the server maintains the stage, all the game logic will be written on the server. And of course, I’ll need to get the rules down as well. 🙃

Holdem

Nodejs Poker Holdem Play

And finally, I want the game to be able to use bots that can fill in if no other real players are available. So building an AI will be a challenge all its own, though I’m sure I can research this for help.

Where and How will I Host the Game Server?

The final component to this game is determining where and how I’ll host the game server, so you can play this game online with other real people. The client-side app will be hosted here on my site here, but it’s the game server that needs to be hosted elsewhere.

The multi-player game that the Zenva course helps you to create uses Heroku to host the game project, so I’ll use that again. The course covers just enough for you to set up a simple game, as any more, I believe, would go beyond the scope of the project, but there’s enough there to get started.

As I work on the game, I’ll post noteworthy updates in future articles. And you can play the work-in-progress versions of the game as I make playable updates, before the game is released to the public!

Sign up using this form to get on my mailing list:

Whew! That’s it for now, and this will be quite a challenge. I’m sure this will take me a while to complete. And I hope you stick with me on this journey! I got this! 💪🏾

– C. out.

In this article we define and publish the exact pre-flop probabilities for each possible combination of two hands in Textas Hold’em poker. An online tool at tools.timodenk.com/poker-odds-pre-flop makes the data visually accessible.

Table of Contents

Introduction

A deck of French playing cards, as it is used in Texas Hold’em, contains 52 different cards; in a heads-up game two players are playing against each other. Both of them get two private cards dealt pre-flop face down. There are $binom{52}{2}=1326$ different possible pairs of cards that players can get. In this work we determine the odds of each starting hand to win against any other starting hand. There is no equation or easy way of calculating the winning probability of a given hand, since it would be required to contain all the rules and mechanics of the game.

Statistical approaches can determine the winning odds of one starting hand against another very quickly. This gives results that are statistically accurate but not guaranteed to be exact. However, for mathematical analysis of certain properties of pre-flop situations, the precise numbers are a requirement.

Win Function

Hold’em cards can have 13 different ranks and four different suits
$$begin{align}
mathcal{R}=&left{text{Ace}, text{2}, text{3}, text{4}, text{5}, text{6}, text{7}, text{8}, text{9}, text{10}, text{Jack}, text{Queen}, text{King}right},
mathcal{S}=&left{text{Club}, text{Heart}, text{Spade}, text{Diamond}right},.end{align}$$A card is an ordered pair of rank and suit; the set of all cards that exist in a the card deck is denoted as
$$begin{align}mathcal{C}=mathcal{R}timesmathcal{S},end{align}$$ with $leftlvertmathcal{C}rightrvert=52$. The set of possible starting hands, every possible combination of two distinct cards, is defined by
$$begin{align}mathcal{H}=left{left{c_1inmathcal{C},c_2inmathcal{C}right}mid c_1neq c_2right}end{align}$$ and has a cardinality of $lvertmathcal{H}rvert=binom{52}{2}=1326$. The set is containing unordered pairs because the two private cards are not ordered either.

Calculating the Cartesian product of the set of possible hands with itself gives a new set of ordered pairs, that is $mathcal{M}=mathcal{H}timesmathcal{H}$, with $leftlvertmathcal{M}rightrvert=1,758,276$. This set contains all combinations of two starting hands as ordered pairs. The order matters, because we define the meaning of each of the pairs as a pre-flop situation where the first starting hand plays against the second.

In this work we search for the winning odds function
$$begin{align}
o:mathcal{M}rightarrowleft{xinmathbb{Q}mid0le xle1right},
end{align}$$ that outputs for any pre-flop situation $left(h_1,h_2right)$, the odds of starting hand $h_1$ to win against $h_2$. Since every card exists only once in a deck, two players cannot play against each other if $h_1cap h_2neemptyset$. For these cases $o$ is undefined.

Nodejs Poker Holdem Poker

Post-flop, five community cards are dealt. Three on the flop, followed by the turn card, and finally the river card. $binom{52}{5}=2598960$ different combinations are possible. We define $mathcal{P}$ as the set of all possible community cards, where each $pinmathcal{P}$ is itself a set of five different cards. The community cards $p$ determine which player wins, that is the one whose starting hand builds the best showdown hand. If both showdown hands are of equal rank at showdown, the pot is split. Given a pre-flop situation $m=(h_1,h_2)$ where the starting hand $h_1$ plays against $h_2$, only a subset of $mathcal{P}$, namely $$begin{align}mathcal{P}_{(h_1,h_2)}=left{pinmathcal{P}mid pcap h_1=pcap h_2=emptysetright}end{align}$$ can be dealt, as some cards are already taken from the deck.

Nodejs

Furthermore a win function
$$begin{align}w:{(minmathcal{M},pinmathcal{P}_m)}rightarrow{0,1}end{align}$$is required, that assesses a situation at showdown and returns $1$, if the first starting hand in $m$ wins against the second hand, given the public cards $p$. In case of loss or split it returns $0$. $w$ is defined by the rules of poker. With these definitions at hand we can define the odds of a hand to win against another hand as
$$begin{align}o(m)=frac{displaystylesum_{pinmathcal{P}_m}w(m,p)}{lvert mathcal{P}_mrvert},.end{align}$$In words, $o$ is dividing the number of possible community cards where $h_1$ wins against $h_2$ by the number of community cards that can be dealt altogether.

Nodejs Poker Holdem Games

Data and Results

With the odds function $o$ at hand, we can define the winning odds matrix $mathbf{M}inmathbb{Q}^{lvertmathcal{H}rverttimeslvertmathcal{H}rvert}$ as
$$M_{i,j}=o(mathcal{H}_i,mathcal{H}_j),.$$ The matrix contains the winning odds for every heads-up pre-flop situation and is undefined at places, where $mathcal{H}_i$ and $mathcal{H}_j$ cannot play against each other (because of shared cards). From its row vectors, i.e. $mathbf{M}_{i,:}$, we can compute the average odds of a hand $mathcal{H}_i$ to win against a random hand, by taking the average of all entries with values. The probabilities for a split between two hands are given by $1-M_{i,j}-M_{j,i}$.

We release $mathbf{M}$ in two ways.

  1. As an online tool with user interface at tools.timodenk.com where the user can pick their pre-flop situation and get the exact odds, i.e. $o(m)$ and $o(m)lvertmathcal{P}_mrvert$.
  2. As a serialized Java object holding the $o(m)lvertmathcal{P}_mrvert$ values for every $m$. The object can be imported into a Java program and processed from there.

We have already conducted some experiments related to the non-transitivity of the win function. For example, we found the three hands
$$begin{align}
h_1=&left{left(text{Ace},text{Club}right),left(text{2},text{Club}right)right}
h_2=&left{left(text{10},text{Spade}right),left(text{9},text{Spade}right)right}
h_3=&left{left(text{2},text{Heart}right),left(text{2},text{Diamond}right)right},
end{align}$$to satisfy$$begin{align}
oleft(h_1,h_2right)approx&0.54gt0.5
oleft(h_2,h_3right)approx&0.53gt0.5
oleft(h_3,h_1right)approx&0.61gt0.5,.
end{align}$$Expressed in words, this means for a hand $h_1$, which statistically beats $h_2$, which in turn beats a third hand $h_3$, it cannot be concluded that $h_1$ beats $h_3$ as well. The win function is not transitive.

The most uneven pre-flop situation exists, if the hands$$begin{align}
h_1=&left{left(text{King},text{Club}right),left(text{King},text{Diamond}right)right}
h_2=&left{left(text{King},text{Heart}right),left(text{2},text{Club}right)right}
end{align}$$play against each other (or suit permutations). The pair of kings has a $94.16%$ chance of winning. The pot is chopped in $1.53%$ of all possible outcomes.

Surprisingly, Aces do not appear in this constellation. The reason is that the hand A2 could hit a straight with just three cards (3, 4, 5). On the other hand, K2 needs four cards (A, 3, 4, 5 or 3, 4, 5, 6) in order to build a straight that uses the 2. Also noteworthy is the fact, that the King of Clubs of $h_1$ blocks flushes, which $h_2$ could have otherwise gotten using the Deuce of Clubs.

Nodejs Poker Holdem Game

The lowest winning probability and highest probability for a split pot exists if $$begin{align}
h_1=&left{left(text{3},text{Club}right),left(text{2},text{Diamond}right)right}
h_2=&left{left(text{3},text{Diamond}right),left(text{2},text{Club}right)right}
end{align}$$battle each other. Both hands have an equal chance of winning, namely $0.71%$. Consequently, a split occurs with a likelihood of $98.57%$.

Holdem

Interestingly, the get-together of 43 vs. 43 (same suits as above) comes with a higher winning probability ($0.73%$). That’s (at least partly) because there are a few more flushes, for which one of the hands does not only play the board.

The lowest split probability of just $0.19%$ is there, if the following hands play:$$begin{align}
h_1=&left{left(text{9},text{Club}right),left(text{8},text{Diamond}right)right}
h_2=&left{left(text{Ace},text{Spade}right),left(text{Ace},text{Heart}right)right},.
end{align}$$In which cases would the pot be chopped? For instance if a straight flush of Clubs from 2 to 6 occurs.

Still unsolved is the search for the longest non-transitive chain of mutually disjoint pre-flop hands, such that $$o(h_1, h_2)>0.5land o(h_2,h_3)>0.5landdotsland o(h_n,h_1)>0.5,.$$

Special thanks goes to Dominik Müller for fruitful discussions and many algorithm optimization ideas.