Author: Gerd Isenberg
Date: 19:38:58 06/03/04
Go up one level in this thread
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 ;-) >> >> >><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.