Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect castling/gating check in FEN validation #777

Open
Curious2021 opened this issue Apr 21, 2024 · 4 comments
Open

Incorrect castling/gating check in FEN validation #777

Curious2021 opened this issue Apr 21, 2024 · 4 comments
Labels
bug Something isn't working libraries Relevant for pyffish and ffishjs

Comments

@Curious2021
Copy link

Curious2021 commented Apr 21, 2024

I’ve noticed an error when setting up custom seriawan chess positions with castling rules disabled causing the gating rules in this variant to fail to initialize when generating otherwise plausible chess starting positions wither symmetrical or non symmetrical. May need to update the coding to recognize custom setups without castling rules to allow gating the pieces when placing them in such scenarios like this.

edit: here’s the original post explaining the exact scenario with the FEN code showing how it can be reproduced.

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/QBBNNRKR[HEhe] w BCDFGbcdfg - 0 1 is a custom Seriwan chess setup that should work correctly if castling rules are disabled. Apparently the gating rules in Seirawan chess doesn’t recognize this possiblility. This may need an update to the coding to account for this scenario.

@ianfab
Copy link
Member

ianfab commented Apr 21, 2024

Please specify more detailed steps to reproduce the issue such as variant config if any, CLI/GUI commands/input, expected vs actual output.

@gbtami
Copy link
Member

gbtami commented Apr 21, 2024

It happened on pychess when he created a custom setup S-chess game with above FEN.
On server side I can see the error message from https://github.com/fairy-stockfish/Fairy-Stockfish/blob/master/src/apiutil.h#L743
I reproduced it in local install:

+0200 2024-04-22 01:05:14.198 [DEBUG] websocket_utils:70 Websocket (139974902806128) message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"create_seek","user":"Anon–IBsimzx6","target":"","variant":"seirawan","fen":"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/QBBNNRKR[HEhe] w BCDFGbcdfg - 0 1","minutes":90,"increment":90,"byoyomiPeriod":0,"day":0,"rated":false,"chess960":false,"color":"w"}', extra='')
+0200 2024-04-22 01:05:14.198 [DEBUG] wsl:124 create_seek {'type': 'create_seek', 'user': 'Anon–IBsimzx6', 'target': '', 'variant': 'seirawan', 'fen': 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/QBBNNRKR[HEhe] w BCDFGbcdfg - 0 1', 'minutes': 90, 'increment': 90, 'byoyomiPeriod': 0, 'day': 0, 'rated': False, 'chess960': False, 'color': 'w'}
create_seek None Anon–IBsimzx6: **seirawan** 90+90
+0200 2024-04-22 01:05:14.230 [INFO] aiohttp.access:211 127.0.0.1 [22/Apr/2024:00:05:14 +0100] "GET /static/images/board/8x8brown.svg HTTP/1.1" 200 0 "http://127.0.0.1:8080/static/board.css" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
+0200 2024-04-22 01:05:14.231 [DEBUG] aiohttp.server:418 Ignored premature client disconnection 2
+0200 2024-04-22 01:05:14.231 [DEBUG] aiohttp.server:418 Ignored premature client disconnection.
+0200 2024-04-22 01:05:25.120 [INFO] index:88 +++ Existing user berado88 connected.
+0200 2024-04-22 01:05:25.154 [INFO] aiohttp.access:211 127.0.0.1 [22/Apr/2024:00:05:25 +0100] "GET / HTTP/1.1" 200 8619 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
+0200 2024-04-22 01:05:25.270 [INFO] aiohttp.access:211 127.0.0.1 [22/Apr/2024:00:05:25 +0100] "GET /static/pychess-variants.js HTTP/1.1" 304 265 "http://127.0.0.1:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
+0200 2024-04-22 01:05:25.693 [INFO] websocket_utils:49 --- NEW /wsl WEBSOCKET by berado88 from 127.0.0.1
+0200 2024-04-22 01:05:25.849 [INFO] aiohttp.access:211 127.0.0.1 [22/Apr/2024:00:05:25 +0100] "GET /notifications?p=0 HTTP/1.1" 200 244 "http://127.0.0.1:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
+0200 2024-04-22 01:05:25.861 [INFO] aiohttp.access:211 127.0.0.1 [22/Apr/2024:00:05:25 +0100] "GET /static/images/pexels-renato-conti-2677849.jpg HTTP/1.1" 304 264 "http://127.0.0.1:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
+0200 2024-04-22 01:05:27.911 [DEBUG] websocket_utils:70 Websocket (139974902962928) message: WSMessage(type=<WSMsgType.TEXT: 1>, data='{"type":"accept_seek","seekID":1,"player":"berado88"}', extra='')
+0200 2024-04-22 01:05:27.911 [INFO] utils:349 +++ Seek 1 joined by berado88 FEN:rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/QBBNNRKR[HEhe] w BCDFGbcdfg - 0 1 960:False
The WHITE KING has moved. Castling is no longer valid for WHITE.
+0200 2024-04-22 01:05:27.911 [DEBUG] utils:392 Failed to create game. Invalid FEN rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/QBBNNRKR[HEhe] w BCDFGbcdfg - 0 1
accept_seek None Anon–IBsimzx6: **seirawan** 90+90 accepted by berado88

@ianfab
Copy link
Member

ianfab commented Apr 21, 2024

Thanks for the context. Technically looks correct to me though, since in a non-960 game there can't be an unmoved king on a different file than the e-file. If this also happens in 960, then I guess it would be a bug.

@gbtami
Copy link
Member

gbtami commented Apr 21, 2024

I think I checked in 960 in the new game dialog. Or not.I have to double check this ....
Yes. It produces the same with 960 checked.

@ianfab ianfab changed the title custom seirawan chess setups causing error when castling rules are disabled. Incorrect castling/gating check in FEN validation Apr 22, 2024
@ianfab ianfab added bug Something isn't working libraries Relevant for pyffish and ffishjs labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libraries Relevant for pyffish and ffishjs
Projects
None yet
Development

No branches or pull requests

3 participants