ml-research / liground

A free, open-source and modern Chess Variant Analysis GUI for the 21st century
https://ml-research.github.io/liground.github.io/
GNU Affero General Public License v3.0
106 stars 35 forks source link

How to Communicate Chess Board State (FEN) to GUI in Real-Time #280

Open 38alysia opened 1 month ago

38alysia commented 1 month ago

Hello,

I am working on a project where I need to display chess positions on a GUI chessboard in real-time. Specifically, I am looking for a way to sync the FEN (Forsyth-Edwards Notation) string, which represents the chess board state, with the GUI, so that any changes in the game state are immediately reflected on the GUI board.

Could you provide guidance or examples on how to establish communication between the program logic (which generates the FEN string) and the GUI to achieve this? Any advice or pointers to relevant documentation or tools that could facilitate this synchronization would be greatly appreciated.

Thank you!

QueensGambit commented 1 month ago

Hey @38alysia ,

you can check out the code here: https://github.com/ml-research/liground/blob/e20dc0d77a654e6a02e2b10703028c66d593670e/src/renderer/components/GameBoards.vue#L58-L66 and here: https://github.com/ml-research/liground/blob/e20dc0d77a654e6a02e2b10703028c66d593670e/src/renderer/components/GameBoards.vue#L379-L384 https://github.com/ml-research/liground/blob/e20dc0d77a654e6a02e2b10703028c66d593670e/src/renderer/components/ChessGround.vue#L253-L255

We use https://github.com/gbtami/chessgroundx for the board rendering, which is an extension of chessground used in lichess.org.