@@ -223,6 +223,61 @@ const char* DtzSuffixes[SUBVARIANT_NB] = {
223223#endif
224224};
225225
226+ const char * PawnlessDtzSuffixes[SUBVARIANT_NB] = {
227+ nullptr ,
228+ #ifdef ANTI
229+ " .stbz" ,
230+ #endif
231+ #ifdef ATOMIC
232+ nullptr ,
233+ #endif
234+ #ifdef CRAZYHOUSE
235+ nullptr ,
236+ #endif
237+ #ifdef EXTINCTION
238+ nullptr ,
239+ #endif
240+ #ifdef GRID
241+ nullptr ,
242+ #endif
243+ #ifdef HORDE
244+ nullptr ,
245+ #endif
246+ #ifdef KOTH
247+ nullptr ,
248+ #endif
249+ #ifdef LOSERS
250+ nullptr ,
251+ #endif
252+ #ifdef RACE
253+ nullptr ,
254+ #endif
255+ #ifdef THREECHECK
256+ nullptr ,
257+ #endif
258+ #ifdef TWOKINGS
259+ nullptr ,
260+ #endif
261+ #ifdef SUICIDE
262+ " .gtbz" ,
263+ #endif
264+ #ifdef BUGHOUSE
265+ nullptr ,
266+ #endif
267+ #ifdef DISPLACEDGRID
268+ nullptr ,
269+ #endif
270+ #ifdef LOOP
271+ nullptr ,
272+ #endif
273+ #ifdef SLIPPEDGRID
274+ nullptr ,
275+ #endif
276+ #ifdef TWOKINGSSYMMETRIC
277+ nullptr ,
278+ #endif
279+ };
280+
226281// Each table has a set of flags: all of them refer to DTZ tables, the last one to WDL tables
227282enum TBFlag { STM = 1 , Mapped = 2 , WinPlies = 4 , LossPlies = 8 , SingleValue = 128 };
228283
@@ -1588,14 +1643,132 @@ void* init(TBEntry<Type>& e, const Position& pos) {
15881643#endif
15891644 };
15901645
1591- fname = (e.key == pos.material_key () ? w + ' v' + b : b + ' v' + w)
1592- + (Type == WDL ? WdlSuffixes[e.variant ] : DtzSuffixes[e.variant ]);
1646+ constexpr uint8_t PAWNLESS_TB_MAGIC[SUBVARIANT_NB][2 ][4 ] = {
1647+ {
1648+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1649+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1650+ },
1651+ #ifdef ANTI
1652+ {
1653+ { 0xE4 , 0xCF , 0xE7 , 0x23 },
1654+ { 0x7B , 0xF6 , 0x93 , 0x15 }
1655+ },
1656+ #endif
1657+ #ifdef ATOMIC
1658+ {
1659+ { 0x91 , 0xA9 , 0x5E , 0xEB },
1660+ { 0x55 , 0x8D , 0xA4 , 0x49 }
1661+ },
1662+ #endif
1663+ #ifdef CRAZYHOUSE
1664+ {
1665+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1666+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1667+ },
1668+ #endif
1669+ #ifdef EXTINCTION
1670+ {
1671+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1672+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1673+ },
1674+ #endif
1675+ #ifdef GRID
1676+ {
1677+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1678+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1679+ },
1680+ #endif
1681+ #ifdef HORDE
1682+ {
1683+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1684+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1685+ },
1686+ #endif
1687+ #ifdef KOTH
1688+ {
1689+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1690+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1691+ },
1692+ #endif
1693+ #ifdef LOSERS
1694+ {
1695+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1696+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1697+ },
1698+ #endif
1699+ #ifdef RACE
1700+ {
1701+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1702+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1703+ },
1704+ #endif
1705+ #ifdef THREECHECK
1706+ {
1707+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1708+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1709+ },
1710+ #endif
1711+ #ifdef TWOKINGS
1712+ {
1713+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1714+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1715+ },
1716+ #endif
1717+ #ifdef SUICIDE
1718+ {
1719+ { 0xD6 , 0xF5 , 0x1B , 0x50 },
1720+ { 0xBC , 0x55 , 0xBC , 0x21 }
1721+ },
1722+ #endif
1723+ #ifdef BUGHOUSE
1724+ {
1725+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1726+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1727+ },
1728+ #endif
1729+ #ifdef DISPLACEDGRID
1730+ {
1731+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1732+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1733+ },
1734+ #endif
1735+ #ifdef LOOP
1736+ {
1737+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1738+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1739+ },
1740+ #endif
1741+ #ifdef SLIPPEDGRID
1742+ {
1743+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1744+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1745+ },
1746+ #endif
1747+ #ifdef TWOKINGSSYMMETRIC
1748+ {
1749+ { 0xD7 , 0x66 , 0x0C , 0xA5 },
1750+ { 0x71 , 0xE8 , 0x23 , 0x5D }
1751+ },
1752+ #endif
1753+ };
1754+
1755+ fname = e.key == pos.material_key () ? w + ' v' + b : b + ' v' + w;
1756+
1757+ const char ** Suffixes = Type == WDL ? WdlSuffixes : DtzSuffixes;
1758+ const char ** PawnlessSuffixes = Type == WDL ? PawnlessWdlSuffixes : PawnlessDtzSuffixes;
1759+ uint8_t * data = nullptr ;
1760+ TBFile file (fname + Suffixes[e.variant ]);
1761+
1762+ if (file.is_open ())
1763+ data = file.map (&e.baseAddress , &e.mapping , TB_MAGIC[e.variant ][Type == WDL]);
1764+ else if (fname.find (" P" ) == std::string::npos && PawnlessSuffixes[e.variant ]) {
1765+ TBFile pawnlessFile (fname + PawnlessSuffixes[e.variant ]);
1766+ data = pawnlessFile.map (&e.baseAddress , &e.mapping , PAWNLESS_TB_MAGIC[e.variant ][Type == WDL]);
1767+ }
15931768
1594- uint8_t * data = TBFile (fname).map (&e.baseAddress , &e.mapping ,
1595- TB_MAGIC[e.variant ][Type == WDL]);
15961769 if (data)
1770+ {
15971771 do_init (e, data);
1598-
15991772#ifdef ANTI
16001773 if (!e.hasPawns )
16011774 {
@@ -1619,6 +1792,7 @@ void* init(TBEntry<Type>& e, const Position& pos) {
16191792 assert (e.key == key);
16201793 }
16211794#endif
1795+ }
16221796
16231797 e.ready .store (true , std::memory_order_release);
16241798 return e.baseAddress ;
0 commit comments