Author: Landon Rabern
Date: 17:03:40 07/02/01
Why does he shift the bitBoard down and then xor with x-2 and then shift it back
up. I would think it would be faster to make a couple lookup tables like this:
bitBoard left[64];
bitBoard right[64];
bitBoard j=1;
for(i=0;i<64;i++)
{
if(i%8==7)
left[i]=0;
else
left[i]=j<<(i+1);
if(i%8==0)
right[i]=0;
else
right[i]=j<<(64-i);
}
and then to get the bits of where the rook can move horizontally just do
for left:
allPieces^(allPieces - left[sq])
for right:
reversePieces^(reversePieces - right[sq])
See the trick with x^(x-2) extends to x^(x-4) , etc.
Then you can just use two seperate while loops to pull out the actual moves,
there will be an extra & operation incurred since you need to mask with what you
are attacking seperately.
So you use only a couple K of memory instead of the 128K used by the regular
bitBoard rookMoves[64][256]. Normally you need to do an & and a >> how much
slower would you think an ^ and a - would be? What if done using the MMX
registers?
Maybe it could be faster for horizontal, but how do you get the vertical
bitBoard back to being vertical quickly? And how do you get the 45 degree
rotated back to to where they need to be quickly? hmmm
Any thoughts?
Landon
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.