How we built a stronger Hokm bot
· varaq
Hokm is a game of partners and hidden cards. Four players sit in two teams, the Hâkem names the Hokm suit, and every card you play has to work against hands you cannot see. A good bot has to do what a good player does: picture what the others might hold, and pick the card that holds up across those pictures. This is how we made our strongest bot better, what got in the way, and where it stands today.

Where we started
Our strongest level, Hard, already played a careful game. On each turn it imagined many possible deals that fit everything it had seen so far, judged each of its cards across those deals, and played the one that did best on average.
That approach plays honestly: it never peeks at anyone's hand. But we had no clear idea how far it was from playing well. Before changing anything, we needed a ruler.
A bot that cheats, on purpose
We built a bot that sees all four hands and solves each deal exactly. It is not a fair player and it never sits at a real table. It is a ceiling.
Against Hard, the all-seeing bot wins by about 1.3 points a deal. No honest player could close that whole gap, because much of it comes from simply knowing where the hidden cards are. Still, it showed us how much room there was, and it gave us a very strong opponent to test against.
Challenge one: measuring skill through luck
Card games are noisy. One lucky deal can decide a match, so comparing two bots by the matches they win needs tens of thousands of matches before the difference means anything.
So we switched to duplicate deals, an idea tournament bridge players will know. Every deal is played twice. The second time, the teams swap cards, so each side plays both the good hand and the bad one. The luck of the cards cancels out, and what is left is the difference in decisions.
With duplicate deals, 2,000 deals are enough to spot a gap of about 0.04 points a deal. That let us trust small improvements instead of guessing at them.
Throughout this post, strength is counted in points per deal: how many more points a bot's team scores in an average deal than the team across the table, measured over many duplicate deals. The numbers look small, but they add up over a match.
Challenge two: exact search is too slow
Our first improvement was to search harder. For each decision, the bot sampled 64 possible deals and solved every one of them exactly.
It worked. This searcher beat Hard by about 0.14 points a deal, a clear and real gain. But it took seconds to choose each card. Our bots play on a server, at many tables at once, and seconds per card for every bot at every table is slow for players and costly to run. We had a stronger bot that we could not seat.
Challenge three: fast, but no stronger
The natural next step was to teach a neural network to copy the slow searcher. A network does not search: it looks at the table and answers almost at once.
We trained one on the searcher's choices, and it was fast, about 2 milliseconds a card. But it only matched Hard. Copying a teacher's guesses carries the teacher's blind spots along with its skill, and the network never saw what actually worked.
The breakthrough: learning from self-play
What changed things was letting the network learn from its own games. It played millions of hands against copies of itself and learned from how each hand actually ended, rather than from what the searcher guessed.
That kind of learning needs a lot of play. Our first version of the game generator spent most of its time waiting, so we rebuilt it. Instead of asking the network about one card at a time, it now collects the decisions from many tables and lets the GPU judge them all in one batch. That alone made it about 14 times faster.
With the faster loop, the network made about 150 million card choices in roughly two hours on a single cloud GPU. Each round of play taught it a little more about which cards hold up over a whole hand.
Where we are now
The new network beats the old Hard level, and head to head it plays level with the slow 64-deal searcher, while choosing a card in about 2 milliseconds.
| Bot | Against old Hard, points per deal | Time per card |
|---|---|---|
| Old Hard | 0 (the baseline) | Instant |
| Slow 64-deal searcher | +0.14 | Seconds |
| New network | +0.08 | About 2 ms |
Against old Hard, the searcher still scores a little more. When the two meet directly, neither comes out ahead, and only one of them is fast enough for a live table.
The network is now playing at the Hard level on our tables. Naming the Hokm suit still uses our established rule-based choice; the network plays the cards.
The honest gap, and what's next
Against the all-seeing bot, the new network still loses most of that 1.3 points a deal. That is expected: any honest player would, because the cheating bot knows what no one at a real table can know.
There is still room on our side of that line. Next, we plan:
- Longer self-play, so the network keeps finding better lines of play.
- A small search on top of the network, so it can check its first instinct in tricky spots.
- Training against a pool of its own past versions, so it does not pick up habits that only work against itself and stays hard to exploit.
Play it yourself
The best test is a real game. Open a Hokm table, choose Hard, and see how the new bot plays as your partner or your opponent.
Play Hokm