Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: sliding attacks in three #define

Author: Gerd Isenberg

Date: 00:24:05 04/10/04

Go up one level in this thread


On April 09, 2004 at 23:46:38, Christophe Theron wrote:

>On April 09, 2004 at 16:27:51, Uri Blass wrote:
<snip>
>So basically bitboards or not bitboards is not the important question. So I
>prefer to have code simpler to read and not to mess with ((b&(b-1))|~b).
>

One reason i like bitboards so much, are the semantic of operators ;-)

Bitwise operations (&|^~) peform basic setwise operations.

Shifting left/right 1,7,8,9 perform fill actions in one direction - or in
general shifting a bitboard is adding a scalar to a vector.

And unary minus or binary minus (one) is nice to isolate/reset the least
significant one bit.
isolate lsb one:  b & -b
               or b & (~b+1)
reset lsb one:    b & (b-1)
               or b ^ (b&-b)

Bytewise (rankwise) minus is nice to get rook attacks, since the next occupied
piece acts like a borrow bit...

So (b&(b-1)) resets the lsb, ~b is the complement set.
The union set of both leave all elements set, except the reset lsb one.
So ((b&(b-1))|~b) is equivalent to the cheaper ~(b&-b).

Gerd

>
>
>    Christophe



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.