Simulations

Part 1: Does Skill Matter in Brisca? A Simulation Tells the Story.

Author

Hector C. Ortiz

Date Published

briscas with chart in the back

TL;DR

Briscas depends way more on luck than I thought.

To understand how skill-based Briscas really is, I ran 20,000 simulated games using an “advanced” bot against two types of opponents: a random bot and a bot that actively tries to lose.

The random bot still won around 30% of the games
The self-sabotaging bot won around 28%



Note: Knowledge of the game is NOT needed to understand this post but in case you are curious, here are the rules.



A few months ago, I was playing Briscas with my wife and, despite trying my absolute hardest, I lost. I promise I’m not a sore loser, but it did leave me wondering, how skill-based is Briscas, really? Or another way of putting it, how many games are doomed from the start simply because of how the cards were dealt? 


I let the question go until recently, at a wedding, when a friend of mine brought it back to life. He told me he had just taught someone how to play Briscas and then immediately lost to them. Beginner’s luck? Cosmic injustice? Or is Briscas less about skill than we’d like to pretend?


So, armed with my software engineering knowledge and far too much confidence, I figured I’d just read some books on statistics but I quickly noticed I would need to get to an advanced level before I could answer the question (Bayesian statistics was interesting tho). Seeing that I don’t want a Phd in statistics (it would be cool tho) I thought I’d brute force the problem. “How many possible games could there be?” I thought. “A few million? A billion?”


Turns out there are 2.1x10^53 possible games of Brisca, more than the estimated mass of the observable universe (1.5x10^53 kg). 


Yes, you read that right. There are literally more possible Brisca games than there is universe to put them in. (If you are curious on how I got the number for the possible games of Brisca its in the appendix at the bottom.)


Since statistical analysis and brute force were clearly off the table, I had to find another approach. That’s when I remembered Monte Carlo simulations, a technique I first learned about while reading a book on algorithmic trading (which I’ll probably write about at some point). The idea is beautifully simple, run a ridiculous number of random simulations and trust that the law of large numbers will eventually feel sorry for you and reveal the truth.


With a clear approach in mind, the next step is the Brisca implementation I could use to run the simulations. The obvious move was to code everything from scratch: the game engine, the rules, the bot, the whole thing. But then I remembered I’m lazy efficient, so I checked GitHub first. At first, the list of results didn’t look promising, many projects were incomplete, outdated, or not quite what I needed. 


By page four of the list, I was ready to give up and accept my fate. But out of sheer stubbornness (and maybe pride), I pushed on. Thankfully, that paid off. The very last repository in the list turned out to be exactly what I needed, a Flask API that implemented the full game logic and even included three different bot difficulty levels.


briscas repo


It wasn’t perfect, but it was a solid foundation. I cloned the repo, ran it, played a test game and immediately lost. That was all the validation I needed. This thing was legit. After reviewing the documentation, I generated a script to interact with the API and automate gameplay. The first version didn’t work, but after a bit of debugging, refinement and chatGPT, the integration was successful.


With that in place, I could finally run simulations to estimate how skill-based Briscas really is. The only remaining question was how many games to simulate. I settled on 10,000, partly because ChatGPT said it was enough, but mostly because my MacBook Air was already wheezing like it was trying to run Crysis.


With everything finally working, I unleashed the advanced bot against a bot whose strategy could be summarized as: “pick a card, any card.” Basically, this was my official monkey test, how often would a completely clueless player win?


Ten minutes and some wheezing later, the results were in:


Advanced Bot

Random Bot

Tied Games

Games Won

6,853

2,983

164

Percentage Won

68.53%

29.83%

1.64%


At this point, all I can say is, I’m never betting on a game of Briscas again. Not unless my opponent is blindfolded, distracted, and holding their cards upside-down and even then, apparently, there’s still a 30% chance they win.


After seeing the results against the random bot, I wanted to dig deeper. What percentage of games are truly unwinnable, no matter what you do? To find out, I created a new bot designed to play as badly as possible, always giving away points whenever it had the chance. Pure sabotage. Maximum chaos. The “throw the game” strategy.


Then I put it up against the advanced bot to see what would happen. Ten minutes later, the results were in:



Advanced Bot

Random Bot

Tied Games

Games Won

7,042

2,853

105

Percentage Won

70.42%

28.53%

1.05%


Even if my opponent is actively trying to lose, like, actively, aggressively, enthusiastically throwing the game I still lose 28% of the time… 


Of course, both bots I used here rely on heuristic logic, and they’re far from perfect. They’re doing their best, but their best might be questionable. So in Part 2, I’m planning to bring in machine learning and training two actual AIs, one that wants to win, and one whose sole purpose in life is to lose.


But even with better bots, the early verdict is clear, if Briscas is a skill-based game, it’s hiding it really well..


Here's the repo with the brisca game and the script






Appendix



Briscas uses a 40 card deck and in a 2 player game, each player starts with 3 cards and plays through 17 rounds where the winner of each round draws first and the loser draws second.


Using these constraints:

- 40 cards means 40! possible deck orders
(815,915,283,247,897,734,345,611,269, 596,115,894,272,000,000,000)

- The initial deal plus 17 rounds means 2¹ = 262,144 different draw sequences


Combine them and you get 2.1x10^53.