Blackjack hand summary always shows aces are worth 1, not 11 #39
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
rosa/casino#39
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Agent Brief
Category: bug
Summary: The per-card breakdown in a blackjack hand's display scores every ace as 1, so the printed addends don't sum to the printed total
Current behavior:
A blackjack hand renders as its card icons, a breakdown of what each card is worth, and the hand's total. The breakdown asks each card for its value in isolation — where an ace is always 1 — while the total applies the soft rule and promotes one ace to 11 when that keeps the hand inside 21. The two disagree, so the line prints arithmetic that does not work:
Only the display is wrong. The soft total itself is right, so a soft hand plays and settles correctly — this is a bug about what the player is told, not about what a hand is worth.
Desired behavior:
Each card in the breakdown shows the value it actually contributes to the total, so the addends always sum to the total shown.
11; every other ace shows1. Where a hand holds several aces, the leftmost one takes the eleven.?— and so is any ace, because whether it counts as 1 or 11 depends on cards not yet visible. Non-ace cards keep showing their value.Key interfaces:
Display for HandandDisplay for DealerHand— currently it derives per-card values independently of the total, which is the defect. Which ace counts as eleven is one decision and should be reached in one place; the breakdown and the total must not each decide it.HandValue::totalis correct and its result must not change. Whatever the fix introduces to attribute values per card has to agree with it for every hand.BlackjackValue::blackjack_valueonCardanswers what a card is worth on its own, with no hand around it. An ace is 1 there. That contract stays as it is — an ace's promotion is a fact about a hand, not about a card, so it does not belong on this trait.Acceptance criteria:
=A,Krenders as🂡🂮 (11 + 10 = 21)A,5renders as🂡🂥 (11 + 5 = 16)A,5,10renders as🂡🂥🂪 (1 + 5 + 10 = 16)— unchanged, the ace is hard hereA,Arenders as🂡🂡 (11 + 1 = 12), the leftmost ace taking the elevenA,A,9renders as🂡🂡🂩 (1 + 1 + 9 = 21)— unchanged?, alongside the withheld total:🂠🂡 (? + ? = ?)🂪🂡 (10 + 11 = 21)🂠with?for their value, and visible non-ace cards are unaffected whether or not the hand holds a hidden cardtotal()returns the same number for every hand it did beforeDisplay for Handdoctest and the dealer hole-card test both currently assert🂡🂮 (1 + 10 = 21); both are updated to the corrected renderingmise run cipassesOut of scope:
HandValue::totalis correct and the soft rule stays as it is.can_doubleoffers on. It admits totals of 10 and 11 only, so a soft hand is treated by its promoted total — that is a separate question about the rules, not about this rendering.+joiner, the parenthesised=total. Only the values inside it change.The brief contradicts itself on
A,A,9, so the implementation departs from one acceptance criterion. Flagging it here rather than quietly resolving it in code.Two criteria cannot both hold:
="A,A,9renders as🂡🂡🂩 (1 + 1 + 9 = 21)— unchanged"1 + 1 + 9is 11, not 21. TheA,A,9line in the Desired behavior block is a copy of the line from Current behavior — the one example the brief did not correct. Its neighbours confirm the intent:A,Ais given as11 + 1 = 12, which uses the promotion, andA,5,10is genuinely unchanged only because that ace is hard.The rule stated in prose settles it: "An ace that the soft rule promoted shows
11; every other ace shows1. Where a hand holds several aces, the leftmost one takes the eleven."A,A,9has a hard total of 11, so the leftmost ace is promoted and the hand totals 21.Implemented as:
Every other criterion is met as written. Treat this comment as the amendment to that one line.