Domino & Developer
Hey Domino, I’ve been chewing on how to map a poker hand to a deterministic score—essentially turning the house of cards into an algorithm. Think we could give luck a calculable edge?
Sure thing, partner. If we strip a hand down to ranks and suits, we can line it up in a table and spit out a number. Call it a “deterministic score.” I’ll give you the math, but just remember—luck’s still the wild card. So yeah, let’s give the house a curveball and see if you can beat me at the table.
Sounds like a neat exercise, but you’ll end up overfitting the table to every possible permutation. Give me the actual scoring formula and I’ll run a quick sanity check—make sure you’re not just coding a spoiler sheet.
Alright, here’s a straight‑up play‑by‑rules score:
1. Give each rank a base value: 2=2, …, 10=10, J=11, Q=12, K=13, A=14.
2. For suits, add a tie‑breaker: Clubs=0, Diamonds=1, Hearts=2, Spades=3.
3. Build a 5‑digit number: start with the highest card’s rank, then its suit, then next highest rank+ suit, etc.
So a hand like A♠ K♥ 9♦ 4♣ 2♠ becomes: 14(3)13(2)9(1)4(0)2(3) → 143213190423.
Now sort all hands by that number – the bigger the number, the better the hand. No hidden tables, just pure math. Try it out and see if the house still gets its edge.
Nice try, but that scheme will rank two‑pair higher than a straight, and a flush higher than a full house. Poker is about hand categories, not a raw concatenated number. If you want a deterministic score, encode the hand type first, then use the rank tie‑breakers. Otherwise the house will still win because the math is wrong.
You’re right—hand types have to trump the raw rank trick. Here’s a clean fix:
1. Assign a base score for the hand type:
- High card = 0
- One pair = 1 000 000
- Two pair = 2 000 000
- Three of a kind = 3 000 000
- Straight = 4 000 000
- Flush = 5 000 000
- Full house = 6 000 000
- Four of a kind = 7 000 000
- Straight flush = 8 000 000
2. Add a tie‑breaker made of the card ranks in descending order, each weighted by a power of 13 (so the first rank matters most).
3. Sum the base score and the tie‑breaker.
That keeps a full house above a flush, a straight above a two‑pair, and so on. Give it a whirl.
That’s the right direction, but your power of 13 tie‑breaker will overflow a 32‑bit int if you’re not careful; use a 64‑bit type or pack the ranks in a string. Also remember that a flush beats a straight even though the highest card might be lower, so the base scores must be spaced wide enough that the tie‑breaker never outweighs a lower category. Once you sort those out, the algorithm should behave like the official ranking.
Got it—use a 64‑bit int and bump the base gaps up to, say, 10 million. That way the tie‑breaker can’t ever outweigh a full house versus a flush. Just pack the ranks in order, multiply each by 13^n, and add to the base. Done.
Nice, just remember to handle the Ace low straight separately; otherwise you’ll mis‑rank A‑2‑3‑4‑5 as a high‑card hand. Also test against all 2,598,960 combinations to catch any off‑by‑one errors. Once that passes, the “deterministic” score will be solid.