SAN Move Disambiguation -- looking for test positition

Discussion of chess software programming and technical issues.

Moderator: Ras

humble_programmer

SAN Move Disambiguation -- looking for test positition

Post by humble_programmer »

According to section 8.2.3.4 of the Mar-94 PGN standard:
First, if the moving pieces can be distinguished by their originating files, the originating file letter of the moving piece is inserted immediately after the moving piece letter.

Second (when the first step fails), if the moving pieces can be distinguished by their originating ranks, the originating rank digit of the moving piece is inserted immediately after the moving piece letter.

Third (when both the first and the second steps fail), the two character square coordinate of the originating square of the moving piece is inserted
immediately after the moving piece letter.
The first and second cases are common enough, but I've never seen a situation where both the rank and file were needed to uniquely identify which piece was being moved. I searched through Crafty's "enormous.pgn" book, but didn't find an example. Could someone provide me an example--either as a FEN position and move, or as PGN--where this type of disambiguation is needed?
User avatar
hgm
Posts: 28405
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: SAN Move Disambiguation -- looking for test positition

Post by hgm »

It can only happen when you have 3 pieces of equal type.

[d]QQ6/Qp5k/8/8/8/8/8/7K w

Neither Qaxb7 nor Q8xb7 are unambiguous.

In the Knights vs Queens games it actually happened quite a lot. R.g. white move nr 5

Code: Select all

[Event "Computer Chess Game"] 
[Site "BASEMENT_PC"] 
[Date "2010.03.21"] 
[Round "-"] 
[White "Dirty Mar 14 2010"] 
[Black "Dirty Mar 14 2010"] 
[Result "1-0"] 
[TimeControl "40/300"] 
[FEN "1q1qk1q1/pppppppp/8/8/8/8/PPPPPPPP/NNNNKNNN w - - 0 1"] 
[SetUp "1"] 

{-------------- 
. q . q k . q . 
p p p p p p p p 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
P P P P P P P P 
N N N N K N N N 
white to play 
--------------} 
1. Nab3 {-9.66/11 7} d5 {+9.60/11 7} 2. Nf3 {-9.61/12 7} b6 {+9.78/12 7} 3. 
d4 {-9.49/14 7} c5 {+9.49/13 7} 4. Nhg3 {-9.57/13 7} c4 {+9.41/13 7} 5. 
Nb3d2 Kf8 {+9.30/13 7} 6. Nbc3 {-9.30/13 7} Qbc8 {+9.22/13 7} 7. Nfe3 
{-9.30/12 7} e6 {+9.44/14 7} 8. h3 {-9.54/13 7} g6 {+9.37/13 7} 9. Kf1 
{-9.77/12 7} f5 {+9.89/13 7} 10. Nh1 {-9.97/14 7} g5 {+10.19/14 7} 11. Kg1 
{-10.09/12 7} h5 {+10.08/14 7} 12. Nef1 {-9.80/14 7} Qh7 {+9.90/14 7} 13. 
Ne5 Kg8 {+9.89/13 7} 14. e3 {-9.62/12 7} Qcb7 {+9.66/11 7} 15. f4 
{-9.65/13 7} g4 {+9.56/14 7} 16. Nhf2 {-9.59/14 7} b5 {+9.56/14 7} 17. N1e2 
{-9.69/13 7} Qe8 {+9.83/13 7} 18. Nc1 {-9.93/12 7} a5 {+9.93/11 7} 19. N3e2 
{-9.92/12 7} Kh8 20. c3 {-9.97/13 7} Qhg7 {+10.04/13 7} 21. b3 
{-10.08/13 7} a4 {+10.10/11 7} 22. b4 {-9.94/12 7} a3 {+10.03/14 7} 23. Kh2 
{-10.04/13 7} Qeg8 {+10.03/15 7} 24. h4 {-10.07/15 7} Qbc7 {+10.02/14 7} 
25. g3 {-10.05/16 7} Qd6 {+10.02/17 7} 26. Kh1 Qa7 27. Kh2 {-10.05/17 7} 
Qgd8 {+10.02/18 7} 28. Kg1 {-10.05/18 7} Qg7 {+10.02/18 7} 29. Kh2 
{-10.05/17 7} Q6b6 {+10.02/17 7} 30. Kh1 {-10.05/15 7} Qa6 {+10.02/16 7} 
31. Kg1 {-10.05/16 7} Qdc7 {+10.02/18 7} 32. Kh1 {-10.05/16 7} Qaa7 
{+10.02/17 7} 33. Kh2 {-10.05/15 7} Qd6 34. e4 {-9.39/14 7} dxe4 
{+9.10/14 7} 35. Nfe3 {-9.18/13 7} Qdb6 {+9.84/14 7} 36. Ndxc4 {-9.91/13 7} 
bxc4 {+9.71/15 7} 37. N3xc4 {-9.71/15 7} Qb5 {+9.65/15 7} 38. Nde3 
{-9.69/14 7} Kg8 {+9.62/14 7} 39. Nb3 {-9.23/14 7} Qe8 {+8.96/14 7} 40. Nc5 
{-9.28/13 7} Qac7 {+8.23/13 7} 41. d5 {-6.65/13 7} exd5 {+6.30/14 7} 42. 
Nxf5 {-6.17/15 7} Qf6 {+6.19/13 7} 43. Nce3 {-6.00/14 7} Qcd8 {+6.06/13 7} 
44. Ned4 {-3.50/14 7} Qa8 {+3.23/13 7} 45. c4 {-2.61/12 7} Qac8 
{+2.51/11 7} 46. cxd5 {+0.04/13 7} Kh8 {-0.60/12 7} 47. Nfxe4 {+0.85/13 7} 
Qb6 {-0.93/14 7} 48. Ndc2 {+1.01/13 7} Qa8 {-1.07/12 7} 49. Nfd6 
{+1.33/13 7} Qg8 {-1.81/12 7} 50. Ndf7+ {+1.62/14 7} Qxf7 {-2.30/16 7} 51. 
Nxf7+ {+1.65/15 7} Kg7 {-2.58/16 7} 52. Nc4 Qba7 {-2.26/15 7} 53. Nfg5 
{+3.53/15 7} Qxd5 {-3.31/14 7} 54. Nce6+ {+3.32/16 7} Kg8 55. Nf6+ 
{+3.06/17 7} Kh8 {-3.05/18 7} 56. Nf7+ {+3.05/17 7} Qxf7 57. Nxd5 
{+2.85/17 7} Qxe6 58. Nde3 {+2.85/16 7} Qc6 59. N4xa3 {+2.74/14 7} Qf3 
{-2.32/15 7} 60. Ng2 {+2.55/15 7} Qf2 {-2.67/17 7} 61. b5 {+2.54/15 7} Kg7 
62. Ne3 {+2.78/16 7} Qb2 {-2.84/16 7} 63. Nec4 {+2.86/15 7} Qxa2 64. b6 
{+2.80/15 7} Qb3 {-2.98/16 7} 65. Nge3 Qa2+ {-3.04/14 7} 66. Nac2 
{+2.98/13 7} Kf6 {-9.61/14 7} 67. b7 {+9.50/13 7} Qa7 {-9.94/15 7} 68. Na5 
{+9.81/14 7} Kg6 69. Ng2 {+10.61/13 7} Qxa5 {-10.87/13 7} 70. b8=Q 
{+12.12/13 7} Kf7 {-12.15/12 7} 71. Qh8 {+12.12/12 7} Ke7 {-12.07/11 7} 72. 
Nce3 {+12.03/11 7} Qa2 {-17.53/12 7} 73. f5 {+17.53/12 7} Qf7 {-18.99/13 7} 
74. Nd5+ {+18.84/12 7} Qxd5 {-19.16/13 7} 75. f6+ Kd6 {-19.32/13 7} 76. Qe8 
{+19.24/13 7} Qf3 {-19.43/12 7} 77. f7 Kd5 {-319.82/12 7} 78. Nf4+ 
{+26.07/10 0.6} Kc4 {-319.84/127 0.6} 79. Qa4+ {+319.85/127 0.5} Kc3 
{-319.86/127 10} 80. Qa2 {+319.87/126 0.3} Qd1 {-319.88/127 0.5} 81. f8=Q 
{+319.89/127 0.4} Qc2+ {-319.90/127 0.4} 82. Ne2+ {+319.91/127 0.4} Kd2 
{-319.92/127 0.4} 83. Qd6+ {+319.93/127 0.4} Ke1 {-319.94/127 0.5} 84. Qxc2 
{+319.95/127 0.5} Kf1 {-319.96/127 0.4} 85. Qf4+ {+319.97/127 0.2} Ke1 86. 
Qcd2# {+319.99/127 0.2} 
{White mates} 1-0
Last edited by hgm on Mon Apr 12, 2010 8:20 pm, edited 1 time in total.
Richard Allbert
Posts: 794
Joined: Wed Jul 19, 2006 9:58 am

Re: SAN Move Disambiguation -- looking for test positition

Post by Richard Allbert »

I can't help you... and HG answered my quesiton also, so this has been edited :)
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: SAN Move Disambiguation -- looking for test positition

Post by sje »

Our Amsterdam friend is correct. The file plus rank disambiguation case is interesting as it was not mentioned in the FIDE rule book. (I don't know if the book has since been corrected.) But it was uncovered in my testing when I wrote the specification.

In the aforementioned position, only the move "Qa8xb7+" needs the special treatment.

From Myopic:

Code: Select all

Myopic v2010.06.25: A simple chess program for small systems
Copyright (C) 2010 by chessnotation@me.com   Some rights reserved.
License: Creative Commons Attribution-Share Alike 3.0
See: http://creativecommons.org/licenses/by-sa/3.0/

Caution: No warranty; use at your own risk.

Enter 'hm' for help, 'qp' to quit.

[] sf QQ6/Qp5k/8/8/8/8/8/7K w - - 0 1
[] dm
Moves: Kg1 Kg2 Kh2 Q7xb7+ Qa1 Qa2 Qa3 Qa4 Qa5 Qa6 Qa8xb7+ Qb6 Qbxb7+ Qc5 Qc7+ Qc8 Qd4 Qd6 Qd8 Qe3 Qe5 Qe8 Qf2 Qf4 Qf8 Qg1 Qg3 Qg8+ Qh2+ Qh8+
[] qp
Done
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: SAN Move Disambiguation -- looking for test positition

Post by sje »

Another early test position:

[d]7k/6p1/8/8/8/QQQ5/QnQ5/QQQ4K w - - 0 1

Code: Select all

[] sf 7k/6p1/8/8/8/QQQ5/QnQ5/QQQ4K w - - 0 1
[] db
  a b c d e f g h 
8   ::  ::  ::  bK 8
7 ::  ::  ::  bP   7
6   ::  ::  ::  :: 6
5 ::  ::  ::  ::   5
4   ::  ::  ::  :: 4
3 wQwQwQ  ::  ::   3
2 wQbNwQ::  ::  :: 2
1 wQwQwQ  ::  ::wK 1
  a b c d e f g h 
[w - - 0 1]
[] dm
Moves: Kg1 Kg2 Kh2 Q1d1 Q1d2 Q1e1 Q1e3 Q2d1 Q2d2 Q2d3 Q3d2 Q3d3 Q3e1 Q3e3 Qa1xb2 Qa2xb2 Qa3xb2 Qa6 Qa7 Qa8# Qaa4 Qaa5 Qab4 Qac5 Qb1xb2 Qb3xb2 Qb5 Qb6 Qb7 Qb8# Qba4 Qbb4 Qbc4 Qc1xb2 Qc2xb2 Qc3xb2 Qc6 Qc7 Qc8# Qca5 Qcb4 Qcc4 Qcc5 Qd4 Qd5 Qd6 Qe2 Qe4 Qe5 Qe6 Qe7 Qf1 Qf2 Qf3 Qf4 Qf5 Qf6 Qf7 Qf8# Qg1 Qg2 Qg3 Qg5 Qg6 Qg8# Qh2# Qh3# Qh6# Qh7# Qxg7+