Index

LaMoSca

Introduction

The structure of a chess program

ProgramThe tasks that a chess program has to perform can be grouped into three broad categories:

  • finding the possible moves in a given position;
  • evaluating the positions reached with each move;
  • choosing the best sequence of moves among all the possible ones.

While the first task is fairly easy to implement, the other two are, for different reasons, far more difficult for a computer.

How hard it is to evaluate a game position on the chessboard correctly is known to anyone who wants to play chess at a level even slightly above that of a player without a long-term strategy.

Choosing the best sequence is a task that only looks simple. In theory it would be enough for the software to generate every possible move from the opening to the end of the game. Counting the options that would have to be examined in this way shows how complex the task is. In the opening, for example, there are 20 possible moves. Since the opponent can answer each of them with another twenty, the first level alone gives a total of 20^2 = 400 alternatives.

Assuming an average of 35 alternatives per level for each player, and about 40 levels in a game of chess, the total number of nodes to analyse is 35^(2*40) = 3.35e+123, which makes a complete search of all the variations impossible.

However, the set of all the possible variations from the initial position forms a tree of moves, in which finding the best sequence means finding an optimal path: a well-known problem in computer science.

Searching for the optimal path in the tree generated by the software is the defining feature of today's chess programs. Making this search more efficient, and so increasing the depth of analysis the computer can reach, is the way to overcome the machine's limits in judging the quality of play.

As for the data structures used by the software, in principle only a few pieces of information are needed:

  • the position of the pieces on the board;
  • the side to move;
  • the list of moves to evaluate;
  • the castling rights of each side;
  • a record of the moves made by the computer, to check the legality of "en passant" captures and to detect draws by repetition and by the 50-move rule (no capture or pawn move in the last 50 moves), and possibly to let the program take moves back.

Each specific algorithm added to the chess program will then need its own data structures.

References

Paolo Ciancarini:
"I Giocatori Artificiali";
Mursia, 1992 - 252 pages (in Italian)
ISBN 88-425-1319-9

Links


Back Index Next