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

Can not cancel move disambiguation #30

Closed ianfab closed 12 months ago

yjf2002ghty commented 12 months ago

The major problem is that currently pawn promotion and seirawan gating use the same syntax in ffish.js. They all use [[+ | -] | piece_id ]. Therefore "a1a2q" can mean either a pawn promotes to q piece or a piece moves from a1 to a2 and gates a q piece at a1. My code uses

board.legalMoves().trim().split(' ');

to get all possible moves, which is provided by ffish.js. To disambiguate moves we need to update ffish.js and use different UCI notation syntax for different actions (SAN notations do not have this problem). For example, using [/] to indicate a seirawan gating move can disambiguate the moves (e.g. "a1a2/q" is unique for seirwan gating after using the new UCI notation syntax).

PyChess and Lichess have their own code on the promotion/gating logic. They are hardcoded and needs to be updated for every variant. In my opinion, fairyground should use all logic provided from ffish.js so that users do not need to change the code when loading a new custom variant, instead of hardcoded logic.

Chessground(x) has no idea on how to move the pieces. You can only change the board by using

chessground.set({
    fen: board.fen()
});

Chessground(x) automatically compares current FEN and the newly set FEN to figure out what pieces have been moved, added and removed, and renders the animation. board.fen() is also provided by ffish.js, so the game logic is totally controlled by ffish.js.

ianfab commented 12 months ago

Thanks, but I think there might be some misunderstanding of what I meant. I just would like clicking "cancel" on the disambiguation dialogue to abort executing the move (or using some default) to not get stuck in a loop of needing to provide valid input.