King Capture Bug with Pinned Piece & Check

Sort:
Avatar of Fleex255

The original thread by LongTermFuture was deleted. I'm re-describing this so I have something to link to.

Normally in spell chess, capturing the opponent king is allowed even if it would leave you in check. However, there is a bug that prevents the king capture in the specific situation where:

  • the piece you would capture the king with is pinned to your own king, and
  • you are already in check from something else.

Consider this (silly) simple position with White to move:

White should be able to win by taking the black king with the rook. This is prevented by the bug: the black rook pins the white rook and the black bishop checks the white king. If either the black rook or bishop was not there, White would be able to take the king despite being in check in the final position. Alternatively, if there was a white knight on d4, it could take the black king because it was not pinned.

The bug usually comes up when wanting to take the king with a jump, but the conditions for the bug are unrelated to jumps.

The technical reason for this behavior is in how the variants client precomputes pinned piece restrictions. When the position is changed by a move or spell, the code looks for pinned pieces and notes the direction in which they are pinned. It also sets an allowBreakPin property to record where captures (of a king) would have to occur to allow moving off the pin line. It should be possible to break a pin if you're capturing the king of the player putting you in check and you are not in check from anyone else (in 4-player variants). There is another variable for which players are putting you in check from which pieces. This is a JavaScript object where the property names (keys) are player IDs. Unfortunately, JavaScript property names are always technically strings even though player IDs are usually stored as numbers. The allowBreakPin logic (to make sure you're capturing the right player's king) uses the === operator to compare player IDs to property names from the checking players variable. This comparison always fails: the text "2" is not the same as the number 2. allowBreakPin therefore never gets filled in if you are in check.

Avatar of howManyCharactersAmIAllow

I really thought it only restricted jumps. Thanks for putting this up!

Avatar of Delhy

Would there be a way to contact chess.com and tell them about this bug or is chess.com just not caring anymore about variants ?

Avatar of 4lex3i_909

Tnks

Avatar of Slugworthy17
Delhy wrote:

Would there be a way to contact chess.com and tell them about this bug or is chess.com just not caring anymore about variants ?

Well they care enough to have monthly championships for variants so…

Avatar of Delhy
Slugworthy17 a écrit :
Delhy wrote:

Would there be a way to contact chess.com and tell them about this bug or is chess.com just not caring anymore about variants ?

Well they care enough to have monthly championships for variants so…

One by year by variant and not even for all of them...