Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix KuhnPoker chip accounting bugs - #189

Open
nph4rd wants to merge 2 commits into
TextArena:mainfrom
nph4rd:fix/kuhn-poker-phantom-ante
Open

Fix KuhnPoker chip accounting bugs#189
nph4rd wants to merge 2 commits into
TextArena:mainfrom
nph4rd:fix/kuhn-poker-phantom-ante

Conversation

@nph4rd

@nph4rd nph4rd commented Mar 9, 2026

Copy link
Copy Markdown

Two bugs in _init_round / step:

  1. Phantom ante deduction — _init_round was missing a return after determining the game winner, falling through to deduct antes for a round that never plays. Broke the zero-sum invariant (chip sum = -2 instead of 0).
  2. Pot not updated on bet/call — step() navigated the action tree but never deducted chips or increased the pot for bet/call actions. The pot was always 2 (just the antes), making fold and call-loss identical (-1), which collapsed the game's strategic depth (no bluffing incentive).

@nph4rd nph4rd changed the title Fix kuhn poker phantom ante deduction after final round Fix KuhnPoker chip accounting bugs Mar 9, 2026
@borgr

borgr commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Ready to merge. Both bugs are real and correctly fixed:

  1. The missing return in _init_round caused a phantom ante re-deduction after the game ended (chip sum went to −2 instead of staying zero-sum).
  2. step() never moved chips on bet/call, so the pot was stuck at the antes and a called-showdown loss was indistinguishable from a fold.

I traced all four terminal lines of the action tree (check-bet-call, bet-fold, check-bet-fold, check-check): pot and per-player chips are now zero-sum and correct, and the deduction fires for the acting player before tree navigation, so resolution ordering is right. Relies on ante == bet == 1, which is the definition of Kuhn poker and hardcoded in __init__.

@borgr

borgr commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Verified both fixes.

  1. The missing return after the end-of-game outcome meant _init_round fell through and re-shuffled/re-dealt/re-anted after the game was already decided. Adding return stops that cleanly.
  2. bet/call only walked the legal-action tree and never moved chips, so betting had no effect on the final chip counts — a called bet scored the same as a check. Deducting the ante and adding it to the pot on bet/call restores real Kuhn accounting.

Deterministic check (fixed deal): chips stay zero-sum; check/check → ±1 swing, bet+call → ±2, and fold-before-call costs only the ante.

LGTM, recommend merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants