Author: Steffan Westcott
Date: 10:24:37 10/15/02
Go up one level in this thread
Gerd,
You may remember in my previous posts I gave algorithms for finding attacks in
just one direction, and gave an example of rook attacks moving up the board. I
notice in your posts that you combine the attacks in all directions as they are
calculated. Your approach is good (although uses many working variables) however
it loses information by combining the intermediate results too early.
The lost information could have been of use, in things like move generation for
example. Consider the following code fragment :
---- CUT HERE ----
BitBoard FillUpOccluded(BitBoard g, BitBoard p)
{
g |= p & (g << 8);
p &= (p << 8);
g |= p & (g << 16);
p &= (p << 16);
return g |= p & (g << 32);
}
BitBoard RookAttacksUp(BitBoard rooks, BitBoard empty_squares)
{
return ShiftUp(FillUpOccluded(rooks, empty_squares));
}
BitBoard RookMovesUp(BitBoard friendly_rooks, BitBoard friendly_pieces,
BitBoard empty_squares)
{
return RookAttacksUp(friendly_rooks, empty_squares) & ~friendly_pieces;
}
---- CUT HERE ----
There is a 1-1 correspondence between set bits in the bitboard returned by
RookMovesUp() and all friendly (read: "white" or "black") rook moves (including
captures) going up the board. This is because at most 1 upward rook move is
possible for each square. So this bitboard can serve as part of a unsorted
movelist.
Cheers,
Steffan
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.