fairy-stockfish / Fairy-Stockfish

chess variant engine supporting Xiangqi, Shogi, Janggi, Makruk, S-Chess, Crazyhouse, Bughouse, and many more
https://fairy-stockfish.github.io/
GNU General Public License v3.0
615 stars 192 forks source link

JavaScript Library Binding #157

Closed QueensGambit closed 4 years ago

QueensGambit commented 4 years ago

Thank you @ianfab for your wonderful work on Fairy-Stockfish.

What is your opinion on adding a JavaScript library binding, ffish.js, for Fairy-Stockfish?

I have seen that you have already created a web assembly fork for Fairy-Stockfish. However, this version is only meant to be used as an engine and does not allow move generation, checking for valid FENs etc., as an engine is supposed to.

I know that there exists chess.js and even a dedicated fork for crazyhouse (crazyhouse.js). Unfortunately, crazyhouse.js is limited to crazyhouse, the development has stopped and it isn't optimized.

I am asking because I started to create an UCI chess variant analysis web GUI which is meant to be later exported to the deskop using electron.js. This way you can integrate the infamous lichess.org chessboard and other powerful web assets while still running the engine executables natively with multi-processing and possibly GPU access via node.js.

image Layout of the GUI (WIP)

I'm planning to open source this GUI after I created the first release candidate. Some open-source chess engines like Muti-Variant-Stockfish and Fairy-Stockfish are expected to be integrated as standard engines in this GUI. Currently, it is using crazyhouse.js as its back-end. Alternatively, I could add a python back-end using pyffish or python-chess but I would prefer avoiding an additional overhead.

The idea would be to have the same functionality as in pyffish.cpp and to use emscripten to make it available in JavaScript.

If you are interested, I can help setting this up.

Best Regards ~QueensGambit

ianfab commented 4 years ago

Thanks a lot for your suggestion.

Yes, I agree it would be very nice to also have a JS binding for Fairy-Stockfish, as I think it provides a nice framework for chess variant development. Actually, I had a similar idea of developing a local GUI for chess variants using some binding of Fairy-SF for the chess variant logic, preferably with electron to make use of chessground, since there are many variants in Fairy-Stockfish that can not be properly played/analyzed in any existing GUI, some not even in XBoard/Winboard and even if so the user experience is not that nice. However, due to the lack of time and also lack of experience with web/js development it never got beyond an idea, so I am excited to see that you are working into a similar direction and that you apparently already made a lot of progress.

As mentioned I do not have much experience with js development, but one of the main reasons why I did not try to compile the engine to js yet is that the engine needs much more adjustments regarding the threading logic than when compiling for webassembly. However, when only using it as a library for the chess logic instead of as an engine, then maybe it is much easier to just ignore/skip most of the threading code that is problematic for the conversion to js. Any contributions are very welcome, and I of course would try to provide help wherever I can.