Retrucada

9,000 simulated campaigns to get Retrucada's shop right

Retrucada is 1-on-1 truco, the Brazilian card game, played in a corner bar. In the campaign you go through 9 bars, and between them you spend bottle caps at the shop: charms that bend the rules your way, and changes to your deck. In a single day the shop changed three times, and the third change was to undo the excess of the first. To see how big each change was, I had the robot play thousands of campaigns.

The shop

Every win pays bottle caps. The shop shows three charms and two deck changes:

Deck changes don't take a pocket slot. Keep that in mind.

The method

To measure a rule, the medium robot plays the whole campaign in your place. It shops following a simple script:

The number that matters is how many campaigns beat all 9 bars. Each setup plays 300 campaigns, always with the same seeds: the same cards, the same opponents, the same shop. Only the rule changes.

To find what causes an effect, I switch off one piece at a time: the same campaigns without blessing, without marking, without the whistle. If the number drops, that piece mattered.

The story in three versions

0.30.0: "a shop worth it"

Deck changes were so weak nobody bought them: of the 41 shop purchases analytics recorded, only 9 were deck changes. The simulation agreed: buying deck changes didn't help, and may even have hurt, because it spent caps that could have gone to charms.

So I made them all stronger. Marking now marked all four cards of a rank, a blessed card was always yours, and copying a card joined the shop.

0.31.0: six new charms

Four-leaf clover, ice bucket, straw hat, whistle, piggy bank and fanny pack, so the shop wouldn't keep showing the same ones.

0.34.1: "a fairer shop"

I played it and found it overpowered: you could mark and bless without end, because deck changes don't take a pocket slot. The simulation measured how big the problem was.

Rules version Paulista, charms only Paulista, with deck changes Mineiro, charms only Mineiro, with deck changes
Before 0.30.0 19% 15% 8% 9%
0.30.0 (strong deck changes) 19% 33% 8% 20%
0.31.0 (new charms) 25% 43% 12% 18%
0.34.1 (fairer shop) 14% 27% 8% 14%

Campaigns that beat all 9 bars, with the medium robot playing for you; 300 campaigns per cell. The 95% confidence interval is about ±5 points. Paulista and mineiro are the two styles of truco in the game.

Strong deck changes more than doubled the campaigns won in paulista. The new charms added a bit more on top.

What drove the number

With everything from 0.31.0 on, I switched off one piece at a time:

Campaign with deck changes Paulista Mineiro
Everything on 43% 18%
No blessing 33% 14%
No marking 37% 17%
No copying 38% 14%

Blessing weighed the most. A strong card that never goes to the opponent and also wins ties is worth a lot in a three-card game.

Among the new charms, the surprise was the whistle. It gave +1 point every time the opponent folded to one of your calls. That sounds small, but the robots fold a lot, so it nearly doubled what calling truco earned. With charms only, paulista went from 25% to 19% without it: all of the new charms' gain in paulista came from the whistle. In mineiro, the ice bucket weighed the most (12% down to 9% without it).

What changed

0.34.1 put a cap on deck changes:

Deck changes are still worth buying (in paulista, from 14% to 27%), but they no longer decide the campaign. Campaigns already in progress keep the rules they started with: every saved campaign stores its rules version.

The lucky coin that barely did anything

The lucky coin said: "You play first in the first hand of every match." That sounds like an edge, but in 1-on-1 truco whoever plays first shows their card first, and whoever answers picks a card knowing what it has to beat.

I measured it with the medium robot against itself, 2,000 matches per case, in both styles:

Leads the 1st hand Answers in the 1st hand
Paulista 48.8% 51.2%
Mineiro 49.4% 50.6%

Leading doesn't help; if anything it hurts, and the gap is within the noise. The coin cost 4 caps for almost nothing. Now it makes the opponent lead the first hand, and you answer having seen their card. It's still a weak charm; I'm keeping an eye on it.

Small samples lie

The first rounds used 60 to 100 campaigns and 800 matches. They got the direction right, but exaggerated the size:

Now every number comes with its confidence interval next to it. A difference smaller than the interval decides nothing.

Where the simulation falls short

For developers

In Retrucada's code, all of this runs with one command:

pnpm balance 300 paulista --campaign --player=medium --shop=mods --rules=7 --off=bless

It takes about 4 minutes per setup, and several run in parallel. Every change to the campaign rules now goes through it before shipping.

If your game has a robot, the recipe carries over:

  1. Put the robot in the player's seat and measure one thing that matters (here, beating the campaign).
  2. Use the same seeds for every version, so only the rule changes between runs.
  3. Switch off one piece at a time to find what causes the effect.
  4. Run enough (here, 300 campaigns) and put the confidence interval next to every number.

If you play and something feels too strong or too weak, use the feedback button. This whole story started with "it's overpowered".