Author: Volker Böhm
Date: 14:33:52 06/03/04
Go up one level in this thread
On June 03, 2004 at 15:52:54, Gerd Isenberg wrote:
>>>Perhaps you have an Idea about another problem:
>>>
>>>I whant to know if a special piece is attacking a field and no opponent piece is
>>>defending this field by one check. For queen it is simple as I am only using one
>>>bits for queens:
>>>
>>>if ((attackfield[pos] & (whitequeenbit + blackbits)) == whitequeenbit)
>>> // ... check if queen can mate on pos
>>>
>>>for rooks I have 2 bits. Thus this check does not work:
>>>if ((attackfield[pos] & (whiterookbits + blackbits)) == ???
>>
>>
>>Hmm, i guess "+" is meant like bitwise or?
>>So you have a set of white rooks combined with all other black pieces attacking
>>a square. And you want to know whether this set is an not empty subset of the
>>white rooks.
>>
>>someSet = attackfield[pos] & (whiterookbits + blackbits);
>>
>>1. condition someSet is not empty.
>>2. condition the Intersection of someSet and blackbits is empty
>>
>>if ( (someSet != 0) && ((someSet & blackbits) == 0) )
>
>quatsch! Why not simply
>
>if ( (attackfield[pos] & whiterookbits) != 0
> && (attackfield[pos] & blackbits) == 0 )
Yes thats what I am using. The compiler is making two jumps. I wondered if you
can get it by one jump.
>
>
>>
>>or probably to relax the branch target buffer a bit, assuming compiler is able
>>to use setCC instructions:
>>
>>if ( (someSet != 0) + ((someSet & blackbits) == 0) == true+true )
>
>if ( ((attackfield[pos] & whiterookbits) != 0)
> + ((attackfield[pos] & blackbits) == 0) == 2*true) // ;-)
this is a cool one. But it doesn´t seems to help much.
>
>
><snip>
>
>piece codes of course, may be a pointer is smarter, for ranks directly to the
>board, for other direction via copying six board members to one temporary array
>(or already to registers?)which makes this method even more slow.
>
>int pack6Squares2OccupiedState(const int *ray)
>{
> return
> (
> (
> (-ray[0] & 0x10)
> | (-ray[1] & 0x20)
> | (-ray[2] & 0x40)
> | (-ray[3] & 0x80)
> ) >> 4
> ) |
> (
> (-ray[4] & 0x10)
> | (-ray[5] & 0x20)
> );
>}
>
>
>And to call pack6Squares2OccupiedState(&board[b1]) for above case.
>
>>If the piece codes were already negative (-2...-14) one would even safe the six
>>negates ;-)
>>
>>12 instructions, three cycles?
>>
>>Ok, i guess still too expensive, if you like to call bitboard sliding
>>attack-getters on the fly.
>>
>>Cheers,
>>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.