Handling side pots correctly is one of the most critical logic challenges in a poker engine, as errors here directly result in financial loss and regulatory failure. The solution requires a deterministic, multi-pass evaluation algorithm that decouples pot creation from hand evaluation.

The core principle is: A player can only win a pot they contributed to. The engine must logically segregate the total chips on the table into distinct "Pots" (Main, Side 1, Side 2, etc.) based on the minimum effective stack at each stage of the betting.

1. The Data Model: Pot Segregation

Do not store a single totalPot integer. Instead, maintain a list of Pot objects, each tracking:

id: Unique identifier.