Fathom icon indicating copy to clipboard operation
Fathom copied to clipboard

Outputs ambiguous moves

Open sesse opened this issue 7 years ago • 2 comments

Fathom occasionally does not disambiguate moves properly:

sesse@pannekake:~> fathom --path=/srv/syzygy '2Q5/6P1/8/8/8/1k5K/8/2Q5 w - - 1 16'
--path=/srv/syzygy 2Q5/6P1/8/8/8/1k5K/8/2Q5 w - - 1 16
[Event ""]
[Site ""]
[Date "??"]
[Round "-"]
[White "Syzygy"]
[Black "Syzygy"]
[Result "1-0"]
[FEN "2Q5/6P1/8/8/8/1k5K/8/2Q5 w - - 1 16"]
[WDL "Win"]
[DTZ "1"]
[WinningMoves "Kg2, Kh2, Kg3, Kg4, Kh4, Qa1, Qb1, Qd1, Qe1, Qf1, Qg1, Qh1, Qb2, Qcc2, Qd2, Qa3, Qcc3, Qe3, Qcc4, Qf4, Qcc5, Qg5, Qcc6, Qh6, Qcc7, Qcc2, Qcc3, Qcc4, Qg4, Qcc5, Qf5, Qa6, Qcc6, Qe6, Qb7, Qcc7, Qd7, Qa8, Qb8, Qd8, Qe8, Qf8, Qg8, Qh8, g8=Q, g8=N, g8=R, g8=B"]
[DrawingMoves ""]
[LosingMoves ""]

16. Qcc4# 1-0

The problem is that there are two white queens on the c file; one on c1 and on c8. (Granted, only one of them can checkmate, but checks and checkmates are not used for disambiguation; see the PGN standard, section 8.2.3.5. In any case, “c” is redundant.) Also note that Qcc4 is output twice in the WinningMoves list.

The correct disambiguation in this case would be Q8c4#.

sesse avatar Jan 15 '18 17:01 sesse

Perhaps something like this:

diff --git a/src/apps/fathom.c b/src/apps/fathom.c
index e58406b..2e610ea 100644
--- a/src/apps/fathom.c
+++ b/src/apps/fathom.c
@@ -326,9 +326,9 @@ static void move_to_str(const struct pos *pos, unsigned move, char *str)
         *str++ = 'a' + f;
     else if (tb_pop_count(att) > 1)
     {
-        if (tb_pop_count(att & (BOARD_FILE_A >> f)) <= 1)
+        if (tb_pop_count(att & (BOARD_RANK_1 << (8 * r))) <= 1)
             *str++ = 'a' + f;
-        else if (tb_pop_count(att & (BOARD_RANK_1 >> r)) <= 1)
+        else if (tb_pop_count(att & (BOARD_FILE_A << f)) <= 1)
             *str++ = '1' + r;
         else
         {

sesse avatar Jan 15 '18 17:01 sesse

Fixed in https://github.com/jdart1/Fathom/commit/59f96c00e9762672eb36006b6aeb9b9338864ba3

jdart1 avatar Dec 09 '18 22:12 jdart1