Say the payout in chips, not just in money #73

Closed
jheaps wants to merge 1 commits from fix/casino-holdem-payout-in-chips into fix/casino-holdem-move-seat-on-touch
Owner

"Ann — $135" is the answer to the arithmetic. The dealer's actual job at that moment is working out that $135 is a black, a green and two reds, while four people watch them do it. Stacked on #72.

The chip legend has known the denominations all along. It was only being used to read chips into an amount — counting a seat's stack — and never to turn an amount back into chips.

Final Payouts
  Ann — $135
  1×$100, 1×$25, 2×$5

Why greedy is the right algorithm here

Largest first is greedy, and so not optimal for an arbitrary set of values. Poker chips are not arbitrary: every real set is canonical — each denomination divides the next, 1/5/25/100/500 — and greedy is exactly optimal on those. A dealer who invents a 3-and-7 chip set still gets a valid answer, possibly one chip longer than it needed to be, which is a fair trade for not solving a knapsack in a modal.

Two cases where saying nothing is right, and one where it isn't

A table with no chip legend gets the amount on its own — it hasn't told us its denominations, so there's no advice to give. (The first version of this said "$135 no chip covers" there, which the tests caught.)

But a legend that exists and can't reach the amount does say so: $3 no chip covers when the smallest chip is $5. Half a dollar in a dollar-chip game is the dealer's problem to solve, and they can only solve it if they're told, so it's never rounded away.

Validation

12 tests (244 total): the breakdown adds up to the amount across eight amounts, cent chips make cent amounts exactly, a jumbled legend still pays largest first, the colour comes along for a future caller, and the two no-advice cases are told apart from the can't-reach one.

Driven through a real all-in hand at four viewports: $135 reads 1×$100, 1×$25, 2×$5 and a tournament-sized $1,350 reads 2×$500, 3×$100, 2×$25, fitting without spill down to 360px. With the legend emptied the line disappears and the payout stands alone. Contrast clean, no console errors.

"Ann — $135" is the answer to the arithmetic. The dealer's actual job at that moment is working out that $135 is a black, a green and two reds, while four people watch them do it. Stacked on #72. The chip legend has known the denominations all along. It was only being used to read chips *into* an amount — counting a seat's stack — and never to turn an amount back into chips. ``` Final Payouts Ann — $135 1×$100, 1×$25, 2×$5 ``` ## Why greedy is the right algorithm here Largest first is greedy, and so **not** optimal for an arbitrary set of values. Poker chips are not arbitrary: every real set is canonical — each denomination divides the next, 1/5/25/100/500 — and greedy is exactly optimal on those. A dealer who invents a 3-and-7 chip set still gets a valid answer, possibly one chip longer than it needed to be, which is a fair trade for not solving a knapsack in a modal. ## Two cases where saying nothing is right, and one where it isn't A table with **no chip legend** gets the amount on its own — it hasn't told us its denominations, so there's no advice to give. (The first version of this said "$135 no chip covers" there, which the tests caught.) But a legend that exists and **can't reach** the amount does say so: `$3 no chip covers` when the smallest chip is $5. Half a dollar in a dollar-chip game is the dealer's problem to solve, and they can only solve it if they're told, so it's never rounded away. ## Validation **12 tests (244 total)**: the breakdown adds up to the amount across eight amounts, cent chips make cent amounts exactly, a jumbled legend still pays largest first, the colour comes along for a future caller, and the two no-advice cases are told apart from the can't-reach one. Driven through a real all-in hand at four viewports: $135 reads `1×$100, 1×$25, 2×$5` and a tournament-sized $1,350 reads `2×$500, 3×$100, 2×$25`, fitting without spill down to 360px. With the legend emptied the line disappears and the payout stands alone. Contrast clean, no console errors.
jheaps added 1 commit 2026-09-01 17:09:14 -06:00
"Ann - $135" is the answer to the arithmetic. The dealer's actual job at that moment
is working out that $135 is a black, a green and two reds, while four people watch
them do it.

The chip legend has known the denominations all along. It was only being used to read
chips *into* an amount -- counting a seat's stack -- and never to turn an amount back
into chips.

  Final Payouts
    Ann - $135
    1x$100, 1x$25, 2x$5

Largest first, which is greedy and so not optimal for an arbitrary set of values. Poker
chips are not arbitrary: every real set is canonical -- each denomination divides the
next, 1/5/25/100/500 -- and greedy is exactly optimal on those. A dealer who invents a
3-and-7 chip set still gets a valid answer, possibly one chip longer than it needed to
be, which is a fair trade for not solving a knapsack in a modal.

Two cases where saying nothing is the right answer, and one where it is not.

A table with no chip legend gets the amount on its own -- it has not told us its
denominations, so there is no advice to give. But a legend that exists and cannot reach
the amount does say so: "$3 no chip covers" when the smallest chip is $5. Half a dollar
in a dollar-chip game is the dealer's problem to solve and they can only solve it if
they are told, so it is never rounded away.

12 tests (244 total): the breakdown adds up to the amount across eight amounts, cent
chips make cent amounts exactly, a jumbled legend still pays largest first, the colour
comes along for a future caller, and the two no-advice cases are told apart from the
cannot-reach one.

Driven through a real all-in hand at four sizes: $135 reads "1x$100, 1x$25, 2x$5" and
a tournament-sized $1,350 reads "2x$500, 3x$100, 2x$25", fitting without spill down to
360px. With the legend emptied the line disappears and the payout stands alone.
Contrast clean, no console errors.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
jheaps closed this pull request 2026-09-02 09:57:53 -06:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jheaps/JoshHeaps.Net#73