AI & Technology

Building AI Opponents for a Board Game: We Replay Every Game Our Bots Lose

By Paolo Montemurro, Founder and CEO of Mont3 Suisse

Mont3land, and who you play against 

Mont3 is a five-person AI studio in Lugano, Switzerland. This year we built Mont3land, a property-trading board game around Switzerland for two to six players. It runs free in the browser, in four languages, with online rooms and bots at five levels. The code was written by a coding agent, Claude Code, from our prompts. 

The game in short: players roll two dice around a loop of 48 spaces and buy the towns, cities, companies, rail lines and utilities they land on, or bid for them at auction. Whoever stops on a property pays rent to its owner, and chalets and hotels raise that rent. A small stock exchange runs beside the board, with bonds, stocks and crypto. You win by being the last player with money, or the richest when the last round ends. 

A side effect of building it as a web page, in TypeScript and React: wrapped in Capacitor, the same code became an Android app, with nothing of the game written twice. 

A board game is only as good as its opponents. This article is about three things we learned making them: how the bots decide, how they get better from the games people win against them, and how the game tells you who is really ahead. 

Five bots, and no machine learning 

None of the five bots uses a neural network or a language model. They are rules and arithmetic that run in the player’s browser.  

Setting up a game. Each seat is a person or a bot, and each bot plays at one of five levels: Easy, Medium, Difficult, Best or Angry. 

Easy buys and builds when it can, and bids low. Difficult works out what every property is expected to bring its owner over the coming rounds: rent by how often a token lands there, a company by how often its number is rolled. It bids up to what a property is worth to itself plus what it is worth to the rival it keeps it from. Medium plays some turns like Easy and some like Difficult. 

Best looks ahead. It takes Difficult’s answer and a few alternatives, plays each one forward on dice and cards it cannot know, and keeps the one that leaves it best off. This is the idea of pure Monte Carlo game search. Angry is Best turned against one person at the table. 

No bot sees the next roll or a hidden card. A harder bot reasons better; it does not cheat. 

First, the bots played each other 

Difficult’s judgement comes down to a set of weights, such as how many rounds ahead it reckons. We did not guess them. The agent wrote a tool that moves one weight, plays 400 games against the bots as they were, with two, three, four and six players, and keeps the change only where it wins more. 

The idea is old: Arthur Samuel’s checkers program improved by playing against itself in the 1950s. After the first tuning, the new Difficult beat the old one in 91% of four-player games. 

Self-play has one blind spot. It only shows how bots do against bots. 

Every game is recorded 

A game of Mont3land is its starting setup plus every answer given in it, about 2,000 of them at a table of six. Every game a signed-in player finishes is kept on our server in that form. So any game can be played again, move by move. 

The agent wrote a second tool that replays those games and reports how each one was won. It lists what the winner bought at auction against the list price, where their money came from, which sets they collected and when, and what broke the players who went out. One detail took care: a game only replays under the rules it was played by, so the tool fetches the engine of earlier versions from the code history until one plays the game through. 

What the replays showed: the rail lines 

I had won four games out of five at a table of six, against five of our strongest bots: one Angry and four Best. The replays showed how. In one game I held all four rail lines by round 7, for CHF 995 in total. Over the game they brought CHF 24,690 in fares. 

 

The deed of a rail line. The fare grows with every line its owner holds, from CHF 30 with one to CHF 220 with all four. 

Meanwhile the bots were bidding one another up to CHF 860 and CHF 940 for a single company. The tuning of the night before could not see it, because it had only played bot against bot. 

So we tested the suspicion the way we test everything. One seat was told to go for the rail lines alone, against five normal bots, over 1,200 six-player games. An even share of the wins is 16.7%; that seat won 33.8%. 

The bots held the rail lines far too cheap. Now they count a line’s fares for the whole game, and each bot has a goal: one kind of property it collects and pays more for. With that change, the seat that goes for the rail lines alone wins 15.2%. 

Three mistakes one win showed 

After that change I finished eleven games against the bots. I won one, and eight ended in my bankruptcy. We replayed the one win to see whether it was luck. 

It was not the dice. The bots had made three mistakes. 

They put CHF 800 more into companies that a card had already stopped from earning. They let a card go cheaply that was then played against them. And they sold me the pieces that completed my sets: one city went for CHF 540, and the set it completed took CHF 5,153 in rent. 

Each mistake became a rule or a weight. Then came the check we trust most. The changed bots were put back into that recorded game, at those exact moments, under the rules of that day. None of the four investments and none of the three offers was made again. 

The bots do not learn while you play 

Nothing adapts during a game, and no model is trained on players. What learns is the loop around the bots: record the game, replay the wins, find what they have in common, try it on one seat over 1,200 games, change the bot, and check the change against the recorded game. 

The agent does the replaying and the measuring. A person decides what counts as a flaw. 

The loop had a side effect we did not expect. Difficult, retrained twice in those days, caught up with Best. Alone among five Difficult bots, Best now wins 16% of six-player games, an even share. Four days earlier it won 30%. 

Who is winning: not the richest, the best placed 

Next to each player’s name the table shows a chance of winning. To get it, the game is played out to its end 400 times from the table as it stands, with Difficult in every seat and with dice and cards nobody at the table can know. The figure is the share of those games the player wins. It runs in the background, at about 30 milliseconds a game. 

This figure often disagrees with the wealth column. Wealth counts a property at its price. The chance of winning counts what it will bring, and to whom. Four rail lines bought for CHF 995 look small on the balance sheet in round 7. 

Round 9 of a game between four bots. Ueli is the richest, worth CHF 2,429. Giulia, worth CHF 1,511, has the best chance of winning: 42%, shown under her token. 

We measured it on 54 four-player games between Difficult bots, looking at the table at rounds 6, 12 and 20 of 35. At round 6 the player with the best chance was not the richest one at 65% of the tables, and at round 20 still at 17% of them. Where the two differed, the best-placed player went on to win 52% of the games and the richest 23%. 

A Stats screen draws the three lines round by round: chance of winning, cash and worth. Reading them after a game shows the round in which it was decided. 

The Stats screen of the same game at round 22. Ueli (blue) is still the richest, worth CHF 3,620, but Reto (yellow) has an 83% chance of winning. 

What we would tell another team 

  1. Store a game as its setup plus every answer, so that it can be replayed. 
  2. Tune the bots by self-play, and do not trust it alone. 
  3. Replay the games people win, and look for what those wins have in common. 
  4. Test a suspected flaw on one seat, over enough games to see past chance. 
  5. Check each fix against the recorded game that exposed the flaw. 
  6. Show players their chance of winning, worked out without looking at the dice to come. 

Mont3land is free to play at games.mont3.ch/mont3land, against the bots or online with friends. We are writing the method up as a guide, How to build a videogame with AI and Claude Code. The rest of what the studio builds, AI products, agents and local AI for companies, is at mont3.ch. 

Paolo Montemurro 

Author bio: Paolo Montemurro is the founder and CEO of Mont3 Suisse, an AI studio in Lugano, Switzerland, that builds AI products, agents and local AI for companies. He is a visiting lecturer at USI, Università della Svizzera italiana, and at the Glion Institute of Higher Education. 

Related Articles

Back to top button