No, the castling availability potentially applies to all future positions, not just the next move.mambofish wrote:If you change the rules for the ep field, you would presumably also have to change them for the castling field, to remain semantically consistent.
Programmer bug hunt challenge
Moderators: hgm, Rebel, chrisw
-
- Posts: 4675
- Joined: Mon Mar 13, 2006 7:43 pm
Re: Programmer bug hunt challenge
Re: Programmer bug hunt challenge
And what about the situation where the pawn move revealed a check on the enemy king? Even if an opposing pawn could theoretically capture e.p., this would also not be legal. Would you omit the e.p. square in this case as well from the FEN notation?
FEN says nothing about the legality of moves for the next player, and I personally think it should remain that way![Wink :wink:](./images/smilies/icon_wink.gif)
FEN says nothing about the legality of moves for the next player, and I personally think it should remain that way
![Wink :wink:](./images/smilies/icon_wink.gif)
-
- Posts: 28
- Joined: Sun Mar 12, 2006 12:08 am
- Location: Midlands, England
Re: Programmer bug hunt challenge
There is a potential difficulty with that, the clause "unless capture is possible" needs stricter definition. What if the en passant capture is a pseudo-legal move but not a genuinely legal move i.e. it leaves the moving side in check?Dann Corbit wrote:I think that the standard should redo e.p. so that the square is not named unless capture is possible.
[D]1k6/3r4/8/3Pp3/8/3K4/8/6R1 w - e6 0 2
At present, it is not necessary to check for legal moves (psuedo-legal or otherwise) to write a FEN string. If the proposed change is to only name the en passant square when genuinely legal en passant capture(s) are possible, then programs writing FEN strings must check for the legality of moves i.e. become more complex.
On a related issue, for the purposes of 3-time repetition, section 9.2 of the FIDE Laws of Chess deem that a position is repeated only if :
The part I want to draw attention to is the clause "the possible moves of all the pieces of both players are the same".if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same. Positions are not the same if a pawn that could have been captured en passant can no longer in this manner be captured or if the right to castle has been changed temporarily or permanently.
With the current FEN standard, it is possible to have 2 chess positions which are considered a repetition by the FIDE laws, but have different en passant square encoding in FEN. For example:
[D]r3k3/8/8/4p3/4P3/8/8/1R2K3 w - - 0 2
[D]r3k3/8/8/4p3/4P3/8/8/1R2K3 w - e6 0 2
If we imagine the FEN standard were changed to only name the en passant square when genuinely legal en passant capture(s) are available, the last example shown is not possible. The conditions for position repetition then become exactly equivalent to :
if the corresponding first four fields of the FEN encoding for the positions are the same
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Programmer bug hunt challenge
I think the right answer is that an EP target is given only when an EP capture is possible. The pinned pawn issue doesn't matter to me as much as the original case. But I can handle it however you throw it at me so it really doesn't matter. Same problem with PGN games. Too many screw up castling and use zero-zero (among others). Some put a space after 21. Ne5, others just produce 21.Ne5. I've made my parsing handle these odd cases over the years to avoid confusion when it would fail on a PGN read...mambofish wrote:And what about the situation where the pawn move revealed a check on the enemy king? Even if an opposing pawn could theoretically capture e.p., this would also not be legal. Would you omit the e.p. square in this case as well from the FEN notation?
FEN says nothing about the legality of moves for the next player, and I personally think it should remain that way
But following the standard would be nice, IMHO...
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Programmer bug hunt challenge
I don't see where repetition (or even the 50 move rule) would be a problem. For there to be a true EP target (according to my terminology) the position could _not_ have occurred previously in the game, because a pawn must be pushed the previous move to generate an EP target. And once the pawn is pushed, the 3-fold repetition counter starts over as does the 50 move rule. So how could there be an ambiguity? And it is certainly legal for two identical positions to be converted to FEN, where one has the EP target and one does not. Because the one that does not did not have a pawn push the previous move...steffan wrote:There is a potential difficulty with that, the clause "unless capture is possible" needs stricter definition. What if the en passant capture is a pseudo-legal move but not a genuinely legal move i.e. it leaves the moving side in check?Dann Corbit wrote:I think that the standard should redo e.p. so that the square is not named unless capture is possible.
[D]1k6/3r4/8/3Pp3/8/3K4/8/6R1 w - e6 0 2
At present, it is not necessary to check for legal moves (psuedo-legal or otherwise) to write a FEN string. If the proposed change is to only name the en passant square when genuinely legal en passant capture(s) are possible, then programs writing FEN strings must check for the legality of moves i.e. become more complex.
On a related issue, for the purposes of 3-time repetition, section 9.2 of the FIDE Laws of Chess deem that a position is repeated only if :The part I want to draw attention to is the clause "the possible moves of all the pieces of both players are the same".if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same. Positions are not the same if a pawn that could have been captured en passant can no longer in this manner be captured or if the right to castle has been changed temporarily or permanently.
With the current FEN standard, it is possible to have 2 chess positions which are considered a repetition by the FIDE laws, but have different en passant square encoding in FEN. For example:
[D]r3k3/8/8/4p3/4P3/8/8/1R2K3 w - - 0 2
[D]r3k3/8/8/4p3/4P3/8/8/1R2K3 w - e6 0 2
If we imagine the FEN standard were changed to only name the en passant square when genuinely legal en passant capture(s) are available, the last example shown is not possible. The conditions for position repetition then become exactly equivalent to :if the corresponding first four fields of the FEN encoding for the positions are the same
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Programmer bug hunt challenge
It seems to me that requiring the e.p. field in a FEN to be only present if there actually is a legal e.p. capture just puts a completely needless burden on the routine that converts board positions to FENs. No information is lost by putting a superfluous e.p. square. A possible reader for which the presence of an actual capture makes any difference almost certainly will have the intelligence and information to figure out for itself if the capture exists, if it wants to know that.
FENs are designed as a tool to make life easy. So I think the existing standard made the good choice.
FENs are designed as a tool to make life easy. So I think the existing standard made the good choice.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Programmer bug hunt challenge
Here's the reason it is bad: You have a position with a white pawn at e4 and no black pawns on the d or f file. If the last move was e4, you get an EP target of e3. If the last move was something else, the ep target would be blank. Yet the two positions are absolutely identical. Why should they have different FEN strings?hgm wrote:It seems to me that requiring the e.p. field in a FEN to be only present if there actually is a legal e.p. capture just puts a completely needless burden on the routine that converts board positions to FENs. No information is lost by putting a superfluous e.p. square. A possible reader for which the presence of an actual capture makes any difference almost certainly will have the intelligence and information to figure out for itself if the capture exists, if it wants to know that.
FENs are designed as a tool to make life easy. So I think the existing standard made the good choice.
Whatever program writes the FEN string has some responsibilities anyway. The 50 move counter. Castling status. So why not simply get the EP target right so that there is no ambiguity as presently exists???
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Programmer bug hunt challenge
Because it is easier and hurts no one. There exists no ambiguity: it is always fully clear from a FEN if ep capture is possible or not.bob wrote:Why should they have different FEN strings?
Writing the 50-move counter and the castling status is trivial, as they are supplied in the definition of the position. The last move is also available, and if not, there is no way to determine e.p. status. All that is totally trivial compared to figuring out if you are in-check after an e.p. capture. For that you have to know the rules of Chess and in effect include a full move generator. That is at a totally different diffciculty level.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: Programmer bug hunt challenge
Who cares about the "difficulty level"? The position where one side has played e4 is identical with the position where he has not, if there is no EP possible. Yet now we have two different FEN representations of the _identical_ string. Which makes position comparisons more complicated than necessary. Chess doesn't have a "pseudo-legal move" concept. Neither should it have an ambiguous position description. Regardless of how complex it makes the code that produces the FEN string...hgm wrote:Because it is easier and hurts no one. There exists no ambiguity: it is always fully clear from a FEN if ep capture is possible or not.bob wrote:Why should they have different FEN strings?
Writing the 50-move counter and the castling status is trivial, as they are supplied in the definition of the position. The last move is also available, and if not, there is no way to determine e.p. status. All that is totally trivial compared to figuring out if you are in-check after an e.p. capture. For that you have to know the rules of Chess and in effect include a full move generator. That is at a totally different diffciculty level.
What business does a program that doesn't "know the rules of chess" have producing position descriptions? Does it not need to know about move legality, in check status and so forth?
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Programmer bug hunt challenge
Lzy people like me do!bob wrote:Who cares about the "difficulty level"?
![Laughing :lol:](./images/smilies/icon_lol.gif)
![Laughing :lol:](./images/smilies/icon_lol.gif)
![Laughing :lol:](./images/smilies/icon_lol.gif)
For instane, if I want to transplant FEN I/O routines from one Chess program (like Joker) to completely different program (like microMax, or a tablebase generator) that have completely different routines for move generation, I would have to change a lot more. Drawing on the Chess knowledge of the host program needlessly increases the interdependence, and reduces the portability of the routine between programs.
If I would want to use a FEN routine in a Chess variant, with fairy pieces, I would only hav to change the list of allowed letters and their encodings. If I would have to test for legality, it would be a disaster...