Sechsundsechzig

About the bot

At the “Neural” level you play a neural network with 0.84 million weights, a card transformer. Nobody showed it how to play well. It only knew the rules and played 33 million hands against itself.

33M
hands of self-play in training
3.6 h
training on one graphics card (RTX 4090)
≈ 20 ms
thinking time per move, in the browser
56.3%
of hands won against “Strong”

Three bots with rules, one without

The Easy and Medium levels follow rules of thumb: lead cheap cards, keep pairs together, give up high cards only for tricks worth it. Strong adds a search on top. For each move it samples hundreds of possible distributions of the unseen cards, plays each one out and picks the move with the best average. Once no more cards are drawn it calculates exactly.

Neural does not search. The network looks at the position once and gives a probability for every legal move. Its judgement comes from training, not from rules a person wrote down.

What the network sees

A real example from self-play. Diamonds are trumps; the hand holds ace, ten, king and queen of trumps, plus the ten of clubs and the king of spades. The trump nine lies face up, and two tricks are already won. The network gets no pictures, only numbers: for each of the 24 cards, whether it is in the own hand, already played, face up or still unknown.

Your hand

Face-up trump

Stock: 8 cards

Points 10 : 0, tricks 2 : 0

The card inputs: six rows of 24 cells

Each cell is one card. Filled means 1, empty means 0. Trump is always on the left.

♦︎♣︎♠︎♥︎
A10KQJ9A10KQJ9A10KQJ9A10KQJ9
Own hand
Already played
Shown by opponent
Face-up trump
Card led
Still unknown

On top come four more card rows (what the opponent may still hold, what they played, the last trick), 47 numbers for stock size, score, tricks, closing, the meld obligation and pairs in hand, and the whole trick sequence: which card fell in which trick, who led and who won.

The network’s answer

Probability for each legal move. Value of the position: +3.0 game points.

play ten of diamonds39%
meld 40 (diamonds)34%
play ace of diamonds26%
play queen of diamonds< 1%
play king of diamonds< 1%
play ten of clubs< 1%
play king of spades< 1%
close the stock< 1%
The network spreads its choice over three moves: lead the ten of trumps, meld 40 and lead the ace of trumps. It sees no important difference, because it expects the biggest win either way: +3 game points, the opponent takes no trick. With the four top trumps it either draws the opponent’s trumps first and melds later, or melds at once. Giving away the non-trump cards or closing it rates as worthless.

Two tricks make learning easier. The cards are rotated so that trump is always the first suit: whether hearts or spades are trumps changes nothing about the game, so the network learns each situation once instead of four times. And the network is not told which of the other three suits is which, only rank and whether it is trump. Every situation is therefore the same for all three suits.

Architecture

The network is a small transformer, built around the cards. Each of the 24 cards gets its own slot with 31 features: where it is, whether the opponent may still hold it, and its history, meaning in which trick it fell, who played it and who took the trick. A 25th slot holds the game state: stock, points, tricks, closing.

In 4 blocks the slots look at each other (attention). Each card knows which cards share its suit and which card it met in the same trick, and learns by itself how much that matters. At the end every card scores its own move, king and queen together score the meld, and the game-state slot decides on exchanging and closing and estimates the game points the hand will end with. That number is what the evaluation chart in the game shows.

In the browser the network runs in plain JavaScript, with no library and no server. The weights are stored as 8-bit numbers inside the game file (1.2 MB). The rounded weights choose the same move as the original in 99.0% of positions.

How much accuracy does rounding cost?
Bits per weightsame move as the original
899.0%
697.1%
593.5%
487.5%

24,361 positions from self-play.

What the bot sees24 cards and one game-state slot, trump firstper card 31 features + rank + trump? · game state: 43 numbersembedding → 128 numbers per slotTransformer block× 4198,272 weights × 4attention, 4 heads+ same suit, + same trickLinear 128 → 512 → 128LayerNorm · GELUshortcutsMove scoreper cardMeldfrom king + queenGame stateexchange, close, value837,649 weights in total, stored as int8 in the browser

Training by self-play

Training used PPO (Proximal Policy Optimization), a standard reinforcement learning method. In each of the 4,000 rounds the graphics card plays 8,192 hands at once. Half of them against the current network, the other half against up to 12 older versions, so it does not develop a weakness that only it fails to exploit.

The only feedback is the result: game points won or lost, 1 to 3 per hand. Which moves led there, the network has to work out itself. The learning rate falls from 0.0003 to 0.00001 over the run, so the network fine-tunes at the end instead of jumping around.

Win rate against the three rule-based bots during training

Measured every 200 rounds: 250 hands against Easy and Medium, 1,000 against Strong.

40%50%60%70%80%even01,0002,0003,000training round76% vs Easy64% vs Medium56% vs Strong40%50%60%70%80%even02,000training round76% 64% 56%
After only 200 rounds the network clearly beats Easy and Medium. Against Strong it pulls ahead after 400 rounds and reaches 55% after about 600 rounds. Single points vary by one or two percentage points. The final measurement over 4,000 hands: 56.3% ± 0.8.
Values as a table
Roundvs Easyvs Mediumvs Strong
20077.6%59.0%50.0%
40078.1%62.9%53.4%
60075.8%65.1%55.0%
80074.9%64.1%54.6%
1,00074.4%64.4%55.5%
1,20078.0%64.3%55.6%
1,40075.5%63.3%53.7%
1,60076.8%64.1%53.1%
1,80075.6%64.3%55.1%
2,00076.4%66.5%55.9%
2,20077.8%62.6%54.6%
2,40076.0%63.5%54.8%
2,60075.7%63.9%55.1%
2,80078.4%65.3%56.2%
3,00076.6%65.8%55.3%
3,20076.6%63.3%55.7%
3,40075.8%61.3%55.3%
3,60080.5%63.4%56.0%
3,80076.2%64.8%56.0%
4,00075.8%64.2%56.2%

What the network picks up: actions per hand in self-play

Average over both seats, measured every 10 rounds.

0.000.400.801.2001,0002,0003,000training round0.75 melds0.47 closes0.42 nine exchanges0.000.400.801.2002,000training round0.75 0.47 0.42
At first the network plays at random: it closes in 61% of hands and loses 43% of all hands that way. After a few rounds it almost stops closing and learns to meld first. Closing returns only afterwards, now on purpose: in the end almost every second hand is closed, and only 3% of hands are lost that way.

How strong is it?

Everyone against everyone, 1,000 hands per pair. Each deal is played twice with seats swapped, so luck of the deal cancels out. Read a row: how often this bot wins against the opponent in the column.

row vs column, wins in %RandomEasyMediumStrongNet at 400Net at 1,600Net final (Neural)
Random1987756
Easy813021222423
Medium927036353538
Strong927864464544
Net at 400937865534747
Net at 1,600957664545351
Net final (Neural)947762555249
The networks after 400 and 1,600 rounds are snapshots from the same training. Already after 400 rounds it beats Strong. With 1,000 hands per pair, differences below three points are chance. It loses only 6 in 100 hands to random play, because even a random player sometimes gets the better cards.

Does it play differently from the search bot?

Both win about equally often against the weak levels, but not in the same way. Measured over 13,000 hands per bot:

Takes the trick when it canas second player, when a card would win
85%
77%
Leads an ace or tenshare of leads
30%
36%
Leads a trumpshare of leads
23%
23%
Trumps a non-trump leadas second player
24%
23%
Closes the stockshare of hands
36%
34%
Wins after closingshare of its own closes
92%
89%
The most visible difference: the network leaves a trick it could take more often (77% against 85%). In exchange it leads aces and tens more often. It saves trumps for later and prefers to collect the points actively. Both close about equally often and win afterwards about equally often.

The bot as a coach

The network helps you too. The Hint button shows its best move, how sure it is and what the second choice would be. When a rule of thumb agrees with the network, its reasoning is shown as well.

The evaluation chart is on by default (you can turn it off under Training aids in the settings). Like in chess, it shows after each of your moves how the network rates the position, and grades your move: best, good, inaccurate or mistake. To do so the network plays through every legal move in several possible card distributions and measures how many game points your choice costs compared with the best move. Hover over the chart to see what you played and what would have been better. At the end of the hand a report lists every trick with its cards, points, the change in position and what your move cost.

Play against the network