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

Board editor: possibly disable 960 Castling in standard #12926

Open
moggymew opened this issue May 29, 2023 · 7 comments
Open

Board editor: possibly disable 960 Castling in standard #12926

moggymew opened this issue May 29, 2023 · 7 comments
Labels
good first issue Narrow in scope (but not necessarily easy)

Comments

@moggymew
Copy link

Exact URL of where the bug happened

https://lichess.org/analysis/r5k1/1pp1qb1p/1p1r1p2/2n1pPp1/4P3/P2P1NP1/1PR1Q1BP/1R4K1_b_q_-_0_1?color=black

Steps to reproduce the bug

  1. Set up the position with white to move.
  2. Turn on Analysis
  3. The illegal queen-side castling recommendation will display (see screenshot) after a short time.
  4. I am then able to castle (illegally) on the queen's side.

image

What did you expect to happen?

I did not expect to be able to castle !!

What happened instead?

See screenshot - a suggested move is to castle long:
image

Operating system

Windows 10 and Android

Browser and version (or alternate access method)

Vivaldi (Windows 10) and Chrome (Android)

Additional information

No response

@moggymew moggymew added the bug label May 29, 2023
@TBestLittleHelper
Copy link
Contributor

If you don't want castle, then don't give black castling right : the fen you are looking for is
r5k1/1pp1qb1p/1p1r1p2/2n1pPp1/4P3/P2P1NP1/1PR1Q1BP/1R4K1 b - - 0 1

When you do from position, castle are allowed in positions like this as is treated as a chess960 game.

@moggymew
Copy link
Author

Thanks for the quick reply. Here's the set up page. I am not sure how you tell Lichess not to treat it as a chess960 game (it appears to be set as Variant | Standard). Whey would you want to turn off castling in a standard game?
image

@kraktus kraktus removed the bug label May 29, 2023
@kraktus kraktus changed the title BUG - Illegal castling Board editor: disable 960 Castling in standard May 29, 2023
@kraktus kraktus changed the title Board editor: disable 960 Castling in standard Board editor: possibly disable 960 Castling in standard May 29, 2023
@benediktwerner
Copy link
Member

benediktwerner commented May 30, 2023

Whey would you want to turn off castling in a standard game?

It's not "turning off castling in a Standard game". It's whether castling is still allowed in the current position. Once somebody lost castling rights on a side, it's impossible to get them back. Even in a position where castling looks like it would usually be allowed, it may still not be allowed because the rook or king already moved. If you don't want castling rights to be possible in the given situation, you can simply disable them.

Though maybe adding 960 to the selection menu and disallowing 960 castling otherwise (i.e. always disabling casting rights
if they aren't standard) wouldn't be a bad idea.

@benediktwerner benediktwerner added the good first issue Narrow in scope (but not necessarily easy) label May 30, 2023
@raulriverarojas
Copy link

This issue actually happens from any game/analysis that comes "FromPosition" variant. The same castling is given as a legal move when playing a challenge game "from position" variant game. Therefore, I think the issue is coming from the scalachess repository but I could be wrong. I don't have a good enough understanding of how lila work on a whole to figure this stuff out just yet so if anyone is able to use this info to figure it out faster go for it
StandardGameMoveSet
FromPositionMoveSet
The two pics show the legal king moves when reached through a 'from position game' vs legal k moves from a standard game.

@raulriverarojas
Copy link

raulriverarojas commented Aug 4, 2023

I specifically think the issue is coming from (https://github.com/lichess-org/scalachess/blob/master/src/main/scala/Situation.scala) in scalachess where genCastling() [line 252] calculates different castling paths for standard vs chess960 but includes the 'fromposition' variant along with the 'chess960' variant when calculating 960 castling paths

// calulate different path for standard vs chess960
path =
if variant.chess960 || variant.fromPosition
then Bitboard.between(king, rook) | Bitboard.between(king, kingTo)
else Bitboard.between(king, rook)

I cannot confirm this since idk how to confirm my lila is using my local scalachess so if anyone knows how to configure lila to use a local version of scalachess or has that set up already and can check if thats the case that would be really helpful. Thanks

@avannaa
Copy link
Contributor

avannaa commented Aug 5, 2023

this is expected behavior, though i suppose that assuming any "from position" might be 960 (and thus apply 960 castling rules) is mostly more confusing than not. like, if your from-position represents a situation where you've already castled, you're supposed to uncheck the "castling possible" boxes when setting up the position.

that said, i agree that this is pretty confusing for most people, as most users don't even know that 960 exists, let alone want to apply 960 castling rules to their position. still, it should be possible for people to set up positions where they want to apply 960 castling rules.

@princess-emma
Copy link

What if you disable castling by default? That way the behavior is consistent both on standard chess and Fisher random.
Or disable it by default only if it's not a standard initial position for the king/rooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Narrow in scope (but not necessarily easy)
Projects
Status: No status
Development

No branches or pull requests

7 participants