πŸ“š Basics of Probability

Why do we need maths in games?

Any game β€” from simple board games to complex computer RPGs β€” is, first and foremost, a system of rules. And where there are rules and possible outcomes, mathematics inevitably appears. We often think that in a game, everything is decided by luck or, conversely, by β€œgut feeling” and experience. But behind the apparent randomness, there are clear laws of probability theory, mathematical statistics and even game theory. Understanding these laws allows not only to increase the chances of winning, but also to get much more pleasure from the game β€” by consciously analyzing the situation, weighing the risks and finding the best moves.

Project goals and objectives

The goal of this project is to demonstrate how mathematical methods help in analyzing games, developing effective strategies and debunking common myths about "luck". To this end, we will address the following objectives:

  • Introducing basic probabilistic concepts (event, frequency, probability, expected value) using examples from games.
  • Analyzing probabilities in games that use dice, taking "Monopoly" and a standard dice game as examples.
  • Examining strategies in board games that are built on randomness ("Catan").
  • Exploring how random number generators work in computer games and why "randomness" is not actually entirely random.
  • Learning to make decisions based on expected value, determining when a risk is justified and when it is not.
  • Examining elements of game theory, using zero-sum antagonistic games ("Rock, Paper, Scissors") as an example.
  • Exploring some typical probability-related paradoxes and errors that players experience.
  • Performing a practical simulation of rolling two dice using Python and comparing the theory with the experimental results.

Examples of games where winning depends on calculation and probability include chess (though it involves no randomness, analyzing potential moves is a matter of pure combinatorics and positional evaluation), Monopoly (which combines the randomness of dice rolls with a strategy for purchasing real estate), and computer RPGs (where factors like the chance of a critical hit or the discovery of rare items come into play). Mathematics is what connects them all.

Fundamental probabilistic concepts for game analysis

Before diving into specific games, it is worth refreshing some basic concepts of probability theory. Understanding them is the key to everything that follows.

An event is any outcome or set of outcomes that we are interested in. For example, in a game involving a single six-sided die, an event could be "rolling a 6" or "rolling an even number".

Frequency of event is the ratio of the number of favorable outcomes to the total number of experiments (tosses, moves) performed. For example, if we roll a die 100 times and a six appears 18 times, the frequency is 18/100 = 0.18. Frequency always depends on actual context and can fluctuate.

Probability is a theoretical measure that predicts the proportion of favorable outcomes in a long series of random experiments, assuming that all outcomes are equally likely. For a fair die, the probability of rolling a six is \( \frac{1}{6} \approx 0,1667 \). As the number of rolls increases, the observed frequency will tend toward this probability (the law of large numbers).

Expected value is the mean value of a random variable, weighted by probabilities. If, in a game, one can win an amount \(x_i\) with a probability \(p_i\), then the expected value of the winnings is equal to \( \sum x_i p_i \). This represents the average amount one would receive per turn if the game were played many times.

Take the example of a die: one rolls a die and receives a number of dollars equal to the number that comes up. In this case, the expected value is \( 1 \times \frac{1}{6} + 2 \times \frac{1}{6} + \dots + 6 \times \frac{1}{6} = 3,5 \) dollars. Although this is not a whole number, it represents the average winnings one would get over a long series of rolls.

Another example: one draw one card from a standard 36-card deck. If it’s an ace, one gets 100 points; otherwise, one gets 0. The probability of drawing an ace is \( \frac{4}{36} = \frac{1}{9} \approx 0,1111 \). The expected value is \( 100 \times \frac{1}{9} + 0 \times \frac{8}{9} \approx 11,11 \) points. Knowing the expected value helps decide whether it’s worth playing such a game if there is a cost to participate.