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

Implement a faster isInCheck #19

Open
neongreen opened this issue Jul 20, 2023 · 2 comments
Open

Implement a faster isInCheck #19

neongreen opened this issue Jul 20, 2023 · 2 comments

Comments

@neongreen
Copy link
Owner

https://www.chessprogramming.org/Check

Currently a lot of time is spent on isInCheck

@neongreen
Copy link
Owner Author

NB: for simplicity we can just do the slow check if the last move is complicated (en passant or castling)

@neongreen
Copy link
Owner Author

The point is:

The cheapest and most straightforward way to detect checks is to consider the previous move just made by the opponent. It might be a direct check or discovered check, so one has to test whether piece on target square attacks the king, or whether piece on origin square is attacked by an own sliding piece on an otherwise open ray in opponent king direction [2]. If the last move was an en passant capture, one has to consider a few more complicated cases of possible discovered checks, since the captured pawn is not on the target square, and two pawns disappear from the 4th (5th) rank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant