lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
14.99k stars 2.23k forks source link

Board editor: possibly disable 960 Castling in standard #12926

Open moggymew opened 1 year ago

moggymew commented 1 year ago

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

TBestLittleHelper commented 1 year ago

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 commented 1 year ago

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

benediktwerner commented 1 year ago

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.

raulriverarojas commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.

Nala60 commented 5 months ago

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.