
Build this a random night over summer, it was around 11pm and I had to be up for a flight at 4am, figured no sleep made more sense than 5 hours of sleep. Was heading to a buddies cabin for our yearly trip where we play 31 pretty commonly, figure it’d be fun to see if I could whip up a healper for it.
Build was pretty straightforward, given leaning heavily on LLM & some existing repos for other card games. Most of the compute heavy stuff (simulating games) was done locally and then moved over to my VPS as lookup tables as we are heavily compute constrained on that thing.
From messing around with it, Topk seems to be the best policy, uniform considers too many futures that we’d never get to and greedy isn’t explorative enough.
Best example of this is below, the bot makes the call to retain lower points since we have future outs for trips and at large that 2 point bump isn’t worth narrowing on a suite so early. In so far that it is willing to drop the 7 of hearts before for the upcard as opposed to break up the pair.

Some cool info I found along the way in this exercise which serves as good heusitics when playing unassisted


Tldr on how 31 is played below
Object of the Game
The goal is to obtain a hand that totals 31 in cards of one suit; or to have a hand at the showdown whose count in one suit is higher than that of any other player.
Rank of Cards
A (high), K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, 2 (low)
Card Values/scoring
An Ace counts 11 points, face cards count 10 points, and all other cards count their face value.
The Play
Before play begins, all players put an equal amount of chips into a pot. The player on the dealer's left has the first turn. On each turn, a player may take one card from the widow and replace it with one card from their hand (face up). (Variation: Players may exchange any number of cards with the widow in this manner.)
Players take turns, clockwise around the table, until one player is satisfied that the card values they hold will likely beat the other players. A player indicates this by "knocking" on the table. All other players then get one more turn to exchange cards. Then there is a showdown in which the players reveal their hands and compare values. The player with the highest total value of cards of the same suit wins the pot.
If there is a tie for the highest score, the player with the highest-ranking card wins. Example: K, Q, 6 (total 26) would beat Q, 9, 7 (also total 26). If there is a tie in the highest cards, the next highest cards are compared, and so on.
Any time a player holds exactly 31, they may "knock" immediately, and they win the pot. If a player knocks before the first round of exchanges have begun, the showdown occurs immediately with no exchange of cards.
After the pot has been won, all the players put in chips for the next hand.



