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

King blocked at last rank #2

Closed
ratosh opened this issue Jan 30, 2018 · 3 comments
Closed

King blocked at last rank #2

ratosh opened this issue Jan 30, 2018 · 3 comments

Comments

@ratosh
Copy link

ratosh commented Jan 30, 2018

It seems that it does not consider enemy attacks. Tested on this board:
6k1/4rp1p/6pP/3p2P1/5P2/3bP1K1/1q6/2R5 w - -

@sandermvdb
Copy link
Owner

Thanks for raising this issue 👍
I've updated the code which will be part of the 1.8 release:

private static boolean kingBlockedAtLastRank(final int kingIndex, final int kingColor, final ChessBoard cb) {
    return cb.colorToMove != kingColor && (Bitboard.RANKS[7 * kingColor] & cb.pieces[kingColor][KING]) != 0 
      && (StaticMoves.KING_MOVES[kingIndex] & cb.emptySpaces & ~cb.attacksAll[1 - kingColor] & Bitboard.RANKS[7 * kingColor]) 
      == (StaticMoves.KING_MOVES[kingIndex] & cb.emptySpaces & ~cb.attacksAll[1 - kingColor]);
}

@ratosh
Copy link
Author

ratosh commented Jan 31, 2018

Still a small problem when moving a rook or a queen from rank6 to rank7. attacksAll will have attacks to rank6 and this function when detecting safe rook checks will return the king is blocked.
3k4/7R/8/8/8/8/8/7K w - -

@sandermvdb
Copy link
Owner

Performance vs accuracy...

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

2 participants