AndrewGrant wrote: ↑Sun Aug 16, 2020 3:57 pm
TL;DR: Cleaned up the Fathom code base and put it up on Github under the name Pyrrhic. Code is faster, easier to look at, and far less likely to have any conflicts with your code names. It also has all the "safety nets" removed.
https://github.com/AndyGrant/Pyrrhic/
So I was looking at compiling Ethereal under C++, as a potential segway to NNUE as it seems I will inevitably be forced to go that route if I want to stay in my current position. So it turns out that the version of Fathom I was using (some time in 2018) was real rough for compiling in C++, so I went to JDart's Fathom and pulled the latest in hopes of grabbing 7man TB support as well.
That was also as mess. As great as Fathom is, it takes up some names in the namespace that it really has no right to. A few examples: WHITE_KING , ... BLACK_PAWN, BEST_NONE, SCORE_ILLEGAL, BOARD_RANK_1, BOARD_FILE_A, BLACK, WHITE, W_PAWN, ... B_KING, and much more. Fathom, or Syzygy, has no right to claim those things. I expected to be able to simply update my Fathom files and have things work -- wrong. There were all sorts of namespace collisions that went undetected, leading to crashes.
So I took Fathom and basically renamed everything. If it appears in tbchess.c, Fathom's "mini" chess implementation to support probing, then it starts with PYRRHIC_ or pyrrhic_. I tried not to touch the actual Syzygy probing code too much, but I also renamed plenty of things there, like #define max, #define min, #define Swap, #define PAWN, #define PIECE.
I also deleted a lot of safety nets that are in Fathom that I see no purpose for. Fathom would check to see if the board was legal -- that's your job not Fathom's. Fathom would check if castling rights were null and that the previous move was zeroing when probing WDL -- that's your job not Fathom's. I also removed some of the DTM probing code, as I currently don't make use if it and therefore cannot test it, and therefore would not feel comfortable releasing something with it in.
Over the course of the cleanup I probably played around 200,000 games at various stages to confirm that nothing was functionally different. The final test, based on the initial commit of the Pyrrhic repo, returned the following: Score of Pyrrhic vs Fathom: 6554 - 6427 - 21019 [0.502] 34000. So at the end of the day, Pyrrhic performs the same as Fathom, with slightly more speed (this has been consistent in the other 166,000 games), and no introduced crashes or segfaults that I could detect.
As of now, I would expect a user to modify about a dozen lines in tbconfig.h, and nothing more. Terje, the author of Weiss, is going to try it as well shortly I believe. You now MUST provide Fathom with your move generation code. No more free lunches for people who cannot encapsulate their attack generation.
I will be replacing Ethereal's Fathom with Pyrrhic today.