Author: Dan Newman
Date: 01:54:15 07/31/00
Go up one level in this thread
On July 30, 2000 at 10:24:51, Larry Griffiths wrote:
>Hellow again :)
>
>Im back to the efficiency thing again in my bruteforce code...
>I know I could see if the king is in check after looking at the squares are
>empty and that there is a rook on the proper square that has not moved.
>
>Must I do the extra 4 tests to see if the king and rook destination squares are
>not attacked by the opponents pieces or are there any tricky ways to bypass this
>:)
>
>//---------------------------------
>defbbGenNonSlidingMoves(MySquare,bbMaskKingAttacks);
>if(tcSquare[MySquare]->MoveCount==0)
> {
> defbbPiecesAttackingABlackKing(MySquare);
> if(!bbAttackedByPieces[0])
> {
> // See if King can Castle Kingside.
> if(tcSquare[MySquare+1]->Type==ptEMPTY)
> {
> if(tcSquare[MySquare+2]->Type==ptEMPTY)
> {
> if(tcSquare[MySquare+3]->MoveCount==0)
> {
> if(tcSquare[MySquare+3]->TypeColor==ptcBROOK)
> {
> defbbPiecesAttackingABlackKing(MySquare+1);
> if(!bbAttackedByPieces[0])
> {
> defbbPiecesAttackingABlackKing(MySquare+2);
> if(!bbAttackedByPieces[0])
> {
> MoveTo=MySquare+2;
> TCAddMoveOnly;
> }
> }
> }
> }
> }
> }
> // See if King can Castle Queenside.
> if(tcSquare[MySquare-1]->Type==ptEMPTY)
> {
> if(tcSquare[MySquare-2]->Type==ptEMPTY)
> {
> if(tcSquare[MySquare-3]->Type==ptEMPTY)
> {
> if(tcSquare[MySquare-4]->MoveCount==0)
> {
> if(tcSquare[MySquare-4]->TypeColor==ptcBROOK)
> {
> defbbPiecesAttackingABlackKing(MySquare-1);
> if(!bbAttackedByPieces[0])
> {
> defbbPiecesAttackingABlackKing(MySquare-2);
> if(!bbAttackedByPieces[0])
> {
> MoveTo=MySquare-2;
> TCAddMoveOnly;
> }
> }
> }
> }
> }
> }
> }
> }
> }
Those tests must eventually be done--somehow--if the move is going
to be made. In the past I've just done those tests right in the move
generator (except for the king moving into check test--I generate
pseudo-legal moves). What I do now is carry pseudo-legality a bit
further, generating the castling moves as long as the side-to-move
still has the right to castle and isn't in check (two very easy tests
in my case). I don't bother testing for empty squares or attacks on
the squares over which the king moves in the move generator. I do
those tests later, just before trying the move. The idea is to delay
doing any work until the last moment in the hope that a cutoff will
make it unnecessary.
-Dan.
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.