Introduction

Introduction

Why should we interweave the study of chess and computing? Chess is undoubtedly one of the most enigmatic and sophisticated games enjoyed in every corner of our vast planet.

Why should we interweave the study of chess and computing? Chess is undoubtedly one of the most enigmatic and sophisticated games enjoyed in every corner of our vast planet. On its first move, the participant with the white pieces has the option to select between 20 distinct moves. Similarly, the competitor with the black pieces can respond with 20 alternative moves. This apparently simple nuance implies that the number of possible games with just two moves rises to a total of 400. As is evident, the growth is exponential and, consequently, it rapidly transforms into an overwhelming task for human beings, who must rely on their instinct and precise, insightful calculation.

Fortunately, machines, with their capacity to carry out millions of operations per second and execute them without tiring, provide us with a viable solution. This computational power has allowed humans to unveil new secrets in this ancient game. However, despite the immense support they provide, these machines also have their limitations. A tangible example is that the question of whether a result is inevitable from the beginning of a game has not yet been resolved. In other words, we still do not know if, given optimal moves by both sides, a victory or a draw is an ineluctable outcome.

The relationship between chess and computing has been close since the dawn of the latter discipline. Alan Turing, one of the pioneers of computer science and a fervent chess player, is recognized as the creator of the first chess program, called Turochamp. This program was based on the Minimax algorithm and the use of a heuristic (concepts that will be analyzed in more detail in later sections of this book). Although Turing was unable to test his program on a computer before his death, he managed to simulate the algorithm by acting himself as a machine capable of executing a series of instructions.

This book is structured in five chapters, which approach chess from different angles. The first part focuses on problems and mini-games derived from chess, such as the challenge of placing nn queens on an n×nn \times n board without them attacking each other and the knight’s tour, where, using a knight, we must traverse all the squares of the board without repeating any. These games are linked with computer science concepts such as graphs, algorithmic complexity, Hamiltonian paths, graph coloring, among others.

The second chapter concentrates on artificial intelligence applied to chess in general, including the methods that computers employed to play chess in past decades.

The third chapter explores advances in artificial intelligence using reinforcement learning and what techniques have allowed AlphaZero to revolutionize chess as we know it.

The fourth chapter discusses the latest advances in artificial intelligence. Stockfish’s response to the defeat against AlphaZero and how a new model called Maia seeks to imitate human decision-making in chess.

In the fifth chapter, the most important chess standards will be analyzed. These include FEN, PGN, and UCI. These are used in many chess programs to facilitate communication within them and with other programs. In particular, FEN and PGN are widely used and it is highly recommended to understand how they work.

This book aims to introduce the reader to the fascinating world of computing through its relationship with chess. Although it is especially designed for those familiar with chess, two appendices are provided with information about the rules of chess and the notation used for those who are not. Regarding computing, no prior knowledge is required. All computer science concepts used throughout the book are explained as they appear, always striving to make them accessible to someone unfamiliar with computer science. For this reason, it is strongly recommended to read the book in order, as the concepts are built from the first chapter to the last.

After reading this book, you will acquire useful knowledge about computer science that will be relevant not only for chess, but also for many other disciplines in which computer science plays a crucial role. This book will therefore allow you to develop the so-called computational thinking, so in demand today, which will enable you to understand the world from new perspectives.