Auto-generation of positional test positions

05zerofive
05zerofive
Mar 7, 2016, 7:16 AM |
4

There are two main types of test positions to measure a player's chess ability, one is tactical and the other is positional.

Positional test positions could contain an evaluation features which may increase the chances to achieve a winning position.

Evaluation features can be a piece mobility, knight outposts, rook in 7th rank, rook in open file, two bishop advantage, pawn structures, good piece placement, space advantage and others.

The program will do the automatic generation of positional test positions by parsing every game in a file looking at each position in each game then evaluate it using the computer chess engine Stockfish 7 (Sf7). Whenever a position meets the pre-defined conditions, it is saved in a file in PGN and EPD format.

Here are the conditions and the process that I use to achieve the goal.

1. Parse a given PGN file (TataStell2016.pgn) for example and let Sf7 analyze the position by running it at multipv 2, using 2 threads and 256 MB Hash at 1 minute. Start evaluating positions at move 16 till move 60.

The engine output would look like the following.

info depth 25 seldepth 36 multipv 1 score cp 21 time 59502 pv b2b4 c6e7
info depth 25 seldepth 36 multipv 2 score cp 14 time 59502 pv e4d5 f6d5

The first bestmove is b2b4 with a score of 21 CP (CentiPawn) or 0.21 Pawn. The second bestmove is e4d5 with a score of 14 CP or 0.14 of a Pawn. The conversion is, 100 CP = 1 Pawn.

2. When the score of the first bestmove is more than 150 CP or 1.5 Pawns, this position is not saved, else if the score is below 15 CP, this position is also not saved. The score of the first bestmove should be within the window of [+15, +150], CP. The idea behind the algorithm is that we don't consider a position as positional, when it is already close to winning and not really a bad position too.

3. When the position passes the first condition in (2), now it is subjected to the 2nd condition and that is, to measure the difference between the score of the first bestmove and the score of the second bestmove. This difference must be within a window of [+15, +100] CP. For example the score of first bestmove is 21 CP and the score of the second bestmove is 14 CP as in the example in (1), that difference is, 21-14 = 7 CP. Since this difference is outside the window of [+15, +100], this position is also not saved. The idea behind this window is that the score of the second bestmove should not be too far (diff <= +100 CP) from the score of the first bestmove to avoid saving a position that has an easy move. And the score of second bestmove must not be too close (diff >= +15 CP) so that this position has only 1 reasonable best move.

4. When the side to move in the position is in check then this position is not saved. The idea is that the side to move must not be limited to check evasion moves.

5. When the bestmove found by Sf7 is a capture or a checking move, this position is also not saved. This will avoid saving a position that may look tactical.

6. When the white pieces (not pawns) is below 2 rooks and 1 minor the position is not saved, same with black material. The reason is to save only those positions where there are still more evaluation features that can be exploited.

The output saved with PGN format would look like this.

[Event "WCh Women 2016"]
[Site "Lviv UKR"]
[Date "2016.03.03"]
[Round "2"]
[White "Hou, Yifan"]
[Black "Muzychuk, Mariya"]
[Result "*"]
[FEN "3r1rk1/2p1bppp/p1n1q3/1p1pP3/5B2/2P1QP2/PPB2P1P/R2R2K1 b - - 4 17"]

[Setup "1"] 

17...Na5 18.Qe2 f5 *

The first move 17...Na5 is the bestmove found by the engine when it was run at multipv 2. The second move Qe2 and third move f5 are the moves from Sf7 after 1 minute of search at 2 threads for each move at multipv 1. This kind of test position has two moves that a player should solve, the first is Na5 and second is f5.

And the output with EPD format is like the following.

3r1rk1/2p1bppp/p1n1q3/1p1pP3/5B2/2P1QP2/PPB2P1P/R2R2K1 b - - bm Na5; sm Rd7; ce +33; acs 60; acd 23; fmvn 17; eco "C80"; id "05zerofive positional test suite, no. 1"; Eve "WCh Women 2016"; Dat "2016.03.03"; Rou "2"; Whi "Hou, Yifan"; Bla "Muzychuk, Mariya";

That bm or bestmove is according to Sf7 and that sm or supplied move is the actual move in the game.

Download some generated positions from Tatasteel 2016 in pgn and epd format.

Download some positions from Aeroflot 2016.

A sample positional puzzle from Women's World Chess Champs 2016.

And from TataSteel 2016.