0

It's a poker game with bluetooth and I encounter some difficulties to redistribute the side pots. Does someone have any experiences with that?




    for(int k = 0; k < numberOfPlayer; k++)
                {
                    canWinSidePotUpTo[k] = -1;
                }
                for(int i = 0 ; i < sidePot.size(); i++) {
                        if (sideTempToRaiseListSorted.get(i) != sideTempToRaiseListSorted.get(i + 1)) {
                            for (int k = 0; k < numberOfPlayer; k++) {
                                print("All in ToRaiseList[" + k + "] = " + toRaiseList[k]);
                                print("All in TempToRaise[" + k + "] = " + tempToRaise[k]);
                                if (sideTempToRaiseListSorted.get(i) == max(toRaiseList) - max(tempToRaise)) {
                                    continue;
                                }
                                if (sideTempToRaiseListSorted.get(i) == (toRaiseList[k] - tempToRaise[k])) {
                                    canWinSidePotUpTo[k] = j;
                                }
                                if (sideTempToRaiseListSorted.get(i + 1) == (toRaiseList[k] - tempToRaise[k])) {
                                    canWinSidePotUpTo[k] = j;
                                }
                                print("All In canWinSidePotUpTo[" + k + "] " + canWinSidePotUpTo[k] + " + i = " + i);
                            }
                            print("All In sideTempToRaiseListSorted.get(" + i + ") " + sideTempToRaiseListSorted.get(i) + " + i = " + i);
                            print("All In sideTempToRaiseListSorted.get(" + (i + 1) + ") " + sideTempToRaiseListSorted.get(i + 1) + " + i + 1 = " + i + 1);
                        }

                    j++;
                }

The expected result is to be able to set the array canWinSidePotUpTo[player] for each player. The side pot start at index 0 and if the player can win only the pot then canWinSidePotUpTo[player] = -1. All player which are allin have canWinSidePotUpTo[player] = -1 and then canWinSidePotUpTo[player] should be set according to the stack at allin... the actual result is:

All In canWinSidePotUpTo[0] -1 + i = 1
All In canWinSidePotUpTo[1] 1 + i = 1
All In canWinSidePotUpTo[2] 1 + i = 1
All In canWinSidePotUpTo[3] -1 + i = 1

That the result for:

player:hand:stack allin
0:AA:900
1:KK:1100
2:QQ:1300
3:JJ:1500
pot = 3600
sidepot(0)= 600
sidepot(1) = 400
Flop:AKQJ9

Any help would be welcome!

DisD
  • 11
  • 4
  • Please edit your question title to what you really want to ask. As for now the answer for your question is just `Yes`, as someone for sure `have experiences with a poker app in android`. But it won't answer your question, right? – Vladyslav Matviienko Jun 26 '19 at 08:04
  • Also you have told the expected result, and what is the actual result? – Vladyslav Matviienko Jun 26 '19 at 08:05
  • Thank you for your comment, a moderator has changed the title and Ive edited the post. – DisD Jun 26 '19 at 08:29

2 Answers2

1

In software, I think it's simpler to do it in the opposite order from how a live-game dealer would. In a casino, the side-pots are awarded first, then the main--mainly because the pots are consolidated during betting and sometimes that's the only way to do it.

But in software, you can keep track during betting of each player's total contribution to the pot, including antes and blinds, as the betting happens. You don't have to calculate it after-the-fact. So to award the pots, then, you just start with the best hand. Award him his contribution, plus up to that amount from each of the other players, then remove him (and any other players with no contribution left) from the list. Then repeat: find the best remaining hand, award him his remaining contribution plus up to that amount from each of the others, then remove from list, etc.

Lee Daniel Crocker
  • 12,927
  • 3
  • 29
  • 55
0

I've been answering a variety of these questions, because often they come with clues and nothing super concrete. If you'd like to see the algorithm I wrote, assuming you still care, I'm linking to the code here: https://dotnetfiddle.net/P0wgR5

It doesn't care about bets, it's at the point where everyone's committment has been tallied and it's time to distribute to the winners. It handles folded hands, all-ins/overbets, and I haven't found a bug yet.

  • Thank you but i did manage the problem in a other way than the solution proposed but managed to. – DisD Jan 12 '22 at 19:45