Author: Volker Böhm
Date: 02:47:23 06/04/04
Go up one level in this thread
On June 03, 2004 at 22:38:58, Gerd Isenberg wrote:
>On June 03, 2004 at 17:33:52, Volker Böhm wrote:
>
>>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.
>
>One advantage here, if the first condition is already false, the second don't
>need to be executed at all. If branch prediction is easy, that's fine.
>
>
>>>
>>>
>>>>
>>>>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.
>
>Forgot those micro optimizations ;-)
Yes I do. Our code will run under c++ and java. Thus in general I am only
allowed to use code a java interpreter will understand. Java does not accept
arithmethics on booleans. Sometimes I use a ConvBool function that usually is
compiled to nothing in c++ to fix this problem. Here all this stuff is too
complicated and will not result in speed gain. The ConvBool: (int
ConvBool(boolean aBool) {return aBool ? 1:0;}) Funny a int ConvBool(boolean
aBool) {if (aBool) return 1; else return 0; } doens´t work as well. (boolean is
a macro that expands to bool for java compatibility)
>
>
>>>
>>>
>>><snip>
>>>
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.