Professional Documents
Culture Documents
Quiz04
Quiz04
Chess engines operate by generating a decision tree, pruning irrelevant branches, assigning scores to
the leaves, and consulting the minimax oracle for an optimal decision. The minimax algorithm is a
decision rule that minimizes the maximum possible loss of a worst-case scenario for the player. The
minimax algorithm is able to minimize potential loss by using positional evaluations to predict the
opponent’s next move. The results of a minimax algorithm are normally displayed on a tree diagram
to represent each combination.
Linear Algebra matrix computations can be used a powerful tool to solve Game theory problems.
There are popular games of our childhood which can be solved through game theory using Linear
Algebra.
Rock, Paper, Scissors is one of the simplest examples of Zero Sum Games. A Payoff Matrix can be Figure 2. Binary chessboard
determined , produces a symmetrical result. For example, we count the scores of two players over
multiple games. For every win, a player adds one point, for every loss, a player subtracts a point, and
for every tie neither adds nor subtracts a point from the score. The Payoff Matrix would look like this:
Figure 4. Minimax Algorithm
n=m=3
P 1 = P 2 = {Rock, Paper, Scissors} In a typical minimax algorithm, you would need a function to evaluate the score for the original player
and a separate function to evaluate the score for the opponent. However, in chess, the scores for
0 1 −1
both players are related because chess is a zero-sum game.
P 1 × P 2 = −1 0 1
.
1 −1 0 In a zero-sum game, the total sum of each outcome is always zero because, in order for a player to
gain points, another player must lose the exact same number of points.
This matrix is akin to a skew-symmetric matrix, which means that the game itself is symmetrical. If Due to the relation between points for players, the negamax algorithm is optimized by using the same
one player wins a point, the other player loses a point. If both players tie, then both players neither function for the original player and the opponent, and only negating the total point value found when
receive nor lose a point. This is the essence of a Zero Sum Game: for every positive choice a player evaluating for the opponent.
makes toward a reward another player makes a negative choice that diametrically opposes it.
Matching Pennies or Head-Tails
Chess Figure 3. Cartesian coordinate chessboard
Cartesian coordinate system is also used for specific advantages. In the Figure In the game of matching pennies, each player has a penny and must secretly turn the penny to ei-
The game of chess has attracted mathematicians for generations. With its geometric board and vector ther heads or tails. They then reveal their choices simultaneously. If the pennies match—both heads
like piece movement, the proposition that chess can be solved mathematically has caused centuries of 1, Chess pieces are numbered as 01 to 07 whereas black pieces are
or both tails—player A keeps both pennies, so he wins one from player B. If the pennies do not
man hours to be spent searching for the elusive formula which will reduce chess to a precise formula represented from 11 to 17 . match—one heads and one tails—B keeps both pennies, so she wins one from A. Let’s write this game
which if followed, will inevitably result in victory. Deriving this formula by hand is generally accepted in normal form! If the pennies match, A wins one penny and B loses one, so their payoffs are (1,-1). If
as impossible, but it is hoped (by some) or even believed (by a small but vocal minority) that the they pennies don’t match, A loses one and B wins one, so their payoffs are (-1,1). If we say
How do Chess engines predict
computer, pointed in the right direction, will one day do just that: derive the formula that will solve
chess. The use of linear algebra to achieve this end, specifically in the endgame of chess, will be • choice 1 is heads • choice 2 is tails
As illustrated below, the math involved in solving even basic chess positions is quite complicated. It
discussed. Heads (1) Tails (2)
is interesting to note that although chess is played in 2 dimensional space (or R2), it is actually solved
in 3 dimensional space (or R3). The basic concept is that matrices are manipulated in layers, so that a Heads (1) (1,-1) (-1,1)
single chess position may have hundreds of submatrices associated with it, in 4 or more layers. The Tails (2) (-1,1) (1,-1)
position below has only the white king and rook, so it is far simpler to conceive.
Table 1. A Game Theory table for Heads and Tails
We can also break this into two matrices in the usual way, one showing the payoff for A:
" #
1 −1
A=
−1 1
and one showing the payoff for B:
" #
−1 1
B=
1 −1
If we want to breakdown the possibilities, we reach quite fascinating numbers. The number of distinct
If we examine this game, it’s easy to see no pure strategy is a Nash equilibrium. If A chooses heads,
chess positions after White’s first move is 20 (16 pawn moves and 4 knight moves). There are 400
B will want to choose tails. But if B chooses tails, A will want to choose tails. And if A chooses tails,
distinct chess positions after two moves (first move for White, followed by first move for Black). There
B will want to choose heads. And if B chooses heads, A will want to choose heads! There’s always
are 5,362 distinct chess positions or 8,902 total positions after three moves (White’s second move).
someone who would do better by changing their choice. It’s a lot like rock, paper, scissors.
There are 71,852 distinct chess positions or 197,742 total positions after four moves (two moves for
White and two moves for Black) and the so on. Implementation of the chess board on matrices and
References
using the concepts of Linear Algebra to calculate the decision tree has been the study of last 30 to
40 years at least. [1] https://kevinbinz.com/2015/02/26/decision-trees-in chess/.
[2] https://math.ucr.edu/home/baez/games/games13.html.
[3] Sean Hurst. Game theory through linear algebra.
[4] Douglas Steiner. Matrix applications in chess. 2009.