Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: sliding attacks in three inlines

Author: Gerd Isenberg

Date: 14:54:04 04/14/04

Go up one level in this thread


On April 14, 2004 at 17:00:36, Tord Romstad wrote:

>On April 14, 2004 at 16:52:36, Gerd Isenberg wrote:
>
>>i really prefere even more inlines for abstraction...
>>Isn't there a cheaper tricks to do isCommonA1H8Diagonal, etc. with 0x88?
>
>I am not sufficiently fluent in bitboards to understand quite what your
>code is doing, but assuming that the function determines whether it is
>possible to get from square x to square y on an empty board by sliding in a
>direction parallel to the a1-h8 diagonal, this is indeed a very cheap operation
>with 0x88 (or other 16-file board representations).  You just subtract x from y
>and look up the answer in a 256-byte lookup table.
>
>Tord

Ah, yes i remember. Seems a bit cheaper, a tiny lookup.

Yes the boolean functions check whether a rook or bishop on square x attacks
square y ( or vice versa). Both square coordinates are translated to bitset
metric, 2**sq, by lookup or 1<<sq. The difference of this power of two bitboard
metric values is a binary "one"-sequence from "less" (including) until "greater"
(excluding). To exclude less, we take "less"*2. The intersection of this
"inbetween"-values with the appropriate "path" leaves a set of all squares
between x and y on that ray. Path is the set of all squares on a ray(x,y).

eg., testing those two squares {e2,e6} on a common file:

a0 = 2**0 = lsb = bottom-left (not right! as regular with binary numbers)

Y|X
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0

Y
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

X<<1 (is right here due to the mapping!)
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0

Y-(X<<1)
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0

path set (e2,e6)
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0

final "inbetween" set
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0

If the intersection of this inbetween-set with the "all"-occupied-set is empty,
no man sits on those squares, x is controlled by y with that sliding piece.

The functions seems interesting to check the validity of sliding moves after a
hash hit. A kogge stone fill is also nice for that purpose, shifting x in y
direction. Kogge stone takes some instructions more, but no path lookup.
And Kogge Stone gets sets of squares for x in y direction, rather than a boolean
property.

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.