![]() |
LaMoSca v0.05Evaluating positions |
ObjectiveIn this version the program chooses its move by evaluating the positions that can be reached from the current one. The metricsThe move is chosen according to how good the resulting position on the board is. This judgement, however, has to be expressed as a number so that the program can compute it. Several metrics are possible, each judging a different aspect of a position, and the evaluation used by programs is often a weighted combination of them. Material
This is the simplest criterion, the one used by anyone who starts playing chess. The better a move manages to tip the
balance of pieces on the board in one's favour, the better the move. Position |
|
The value of a piece depends not only on its type but also on where it stands on the board. A pawn, for example, is more important the more it controls the centre and the closer it gets to promotion. This can be evaluated by adjusting the value of the pieces (usually multiplied by 100 so as to work with integers) by amounts that depend on the position of the piece and are stored in matrices. For pawns, for example, values like those in the first matrix alongside could be used to push them forward. For bishops and knights, a matrix like the second one alongside could be used to draw them towards the centre. The negative values in these matrices serve to encourage some classic opening moves. |
0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 20, 20, 15, 10, 5, 4, 8, 12, 16, 16, 12, 8, 4, 3, 6, 9, 12, 12, 9, 6, 3, 2, 4, 6, 8, 8, 6, 4, 2, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 0, -4, -4, 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, 5, 5, 5, 5, 0, 0, 0, 0, 5, 10, 10, 5, 0, 0, 0, 0, 5, 10, 10, 5, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, 0, 0, -5, -5, 0 |
Mobility
The value of a piece also depends on how much it can take part in the game: positions in which the pieces are
hampered in their movements count negatively. Pawns
The strength of pawns depends largely on their relative position and on how well they defend each other by forming
complex structures. King safety
Defending the king with minor pieces gives relative safety and leaves the heavier pieces free to attack the
opponent's side. Balancing the factors
Combining different metrics is rather complex, because it can be hard to find the right relative weights while
keeping the evaluation both fast and accurate. The difficulty comes from the fact that the evaluations often
complement each other and their weight changes as the game goes on, so it is hard to appreciate the benefit of one
metric or another. The codeIn this version of the program the position is evaluated only on the basis of the material balance, adjusted according to the position of the pieces only for pawns, to push them forward, and for bishops and knights, to draw them towards the centre. Because of the positional adjustments, the conventional material values have to be scaled by a factor of 100, so the values of pawn, knight, bishop, rook and queen become: 100, 300, 300, 500, 1000 Although this evaluation is simplistic, for now it is better not to complicate the code and the range of values it can produce. More refined evaluation functions can be studied in the programs listed in the index. Running the programRunning the program with logging enabled, you can see the evaluation of the positions reached with each of the generated moves. For the opening, for example, the values are: a2a3=1 a2a4=2 b2b3=2 b2b4=4 c2c3=3 c2c4=6 d2d3=8 d2d4=12 e2e3=8 e2e4=12 f2f3=3 f2f4=6 g2g3=2 g2g4=4 h2h3=1 h2h4=2 b1a3=5 b1c3=10 g1f3=10 g1h3=5 Since no pieces are exchanged, these values come only from positional evaluation. In particular, the highest-valued moves are the advances of the central pawns (d2d4, e2e4), which combine the value of the destination square with the negative weights of the starting squares. |
DownloadTo be completed
To do
|
References
Paolo Ciancarini: Links |
| Back | Index | Next |