Author: Ralf Elvsén
Date: 17:46:04 01/28/02
Go up one level in this thread
On January 28, 2002 at 13:26:02, Sune Fischer wrote: >On January 28, 2002 at 13:04:05, Sune Fischer wrote: > >This is what I get for half the rook, similar stuff is done for the backwards >attacks using the reversed occupied bitboard. > >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; >} > > >..untested, but something along those lines. >Not entirely sure how to do it for the bishop, I guess we just shift to the >lower right corner when attacking north-west and lower left when attacking >north-east. > >But what happens if x=0? >Will y then be 0 or something strange, the bitboard is unsigned so it should >remain 0 right? > >-S. I think one should change y = x&RANK1 to y = x|0x80 That way the most significant bit in the rank will be set and when you do the x^(x-2)-thing you will get a correct answer. I don't understand how you can use the same "occupied" to get the file attacks but it's late here... :) x will never be zero since there is slider at "square". Ralf
This page took 0.01 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.