# About the value of cards in the game "Drunkard"

Recently, I have been playing a lot of games with my 5-year-old son in the “Drunkard” card game. Both he and I rejoice when we win, and we are upset when we lose.

At some point I wondered: what is the “financial” value of each card in the “Drunkard”? Since Six beats Ace (see the version of the rules under the cut), the value system in “The Drunkard” is cyclical, and the answer is not obvious. For example, is the Seven of Six more valuable? Seven beats Six - yes! But on the other hand, each of them beats only one other card in the game (Seven - Six, and Six - Ace) - so they are equal in value? But the Ace, beaten by the Six, in itself is much more valuable than the Six, beaten by the Seven - does the Six mean more ?!

I decided to bring a mathematical model to the analysis of the value of cards in “The Drunkard”. The results were the most unexpected.

For starters, here are the rules for our version of this game:

As is clear from the rules, victory in this game depends solely on luck - the winner is determined by the distribution of cards, since nothing depends on the players at all.

So, how can we determine the “value” of a card in a “Drunkard”? I decided to determine the value of the card through the expected number of cards that this card will bring if the game continues indefinitely.

Let's start with a simple task: determining the expected number of cards for only Six and only one battle. There are 36 cards in the deck, so if we go with the Six, it enters the battle with another (randomly selected) card from the remaining 35. What can happen? With an probability of 4/35, the Ace will drop out, and then we will get the Six and Ace. With a probability of 3/35, another Six will fall out, and a dispute will occur - and since we assume an absolutely random alignment, we are equally likely to win or lose it, which means that on average it is expected that our Six will remain with us . In all other cases, we lose the six. Total, the expected number of cards for the Six after one battle: 7/35 Six + 4/35 Aces.

Now, fill in the matrix for the expected number of all cards for one battle (the Six row is the expected number of cards received after one battle with the participation of our Six).

Obviously, it is not enough to take into account one battle to determine the value of the map. For example, Six has a chance to win an Ace, who will play at some point in the future and, in turn, has a chance to win other cards. How to get a similar matrix, but with the expected number of cards in two battles? The answer is astonishingly simple - you just need to multiply this matrix by itself! (Basics of matrix multiplication: to get the element (X, Y) of the multiplication result, you need to scalarly multiply the row X of the first matrix by the second column Y, that is, multiply the corresponding elements of these two vectors in pairs and add the results).

For example, the probability of starting with the Six and holding the Six after 2 battles is (7/35) ^ 2, since the Ace potentially won in the first battle does not increase the chances of getting the Six in the second. However, the same Ace increases the chances of getting each of the other cards in the second battle - but the expected number of cards for the Ace in the second battle is multiplied by the probability of getting the Ace in the first battle (4/35). Etc.

Here one can quite reasonably object that by the time of the second battle the probabilities will not be the same as at the time of the first, since we assume certain results of the first battle. Indeed, ideally, we would calculate all the paths of this garden of diverging paths. But this is not easy to do, so we assume that the changing probabilities are the same for all cards and the errors are somehow averaged.

So, quite a bit of code hack:

Please note that after a certain number of battles all the expected number of cards for one card become the same - since (due to the circular system of values) in the end we can win

For clarity:

Unexpected conclusions:

At some point I wondered: what is the “financial” value of each card in the “Drunkard”? Since Six beats Ace (see the version of the rules under the cut), the value system in “The Drunkard” is cyclical, and the answer is not obvious. For example, is the Seven of Six more valuable? Seven beats Six - yes! But on the other hand, each of them beats only one other card in the game (Seven - Six, and Six - Ace) - so they are equal in value? But the Ace, beaten by the Six, in itself is much more valuable than the Six, beaten by the Seven - does the Six mean more ?!

I decided to bring a mathematical model to the analysis of the value of cards in “The Drunkard”. The results were the most unexpected.

For starters, here are the rules for our version of this game:

- The game involves 2 players.
- 36 cards (from sixes to aces) are dealt equally.
- Each player removes the top card of his deck and puts it face up - there is a "battle". The player who wins the battle puts all battle cards under the bottom of his deck.
- The winner of the battle is determined by the usual seniority of the cards (from top to bottom): Ace, King, Queen, Jack, Ten, Nine, Eight, Seven, Six. There is only one very important exception: Six defeats Ace.
- If identical cards participate in the battle (for example, two tens), then a “dispute” occurs: on top of the “arguing” cards face down on the card (they are passive hostages of the dispute), and then face up two more cards that enter the battle. The winner takes all the dispute cards.

As is clear from the rules, victory in this game depends solely on luck - the winner is determined by the distribution of cards, since nothing depends on the players at all.

So, how can we determine the “value” of a card in a “Drunkard”? I decided to determine the value of the card through the expected number of cards that this card will bring if the game continues indefinitely.

Let's start with a simple task: determining the expected number of cards for only Six and only one battle. There are 36 cards in the deck, so if we go with the Six, it enters the battle with another (randomly selected) card from the remaining 35. What can happen? With an probability of 4/35, the Ace will drop out, and then we will get the Six and Ace. With a probability of 3/35, another Six will fall out, and a dispute will occur - and since we assume an absolutely random alignment, we are equally likely to win or lose it, which means that on average it is expected that our Six will remain with us . In all other cases, we lose the six. Total, the expected number of cards for the Six after one battle: 7/35 Six + 4/35 Aces.

Now, fill in the matrix for the expected number of all cards for one battle (the Six row is the expected number of cards received after one battle with the participation of our Six).

Six | Seven | Eight | Nine | Ten | Jack | Lady | King | Ace | |
---|---|---|---|---|---|---|---|---|---|

Six | 7/35 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4/35 |

Seven | 4/35 | 7/35 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

Eight | 4/35 | 4/35 | 11/35 | 0 | 0 | 0 | 0 | 0 | 0 |

Nine | 4/35 | 4/35 | 4/35 | 15/35 | 0 | 0 | 0 | 0 | 0 |

Ten | 4/35 | 4/35 | 4/35 | 4/35 | 19/35 | 0 | 0 | 0 | 0 |

Jack | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 23/35 | 0 | 0 | 0 |

Lady | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 27/35 | 0 | 0 |

King | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 31/35 | 0 |

Ace | 0 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 4/35 | 31/35 |

Obviously, it is not enough to take into account one battle to determine the value of the map. For example, Six has a chance to win an Ace, who will play at some point in the future and, in turn, has a chance to win other cards. How to get a similar matrix, but with the expected number of cards in two battles? The answer is astonishingly simple - you just need to multiply this matrix by itself! (Basics of matrix multiplication: to get the element (X, Y) of the multiplication result, you need to scalarly multiply the row X of the first matrix by the second column Y, that is, multiply the corresponding elements of these two vectors in pairs and add the results).

For example, the probability of starting with the Six and holding the Six after 2 battles is (7/35) ^ 2, since the Ace potentially won in the first battle does not increase the chances of getting the Six in the second. However, the same Ace increases the chances of getting each of the other cards in the second battle - but the expected number of cards for the Ace in the second battle is multiplied by the probability of getting the Ace in the first battle (4/35). Etc.

Here one can quite reasonably object that by the time of the second battle the probabilities will not be the same as at the time of the first, since we assume certain results of the first battle. Indeed, ideally, we would calculate all the paths of this garden of diverging paths. But this is not easy to do, so we assume that the changing probabilities are the same for all cards and the errors are somehow averaged.

So, quite a bit of code hack:

```
require 'matrix'
# Матрица ожидаемых кол-в для одного сражения
m1 = Matrix[
[7.0/35, 0, 0, 0, 0, 0, 0, 0, 4.0/35],
[4.0/35, 7.0/35, 0, 0, 0, 0, 0, 0, 0],
[4.0/35, 4.0/35, 11.0/35, 0, 0, 0, 0, 0, 0],
[4.0/35, 4.0/35, 4.0/35, 15.0/35, 0, 0, 0, 0, 0],
[4.0/35, 4.0/35, 4.0/35, 4.0/35, 19.0/35, 0, 0, 0, 0],
[4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 23.0/35, 0, 0, 0],
[4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 27.0/35, 0, 0],
[4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 31.0/35, 0],
[0, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 4.0/35, 31.0/35]
]
# Матрица ожидаемых кол-в после 1000 сражений (m1 в степени 1000)
m1000 = m1 ** 1000
# (значения округлены) => Matrix[[0.0667, 0.0667, 0.0667, 0.0667, 0.0667, 0.0667, 0.0667, 0.0667, 0.0667], [0.0095, 0.0095, 0.0095, 0.0095, 0.0095, 0.0095, 0.0095, 0.0095, 0.0095], [0.0127, 0.0127, 0.0127, 0.0127, 0.0127, 0.0127, 0.0127, 0.0127, 0.0127], [0.0178, 0.0178, 0.0178, 0.0178, 0.0178, 0.0178, 0.0178, 0.0178, 0.0178], [0.0267, 0.0267, 0.0267, 0.0267, 0.0267, 0.0267, 0.0267, 0.0267, 0.0267], [0.0444, 0.0444, 0.0444, 0.0444, 0.0444, 0.0444, 0.0444, 0.0444, 0.0444], [0.0889, 0.0889, 0.0889, 0.0889, 0.0889, 0.0889, 0.0889, 0.0889, 0.0889], [0.2667, 0.2667, 0.2667, 0.2667, 0.2667, 0.2667, 0.2667, 0.2667, 0.2667], [0.4667, 0.4667, 0.4667, 0.4667, 0.4667, 0.4667, 0.4667, 0.4667, 0.4667]]
```

Please note that after a certain number of battles all the expected number of cards for one card become the same - since (due to the circular system of values) in the end we can win

**all the**cards, then the expected number for all cards converge to one number. Now there is very little left - add up all the numbers in each row to find out the “value” of each of the cards (that is, the expected number of cards after 1000 battles):```
m1000.row_vectors.map {|row| row.reduce(&:+).round(3)}
# [0.6, 0.086, 0.114, 0.16, 0.24, 0.4, 0.8, 2.4, 4.2]
```

For clarity:

Six | Seven | Eight | Nine | Ten | Jack | Lady | King | Ace | |
---|---|---|---|---|---|---|---|---|---|

Value | 0.6 | 0.086 | 0.114 | 0.16 | 0.24 | 0.4 | 0.8 | 2.4 | 4.2 |

Unexpected conclusions:

- The value of the Six lies between Jack and Queen!
- Only with King and Ace, the expected final number of cards exceeds 1 (that is, a positive ROI is expected).