5

I'm writing a Poker Server piece of software and well, I want it to be accurate...

Basically I want to know what the correct way to deal with this following situation is:

[ second round of betting. everyone has already contributed 5 units to the pot ]
Player 1 raises the minimum bet to amount X (say 5 units)
Player 2 calls amount X (calls 5 units)
Player 3 has only a fraction of X. He calls All-in at this point and pays his remaining 3 units.
Player 4 has only a fraction of X. He also calls All-in at this point and pays his remaining 1 unit.
Player 5 folds.

The pot at this point contains 5 * 5 from the first round of betting plus 5 + 5 + 3 + 1 units making a total potential winnings of 39 units.

Player 4 goes on to win.
Player 3 comes second.
Player 1 and 2 comes third, with their best five cards all coming from the table.

How do I calculate how much money is spread out and who gets it? Is the following assertion correct or is this inaccurate and how?

Step 1: We rank the players by their cards if they are still in. So we get:

Player 4 (winner)
Player 3 (winner of remaining money)
Player 1 (split of remaining)
Player 2 (split of remaining)

Step 2: We scan that list in order to find the biggest contributions and create a ratio.

Player 4 (6 units total)
Player 3 (8 units total)
Player 1 (10 units total)
Player 2 (10 units total)
-- Pot contains 39 units
-- Winners have contributed 34 units

Step 3: Question. Is the ratio against the total pot... or the other winners? Is this correct? Get a ratio compared to others?

Player 4 gets contributed 6 units of 34 by other winners = eligible 17.647% of pot
Player 3 gets contributed 8 units of 34 by other winners = eligible 23.529% of pot
Player 1 gets contributed 10 units of 34 by other winners = eligible 29.412% of pot
Player 2 gets contributed 10 units of 34 by other winners = eligible 29.412% of pot
[ total adds up to 100% ]

If we do it based on the total pot... not on total contributions by winners we get:

Player 4 gets contributed 6 units of 39 of total pot = eligible 15.385% of pot
Player 3 gets contributed 8 units of 39 of total pot = eligible 20.513% of pot
Player 1 gets contributed 10 units of 39 of total pot = eligible 25.641% of pot
Player 2 gets contributed 10 units of 39 of total pot = eligible 25.641% of pot
[ total adds up to 87.18% ... so this is the wrong answer right? ]

So to continue with the first method... of calculating a ratio only between other winners can someone confirm the correct payout of the 39 units would be:

Player 4 gets 6.88 units back `((39 units * 17.647) / 100)` ?
Player 3 gets 9.17 units back `((39 units * 23.529) / 100)`
Player 1 gets 11.47 units back `((39 units * 29.412) / 100)`
Player 2 gets 11.47 units back `((39 units * 29.412) / 100)`
[ total pay out of 39 units = 39 units ]

So my question is, Is this split pot formula accurate?

*EDIT ------------------------------ *

Ok this is clearly wrong. Everyone is getting an equal payout even though 3 of them lost. All they are getting out is what they bet put a tiny bit extra from the folded player. I now think the algorithm should do the following:

Player 4 wins. Paid 6 units. Takes upto 6 units from every player (including folded players)
Player 3 wins. Takes remaining 1 unit from all players including folded players
Player 1 and 2 split the rest..

This gives a result of:

Player 4 gets own Player 1's first 6, Player 2's first 6 ... All of Player 5's 5...
Total winnings for Player 4 is 29 units.

Player 3 gets to take winnings next. He contributed 2 units more than Player 3. So he takes 2 unit from everyone who has a unit still left in their pot.
Total winnings for Player 3 is 6 units.

Player 1 and Player 2 equally share the remainder giving them 2 units back each.

Is this correct?

2
  • 1
    It's worth me commenting that to win against a 39 unit pot, having gone all in with 6 units to win back less than 7 is a bit questionable.. which is why I post my understanding of the logic here. Mar 25, 2012 at 18:31
  • Your method is error-prone and difficult to maintain. Check my answer :).
    – Loc Nguyen
    Jul 16, 2012 at 9:49

2 Answers 2

8

There have been several posts already here explaining how to compute side-pots (note that the subject of penalty blinds has not been dealt with but that is another topic).

Here's one such topic:

How are side pots built?

Question. Is the ratio against the total pot... or the other winners? Is this correct? Get a ratio compared to others?

The question doesn't make much sense because you're not expressing side-pots as a "ratio" of the total pot. That is not how pots, pots winnings, pots rake and "pots-splitting" are computed. You're never expressing winning as a ratio of the total pot.

What you do is you compute exactly how many pots and side-pots there are and see which players are eligible for which pot.

In your example, there are exactly three pots:

  • pot 1: 29 (pot one could also be called the "main pot")

  • pot 2: 6 (pot two could also be called "side-pot 1")

  • pot 3: 4 (pot three could also be called "side-pot 2")

The sum of all these pots gives the total pot (39).

Pot 1 has 29 because player 4 is eligible for up to "6". How many players did put up "up to 6"? Five players. Four of which who did put 6 in and one of them (player 5) who did put 5 in. This gives 6 * 4 + 5 * 1.

having gone all in with 6 units to win back less than 7 is a bit questionable

That would indeed be questionable. Thankfully this is not at all how it works. Player four wins back 29, so he's making a net win of 23 (29 - 6). You can also get that 23 by computing: 3 players matching up to 6 (18) + one player matching up to 5 (18 + 5, gives the net win of 23).

Pot 2 has 6 units because it's 2 * 3. You can verify this by checking how many players can match up to 8 (there are only three players who can do that), and then remove what already went into pot 1. Three players did put more than 6 in, so you have 3 * 2.

Pot 3 has 4 units. There are two players who can match up to 10. Once you remove from their stack what already went into the two other pots, this leaves 4 unit in the last pot.

Player 4 has the best hand and wins 29 (+23 net)

Player 3 has the second best hand and wins back pot 2, which only has 6. So although player 3 is a "winner", he's making a net of -2 (he did put 8 in but only got 6 back). This is normal because he's "winnning", but he's still beat by player 4.

Players 1 and 2 do split the remainder (pot 3), which has only 4 units. So they each get back 2 out of their 10 (net loss: -8).

Player 5 did lose its 5. Net loss: -5

Which gives:

+23
 -2
 -8
 -8
 -5
---
  0

Which adds up to zero and which is normal since in the absence of rake poker is (chip-wise) a zero-sum game.

As a final note, I'd advice to use as few decimal computation as possible when implementing an online poker client: the last thing you want are approximation errors.

The only tricky case is when players are splitting a pot. In some cases there are no issue (like above, where two players share an even pot), but in other cases you may have problems.... For example if three players are sharing a pot that has 8 cents (can happen at micro-limits). In that case two players must get 3 cents back and one of them must get 2 cents back (giving 2 / 2 / 4 would be a mistake). There's simply no way around that and as far as I know the player who gets only 2 (while the two other gets 3) is randomly chosen.

But, once again, trying to express each pot as a % of the total pot is a recipe for approximation errors so don't do that.

Moreover, in every single case, no matter how many pots there are, the exact amount of every single pot can be precisely computed, down to the cent.

Note that there may be edgy cases, like what you should do when a player posts a "penalty blind"... Basically it's chips you did put in, but contrarily to any other chips you did put in, it does not really count towards determining the various pot sizes (besides the fact that the penalty blind is added to one of the pot).

2
  • @amigal: ah ah, thanks... But I've got no merit: I've been forced to deal with all this for a poker software I'm developing (a tracker & HUD) ; ) In some case it's tricky because some sites do not write out the side pots details (only the total pot amount is shown) and it's kinda tricky to determine the pot sizes (which is important, for example, if you want to compute the all-in expected value, etc.). : ) Mar 26, 2012 at 11:31
  • This is a brilliant answer @TacticalCoder. I always figured that because you could work out a ratio in hindsight, you could work it out upfront but now I can see that you can't. Thank you. Mar 26, 2012 at 22:16
1

Coding sidepot management from "sidepot rules" is not very easy. Having done this myself, I'll give a general algorithm in two phases. This approach doesn't care about pot sizes, so any overlay to the pot, such as penalty blinds, is irrelevant. You will also be able to rake sidepots in proper sequence if you need to.

Manage Sidepots

  1. Manage the sidepots at the end of each street/round. The number of new sidepots is simply one less than the number of different player bet totals, after returning any uncalled bets to the last aggressor.
  2. Keep a list of the last sidepot each player is eligible to win.

Award Sidepots

  1. Evaluate hands, building a list of hand ranks. If the game is High/Low Split (e.g. 8 or Better), do all Low awarding before any High.
  2. Going through your sidepots, build a list of winners of a particular sidepot (the list will consist of a single player unless there are ties). These winners should fit the eligibility built in the managed phase. Be careful not to award ineligible players shares of pots for which they tie by hand rank (an easy mistake that will depend on your hand evaluator).
  3. Award each winner his down-rounded share of each sidepot, half of that if this is a Low award, taking the award amount out of that sidepot (so that when you run High after Low, you don't have to deal with the logic of splitting).
  4. Distribute the remainder by share. You may want to start from the small blind or there will be a bias for the zeroith seat. If you do steps 3 and 4 right, there should be no round-off errors.

Calculating sidepots at any point in the hand based on player chip contribution is another way and probably the intuitive way. However, you have to remember to (a) keep a side count of miscellaneous dead money and (b) include contributions from players that have folded earlier in the hand (the biggest downside of the contribution method, in my opinion).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.