Author: Bruce Moreland
Date: 10:39:51 12/27/02
Go up one level in this thread
On December 27, 2002 at 03:23:10, Russell Reagan wrote: >On December 27, 2002 at 02:57:11, Bruce Moreland wrote: > >>>if number of pieces giving check is 1 >> >>Calculating this number is difficult. > >Using bitboards it doesn't seem too difficult. Maybe it's not efficient (?), but >it's not difficult. Something like... > >// Maybe not totally correct, but you get the idea (I hope) >bitboard checkers = 0; >checkers |= knightAttacks(kingSquare) & enemyKnights; >checkers |= rookAttacks(kingSquare) & (enemyRooks | enemyQueens); >checkers |= queenAttacks(kingSquare) & (enemyBishops | enemyQueens); >checkers |= friendlyPawnAttacks(kingSquare) & enemyPawns; >int numChecks = count(checkers); > >>> generate moves that capture the piece giving check >>> generate moves that block the checking piece >>>generate capture moves for king >>>generate non-capture moves for king >> >>Or more generally, generate all moves for the king. > >Well, the seperation of king move generation was to prevent someone saying, >"generating all king moves would include castling, and you can't castle out of >check." Plus I have seperate move generators like that in my program. > >Russell If you know that black wasn't in check *before* white's last move, meaning, if you know that the position was legal as of that point, you can do something else. If there is an en-passant capture, to hell with it, first of all. The first thing to do is check to see if the piece that moved gave check. If it did, you are done. If it did not, you check to see if the piece started out on queen-ray emanating from the target king. If not, you are done. Otherwise, you can run that ray looking for an appropriate piece. bruce
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.