Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputs ambiguous moves #22

Open
sesse opened this issue Jan 15, 2018 · 2 comments
Open

Outputs ambiguous moves #22

sesse opened this issue Jan 15, 2018 · 2 comments

Comments

@sesse
Copy link

sesse commented Jan 15, 2018

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
Copy link
Author

sesse commented Jan 15, 2018

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
         {

@jdart1
Copy link
Contributor

jdart1 commented Dec 9, 2018

Fixed in jdart1@59f96c0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants