For an indepth look at the rules and hand ranks of Texas Holdem Poker, go do a quick read about them on pokernews.com.
To play the heads up game this article is about, go here.
This is a "heads up" game which means it is just two players against each other. In this case, it is the human versus the computer program I wrote.
Each player gets two cards ("hole cards) that only they can see. There are 4 stages of the hand and each stage has a betting component.
At each stage, a player may bet, check (make no bet and pass the option to the other player) or fold to a bet. A player may only fold to a bet otherwise they have to bet or check. If both players check, the next stage of the hand is invoked.
Stages:
preflop - each player is dealt two cards only they can see and bets or checks

flop - 3 "community cards" are dealt face up. Each player mentally combines their hole cards with the community cards to make a poker hand. Betting or checking happens at each stage. Since the hole cards are secret, a player can pretend they have a good hand (bluff) and bet accordingly. In the screenshot below, the human has two pair, a pair of 10s and a pair of 4s.

turn - a fourth card is dealt face up

river - a fifth card is dealt face up

A winner is determined in one of two ways; a player folds at any stage against another's bet or the last stage of the hand is reached and the best hand wins.
If both players stay in on the river, the hole cards are revealed and the computer determines the winning hand.

The computer had a strong hand on the turn, three of a kind, and there was the threat of a straight being made by the human. All the human needed was a 4 or a 9 to make straight as the human had a 5 hole card (straight of 9,8,7,6,5 or straight of 8,7,6,5,4). A change I might make in this situation is for the computer to make a big bet on the turn to force the human to gamble and call in hopes of making a straight or force the human to fold and give the computer a win.
Here's a high level overview at how the code determines potential threats (as in the threat of the human making a straight) and how much to bet.
To see all the criteria the computer uses to make a decision, when playing click on the Toggle Dev button.

Once Toggle Dev is clicked, you'll see all the info in the screenshot below.
The goal of the program is to reduce all these values to a number on a scale of 1 to 1000. In general, if the number rating for the hand is a 700 or better, a bet is made. There are more aspects to it, such as if the computer is on a draw, like trying to make a flush, the program calculates the odds of making the flush and compares it to the cost.
For example, if there is a 1 in 5 chance of making the flush and the human bets 100 chips against a 300 chip pot, the computer then has to call 100 chips for a chance to win a final 500 chip pot. It's a break even risk as the computer has a 1 in 5 chance of making their flush (assuming the human doesn't make a higher flush). This is called calculating pot odds to probability. For a more in depth look at how to calculate pot odds, go here.

The playing style of the human is also determined. The human can be loose, tight or average. Clicking on Street History will reveal the criteria for determing the player style.

The challenge of programming this is to not end up in a near infinite decision tree. That is, not have "if (player === "loose" && potOdds === "good" && threat < 700 && hope > 700 && firstToAct === true && numShowDownsWon > 10 && other endless conditionals) { do action" and simply have "if (evalCriteria >=700) { do action".