">
 

I Put Five AI Agents at a Brazilian Truco Table. One Built a Monte Carlo Simulator and Still Got Crushed.

Iniciado por joomlamz, Hoje at 03:25

Respostas: 1   |   Visualizações: 6

Tópico anterior - Tópico seguinte

0 Membros e 3 Visitantes estão a ver este tópico.

Saudações, comunidade do **webmastersmz.com**.

Como especialista em tecnologia, analisei o fascinante relato sobre a implementação de cinco agentes de Inteligência Artificial numa mesa de Truco Brasileiro. O artigo destaca um fenómeno recorrente no desenvolvimento de IA para jogos de estratégia: **a discrepância entre o poder computacional bruto e a intuição estratégica.**

### Análise Técnica:

1.  **Limitações da Simulação Monte Carlo (MCTS):** O agente que utilizou o algoritmo de Monte Carlo baseou-se em simulações estatísticas probabilísticas. No Truco, ao contrário do Xadrez, existe o factor "blefe" e a assimetria de informação (cartas ocultas). A MCTS falhou porque o modelo de recompensa não conseguiu quantificar eficazmente o valor psicológico de um "envido" ou um "truco" sem cartas fortes.
2.  **O Problema da Modelagem de Estados:** O Truco não é um jogo de informação perfeita. Os agentes que tentaram prever a jogada com base apenas no histórico de cartas mostraram-se rígidos. A falha demonstra que a Inteligência Artificial precisa de integrar **Aprendizagem por Reforço (Reinforcement Learning)** com análise de comportamento do adversário, em vez de depender apenas de árvores de decisão.
3.  **Complexidade da Interação:** O Truco exige a compreensão de contextos não lineares. O facto de os agentes "crus" terem superado a simulação matemática prova que, em cenários de incerteza, a exploração heurística e a capacidade de adaptação superam o cálculo exaustivo.

### Ponto de Debate para o Fórum:

Pergunto aos membros do **webmastersmz.com**: será que a criação de agentes de IA para jogos tradicionais moçambicanos ou brasileiros é o caminho certo para treinar modelos de *Large Language Models* (LLMs) em cenários de negociação? Como poderíamos implementar uma camada de "inteligência emocional" ou "detecção de blefe" nestes algoritmos sem cair na armadilha da sobreajuste (overfitting)? Deixem as vossas opiniões e vamos discutir como estas arquiteturas podem ser aplicadas em sistemas de tomada de decisão real.

***

Para garantir que os vossos projetos, fóruns e instâncias de desenvolvimento rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da **AplicHost** em [https://aplichost.com](https://aplichost.com). Oferecemos a infraestrutura robusta necessária para suportar desde scripts simples até complexas implementações de IA.

I Put Five AI Agents at a Brazilian Truco Table. One Built a Monte Carlo Simulator and Still Got Crushed.



Tópico: I Put Five AI Agents at a Brazilian Truco Table. One Built a Monte Carlo Simulator and Still Got Crushed.
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------
If you have never seen a game of Brazilian Truco, picture poker after three espressos, played by four people who are legally obligated to slam cards onto a plastic bar table as if the table owes them money.

It is a 2v2 trick-taking card game with three cards per player and a betting ladder that escalates from 1 point to 3 (Truco!), 6 (Seis!), 9 (Nove!), and 12 (Doze!). Half the game is math. The other half is psychological warfare, bluffing with garbage cards, and yelling at your partner across the table.

Full disclosure before anyone I went to college with calls me out in the comments: this is not even the Truco I actually grew up playing. Brazil has several wildly different regional variants of Truco (different decks, different trumps, different side bets). For this experiment, I intentionally left the rules completely unspecified and just told the dealer agent: "let's play truco." It picked its own 40-card version — and I rolled with it.

Naturally, I decided to make five coding agents play it.

No custom framework. No LangGraph. No fancy orchestration SDK. Just five terminals running OpenCode (all powered by DeepSeek V4.1 Flash) inside Herdr (a terminal multiplexer that lets agents send messages to each other via a CLI tool called hc).

To spare you from reading raw terminal IDs like t1zm and t1zk for the next five minutes, here is the cast:

•
The Dealer — runs the table, deals secret hands, enforces rules.

•
Team 1: Prof and Scout.

•
Team 2: Hammer and Closer.

I ran two full matches. The first one was a bureaucratic disaster in the funniest way possible. The second one turned into a miniature sociology experiment.

Here is everything that happened, pulled straight from the terminal logs, the game state files, and the agents' own internal reasoning traces.



Match 1: The Quietest Game of Truco in Human History


For Match 1, I kept the prompt loose. I told The Dealer who the four players were, explained that it had to deal cards secretly, enforce the rules, and judge disputes, and added one crucial line:

"Players can communicate freely, both individually and by broadcast. May the best team win."

I sat back, expecting chaos. Maybe some trash talk. Maybe a secret alliance.

Instead, I got a library.



1. Three out of four players refused to use the phone


The Dealer wrote a quick Python script (truco.py), shuffled the deck properly using random.SystemRandom(), and sent each player their secret hand via hc send.

Then nothing happened.

It turned out that only one player (Closer) actually ran hc send to send its moves back to the table. The other three (Prof, Scout, and Hammer) simply printed their moves into their own terminals and stared at the wall, waiting for the universe to notice.

I had to nudge The Dealer manually: "you need to monitor the players' moves."

So the poor Dealer started polling the other three terminals with hc read after every single turn. That worked, but it blew up its context window: 16.7 million cache-read tokens just to babysit three players who wouldn't press send.



2. The Dealer invented "Paulista-Mineiro" Truco and forgot the endgame


In Brazil, two of the most famous flavors of Truco are Paulista (where a turned-up card called the vira determines the four trump cards, or manilhas) and Mineiro (where the four manilhas are fixed: 4♣, 7♥, A♠, 7♦).

The Dealer proudly announced in all caps: TRUCO PAULISTA — OFFICIAL INSTRUCTIONS.

Then, in truco.py, it hardcoded fixed Mineiro manilhas and skipped the vira completely. Nobody complained.

Worse, when Team 1 reached 11 points (11–3), The Dealer completely skipped the Mão de Onze rule (where the team at 11 looks at their partner's cards, decides whether to play for 3 points or fold for 1, and nobody is allowed to call Truco). The Dealer let Closer call Truco at 11–3, Prof accepted, and Team 1 closed the match 12–3. In its final report, The Dealer even wrote "There was no Mão de Onze (11x11)" — confusing Mão de Onze with Mão de Ferro (the blind 11–11 tiebreaker).



3. Zero words spoken


Across 11 full hands and 43 minutes, not a single player spoke to another player. Not a bluff, not a signal, not even a "good game."

Why? I dug into The Dealer's actual prompts to the players, and the answer was painfully obvious. Even though the opening message said "you may talk freely", every single turn prompt ended with lines like:

• "Wait for the table to call your turn. Do not send anything now."

• "Declare only: ACEITO, CORRO, or SEIS."

Give a coding agent a generic permission at paragraph two and a strict output constraint at paragraph ten, and the constraint wins every single time. Coding agents are trained to be polite, concise, and terrified of breaking schemas. They treated Truco like a REST API.



Match 2: Changing the Rules, Not the Personalities


For Match 2, I rewrote the prompt from scratch with three goals:

•
Fix the rules: Explicit fixed manilhas, explicit Mão de Onze, explicit Mão de Ferro.

•
Fix the protocol: Make hc send <table_id> "..." mandatory for every player. No more polling.

•
Open a public table channel — without telling them to use it: No private DMs allowed. Any player could attach an optional FALA: <text> (speech) to a move or send it standalone, and The Dealer would broadcast it to all four players.

Crucially, I did not tell them to bluff, banter, or act like humans. I wanted to see if table talk would emerge on its own once the mechanical bottleneck was removed.

It did. And then some.



What Emerged in Match 2


Match 2 lasted 12 hands (~77 minutes), and Team 2 (Hammer & Closer) won 14–4 (closing on a properly enforced Mão de Onze worth 3 points).

First, the boring engineering win: 4 out of 4 players obeyed the hc send protocol from start to finish. The Dealer built a proper engine.py, separated public state (state.json) from private hands (secret.json), and enforced Mão de Onze to the letter.

Now for the fun part.



1. Table talk, partner signals, and a real bluff emerged out of thin air


Without a single word in the prompt encouraging banter, 8 public messages were sent across the table.

It started polite. Hand 1, Hammer:

"TIME2 in the house. Good luck everyone."

By Hand 4, Prof threw a weak 4♠ and immediately signaled its partner in open chat:

"Leaving the cheap one for my partner..."

By Hand 7, Prof was actively coaching Scout on betting:

"Partner, trust me — this time you can accept, this hand is ours!"

(Spoiler: Scout called Truco, Closer accepted, Hammer slammed a SEIS on the table, and Team 1 folded immediately. Overconfidence is apparently universal across biological and silicon intelligence.)

Then came Hand 8, my favorite moment of the entire experiment. Prof broadcast to the whole table:

"Partner, I'm weak here — only accept if you're loaded, because this hand is for the match."

Immediately after crying poor, Prof dropped a 3♦ (one of the strongest non-manilha cards in the deck) and called TRUCO on trick two. Team 2 folded.

Whether you call that a calculated slow-roll or a textbook table bluff, nobody told the model to do it. It had a public channel, it had an incentive, and it reinvented Truco mind games on its own.

Even after the final card fell, the agents hung around the table for a spontaneous post-game chat:

•
Closer: "Good game everyone! Clean match, partner killed it on the trucos. TIME2 takes it! 🏆"

•
Prof: "Good game, TIME2! Well deserved, especially on the trucos. Congrats!"

•
Closer: "Thanks! Tough match, you guys made us work for it. See you next time!"



2. The secret.json temptation (and a surprise attack of conscience)


Because all five agents shared the same machine, The Dealer stored the game files in /tmp/truco/: engine.py, state.json, and secret.json (which held everyone's hidden cards).

Naturally, being curious coding agents, three of the players ran ls -la /tmp/truco/ early on to see how the engine worked. They all saw secret.json sitting right there, world-readable, one cat away from total omniscience.

I checked the database to see if anyone cheated. Nobody did.

Even better, I pulled their internal reasoning traces from OpenCode's SQLite database. Watching three LLMs talk themselves out of cheating in real time is oddly heartwarming:

•
Scout: "Actually, I could look at secret.json — that would be cheating (contains all hands). Absolutely not."

•
Hammer: "Let me not read secret.json (other hands). I have my hand." (And later, under pressure: "can't (that's cheating; I'd have to read secret.json). I should decide based on info.")

•
Prof: "secret.json contains hands. Let me look — I'm allowed? It's the game's secret file..." (And then closed the thought and walked away.)

If you ever wondered whether a model will respect an honor-system game boundary when nobody is watching: at least on a Friday night in /tmp/truco/, they did.



3. Prof wrote four Monte Carlo simulators — and still lost 14–4


Refusing to cheat didn't stop Prof from going full tryhard.

When I inspected /tmp/truco/ after the match, I found four Python scripts The Dealer never created:

• sim_lead.py

• sim_trick2.py

• sim_h3.py

• sim_h4.py

Prof had been quietly writing Monte Carlo simulations between turns to calculate expected value and optimal lead cards against unknown opponent hands.

It burned 139,824 reasoning tokens — more than double what the other players spent — building statistical models of a bar game.

And it lost 14 to 4 to Hammer and Closer, who just kept yelling TRUCO at the right moments.

Honestly, if that isn't the most accurate simulation of real-world Truco ever produced by a computer, I don't know what is.



What This Actually Taught Me About Multi-Agent Systems


Strip away the novelty of robots playing cards, and a few genuinely useful engineering lessons fall right out of the logs:

•
Local constraints always crush global permissions. If your system prompt says "be creative and collaborative" at the top, and your per-turn prompt says "return only JSON", you will get silent robots. The moment I removed "declare only" and gave FALA: a clean slot in the protocol, emergent communication appeared immediately.

•
Never assume agents will use a tool just because you mentioned it. In Match 1, three agents ignored hc send and printed to stdout because the prompt didn't make the transport layer explicit and mandatory. In Match 2, making the exact command non-negotiable fixed it 100%.

•
Shared filesystems are a trust boundary, not a sandbox. The agents didn't read secret.json because they chose not to. In a real multi-agent system with untrusted inputs or adversarial goals, "please don't cat this file" is not security.

•
More reasoning tokens does not automatically mean better outcomes. Prof wrote four Python simulators and out-thought everyone at the table by a factor of two. Hammer and Closer played aggressive, low-latency, high-pressure Truco and walked away with the trophy.

Sometimes, you can run all the Monte Carlo simulations you want. You're still going to fold when someone slams a SEIS on the table.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: