robertnurnberg / matetools

Python scripts to manipulate and provide mating PVs for Chest-like EPD files.
GNU General Public License v3.0
3 stars 1 forks source link

matetools

A collection of Python scripts to manipulate and provide mating PVs for Chest-like EPD files. Such files store chess mate puzzles in the form

<FEN>' bm #'<bm>';'{<comments>}

Here FEN usually means just the first four fields of a standard FEN, and bm is a nonzero integer that indicates the (currently) fastest known mate for the given position, assuming best play from both sides.

The aim of the scripts in the repo is to convert such collections of puzzles into the format

<FEN>' bm #'<bm>';'{' PV: '<PV>}';'{<comments>}

where PV is a proven PV for the claimed mate.

To this end the following scripts are provided:

By way of example, the following EPD files are provided:

Automatic creation of new test positions

With the help of the script advancepvs.py it is easy to derive new mate puzzles from the information stored in matetrackpv.epd. For example, the file matedtrack.epd has been created with the command

python advancepvs.py --plies 1 --mateType won && sed 's/; PV.*/;/' matedtrackpv.epd > matedtrack.epd

Similarly, the file mate-in-2.epd was created with

python advancepvs.py --targetMate 2 && grep 'bm #2;' matedtrackpv.epd | awk -F'; PV' '\!seen[$1]++' > mate-in-2.epd

Trivia

A collection of games from the Lichess masters db that feature positions in matetrack.epd can be found in matetrack_masters.pgn. The file contains 32 white wins, 10 black wins and (surprisingly) 1 draw. The collection was created with the command

python get_lichess_pgns.py matetrack.epd --db master --pgnFile matetrack_masters.pgn

Related repositories


Code style: black