Perudo AI - Alpha Version

game_image
I am working on AI for Perudo on BGA. At the time, they gave me a yellow light which means "when we're ready, we'll contact you," which is a good one.

TL:DR; Perudo is poker version of dice with dice being both your hole card and your stack. Due to the similarity, the AI employs a strategy that resembles poker.

Rule

The variant used on Perudo is called Asmodée. Each player starts with 5 dice. The die is like the normal dice with the 1 side is changed to the wild 'paco'. The paco can be everything.

If you're the first one to bid, you must make a bid of how many dice rolled a specific face value. For example, if I bid 8 dice of , that means I'm bidding that, if we reveal every dice rolled and I count the dice count of , the dice count will be at least 8.But there's a catch. The 1 side is a joker side called 'pacos'. This 'pacos' can count as anything the bidder bid. For example, if I bid 8 dice of , all pacos will turn into a if someone challenged my bid--making the game more has higher variance. To make things worse, You can't bid on pacos on the very first bid.

The next player in turn will take turns to bid.

You have three options:

A. Dudo

Someone bid 9 dice of . "Realy? 9 dice of ?" If you believe the number of that appears is less than 9, then you called "Dudo." If you accuse correctly, the bidder lose a die. If you accuse incorrectly, you lose a die. Lose every dice and you are eliminated.

B. Calza

Someone bid 9 dice of and you believe that the dice count is exactly 9--you may call calza. If you calza correctly, you recove one die. If you calza wrongly, you lose one die. Dudo can be called by the next player in turn, but anyone except the real bidder may call calza.

Remember that when resolving dudo or calza, you must account for the pacos. This is why the game turned into a high-variance game.
C. Bid

If you think that neither Calza or Dudo is an option--you can increase the bid.

There are 2 possible scenarios:

Scenario #1: If the previous bid is not a pacos bid then you can either.

A. Raise the number of dice being bid. From 7 of into 8 of , or
B. Raise the face value of the dice being bid at. From 7 of into 7 of , or
C. A mixture. From 7 of into 8 of , or
D. Bid pacos with new bid is half of the dice being bid. Ex: From 7 of into 4 of [pacos].

Scenario #2: If the previous bid pacos, then you can either.

A. Raise the number of pacos being bid. From 4 of [pacos] to 5 of [pacos], or
B. Revert the face value back to numerical value, but the new bid is old bid x 2 + 1. For example: From 4 of [pacos] to 9 of

The bidding continues until a Calza or a Dudo is shot. Then every player re-roll their dice to restart for a new game.

Palifico:

As times goes, player loses dice. When one player gets to one die for the first time, the game enters palifico. The original bidder can bid pacos and the next bid can't change the face value of the dice--only the amount of dice being bid. This is a perfect chance for the player in disadvantage to at least lift some finger.

The game goes on until the last man standing.


Remember this dice scene from Pirates of The Caribbean?
STRATEGY

In poker, your hand is your card and your stack is your casino chip. In Perudo, your dice become both your card and casino chip. So to say the least, this is a simplified version of poker.

Using flawed math logic:

  • Poker demands a complex poker AI.
  • A simplified poker demands simpler poker AI.
  • Perudo is a simplified poker.
  • Therefore, we need simple poker AI.

First instinct shows that we should use mathematical probability to decide whether to dudo or not. It's simple: If the probability that a bid is impossible is 50%, then we should dudo. Right?

But if we use this logic--we will never Calza because the probability that a bid is exact won't ever reach 50% unless we reach final two dice.

But first, let's solve this dilemma.

In a poker competition, the amount of money you won will not be decided by the amount of chip do you have--but it will be decided by when you're eliminated. It doesn't matter if you have a big stack, but if you're eliminated before the player B--whose stack size is significantly smaller to you--then you receive less money than B.

This is same with Perudo. Your dice doesn't matter, when you're eliminated does.

But how will we make this a quantitative calculation?

Poker theorist introduces ICM--Independent Chip Model. What it does is it calculates the probability you finish 1st, 2nd, 3rd, 4th, etc using chip ratio. After we find the probability, it's easy to find the Expected Value (EV).

We will use the exactly same concept. But for Perudo, we will name it IDM--Independent Dice Model. The method is still the same. This is a mere renaming. Further on the text, If I said IDM, I meant ICM--and vice versa.

ICM on Poker has some weakness. Some weakness is fixed by the nature of Perudo.

  • ICM can be inaccurate if the blind increases. Fortunately, the blind doesn't increase in Perudo--it stays at 0.

  • ICM doesn't count for player skill. This is true for Board Game Arena. We can't download data to know one's skill.

The scoring methodology used by BGA is they award score for certain position. In a N=5 player game, the 1st place wins N-1 points, 2nd place wins N-2 until the last place wins 0 point. This payout will be used to calculate the EV.

During our turn, we will calculate our EV using IDM. First, we will consider the EV if we calza. We call this IDM_Calza.

The formula for IDM_Calza is:

Our IDM if we calza correctly x the chance of a correct calza + Our IDM if we calza incorrectly x the chance of a wrong calza.

We will also find our IDM_Dudo by:

Our IDM if we dudo correctly x the chance of a correct dudo + Our IDM if we dudo incorrectly x the chance of a wrong dudo.

To find the probability of a correct dudo or calza, we'll use our dice as a base information and count the probability that it's a good dudo using simulation.

If IDM_Calza or IDM_Dudo exceeds our current IDM, then we know that Calza or Dudo is the correct move. If not, then we know neither Calza nor Dudo is the correct move. Because neither is the correct option, then bidding is the only move. We will pick the bid that is the least likely to be impossible.

But what about the starting bid? There is no IDM_Calza or IDM_Dudo to calculates because there is no bid yet. In that case, we're bidding (sum of dice)/4 of a random sided dice. If it's palifico then we're bidding (sum of dice)/7 of random sided dice.

Result

Abiding BGA's Elo system, each player starts with elo of 1500. A game's K factor is equal to 60 x (N / 2) / (N-1), where N is the number of player in the game. The following is the AI's elo performance.


It's an altitude graph of the first leg of Tour De France!

After 22 games, the elo finished at 1601. The average Elo is 1586 with standard deviation of 52.2958. In BGA, a player is considered good if the elo reaches 1600 (just below our 1601, phew!)

Unfortunately, using t-test, we reject the hypothesis that the AI is a good AI by BGA standard. T-test suggests that our actual average of ELO is around 1549 ~ 1597.

The AI played 21 games against 48 players. AI made 65 dudo calls, 35 of them are correct (53%). The AI also made 4 calza calls, 1 of them is correct. Well, I'm fully aware that 21 games are not enough sample, but I'm cutting it early because there are rooms for improvement and I prefer to do it now instead of waiting the 30 games goal.
Feedback

  • A lot of mistakes occur due to human error. I need to make GUI?
  • I used iteration for IDM, making it slow. I need to make a Dynamic Programming version of it.
  • This is pure mathematical iteration. Even tough this causes the program good at picking bluff, it's not good at picking honest move and the truth is, human being are known to be not bluffing enough. I have an idea though.
  • The (n/7) and (n/4) first starting bid sometimes creates sketchy bid. If I get this right, I'm confident I can hit it high.
  • The AI creates sketchy bid that we're sure by human sense is impossible. The thing is the model doesn't consider for IDM if we make certain bid.
  • Now when comparing bids, the AI will pick the least risky move. If there is a tie, the AI will pick the smallest number to bid at from the options. Now this is a wrong move. I should have picked the highest number to bid at from the options instead. By quickly raising the number, I force my opponent to make a pacos bid--making less variance game play.
  • There is a genius trick called "calza gambit". Let's say that each player has 3 dice. The gambit player will bid 2 of . Wary of what the bidder has, the opponent will bid 1 of pacos. The bidder will then calza with having exactly 1 pacos. This is actually a smart move because there's a 57,63% chance of the opponent not having any pacos at all. However, judging by the IDM, this is actually an unwise thing to do. Before the player makes the gambit, the player's IDM is at 0.5. By making the gambit, the player's EV IDM is at 0.4977. This occurs because math dictates that each die lost hurts more then a recovered die heals.
What's next?
  • I will rework the AI again. I have interest at making AI for Coloretto, but there's too many variable. Focus on Perudo for now.
  • When Barclays Premier League kicks in again, I will deploy my model that predicts soccer match result. It's an ambitious project for a 17 year old boy, but who knows?
  • Get myself prepared for my 18th birthday. To be precise, making sure nobody remembers it except my family. Why people celebrate birthday? That's just stupid. "Congratulation! You are 365 days closer to your death!"
  • Focus a little bit on the university entry test.