Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Wait, I see it.

Author: Bas Hamstra

Date: 13:20:04 01/15/03

Go up one level in this thread


On January 15, 2003 at 16:05:32, Bas Hamstra wrote:

>On January 15, 2003 at 13:58:25, Russell Reagan wrote:
>
>>On January 15, 2003 at 07:49:44, Bas Hamstra wrote:
>>
>>>In think I understand now. You do it for the 2 rooks simulteneously. "Floodfill"
>>>(not the correct term, I know) does not necessarily have to start at bit 0, it
>>>can be anywhere. Wow. This really is an enhancement of the X ^ (X-2) trick. This
>>>opens interesting possibilities, like generating "UP" attacks for all rooks and
>>>queens at once, and masking only later (when it's needed) with a RookMask[Sq].
>>>
>>>RookAttacks for one rook at a given square = RookMask[Sq] & UP & LEFT;
>>>
>>>(plus the same for the reversed bitboard)
>>>
>>>Bas.
>>
>>Hi Bas,
>>
>>How would you use x^(x-2) trick to generate "up" attacks and attacks in other
>>directions?

First, forget about my previous post. Sorry if I am a bit slow. I can see how to
do it for one piece though. Suppose you have a queen at c1 and want to generate
UP attacks.

- Shifted = Occupied << C3          // shift Occupied so that Queen is at A1
- Shifted &= FILEMASK[0]            // isolate file
- Shifted = Shifted ^ (Shifted-2)   // floodfill, positive direction
- UP = Shifted >> C3                // Shift back

By applying verious masks like RANKMASK, DIAG1MASK, DIAG2MASK, you can do all
positive directions UP, RIGHT, LEFTUP, LEFTRIGHT. For the others you need the
reversed bitboard. This I am sure of it works.

An alternative avoids shifting and requires extra masking (unsless you use MMX)

- Shifted = Occupied & FILEMASK[2]
- Shifted = Shifted ^ (Shifted-QUEEN-QUEEN)
- UP = Shifted & FILEMASK[2]


Bas.













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.