# Are there any applications of matrices, or linear algebra to chess? If so, are there good books on it?

Chess has never had any appeal to me, but recently my brother bought a chess set, and I realized that the board can be represented as an 8x8 matrix, and each type of of piece as a number from 0 to 6, the 6 pieces, and the empty square. So I've been looking for some info on the internet, but I haven't found too much. Do you know if anybody has made some research on this, or published books, or articles. Matrices have applications on stochastic processes, optimization, best-decision taking, so wouldn't it be possible to create models for best moves according to a situation, and such?

What do you think?

• Sadly, linear algebra is about as applicable to chess configurations as integer arithmetic is to telephone numbers. – Rahul Jan 1 '18 at 23:41
• It's not really a matrix, because matrix multiplication has no obvious meaning. It's just a 2d array. – Qiaochu Yuan Jan 2 '18 at 1:15
• On the other hand, linear algebra is a central component of modern machine learning / deep learning, and AlphaZero recently beat chess: arxiv.org/abs/1712.01815 – Qiaochu Yuan Jan 2 '18 at 1:15

Taking a bit of a stab in the dark... It seems to me unlikely that matrices could be used in the way you describe for chess. The basic operations on matrices are addition, multiplication by numbers and multiplication of matrices. Just to take addition, it would mean something like this: if one position has a king on a1 and another has a queen on a1 then "adding" them gives a position with a bishop on a1 (for example). This doesn't really seem to make any kind of sense in terms of actually playing chess.

On the other hand, linear algebra has huge applications (as you have mentioned) and I wouldn't be surprised if matrices are used in chess programming. But not, I think, in the way you have described.

• And, what if I used a ring, and defined operations that go according to chess rules? – Daniel Bonilla Jaramillo Jan 1 '18 at 23:45
• Not clear what you mean by that, but if you mean using different operations instead of standard matrix addition etc, then you (probably) wouldn't be using linear algebra. You would (again hypothetically because I don't know precisely what you are suggesting) be using matrices as storage devices, not as algebraic objects. – David Jan 1 '18 at 23:59

Linear algebra has been applied to chess endgames in the following paper: http://library.msri.org/books/Book29/files/stiller.pdf.

-Roger Bilisoly

The main problem with trying to represent a chess game as a series of matrices (each representing a state of the board between consecutive moves) is that while it is fairly trivial to represent the board as such, it is not conducive to generating such a board through matrix multiplication.

I just spent a few hours over the past couple of days trying to do this and eventually found this on Google after I realised it can't work.

The main problem is that Matrix multiplication to go from one matrix to another relies on computing the inverse of the initial matrix so that it is 'cancelled out' before moving to the next matrix.

Unfortunately, you can't compute the inverse of a matrix that has identical rows (meaning it has a zero determinant).

Whether you organise a chess board vertically or horizontally, either the middle ranks begin identical (all empty) or the outer files appear identical (Rook,pawn,empty,empty,empty,empty,-pawn,-Rook / Bishop, pawn, empty,empty,empty,empty,-pawn,-Bishop).

You could do the stepping between states by matrix addition, but it's less appealing computationally.

• Welcome to Math.SE. What I take away from your post is that no, there are no interesting applications of "matrices [or] linear algebra to chess". But the argument you give at best concerns one possible application that is tersely presented, only to say "[u]nfortunately you can't" do that. Even taking this at face value, it scarcely proves that no applications of linear algebra to chess are useful. – hardmath Oct 25 '18 at 1:15
• Yes, I definitely don't try to imply that Linear Algebra is not applicable to chess (as others have mentioned it definitely can be), all I am saying is that representing the board as an 8x8 matrix leads to most positions being over-defined and hence non-invertible as matrices. – DrQuarius Nov 1 '18 at 4:39