I am writing a poker application and trying to figure out how to deal with split pots and side pots
There are three roundfour rounds of betting and each round of betting can have multiple orbits
Can only bet the chips in front of you
So if a player is all in a side pot is created
Hands can tie - in which case the pot is split
If it does not spit evenly the 'last aggressor (raise)' gets the odd chip(s)
If you are raised you must call or fold
If you fold you lose your bets even if the hand wins
You cannot just cap you betting and create a side pot
You only create a side pot if you are all in
PlayerA all in 40 Win
PlayerB 80 second
PlayerC 80 last
Player A would take 120 (win 80 as 40 was his money in)
Player B would take 80
But you don't know the win order until the end
And when PlayerA went in you don't know how many people are going to call
What could be good algorithm for this?
This code is C# but really just looking for an approach.
My initial thought is to just record all the betting for each player
street, orbit, bet
Where that gets messy is that in a single orbit you could have multiple players all in for different amounts (bet)
And a different amount is not just all in
Player could be raised and then fold
In that case you know they lose but you still don't know who they lose to
There are rarely more than 3 orbits in a round
You could assume there would never be more than 10 as with min raise players would run out of chip