Author: Gerd Isenberg
Date: 12:23:09 01/28/02
Go up one level in this thread
BITBOARD RookAttacksForward(BOARD &occupied, char square) { BITBOARD a,x,y; x=occupied>>square; // shift board so square ends in lower left corner y=x&RANK1; // mask out ewerything but the first rank a=y^(y-2); // get the attacked bits on this rank y=x&FILE1; // now mask so we get a clean first file y=y^(y-2); // get the attacked squares a=a|(y&FILE1); // add the attacked bits after masking with the file again a=a<<square; // shift the attacked bits back (for ease of readability) return a; } Thanks, very interesting. I can imagine, that this is faster than a table lookup with the risc of cache miss, specially when you do it with assembler with mmx registers (or waiting for hammer and 64bit compiler). Impressed about the y^(y-2) operation, to get the attacked squares. I have to study it a while. Gerd
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.