allowing invalid positions

Discussion of chess software programming and technical issues.

Moderator: Ras

JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: allowing invalid positions

Post by JVMerlino »

ericlangedijk wrote:They do not see it as an option. Even checkmates are seen in these kind of illegal positions :)
Ok, that makes more sense. :)

jm
Aleks Peshkov
Posts: 958
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia
Full name: Aleks Peshkov

Re: allowing invalid positions

Post by Aleks Peshkov »

The problem that UCI has no defined way to report invalid input.
ericlangedijk
Posts: 35
Joined: Thu Aug 08, 2013 5:13 pm

Re: allowing invalid positions

Post by ericlangedijk »

Another one is this:

Code: Select all

8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - c3 0 1
The last move must have been c2-c4 because of the ep square.
Which of course is impossible because of the white bishop already giving check.

Critter crashes, Rybka doesn't (using Arena interface)
lucasart
Posts: 3242
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: allowing invalid positions

Post by lucasart »

ericlangedijk wrote:Another one is this:

Code: Select all

8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - c3 0 1
The last move must have been c2-c4 because of the ep square.
Which of course is impossible because of the white bishop already giving check.

Critter crashes, Rybka doesn't (using Arena interface)
[d]8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - c3 0 1

DiscoCheck has no problem here. For example, here's my perft(5):

Code: Select all

$ position fen 8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - c3 0 1
$ perft 5
d5d4	8513
d5e4	11360
d5c5	5520
d5e5	11084
d5c6	8148
d5e6	8952
53577
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: allowing invalid positions

Post by sje »

Symbolic detects the bogus en passant target then deletes it:

Code: Select all

[] sf 8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - c3 0 1
[] df
8/3P2p1/3p4/3k4/1pP5/4p3/BP6/K7 b - - 0 1
Symbolic detects and rejects positions with more than two checkers to the king. Does your program do this?
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: allowing invalid positions

Post by michiguel »

ericlangedijk wrote:They do not see it as an option. Even checkmates are seen in these kind of illegal positions :)
More interesting is this position

[d]3b4/7k/6p1/4PpK1/5P2/8/8/8 w - f6 0 2

Code: Select all

setboard 3b4/7k/6p1/4PpK1/5P2/8/8/8 w - f6 0 2
d
+-----------------+
| . . . b . . . . |
| . . . . . . . k |
| . . . . . . p . |
| . . . . P p K . |    Castling: 
| . . . . . P . . |    ep: f6
| . . . . . . . . |
| . . . . . . . . |
| . . . . . . . . | [White]
+-----------------+

analyze
0-1 {Gaviota says Black mates}
:-)

A check by a piece can never be defended by an en passant capture or a pawn capture for that matter. So, a safe optimization is to ignore them when a check evasion is generated. So, Gaviota thinks it is mate.

Miguel
AlvaroBegue
Posts: 932
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: allowing invalid positions

Post by AlvaroBegue »

Making some optimization that assumes the rules of chess are being followed is perfectly valid in my opinion. It's a bit like invoking undefined behavior (http://en.wikipedia.org/wiki/Undefined_behavior) in C++, where the compiler might use an optimization assuming that your code complies with the standard, and if your code doesn't then it is allowed to do whatever it does, including crashing, going into an infinite loop or deleting every file in your filesystem.

Perhaps the UCI specification should be explicit about the kinds of things that trigger undefined behavior by complying engines and GUIs.
tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: allowing invalid positions

Post by tpetzke »

I agree it would be nice if the UCI protocol would standardize basic move inputs. However no one prevents a programmer to just add it as an additional command feature.

Accepting moves in LAN was one of the first things I added to the iCE command list because it simplifies my life.

Thomas...
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: allowing invalid positions

Post by sje »

For: [d]
Symbolic lists the only available move:

Code: Select all

[] df
3b4/7k/6p1/4PpK1/5P2/8/8/8 w - f6 0 2
[] dm
exf6
I just don't see the need for doing much retro-analysis for inputting a position. To do a good job would require proving that the input position could be somehow traced to the initial array. No one has ever provided a solution or this, although it might be possible.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: allowing invalid positions

Post by sje »

tpetzke wrote:I agree it would be nice if the UCI protocol would standardize basic move inputs.
It would be nice if the UCI protocol used SAN moves and not the bulky, hard-to-read e2e4 c7c5 g1f3 d7d6 coordinate notation which went out of style forty years ago.