top of page

Blueprint Poker 3 - Hand Rankings

I'm not sure if it is the best approach to making poker hand rankings in UE4, but I made a DataTable as described here.

The datatable is based on a Struct asset with integer (rank), enum (hand type), enum (card), enum (combiner), enum (card), enum (card).

Combiner values can be: Full of, Over, Kicker, None

Card values are : Two to Ace, plus Discard as a special entry for if we don't count the column for a given row.

This enum lets us gather Rank, Result, PrimaryCard, CombinatorType, SecondaryCard, TertiaryCard. We want to order the possible hand results to determine which wins.

There are something around 2.5 million hands possible in poker, but this can be digested to a list of about 1500 winning hands.

The highest is the hand 'Royal Flush'

  • 0,Royal Flush,Ace,None,Discard,Discard

What are the None and Discard values? Other hands need extra information, like a 'Two Pair'.

  • 800,Two Pair,Queen,Over,Seven,Five

In this case, Five is the kicker.

You might see dealer cards QC, QH, 7H, 5S, 7D and have hole cards 4H, 4C.

Anyone with a higher hole card than 5 would beat you, otherwise you'd split.

The lowest hand rank is 'High Card' 7, because you can't get 'High Card' 6 because your other cards would amount to some higher rank. This is because 6,5,4,3,2 is a 'Straight'.

  • 1517,High Card,Seven,Kicker,Six,Discard

Even High Card hand results use a kicker to determine who wins if more than one player has a matching hand, so High Card 7 with 6 kicker beats High Card 7 with 5 kicker for example. You cannot get High Card 7 with 4 kicker. What other cards could fit that result?

In the table, the kicker is normally the SecondaryCard, unless we're looking at Two Pair, where the kicker is in the TertiaryCard list.

Notice in the table that for a given hand which includes kickers, you have to remove the primary card and higher cards from the kicker list, or you'd get inaccurate results (like High Card 7 with 7 kicker). The picture below shows what I mean.

Filling in a table like this would be incredibly tedious in UE4 because you cannot drag or copy/paste values to populate the list quickly like you can in a proper spreadsheet. Instead, it's best to use Google Sheets then export a .csv (which stands for Comma Seperated Values). So long as you have a Struct asset in UE4 which represents the contents of the spreadsheet rows, it'll import just fine.

Why are there two rows of numbers on the left?

In google sheets we have google's Row#, ColumnA#, ColumnB#

When imported into UE4, google's Row# is not included, so we just bring in ColumnA and ColumnB, respectively: RowName, Rank values.

It's best to make the required RowName value an integer so you can do clever tricks with row look ups in blueprint scripts.

[Edit : I rewrote my ranking spreadsheet after realising that Pairs and Kickers need to be compared between players who have the same, because one kicker doesn't determine the result, but one of three in the case of a Pair and one of four in the case of a High Card. Likewise, Three of A Kind doesn't have one card to evaluate for a kicker but two. For intance, if the highest non-trips card is shared, or on the table, we have to look to the next best card held to get the right kicker.]

[Update: I was having some trouble figuring out an easy way to poll Pair and HighCard results.

Luckily I found a third party blueprint asset called Morepork functions, which includes a TotalOfIntArray node. It looks at a bunch of ints and returns the highest. This lets us compare players who may wind up with the same hand ranking (like Pair of Aces). Where there are multiple card to figure out to see who actually wins. So to determine a kicker accurately, you can discard from a player's Cards array the pair they've hit, and also discard any shared cards between betting players, then add up their remaining cards to see who has the smallest value (Ace is 0, and 2 is 12 in the card ranks I'm using).

Three of A Kind

Consider Brian folded to a preflop raise his 29 *as he should* and missed the 9999 he would have got, leaving Beatrix and Boss Hog to slog it out holding an Ace each.

Beatrix AK 99987

Boss Hog AJ 99987

Because the table 87 is less than the hole cards, Beatrix's King would hold up, because they both showed an Ace. For this reason, although the Rank obtained for both player's is 397, a decider function is needed to compare the hands played to determine the winner.

Two Pair is somewhat easier to work out.

Imagine in the hand below that Beatrix, who won a fullhouse had gone all in seriously short stacked and won. But Bob and Bart, calling, had higher chips and had to battle it out between them for the real money in the hand.

They have the same initial hand rank of 799 : Two Pair Queens Over Six, Eight kicker

But the Eight is shared, on the table, and their held cards are lower. They'd split.

Bob 67 QQ865

Bart 64 QQ865

Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page