99* To make it easy to create stand-alone applications that use the Syzygy
1010 tablebases;
1111
12+ Fathom is compilable under either C99 or C++ and supports a variety of
13+ platforms, including at least Windows, Linux, and MacOS.
14+
1215Tool
1316----
1417
@@ -26,64 +29,117 @@ The tool will print out a PGN representation of the probe result, including:
2629* WinningMoves: The list of all winning moves
2730* DrawingMoves: The list of all drawing moves
2831* LosingMoves: The list of all losing moves
29- * A pseudo "principle variation" of Syzygy vs. Syzygy for the input position.
32+ * A pseudo "principal variation" of Syzygy vs. Syzygy for the input position.
3033
3134For more information, run the following command:
3235
3336 fathom --help
3437
35- Pre-compiled versions of ` fathom ` (for all platforms) are available from here:
36-
37- * https://github.com/basil00/Fathom/releases
38-
3938Programming API
4039---------------
4140
42- Fathom provides a simple API. There are three main function calls:
41+ Fathom provides a simple API. Following are the main function calls:
4342
44- * ` tb_init ` initializes the tablebase
45- * ` tb_probe_wdl ` probes the Win-Draw-Loss (WDL) table for a given position
43+ * ` tb_init ` initializes the tablebases.
44+ * ` tb_free ` releases any resources allocated by Fathom.
45+ * ` tb_probe_wdl ` probes the Win-Draw-Loss (WDL) table for a given position.
4646* ` tb_probe_root ` probes the Distance-To-Zero (DTZ) table for the given
47- position.
48-
49- All of the API functions use basic integer types, i.e. there is no need to
50- create and initialize data-structures. Fathom does not require the callee
51- to provide any additional functionality (e.g. move generation) unlike the
52- traditional ` tbprobe ` code. However, chess engines can opt to replace some
53- of the functionality of Fathom for better performance (see below).
54-
55- Chess Engines
47+ position. It returns a recommended move, and also a list of unsigned
48+ integers, each one encoding a possible move and its DTZ and WDL values.
49+ * ` tb_probe_root_dtz ` probes the Distance-To-Zero (DTZ) at the root position.
50+ It returns a score and a rank for each possible move.
51+ * ` tb_probe_root_wdl ` probes the Win-Draw-Loss (WDL) at the root position.
52+ it returns a score and a rank for each possible move.
53+
54+ Fathom does not require the callee to provide any additional functionality
55+ (e.g. move generation). A simple set of chess-related functions including move
56+ generation is provided in file ` tbchess.c ` . However, chess engines can opt to
57+ replace some of this functionality for better performance (see below).
58+
59+ Chess engines
5660-------------
5761
58- Chess engines can be ` tb_probe_wdl ` to get the WDL value during search. The
59- ` tb_probe_root ` functional can be used to help pick the best move at the root.
60- Note that ` tb_probe_root ` is slower and therefore should only be used at the
61- root.
62-
63- Chess engines can opt for a tighter integration of Fathom by configuring
64- ` tbconfig.h ` . Specifically, the chess engines can define ` TB_*_ATTACKS `
65- macros that replace the default definitions with the engine's own definitions,
66- avoiding duplication of functionality.
67-
68- Credits
69- -------
70-
71- The Syzygy tablebases were created by Ronald de Man. Much of the probing code
72- ` tbprobe.c ` is a modified version of Ronald's ` tbprobe.cpp ` for Stockfish (all
73- Stockfish-specific code has been removed). The ` tbcore.c ` file is virtually
74- unchanged from Ronald's original version.
62+ Chess engines can use ` tb_probe_wdl ` to get the WDL value during
63+ search. This function is thread safe (unless TB_NO_THREADS is
64+ set). The various "probe_root" functions are intended for probing only
65+ at the root node and are not thread-safe.
66+
67+ Chess engines and other clients can modify some features of Fathom and
68+ override some of its internal functions by configuring
69+ ` tbconfig.h ` . ` tbconfig.h ` is included in Fathom's code with angle
70+ brackets. This allows a client of Fathom to override tbconfig.h by
71+ placing its own modified copy in its include path before the Fathom
72+ source directory.
73+
74+ One option provided by ` tbconfig.h ` is to define macros that replace
75+ some aspects of Fathom's functionality, such as calculating piece
76+ attacks, avoiding duplication of functionality. If doing this,
77+ however, be careful with including typedefs or defines from your own
78+ code into ` tbconfig.h ` , since these may clash with internal definitions
79+ used by Fathom. I recommend instead interfacing to external
80+ functions via a small module, with an interface something like this:
81+
82+ ```
83+ #ifndef _TB_ATTACK_INTERFACE
84+ #define _TB_ATTACK_INTERFACE
85+
86+ #ifdef __cplusplus
87+ #include <cstdint>
88+ #else
89+ #include <stdint.h>
90+ #endif
91+
92+ extern tb_knight_attacks(unsigned square);
93+ extern tb_king_attacks(unsigned square);
94+ extern tb_root_attacks(unsigned square, uint64_t occ);
95+ extern tb_bishop_attacks(unsigned square, uint64_t occ);
96+ extern tb_queen_attacks(unsigned square, uint64_t occ);
97+ extern tb_pawn_attacks(unsigned square, uint64_t occ);
98+
99+ #endif
100+ ```
101+
102+ You can add if wanted other function definitions such as a popcnt
103+ function based on the chess engine's native popcnt support.
104+
105+ ` tbconfig.h ` can then reference these functions safety because the
106+ interface depends only on types defined in standard headers. The
107+ implementation, however, can use any types from the chess engine or
108+ other client that are necessary. (A good optimizer with link-time
109+ optimization will inline the implementation code even though it is not
110+ visible in the interface).
111+
112+ History and Credits
113+ -------------------
114+
115+ The Syzygy tablebases were created by Ronald de Man. The original version of Fathom
116+ (https://github.com/basil00/Fathom ) combined probing code from Ronald de Man, originally written for
117+ Stockfish, with chess-related functions and other support code from Basil Falcinelli.
118+ That codebase is no longer being maintained. This repository was originaly a fork of
119+ that codebase, with additional modifications by Jon Dart.
120+
121+ However, the current Fathom code in this repository is no longer
122+ derived directly from the probing code written for Stockfish, but
123+ instead derives from tbprobe.c, which is a component of the Cfish
124+ chess engine (https://github.com/syzygy1/Cfish ), a Stockfish
125+ derivative. tbprobe.c includes 7-man tablebase support. It was written
126+ by Ronald de Man and released for unrestricted distribution and use.
127+
128+ This fork of Fathom replaces the Cfish board representation and move
129+ generation code used in tbprobe.c with simpler, MIT-licensed code from the original
130+ Fathom source by Basil. The code has been reorganized so that
131+ ` tbchess.c ` contains all move generation and most chess-related typedefs
132+ and functions, while ` tbprobe.c ` contains all the tablebase probing
133+ code. The code replacement and reorganization was done by Jon Dart.
75134
76135License
77136-------
78137
79138(C) 2013-2015 Ronald de Man (original code)
80139(C) 2015 basil (new modifications)
81- (C) 2016-2018 Jon Dart (additional modifications)
82-
83- Ronald de Man's original code can be "redistributed and/or modified without
84- restrictions".
140+ (C) 2016-2020 Jon Dart (additional modifications)
85141
86- The new modifications are released under the permissive MIT License:
142+ This version of Fathom is released under the MIT License:
87143
88144Permission is hereby granted, free of charge, to any person obtaining a copy of
89145this software and associated documentation files (the "Software"), to deal in
0 commit comments