Author: Russell Reagan
Date: 21:36:56 02/05/05
Go up one level in this thread
On February 05, 2005 at 04:51:35, Uri Blass wrote: >I want to have a loop on all the legal FEN of tablebases positions (at least fen >of 4 pieces) in order to debug my code to use tablebases and also to debug the >function that I plan to write that should check if a FEN is legal. > >I gave the source code of movei to Dann Corbit and he wrote for me a function >that does part of it that is not based on the rest of the code of movei but it >does not check things like if the side to move can capture the opponent king and >I find the program hard to understand because for some reason Dann used a lot of >char ** that I never use in movei. > >It may be because of my lack of knowledge in programming but I see no reason to >use ** for tasks like that and I see no advantage in it and it only cause >problems in understanding such a code. > >I understand that ** should be pointer to pointer but not more than it and >I have no experience with code like that. > >I think simply to read the FEN string char after char and collect information >when I never need to go backward in the string when Dann's code does not do it >and in order to check if there is a single king it simply count K in the >relevant part of the string that is called piece_placement > >It is used as char ** in one function tokenize_position_string and as char * in >another function setup that calls tokenize_position_string(I guess that the >computer simply translate char* to char **) > > >I still do not fully understand the code that Dann wrote for me at this >moment(note that this code has nothing to do with the moves of the engine and it >is only about checking the FEN that the program does not use during games) and I >feel that I spend too much time about trying to understand things that are not >relevant to the playing strength. > >I think that I will write my own code for that task instead of Dann's code and >I already started with it. > >I wonder if you do it. > >Uri For validation purposes, I would not operate on the FEN string itself. I would parse it into some kind of simple board (64 element array maybe). Then I would validate the things that were required to be minimally valid. What is "valid" will depend upon how your engine works. Once I wrote a move generator that was very generic. The board could have white pawns on the first rank, and probably even multiple kings for each color (and probably zero kings too, never tried it). For that one, I did not need to validate the FEN as much. If your engine will work fine with 30 white queens on the board, then don't worry about that "illegal" position. Only validate such a thing if your engine expects that requirement to be met. If your engine expects there to be 9 queens or less, then reject positions with more than 9 queens. Be liberal in what you accept, unless there is a good reason to reject something. You can end up wasting a lot of time trying to reject every position that is technically unreachable from the starting position. In addition, having strict requirements will only make your program less flexible. What if you want to add support for FRC or shuffle chess in the future? Or some other chess variant?
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.