Retrucada

Calling truco every hand used to beat the hard robot. Not anymore

Playing my own campaign in Retrucada, 1-on-1 truco (the Brazilian card game) in a corner bar, I tried something silly: calling truco in every hand, in the first round, before knowing anything. The robot folded almost every time. Only once did it accept and win; the rest of the time I won just by calling. A robot you can beat like that is not a good opponent. So I measured it.

Measuring

I had the medium robot play in my place in two ways: normally, and normally with a single change, calling truco as soon as it can in every hand. Each way played 1,000 matches against each robot, with the same cards in both versions.

Against the robot Playing normally Always calling truco Robot folded to truco
Easy, paulista 73% 48% 6%
Medium, paulista 51% 41% 54%
Hard, paulista 35% 45% 78%
Easy, mineiro 65% 52% 2%
Medium, mineiro 53% 45% 44%
Hard, mineiro 39% 50% 71%

Player wins; the noise is around ±3 points.

Against easy and medium, always calling was worse than playing normally. Against hard, it was 10 points better. Hard is the robot of the Late night stage, the bars after the 9th in the campaign, and one of the levels at the Table. It folded to 3 out of every 4 calls.

Why hard fell for it

The hard robot doesn't see your cards. It draws 200 hands you could be holding, consistent with what it sees on the table, and plays each one out to the end. If you called truco, it gives weight 5 to the hands where you win: whoever calls usually has something to call with.

That works against someone who calls with a good hand. Against someone who calls in every hand, the call says nothing, and the robot kept thinking it did. With the hands where you win weighing 5 times more, it thought it was losing almost every time, and folded.

The fix

Now the robot counts, during the match, how often you called truco in the first round. The reasoning is simple: you have the better hand in about half the hands. If you call in 90% of them, even calling in every good one, you are still calling in at least 80% of the bad ones. The more you call, the less the call weighs.

It starts as if it had already seen 3 neutral hands, so it doesn't jump to conclusions after one or two. And it only reads first-round calls this way: a call from someone who has already seen cards on the table still counts as a signal.

Always calling truco, against hard Before Now
Paulista: player wins 45% 32%
Paulista: robot folds to truco 78% 60%
Mineiro: player wins 50% 41%
Mineiro: robot folds to truco 71% 58%

Always calling no longer pays. Against normal play, nothing changed: 35% and 39% before, 34% and 39% now.

What about medium, which folds half the time?

Medium also folded a lot: to half of the calls. But against it, always calling already lost. To find out whether folding was a mistake, I played the alternative: every time medium folded, I rewound the hand, made it accept, and played to the end with the same cards.

In paulista, in the hands it folded, accepting would have won only 26% of the time. On average it would have lost 1.6 points, against the 1 it loses by folding. It was right: always calling doesn't improve your cards, and half the hands really are weak.

Splitting by the win chance the robot itself computes, I found small mistakes: sometimes it folded with a 30% to 50% chance, mostly in mineiro. I tried four tweaks. None moved the result by more than 2 points, within the noise, so I left medium as it was.

Fear at the end of the match

Another thing showed up in that test: with the player at 9 or 10 points, the robot folded even with a 70% chance of winning the hand. Its rule counted "accept and lose" as losing the match, but didn't count that folding also brings you close to the end. With you at 10, folding gives you 11, and then it's your hand of eleven.

Now medium and hard decide by their chance of winning the match, not by the points in the hand. It comes from a table by score: each hand is a coin flip and is worth what hands usually are in robot-vs-robot matches (in paulista, 79% of hands are worth 1 point, because someone folds to the truco). Far from the end, the math comes out the same as before. Near the end, it changes a lot. With you at 10 points and the robot at 0, medium used to accept 12 of 31 truco calls; now it accepts 26.

This matters most against someone who calls and raises at every chance (truco, six, nine, twelve):

Always raising Before Now
Against medium, paulista 27% 17%
Against hard, paulista 17% 13%
Against medium, mineiro 31% 25%
Against hard, mineiro 30% 22%

A battery of silly strategies

I only found this problem because I tried a silly strategy. So now the robot goes through several before every change: always call, always raise, always accept, always fold and never call, against every level, in both styles. If any of them wins more than playing normally, the test flags it. Today none does.

What about the campaign you're playing?

A campaign in the browser stores only the moves. When you finish the 9 bars, the server replays each of the robot's moves to check them before granting the medal. Until today it replayed them with the new robot, so anyone who had started the campaign before a change had the medal refused. Now the server keeps the old versions of the robot, and the medal counts even if the robot changes mid-campaign.

Where the simulation falls short

For programmers

In Retrucada's code:

pnpm balance --exploit
pnpm balance 1000 mineiro --exploit --vs=hard "--only=truco sempre"

Each cell of the table runs in its own process, and the full battery takes a few minutes. A ⚠ appears when a strategy wins more than playing normally with the same cards.

Two things that paid off:

  1. Play the alternative. To know whether the robot should have accepted, the average win rate isn't enough: rewind the hand, flip the decision and play to the end with the same cards. That shows whether folding was a mistake, and in which range of win chance.
  2. Keep the old robot. Every change to the robot keeps the previous version, and a test fails if the behavior changes without it. Besides not breaking the medal, this made it possible to compare before and after on the same matches, as in the tables above.

If you find another silly way to beat the robot, use the feedback button. I found this one by playing.