chess-elm icon indicating copy to clipboard operation
chess-elm copied to clipboard

When a king is in check do not allow illegal moves

Open RobStallion opened this issue 6 years ago • 1 comments

Need to create logic that checks if a king is in check.

If so it restricts the possible moves that other pieces can make so that it only allows moves that either:

  • block the check
  • capture the piece giving check
  • move the king out of check

RobStallion avatar Mar 20 '19 19:03 RobStallion

I need to think about this logic in a little more detail but it maybe be good to have check and doubleCheck saved in the state somewhere.

If a king is in double check the only way out is to move the king. If there is an option somewhere that says doubleCheck: True (for example), this may be more efficient than needlessly looking for another pieces possible moves when it will not have any.

RobStallion avatar Mar 20 '19 19:03 RobStallion