• Keine Ergebnisse gefunden

Chess Evaluation

Im Dokument TABLE OF CONTENTS (Seite 71-74)

Function

search anyway. We'll try to capture the largest pieces first. Castlings are good moves when they are possible. Normal moves are the ma-jority of moves (not captures, killers, castling, etc.). They are gener-ated starting with pawn moves and ending with king moves. Some programs generate the pawn moves last, some generate moves from the center and out. The order here is not very important, since at this stage you will probably have to generate all the moves anyway.

Finally, en passant captures are generated.

In the early days when chess programs were written exclusively for large computers, people designed large and complicated evaluation functions. Today, very few programmers use more than twenty dif-ferent features. If evaluation functions get too large, they are too difficult to understand. The programmer must understand exactly what the evaluation function does, and that is impossible if the eval-uation function becomes too large. An evaluation function should be as general as possible, so that it encompasses every possible position or situation.

The main provisions in the evaluation function in the Turbo Chess program are piece development (mobility) and pawn structure (their ability to guard and capture). For traditional reasons, a pawn is worth 256 positional points. A bonus of 64 points is worth 114 pawn.

Instead of weighting all squares equally when calculating mobility, each player and each square are assigned an attack value, which is the relative importance resulting from an attack on that square by that player. The attack value of a square depends on its closeness to the center of the board: 2 - 314 * (distance to center) and the rank (in early middlegame 0. 75, 1.5,3,3 points for 5th, 6th, 7th, 8th rank).

In addition, the 8 squares around the opponent's king are assigned extra attack value (in the early middlegame 3 points).

An attack on the opponent is highest in attack value in the early middlegame, and decreases to zero in the endgame. The attack value could depend on the opening (for example, giving queen side attacks is more valuable than king side attacks for black in the Sicilian De-fense). You could also let the program find the opponent's weak spots (weak pawns), and then give extra value for attacking those spots.

This a good way to improve positional play.

The positional value of a queen, rook, bishop or knight is the sum oj the attack values jor the squares which the piece attacks. For queens however, the sum is multiplied by 114 (since the queen otherwise becomes much too aggressive). The positional value for knights is the sum multiplied by 112, and 3 * (distance to center) is subtracted from the value. The positional value of a bishop is normally a bit higher than that for a knight. Indirect attacks (a rook attacking through

another rook) are counted as normal attacks, attacks through blocking pieces (a bishop attacking through a knight) are counted at half value.

8 3 3 3 3 3 3 3 3

7 3 3 3

3.1.

2

3.1

2 3 3 3 6

1.1.

2

1.1.

2 2

21.

4

21.

4 2

1.1

2

1.1

2 3

1.1 21. 21. 1.1

3

4"

2 2 4 4 2 2

4"

5

1

1.1.

2 2

1.1.

1

2'

4 4

2"

4

1

1.1. 1.1.

1

2'

4 4

2"

3

1 1

2" 2"

2

a b c d e 9 h

Figure 6-9. Attack Values For White in the Starting Position The positional value of a pawn is equal to ((PawnRank [Rank)

+

(Rank

+

1) * PawnFileFactor[File)). The PawnRank values are 0, 0, 2, 4, 8, 30 for 2nd to 7th rank (Plus 0, 10, 20, 40, 60, 70 if the pawn is a passed pawn). The PawnFileFactors are 0, 0, 2, 5, 6, 2, 0, 0 for the a to h-file, respectively. Thus, a white pawn on e2 is worth 0+ (2 + 1 )*6 = 18 points, while a pawn on e4 is worth 2 + ( 4

+

1)*6

= 32 points.

The value of the pawn structure is calculated as the sum of the in-dividual pawn values. An isolated pawn gets a penalty of 20 pOints, a double pawn a penalty of 8 points, and an isolated double pawn a total penalty of 68 points. The program shOUld also keep its pawns next to each other to build pawn chains. A pawn is given a bonus of 6 points if another pawn is on one of its sides; otherwise, it is given a bonus of 3 points if it is being covered by a pawn. A pawn is also given a bonus of 3 points for each pawn it covers. A wise chess master once said that every pawn move weakens your game. Because of this, the program is given a penalty of 3 points for moving a pawn. Moving a pawn from e2 to e4 would decrease the pawn structure value of the pawn from 6 to - 3 points (6 for being next to another pawn,

Bonuses and Penalties in Positional Play

Turbo Chess gives bonuses and deducts penalties to assess the value of a given positional arrangement.

Positional Values

Pawns-Worth 256 Positional Points

RANK VAL. Position in rank and file:

IS Queen, Rooks, Bishops, Knights

IF IN IF IN

Positional value of Q,R,B,N = Sum of attack values for all squares the piece can attack, tempered by the following factors:

Queens: attack value x .25

Knights: attack value x .5 - (3 x distance to center)

Rules for the

handles various game conditions. There are always a few special sit-uations that a program will not handle properly. These can be ade-quately dealt with using what we call evaluation spices. An evaluation spice is a special rule for handling special situations. These rules should be as narrow as possible (in contrast to the general rules) to make sure a rule does not affect situations other than those in the special group. A common problem results when a rule inserted to solve one situation causes completely unforeseen changes in other situations which the program handled well before the rule was inserted.

Here are some evaluation spices that Turbo Chess uses.

• Normally, we want Turbo Chess to castle short (to the king's side) early in the game. For this, we give a bonus of 32 points. We also want to give a small extra bonus for long castling (to the queen's side-4 points). Quite often however, because it occurs so early in the game, the castle move is found in the opening library.

• When the program is ahead, it should exchange pieces (but not pawns) in order to reach a clearly won endgame; when the pro-gram is behind, it should not exchange pieces. There is a 32 point bonus for exchanging pieces when ahead.

• In the endgame, the program should advance the king to the center of the board. Kings are usually given a positional value of zero, but in the endgame they are given a penalty of (2 * (distance to center)).

• Placing a rook behind a passed pawn (either your pawn or an opponent's pawn) gives a 16 point bonus.

• Although the program is fond of placing a bishop on d3 or e3 all programs contain special programming to handle it.

Below is the source code for an evaluation spice that handles castling:

function CastlingMovGen : boolean;

var

Im Dokument TABLE OF CONTENTS (Seite 71-74)