Stockfish 1.6 - does not recongnize a lost pawn endgame

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Hart

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by Hart »

When I remove the KQkq tags there is no problem and Stockfish immediately outputs analysis. If I had to guess I'd say crashing is not compiler dependent, but rather dependent on the GUI parsing the FEN. But I suppose this still wouldn't make sense given the working re-compiles using different compiler options.

Code: Select all

  18	00:02.578	   4.871.387	1.900.658	-5.73	1.Kc2 g5 2.Kb3 g4 3.Ka3 Ke4 4.Kb3 Kf3 5.axb5 cxb5 6.c4 bxc4+ 7.Kxc4 Kg2 8.Kd3 Kxh2 9.Kd2 a4 10.Kd1 Kxg3
  19-	00:03.780	   7.491.399	1.989.219	-8.16	1.Kc2 bxa4 2.Kb2 h5 3.Ka3 Ke4 4.Kxa4 Kf3 5.Kxa5 Kg2 6.h4 Kxg3 7.Kb6 Kxh4 8.Kxc6 g5 9.Kd5 Kg3
  19	00:04.234	   8.438.187	2.000.044	-7.11	1.axb5 cxb5 2.c4 b4 3.c5 a4 4.c6 Kd6 5.c7 Kxc7 6.Kc4 a3 7.Kb3 Kd6 8.Ka2 g5 9.Kb3 Kd5 10.g4 Kc5 11.Ka2 Kc4 12.h3 Kc3 13.Ka1 b3 14.Kb1 Kd4
  20-	00:06.655	  13.797.025	2.077.552	-11.03	1.axb5 cxb5 2.Kc2 Kd5 3.h4 h5 4.Kb3 Kc5 5.Kc2 Kc4 6.Kd2 a4 7.Kc2 a3 8.Kb1 Kxc3 9.Ka1 b4 10.Kb1 b3 11.Kc1 a2
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by michiguel »

Hart wrote:I've tried this position with a dozen engines but it fails every time with Rybka 3, RobboLito 0.085g3, Stockfish 1.5.1 (intel x64), and Stockfish 1.6 (x64 ja).
Also, I don't know if this means anything but this FEN shows up as a Chess 960 position when I input it into Arena. Maybe a problem reading the FEN? I noticed the original FEN has the KQkq tags. Does that mean castling should be allowed when it cannot?
It means all those engines are glaurung derivatives :-)

The position is illegal, and the only sensible alternative is to reject the FEN or at least send some sort of warning. In the quest for ELO points, this does not matter, so sometimes commercial authors do not bother to fix these bugs. If I paid for any engine and does not send a minimum warning, it will surely annoy me. Come on... even my poor Gaviota can figure this out.

Miguel
Uri Blass
Posts: 10900
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by Uri Blass »

michiguel wrote:
Hart wrote:I've tried this position with a dozen engines but it fails every time with Rybka 3, RobboLito 0.085g3, Stockfish 1.5.1 (intel x64), and Stockfish 1.6 (x64 ja).
Also, I don't know if this means anything but this FEN shows up as a Chess 960 position when I input it into Arena. Maybe a problem reading the FEN? I noticed the original FEN has the KQkq tags. Does that mean castling should be allowed when it cannot?
It means all those engines are glaurung derivatives :-)

The position is illegal, and the only sensible alternative is to reject the FEN or at least send some sort of warning. In the quest for ELO points, this does not matter, so sometimes commercial authors do not bother to fix these bugs. If I paid for any engine and does not send a minimum warning, it will surely annoy me. Come on... even my poor Gaviota can figure this out.

Miguel
I disagree
A sensible alternative is simply to read the FEN and understand based on the FEN that the kings cannot castle

The engine should understand that KQkq at the end of the FEN string is only an hint that the king may castle in case of doubt and understand that it means that the king can castle except cases when there is an obvious reason that the king cannot castle(and not having rooks on the board is one obvious reason that the kings cannot castle).

Uri
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by michiguel »

Uri Blass wrote:
michiguel wrote:
Hart wrote:I've tried this position with a dozen engines but it fails every time with Rybka 3, RobboLito 0.085g3, Stockfish 1.5.1 (intel x64), and Stockfish 1.6 (x64 ja).
Also, I don't know if this means anything but this FEN shows up as a Chess 960 position when I input it into Arena. Maybe a problem reading the FEN? I noticed the original FEN has the KQkq tags. Does that mean castling should be allowed when it cannot?
It means all those engines are glaurung derivatives :-)

The position is illegal, and the only sensible alternative is to reject the FEN or at least send some sort of warning. In the quest for ELO points, this does not matter, so sometimes commercial authors do not bother to fix these bugs. If I paid for any engine and does not send a minimum warning, it will surely annoy me. Come on... even my poor Gaviota can figure this out.

Miguel
I disagree
A sensible alternative is simply to read the FEN and understand based on the FEN that the kings cannot castle

The engine should understand that KQkq at the end of the FEN string is only an hint that the king may castle in case of doubt and understand that it means that the king can castle except cases when there is an obvious reason that the king cannot castle(and not having rooks on the board is one obvious reason that the kings cannot castle).

Uri
No, it is a very poor practice to do that without at least warning the user. It is a very basic principle that garbage input (the FEN is wrong by definition) should be rejected, warned, or the user, being aware of that possibility and knowing what he/she is doing, forced it with a switch. The user should always be aware of what is going on. Silently fixing the errors is a recipe for disaster. How does the program know that the problem is in the castling or the user just put the rook in the wrong square? If you are automatically analyzing FENs, you are going to get back an answer that is wrong and you won't find it out.

And by the way, crashing or getting confused as mentioned above is NEVER an option.

Miguel
User avatar
beachknight
Posts: 3533
Joined: Tue Jan 09, 2007 8:33 pm
Location: Antalya, Turkey

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by beachknight »

Code: Select all

FEN: 8/6p1/2p4p/pp2k3/P7/2PK2P1/7P/8 w - - 0 1 

Gaviota 0.74.12 x64: all 345 Gaviota TBs installed

   12	00:01	   1.865.415	1.188.162	-2,83	:-(
  12	00:02	   2.449.452	1.200.711	-3,04	1.Kc2 Ke4 2.Kb3 Kf3 3.c4 b4 4.c5 Kg2 5.g4 Kxh2 6.Kc4 Kg3
  12	00:02	   3.740.564	1.380.281	-3,04	1.Kc2 Ke4 2.Kb3 Kf3 3.c4 b4 4.c5 Kg2 5.g4 Kxh2 6.Kc4 Kg3
  13	00:03	   5.016.303	1.299.560	-3,42	1.Kc2 Ke4 2.Kb3 Kf3 3.axb5 cxb5 4.c4 bxc4+ 5.Kxc4 Kg2 6.h4 Kxg3 7.h5 Kg4 8.Kb5 Kxh5
  13	00:04	   6.309.016	1.261.803	-3,42	1.Kc2 Ke4 2.Kb3 Kf3 3.axb5 cxb5 4.c4 bxc4+ 5.Kxc4 Kg2 6.h4 Kxg3 7.h5 Kg4 8.Kb5 Kxh5
  14	00:06	   7.974.193	1.139.170	-3,83	1.Kc2 :-(
  14	00:08	  10.152.686	1.194.433	-3,83	:-(
  14	00:13	  16.542.392	1.203.083	-4,05	1.Kc2 Kf5 2.axb5 cxb5 3.h3 Ke4 4.c4 b4 5.Kb3 Kd4 6.h4 h5 7.c5 Kxc5 8.Ka4 Kc4
  14	00:16	  21.847.476	1.365.467	-4,05	1.Kc2 Kf5 2.axb5 cxb5 3.h3 Ke4 4.c4 b4 5.Kb3 Kd4 6.h4 h5 7.c5 Kxc5 8.Ka4 Kc4
  15	00:18	  23.340.854	1.296.714	-4,46	1.Kc2 :-(
  15	00:21	  27.192.296	1.236.013	-4,46	:-(
  15	00:28	  35.468.190	1.266.721	-4,50	1.Kc2 bxa4 2.Kb2 Kf5 3.h3 Ke4 4.Ka3 Kf3 5.g4 Kg3 6.Kxa4 Kxh3 7.Kb3 a4+ 8.Kc2 Kxg4
  15	00:38	  51.270.887	1.349.233	-4,50	1.Kc2 bxa4 2.Kb2 Kf5 3.h3 Ke4 4.Ka3 Kf3 5.g4 Kg3 6.Kxa4 Kxh3 7.Kb3 a4+ 8.Kc2 Kxg4
  16	00:39	  52.652.616	1.350.067	-4,91	1.Kc2 :-(
  16	01:26	 120.334.195	1.383.151	-4,91	:-(
  16	01:38	 137.256.341	1.400.574	-4,91	1.Kc2 bxa4 2.Kd3 g5 3.c4 g4 4.c5 Kd5 5.Kc2 Kxc5 6.Kc3 h5 7.Kb2 Kb4 8.Kb1 a3
  16	01:38	 137.256.357	1.400.575	-4,91	1.Kc2 bxa4 2.Kd3 g5 3.c4 g4 4.c5 Kd5 5.Kc2 Kxc5 6.Kc3 h5 7.Kb2 Kb4 8.Kb1 a3
  17	01:39	 138.943.519	1.389.435	-5,32	1.Kc2 :-(
  17	01:54	 153.308.399	1.344.810	-5,32	:-(
  17	02:06	 178.151.443	1.402.767	-6,39	1.Kc2 :-(
  17	03:47	 352.080.799	1.544.214	-6,39	:-(
  17	04:04	 381.435.364	1.563.259	-6,58	1.Kc2 bxa4 2.c4 Kd4 3.c5 Kxc5 4.Kc3 Kb5 5.h3 Kc5 6.h4 h5 7.Kc2 Kc4 8.g4 hxg4 9.Kd2
  17	05:12	 511.214.487	1.638.507	-6,36	1.axb5 cxb5 2.Kc2 Ke4 3.Kd2 Kf5 4.h3 Ke4 5.c4 bxc4 6.Kc3 g5 7.Kc2 Kf3 8.Kc3 Kxg3 9.Kb2 Kxh3
  17	05:12	 511.214.501	1.638.508	-6,36	1.axb5 cxb5 2.Kc2 Ke4 3.Kd2 Kf5 4.h3 Ke4 5.c4 bxc4 6.Kc3 g5 7.Kc2 Kf3 8.Kc3 Kxg3 9.Kb2 Kxh3

hi, merhaba, hallo HT
User avatar
beachknight
Posts: 3533
Joined: Tue Jan 09, 2007 8:33 pm
Location: Antalya, Turkey

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by beachknight »

Code: Select all

FEN: 8/6p1/2p4p/pp2k3/P7/2PK2P1/7P/8 w - - 0 1 

Stockfish 1.6.0 JA x64:
  19	00:01	   6.558.196	4.611.952	-7,39	1.axb5 cxb5 2.Ke3 a4 3.Kd3 Kd5 4.Kc2 Kc4 5.Kb2 Kd3 6.g4 g5 7.Ka2 Kxc3 8.Ka3 Kc4 9.Kb2 b4 10.Kb1 Kc3 11.Ka2 a3 12.Kb1 b3 13.Ka1 Kc2
  20-	00:01	   9.673.353	4.912.825	-12,00	1.axb5 cxb5 2.Kc2 a4 3.Kc1 Kd5 4.c4+ bxc4 5.g4 a3 6.Kb1 c3 7.h3 Kc4 8.Kc2 a2
  20	00:02	  11.777.568	4.895.082	-11,31	1.Kc2 bxa4 2.Kb2 h5 3.Ka3 Kf5 4.h3 Ke4 5.Kxa4 Kf3 6.g4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
beachknight
Posts: 3533
Joined: Tue Jan 09, 2007 8:33 pm
Location: Antalya, Turkey

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by beachknight »

Code: Select all

FEN: 8/6p1/2p4p/pp2k3/P7/2PK2P1/7P/8 w - - 0 1 

Protector 1.3.3 x64:

 15/24	00:01	   1.125.374	5.539.218	-3,93	1.Kc2 bxa4 2.Kd3 a3 3.Kc2 Ke4 4.g4 a2
 16/26	00:01	   2.140.071	5.539.218	-4,27	1.Kc2 bxa4 2.Kd3 a3 3.Kc2 Ke4 4.h3 c5
 16/33	00:02	   2.688.425	5.510.540	-4,11	1.axb5 cxb5 2.Kc2 a4 3.g4 Kd5 4.Kb1 Kc4
 17/32	00:02	   3.776.296	5.483.251	-4,26	1.axb5 cxb5 2.Kc2 a4 3.Kd2 Ke4 4.Kc2 Ke3
 18/29	00:04	   5.868.025	5.584.789	-5,78	1.axb5 cxb5 2.c4 bxc4+ 3.Kxc4 g5 4.Kb3 g4
 18/29	00:04	   6.254.917	5.581.507	-5,57	1.Kc2 bxa4 2.Kd3 g5 3.c4
 18/29	00:04	   6.438.215	5.580.651	-5,27	1.Kc2 bxa4 2.Kd3 a3 3.Kc2 Ke4 4.h3 c5
 18/29	00:04	   7.020.426	5.585.929	-5,33	1.Kc2 bxa4 2.Kb2 Ke4 3.c4 Kd4 4.c5 Kxc5
 19/30	00:06	   9.040.842	5.632.518	-6,91	1.Kc2 bxa4 2.Kb2 c5 3.h4 Ke4 4.g4 Kd3
 19/32	00:07	  10.566.652	5.633.929	-6,90	1.axb5 cxb5 2.Kc2 Ke4 3.Kd2 a4 4.Kc2 Ke3
 20/33	00:09	  13.586.965	5.609.630	-6,80	1.axb5 cxb5 2.Ke3 a4 3.Kd3 Kd5 4.Kd2 g5
 20/33	00:09	  13.804.606	5.609.630	-7,02	1.axb5 cxb5 2.Ke3 a4 3.Kd3 g6 4.Kc2 Ke4
 21/42	01:04	  92.352.873	5.507.448	-10,36	1.axb5 cxb5 2.Kc2 Ke4 3.Kb3 Kd3 4.g4 a4+
 21/42	01:39	 139.541.913	5.480.254	-10,15	1.h4 bxa4 2.c4 g5 3.Kc2 Ke4 4.Kb2 Kf3
 21/42	01:46	 149.729.277	5.479.357	-9,85	1.h4 bxa4 2.c4 g5 3.Kc2 Kf5 4.Kb2 Kg4
 22/42	03:05	 257.928.379	5.457.954	-10,62	1.h4 bxa4 2.c4 a3 3.Kc2 c5 4.g4 Kd4

hi, merhaba, hallo HT
metax
Posts: 344
Joined: Wed Sep 23, 2009 5:56 pm
Location: Germany

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by metax »

michiguel wrote:
It means all those engines are glaurung derivatives :-)
I guess this was a joke, but anyway: I have seen many engines crashing on this wrong FEN with the KQkq tags which are certainly NOT Glaurung derivatives :)
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by mcostalba »

metax wrote:
michiguel wrote:
It means all those engines are glaurung derivatives :-)
I guess this was a joke, but anyway: I have seen many engines crashing on this wrong FEN with the KQkq tags which are certainly NOT Glaurung derivatives :)
The function from_fen() that parses the fen string is in position.cpp and the description comment says it all

Code: Select all

/// Position::from_fen() initializes the position object with the given FEN
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).

void Position::from_fen(const string& fen) {
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish 1.6 - does not recongnize a lost pawn endgame

Post by Sven »

mcostalba wrote:
metax wrote:
michiguel wrote:
It means all those engines are glaurung derivatives :-)
I guess this was a joke, but anyway: I have seen many engines crashing on this wrong FEN with the KQkq tags which are certainly NOT Glaurung derivatives :)
The function from_fen() that parses the fen string is in position.cpp and the description comment says it all

Code: Select all

/// Position::from_fen() initializes the position object with the given FEN
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).

void Position::from_fen(const string& fen) {
Looking at the source of that from_fen() function, it is obvious for me that this comment is partially wrong. from_fen() does a lot of error checking (so it is obviously intended to be very robust), but regarding the castle rights part it only does so for the "AHah" style but not for the "KQkq" style castling rights string. A simple fix could look like this (note: I have not tested it):

Code: Select all

// old code
//    else if(fen[i] == 'K') allow_oo(WHITE);
//    else if(fen[i] == 'Q') allow_ooo(WHITE);
//    else if(fen[i] == 'k') allow_oo(BLACK);
//    else if(fen[i] == 'q') allow_ooo(BLACK);

// new code
    else if(fen[i] == 'K') {
        if(piece_on(make_square(initialKFile,  RANK_1)) != WK ||
           piece_on(make_square(initialKRFile, RANK_1)) != WR) {
            std::cout << "Error in FEN at character " << i << std::endl;
            return;
        } else allow_oo(WHITE);
    }
// ... same for other three castle types ...
Also I doubt that it is an acceptable strategy to crash (or show undefined behaviour) on bad input.

EDIT: This sub-thread should perhaps be continued in the programming forum.

Sven