Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: sliding attacks in three inlines

Author: rasjid chan

Date: 01:22:21 04/15/04

Go up one level in this thread


On April 15, 2004 at 02:09:07, Gerd Isenberg wrote:

>On April 14, 2004 at 19:34:57, rasjid chan wrote:
>
>>On April 14, 2004 at 15:52:39, Gerd Isenberg wrote:
>>
>>>Hi Rasjid,
>>>
>>>i found a slight improvement in one of your three interesting sliding attack
>>>macros. It replaces the "inbetween"-expression
>>>
>>> isqBit(y)-1 & ~( isqBit(x)-1 | isqBit(x) )
>>>by
>>> isqBit(y) - isqBit(x+1)
>>>or
>>> isqBit(y) -(isqBit(x)<<1)
>>>
>>>If one subtracts power of two values, greater minus less:
>>>  0100 0000
>>> -0000 0100  the result is
>>> =0011 1100  a "inner" sequence of ones, except "less" is included.
>>>So we start with next greater bit of "less".
>>>
>>>Couldn't resist to use inlines instead of macros ;-)
>>>(not tested!)
>>>
>>
>>Gerd,
>>
>>How in the world can I see how you see how 0's and 1's interact
>>and extract patterns. I'll first cut and paste and learn later.
>>
>>Thanks
>>Rasjid
>>
>
>There is even a bit more to squeeze out of the functions. Eg. for 0x88
>coordinates the difference between 0x88 coordinates maps to an unique direction
>index.
>
>But with 0x88, x+1 may leave the board, so isqBit(x+1) should consider that
>fact, otherwise use (isqBit(x)<<1) or *2. On x86-32 i guess simple 32KByte
>lookup to get the inbetween set is still faster.
>
>Cheers,
>Gerd

I am on something else (debugging a sticky bug )and will check all
these later.

Best Regards
Rasjid


>
>
>bool brq_path_clear(x88sqr gt, x88sqr ls, U64 path) {
>   return ((isqBit(gt) - 2*isqBit(ls)) & path & all) == 0;
>}
>
>bool bstyle_attack(x88sqr x, x88sqr y) {
>   switch (direction0x88Diff[0x88+x-y]) {
>   case leftDown:
>      return brq_path_clear(x, y, diagonal[1][iGetRank(x) + iGetFile(x)]);
>   case rightUp:
>      return brq_path_clear(y, x, diagonal[1][iGetRank(x) + iGetFile(x)]);
>   case leftUp:
>      return brq_path_clear(x, y, diagonal[0][7 + iGetRank(x) - iGetFile(x)]);
>   case rightDown:
>      return brq_path_clear(y, x, diagonal[0][7 + iGetRank(x) - iGetFile(x)]);
>   }
>   return false;
>}



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.