ianfab / fairyground

playground for Fairy-Stockfish in the browser
https://fairyground.vercel.app/
GNU General Public License v3.0
21 stars 5 forks source link

How to get necessary game rule information of a variant (like used piece id)? #27

Open yjf2002ghty opened 1 year ago

yjf2002ghty commented 1 year ago

I'm considering adding a "Board setup" part which allows user to set up the board graphically instead of using FEN, which might be useful for those non-expert users. However, I've looked at the export interfaces of ffish.js library, there is no function that can provide detailed information on the game rule such as used piece id characters (q, r, n, b, etc.) and the promotion relationship between pieces. There is also no function that can provide information such as castling, n-fold repetition (the half move clock value needs this), valid gating area (used in seirawan gating) and other necessary information for setup.

Is there any method to gather these information other than simply using trial-and-error method by changing the FEN and validate it or reading the content of variants.ini and process the game rule entries in it?

ianfab commented 1 year ago

Ideally I think the whole ruleset, i.e., basically the Variant struct, should be exposed to the library in a structured way, especially if one considers maybe even the possibility of doing variant configuration via a GUI, but I am not an expert on how to do this in the cleanest way when interfacing between the languages.

So far in most projects using pyffish or ffishjs I think the set of allowed pieces was just inferred from the start FEN, or hardcoded. Due to potential pawn promotion to pieces not present in the starting position this is not always correct though, so a more direct way would be preferable.