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:
- Charms stay in your pocket for the whole campaign, 5 at most. The Bonfim ribbon wins you the ties, the rue sprig caps what you lose when you fold, the whistle pays when the opponent folds to one of your calls.
- Deck changes alter your deck, which goes with you from bar to bar. You can mark a card (you recognize it by its back when the opponent holds it), bless one (it wins ties and is never dealt to the opponent), copy a card or remove one.
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:
- Charms only: picks one at random among those it can afford.
- Charms and deck changes: first a charm; with the change, a deck change (bless the strongest card, copy the blessed one, mark the strongest, remove the weakest).
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:
- Marking marks a single card again, up to 3 per campaign.
- Blessing goes up to 2 cards, and the second costs 3 caps more.
- A copy of a marked or blessed card counts toward the limit.
- The whistle pays +1 bottle cap per fold instead of +1 point.
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:
- 0.31.0's campaign with deck changes in paulista came out at 58% with 60 campaigns and 43% with 300.
- The lucky coin looked like it cost 6 points with 800 matches; with 4,000, the gap fell to 1 or 2, within the noise.
Now every number comes with its confidence interval next to it. A difference smaller than the interval decides nothing.
Where the simulation falls short
- A robot isn't a person. The robot probably makes worse use of a marked card than you do. That's why "buy deck changes first" did worse for the robot under the new rules, while I felt the abuse playing. The simulation shows directions and relative sizes, not your odds of beating the campaign.
- The shopping script is simple. It picks charms at random and follows a fixed order of deck changes. A good player builds combinations the script doesn't.
- A person found the problem. "It's overpowered" came from playing. The simulation measured the size and found the cause. Together they worked better than either alone.
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
--shop:amulets,mods(charm first) ormods-first.--rules: plays an older rules version, to compare before and after.--offand--off-charm: deck changes and charms the robot never buys.
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:
- Put the robot in the player's seat and measure one thing that matters (here, beating the campaign).
- Use the same seeds for every version, so only the rule changes between runs.
- Switch off one piece at a time to find what causes the effect.
- 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".