The best thing to do with an input like "4k/p/p/pP/8/8/8/K w - a6 0 1" is to flag it as invalid and not to let a broken position into the program.
The user should be informed as early as possible when his input is faulty; we don't want him to waste time waiting for an analysis of what is likely contaminated by a typographical error.
Negascout questions
Moderators: hgm, Rebel, chrisw
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Meta blunders
Greenblatt's MacHack VI, a innovative pioneering chess program from the late 1960s, would on occasion double advance a pawn to block a check by hopping over an occupied square. Perhaps if the program is going to lose, it might as well try to cheat! (Of course, the bug was unintentional. Still amusing, though.)MattieShoes wrote:Hey, setting up illegal positions is cheating! That's a bug in the user!
One hazard of using a third party GUI is that the engine coder can become a bit too complacent due to (supposed) full error checking by the GUI. Take away the GUI and then problems with unsanitized input can start. The best strategy here is "trust but verify".
-
- Posts: 6401
- Joined: Thu Mar 09, 2006 8:30 pm
- Location: Chicago, Illinois, USA
Re: Meta blunders
Gaviota rejects the FEN positions as wrong. With a triple check, accepts the position but gets out of check with no problem (it sees two legal moves).sje wrote:bob wrote:For setting up positions, I just check everything for sanity before doing anything at all. If e6 is set as an ep-target, I check for a black pawn on e5, and a white pawn on either d5 or f5. Ditto for more than 9 queens, or 10 knights, bishops or rooks, and so forth.Code: Select all
bash-3.2$ ./crafty unable to open book file [./books.bin]. Crafty v22.1 (1 cpus) White(1): setboard side to move is bad Segmentation fault
Code: Select all
bash-3.2$ ./crafty unable to open book file [./books.bin]. Crafty v22.1 (1 cpus) White(1): setboard 4k/p/p/pP/8/8/8/K w - a6 0 1 White(1): perft 1 total moves=5 time=0.00 White(1): d +---+---+---+---+---+---+---+---+ 8 | | . | | . |<K>| . | | . | +---+---+---+---+---+---+---+---+ 7 |<P>| | . | | . | | . | | +---+---+---+---+---+---+---+---+ 6 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 5 |<P>|-P-| . | | . | | . | | +---+---+---+---+---+---+---+---+ 4 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 3 | . | | . | | . | | . | | +---+---+---+---+---+---+---+---+ 2 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 1 |-K-| | . | | . | | . | | +---+---+---+---+---+---+---+---+ a b c d e f g h White(1): perft 1 total moves=5 time=0.00 White(1): setboard 4k/p/p/pP/8/8/8/K w - a6 0 1 White(1): d +---+---+---+---+---+---+---+---+ 8 | | . | | . |<K>| . | | . | +---+---+---+---+---+---+---+---+ 7 |<P>| | . | | . | | . | | +---+---+---+---+---+---+---+---+ 6 |<P>| . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 5 |<P>|-P-| . | | . | | . | | +---+---+---+---+---+---+---+---+ 4 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 3 | . | | . | | . | | . | | +---+---+---+---+---+---+---+---+ 2 | | . | | . | | . | | . | +---+---+---+---+---+---+---+---+ 1 |-K-| | . | | . | | . | | +---+---+---+---+---+---+---+---+ a b c d e f g h White(1):
We should build a list of positions to stress test our engines.
Miguel
Code: Select all
setboard 4k/p/p/pP/8/8/8/K w - a6 0 1
Error (wrong FEN or EPD): 4k/p/p/pP/8/8/8/K w - a6 0 1
tellusererror Error loading FEN:
4k/p/p/pP/8/8/8/K w - a6 0 1
setboard 4k/p/p/pP/8/8/8/K w - a6 0 1
Error (wrong FEN or EPD): 4k/p/p/pP/8/8/8/K w - a6 0 1
tellusererror Error loading FEN:
4k/p/p/pP/8/8/8/K w - a6 0 1
setboard
Error (wrong FEN or EPD):
tellusererror Error loading FEN:
setboard rnb1k2r/ppp2ppp/4r3/8/1b6/5n2/PPP3PP/RNB1KBNR w KQkq - 0 1
d
+-----------------+
| r n b . k . . r |
| p p p . . p p p |
| . . . . r . . . |
| . . . . . . . . | Castling: KQkq
| . b . . . . . . | ep: -
| . . . . . n . . |
| P P P . . . P P |
| R N B . K B N R | [White]
+-----------------+
perft 1
depth 0: leaves: 1 accum: 1
depth 1: leaves: 2 accum: 3
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Meta blunders
Symbolic checks input FEN data for everything simple except the case of too many same color-square bishops. Non-simple stuff that's not checked is anything that would require retrograde analysis including proving that a prior move exists for a non-starting position. Doing a proof of reachability would require a separate program and such proof might not even be feasible in some cases.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Meta blunders
I'm not sure how you can have too many wrong color bishops. 8 pawns can promote to the same color bishop if 4 of them make captures. I suppose 10 would be too many, but 9 would be OK.sje wrote:Symbolic checks input FEN data for everything simple except the case of too many same color-square bishops. Non-simple stuff that's not checked is anything that would require retrograde analysis including proving that a prior move exists for a non-starting position. Doing a proof of reachability would require a separate program and such proof might not even be feasible in some cases.
-
- Posts: 13447
- Joined: Wed Mar 08, 2006 9:02 pm
- Location: Dallas, Texas
- Full name: Matthew Hull
Re: Meta blunders
I know a composed chess problem that has a full set of chessmen for white and black, but white's bishops are the same square-color.bob wrote:I'm not sure how you can have too many wrong color bishops. 8 pawns can promote to the same color bishop if 4 of them make captures. I suppose 10 would be too many, but 9 would be OK.sje wrote:Symbolic checks input FEN data for everything simple except the case of too many same color-square bishops. Non-simple stuff that's not checked is anything that would require retrograde analysis including proving that a prior move exists for a non-starting position. Doing a proof of reachability would require a separate program and such proof might not even be feasible in some cases.
Matthew Hull
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Meta blunders
For the sake of openness, I must admit that while Symbolic has pages and pages of code to test for input FEN bogosity, the only possible error message is "Bad Parameter Value". This is because of my faithful adherence to the tenets of the Ken Thompson School of Abbreviated Diagnostics.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Meta blunders
My favorite was the old xerox sigma-x series of computers running UTS or (later) CP-V or CP-6. The only diagnostic you saw when you typed in a bad command to the shell, the editor, etc was "eh?" A couple of programs did expand this to say "eh? @ N" where N was the character number.sje wrote:For the sake of openness, I must admit that while Symbolic has pages and pages of code to test for input FEN bogosity, the only possible error message is "Bad Parameter Value". This is because of my faithful adherence to the tenets of the Ken Thompson School of Abbreviated Diagnostics.
-
- Posts: 718
- Joined: Fri Mar 20, 2009 8:59 pm
Re: Meta blunders
Haha, my engine used to say "eh?" on any unrecognized command. I think I removed it when I actually sat down and created a winboard interface class though.
I can tell how frustrating a bug was by looking at the number and quality of error messages I created for it, as well as comments in the code.
"Illegal FEN" <--for things that never broke
"Illegal FEN (%s)" <--for things that broke once
"WTF?!" <--for things that are doing things that seem impossible and I have no idea why. Generally scattered throughout the code with breakpoints so I can look at the stack and figure out what bizarre sequence might have happened
"****ing son of a *****" <-- Representative of a much longer series of error messages. Signifies that I need to stop coding for a while.
"Illegal FEN: White can castle kingside but there's no rook on h1" <--must have been REALLY bad to force me to do what I should have done in the first place
I can tell how frustrating a bug was by looking at the number and quality of error messages I created for it, as well as comments in the code.
"Illegal FEN" <--for things that never broke
"Illegal FEN (%s)" <--for things that broke once
"WTF?!" <--for things that are doing things that seem impossible and I have no idea why. Generally scattered throughout the code with breakpoints so I can look at the stack and figure out what bizarre sequence might have happened
"****ing son of a *****" <-- Representative of a much longer series of error messages. Signifies that I need to stop coding for a while.
"Illegal FEN: White can castle kingside but there's no rook on h1" <--must have been REALLY bad to force me to do what I should have done in the first place
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Meta blunders
As they say, something is better than nothing.bob wrote:My favorite was the old xerox sigma-x series of computers running UTS or (later) CP-V or CP-6. The only diagnostic you saw when you typed in a bad command to the shell, the editor, etc was "eh?" A couple of programs did expand this to say "eh? @ N" where N was the character number.
And nothing is what you sometimes got from an early Fortran compiler that ran on a DEC pdp-8/e in 4 KWord RAM. (Twelve bit words.) Memory was so tight that the compiler authors had to leave out nearly all error diagnostics. And if there weren't any diagnostics, why bother with error detection? So, much bad Fortran input would be compiled without complaint.
I'm told that the early Berkeley C compilers had only two diagnostics available: "Syntax error" and "Program too complex".