Stockfish Invalid Moves

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

whittenizer
Posts: 85
Joined: Sun May 29, 2011 11:56 pm
Location: San Diego

Stockfish Invalid Moves

Post by whittenizer »

Hi there,

I'm working with the latest version of the code, and noticed something while testing. If enter a move as in "f8e7" without first having moved the "e7" pawn, I would think this would error out but the move I get back is "e7e6". But it doesnt have to be this particular move, any move that is invalid, it will return what should have been the previous move for that color in order for the actual move that was played to work. I'll have to send the exact position later on but hopefully this is clear enough for others to test.

Thank you,

David
whittenizer
Posts: 85
Joined: Sun May 29, 2011 11:56 pm
Location: San Diego

Re: Stockfish Invalid Moves

Post by whittenizer »

Alright, I had misinterpreted what the engine was doing. Its close but here is a different position I tested with:

position startpos moves e2e4 c7c5 g1f3 f8e7

Now, black has just moved, mind ya an invalid move, but the engine replies with a new black move of "d7d6". So, it appears as though whatever side makes an invalid move, the engine will just calculate a move instead for that side that made the invalid move.

Sure, it's doesnt blow up anymore but a bit confusing. I guess the GUI can handle this type of scenerio. I mean, giving the above position, if we're expecting a white reply(not realizing an invalid move was just imputed), but a black move comes back instead, we'd have to catch that in the GUI then.

Anyways, just wanted to mention this.

Thanks
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Stockfish Invalid Moves

Post by Sven »

Illegal moves are ignored, which is conforming to the UCI protocol. We could discuss whether we like it or not (I don't, for instance) but facts are given as they are, unfortunately ... So in fact the engine sees the position after e2e4 c7c5 g1f3, and that is a position with black to move, causing it to search for a black move and eventually replying "d7d6".

How do you think a GUI should "catch" that? In the given case it would be the GUI itself that had sent the illegal move before, so at least the GUI should be written such that its programming errors can be found (or better it hasn't any ...). Your example was for console mode, though. Personally I would prefer a protocol that would allow to return an error message in console mode, but one might argue that console mode is a "developer interface" to an engine, not a "regular user interface".

So I learned: be careful at the UCI console prompt. (WinBoard has some error message concept built into the protocol ;-) )

Sven
whittenizer
Posts: 85
Joined: Sun May 29, 2011 11:56 pm
Location: San Diego

Re: Stockfish Invalid Moves

Post by whittenizer »

Alright, I can see this then. Thanks for your input. I was running this in console mode so no safe guards there.

In the last version I modified the code to cout a message of "Invalid Move". At least I knew how to handle it better. The latest version makes it a bit harder to do this as the code looks quite different. I may try to figure it out, and then again I may just do something in my UI.

Anyways, thanks for the input.

David