Expose resolved variant information in bindings - #1011
Open
gbtami wants to merge 2 commits into
Open
Conversation
gbtami
marked this pull request as ready for review
July 13, 2026 18:34
Contributor
|
Nice. I've been using the |
Member
Author
|
@ianfab what do you think, is this OK or do you have something different in your mind? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fairy-Stockfish already performs the authoritative parsing and processing of
variants.inidefinitions. This includes applying inheritance, defaults and overrides, resolving piece identities and custom Betza pieces, constructing promotion and pocket rules, processing regions, and deriving the final game-ending behavior.Until now, applications using the Python or JavaScript bindings had access only to a small collection of individual helper functions. A GUI needing additional information had to parse
variants.iniagain and try to reproduce part of Fairy-Stockfish’s internal processing.That approach has several problems:
This PR adds a single authoritative introspection API:
Both bindings use the same C++ serializer, so they expose the same fully resolved information.
The result is versioned JSON rather than a direct dump of the internal
Variantrepresentation. Piece sets, enums, bitboards and other implementation details are converted to stable semantic values such as piece names, square lists, booleans and descriptive strings. This keeps the API useful to external applications without making internal enum values or memory representations part of the public contract.The exported information includes the resolved:
A concrete use case is pychess-variants’ user-defined variant support. Pychess previously had to infer pieces, promotions, pockets, royal roles and other properties independently on both its Python server and TypeScript client. Inherited pieces that could not be detected reliably even required GUI-specific metadata inside the INI comments.
With this API, Fairy-Stockfish remains the only component responsible for interpreting the variant definition. Pychess and other GUIs can consume the resolved result for rendering, piece-set validation, board styling, editors, rule descriptions and server-side termination handling.
This PR exposes information Fairy-Stockfish has already parsed and resolved, making that information reusable through the existing bindings.