Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Do you have code to check if a FEN is legal position?

Author: Roman Hartmann

Date: 04:00:55 02/05/05

Go up one level in this thread


Hi Uri,
I wrote my own function to read a fen-string into my chess engine and thought
about that problem as well. The only checks about the legality of a position I'm
doing rightknow is that both sides have a king (and only 1 king for each side)
and that no side has more than 8 pawns and that there are no pawns on the first
or on the 8-th row. No checks are done yet to see if some impossible  promotions
happened (8 pawns but more than 1 queen for one side ...).
I'm also not (yet) checking if the king can be taken in the next move. But I
could easily check if a king is under attack by the side to move and I guess I
will just add a few lines of code to make sure not to import illegal positions
of this kind. I'm not sure how the fen-reader/engine should behave when an
illegal position is encountered (i.e. should it output a message or just ignore
the illegal position).

Roman



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.