LeelaChessZero / lc0

The rewritten engine, originally for tensorflow. Now all other backends have been ported here.
GNU General Public License v3.0
2.38k stars 525 forks source link

gaviota support for uci and selfplay #2044

Open hans-ekbrand opened 1 month ago

hans-ekbrand commented 1 month ago

This patch provides support for Gaviota endgame table databases in both uci mode and selfplay mode. The intended use case that motivated me writing it is to generate better training data, but since uci mode is covered, it can be used generally.

The implementation is inspired by the implementation of syzygy support, and much of the code is copied from rescorer/rescorer.cc which already supports Gaviota. Unlike the syzygy implementation it provides no new classes since Gaviota support only required two new functions, both located in search.cc.

The implementation is done via Search::MakeRootFilter() which deletes legal but sub-optimal moves from the root node before search is started. With syzygy, optimal included every move that did not worsen the game outcome, but with Gaviota support we can define optimal moves as moves "resulting in the shortest path to mate" (for the winning side) and "resulting in the longest path to mate" for the losing side. (For drawn positions both syzygy and Gaviota treats all non-losing moves as optimal).