1

My partner and I chose for our topic to be Matrices in Computer Science for a project in our linear algebra class. We decided to mainly focus on how matrices can be used to store data and transform it. An example that we chose was using a matrix to store the position of each chess piece on a chess board in a matrix. The matrix is as shown below. However, we realized that we did not know how to move a single chess piece using linear algebra concepts. Let's say I wanted to move a single pawn (1 on in the matrix). How would I go about doing that? Is there a transformation that I could do to the matrix that would keep everything else intact but reposition the pawn in the matrix? And how would I go about moving every other piece as well? Any help would be appreciated.

$\begin{bmatrix} 9 & 8 & 10 & 11 & 12 & 10 & 8 & 9 \\ 7 & 7 & 7 & 7 & 7 & 7 & 7 & 7 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0& 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\3 & 2 & 4 & 5 & 6 & 4 & 2 & 3 \\ \end{bmatrix}$

Miguel
  • 11
  • 1
    Honestly, a matrix is a horrible tool to represent chess in. There's no non-hacky way to do this. It's better to just use an array, which has less structure and hence more flexibility. – Rushabh Mehta Mar 05 '20 at 23:54
  • The matrix representation is poor because viewed as a transformation (which is what matrices are), it is really meaningless. Not trying to degrade your work, but just letting you know. – Rushabh Mehta Mar 05 '20 at 23:54
  • If you're looking for a game where "moves" can be nicely modeled with linear algebra, you should maybe consider the game lights out – Ben Grossmann Mar 06 '20 at 00:09
  • Most moves in chess change two entries of your matrix, the one where the piece moves from and the one the piece moves to. But some moves change three entries, namely castling and en passant captures. – Andreas Blass Mar 06 '20 at 00:13
  • Another object that can be nicely stored an manipulated with linear algebra is a graph, i.e. a network. Relabelings can be done through multiplication by permutation matrices. – Ben Grossmann Mar 06 '20 at 00:14
  • @Omnomnomnom thank you. We were also struggling trying to find ideas for games to cover in our project. Now we have another – Miguel Mar 06 '20 at 00:35

1 Answers1

0

If by a "transformation" you mean multiplying that matrix by another matrix, then, as others have mentioned in the comments, this probably isn't the best way to do it.

There are some things you cannot do with matrix multiplication. For example, you cannot increase the rank. By moving the pawn, the rank would increase by 1, which is impossible. Any action that would produce one more linearly independent row or column is impossible.

Another issue is that applying matrix rules in these scenarios can be artificial or arbitrary. You labeled the empty positions by $0$'s, but you may just as well have decided to use some other number. However, for matrix multiplication, a row of $0$'s is very different from a nonzero row, and will usually change the relevant properties of the matrix significantly.

twosigma
  • 3,332