next up previous contents
Next: Game tree search Up: Development Previous: Program structure   Contents

Static evaluation function

The heuristics for the positional evaluator of CHEOPS are based on those of GNU CHESS [5] and CRAY BLITZ [3]. Many of the criteria involve a calculation of distance between squares on the board; this distance function varies with the type of piece under consideration. For example, queens can move along any line, while rooks can move only on ranks and files; thus, the span between two fixed squares is not always equidistant for queens and rooks. Using the standard (Euclidean) means of computing distance is not feasible, even as an approximation, as it uses relatively slow floating-point calculations. Thus, functions were derived for actual piece-wise distance, which were later found to have been previously discovered and named by mathematicians [6]. ``Rook-wise'' distance is known in mathematics as Manhattan distance, and is represented by the following general formula:

\begin{displaymath}D(x, y) = \sum_{i=1}^{m} \left\vert x_i - y_i\right\vert. \end{displaymath}

``Queen-wise'' distance, known as Chebychev distance, is given by the following function:

\begin{displaymath}D(x, y) = \max_{i=1}^{m} \left\vert x_i -
y_i\right\vert. \end{displaymath}

Kings, which move the same as queens, also use Chebychev distance. Except that they can only reach half the squares on a chessboard, bishops also measure distance Chebychev-style. For knights and their unusual L-shaped moves, no suitable distance function could be found, so either of the above-noted functions is used as an approximation in the program.

Following is a detailed description of the static evaluator; any numerical constants cited refer to default values which may be changed by the user.

The base material value of a pawn is 100 points. Isolated pawns (those which have no friendly pawns on adjacent files) are given a penalty which is a function of the file they occupy: pawns on the outermost files lose 12 points, those on files 2 and 7 lose 14, those on 3 and 6 lose 16, and those on the innermost lose 20. Pawns whose advance is restrained by an opposing pawn on an adjacent file, and which have no friendly pawn to support that advance, are considered to be backward, and lose 6 points. Doubled pawns--that is, pawns which occupy a file containing other friendly pawns--are penalized 12 points. Finally, pawns are given a bonus for proximity to the opposite edge of the board, effectively receiving 1 point for each square distant from their home edge.

Knights start off at 330 points, and are given a 1-point penalty for each square distant from either king. Knights are also given a bonus for inverse Chebychev distance to the centre; the bonus starts at 0 in the corners and increases by a factor of 10 per square towards the centre.

Bishops also have a base value of 330 points. The presence of both king's and queen's bishops is necessary to avoid a penalty of 20 points. Individual bishops receive bonuses for proximity to centre, calculated and weighted (by default) in the same manner as for knights. Bishops also receive a bonus for mobility and X-ray mobility through pieces except pawns. This bonus is 1 point for every square under attack, plus a one-time 8-point bonus for attacks on an enemy queen, rook, or king. The weights for the mobility and X-ray mobility attacks are separately adjustable.

A rook is worth 500 points initially. Rooks receive a bonus for inverse Manhattan distance to the enemy king; the bonus increases by 20 points for every square closer to the king. Mobility and X-ray mobility bonuses are handled the same as those for bishops, and while the default weights are the same, they are independently adjustable. Also, rooks lose 10 points for the presence of friendly pawns on their file.

Queen heuristics are very simple: they start off at 900 points and receive bonuses for their proximity to the centre (in increments of 10) and to the enemy king (in increments of 20).

A king has no material value; such a number would be irrelevant as the capture of the king signals the end of the game. Instead, kings are given a penalty in steps of 10 for their proximity to the centre of the board. This penalty is a function of the stage of the game, which is determined by the combined base material value of the remaining pieces. If this sum is below a user-defined threshold (default 1500), the board is considered to be in endgame and the centre penalty is lifted. Kings are given a 20-point bonus for castling, and a 16-point penalty if they occupy a square which has no immediately adjacent friendly pawns.

The score for a board is, in effect, the sum of the scores of the opponent's pieces subtracted from the sum of the scores of the current player's pieces. If the static evaluator inspects a board in checkmate, however, this evaluation algorithm is dispensed with and the board is given a score of positive or negative infinity, depending on which side has been mated. For obvious reasons, this score is not user-adjustable. For a draw, however, the board value is user-defined (default 0). The rationale for this decision is for chess matches: when a computer has won the first four games in a six-game match, for example, there is no further need to win subsequent games; a draw may therefore be valued as a win ($+\infty$). On the other hand, a computer losing 2-3 should count a draw as a loss ($-\infty$) in the sixth and final game.


next up previous contents
Next: Game tree search Up: Development Previous: Program structure   Contents
Tristan Miller 2002-02-06