Author: Gerd Isenberg
Date: 12:50:58 11/24/05
Go up one level in this thread
>If you have a lot of code in your eval and elsewhere, where you simply do some
>conditional add or sub - and the condition is rather random and therefor likely
>to produce some mispredictions with this very short bodies - you are free to use
>the boolean*int multiplication on C level. For Less/greater compares you are
>able to convert the compare expression to (arithmeticExpression < 0) and to do a
>shift arithmetic right with arithmeticExpression and (sizeof(int)*8-1), to get
>a {-1,0}-range - a mask to apply the boolean multiplication by bitwise and.
>
>From the initial conditional statement ...
>
>if ( distance1 < distance2 )
> eval += bonus;
>
>... via < 0 ...
>
>if ( distance1 - distance2 < 0 )
> eval += bonus;
>
>... to the final sub(lea)-sar-and expression:
>
>eval += ( (distance1 - distance2) >> 31 ) & bonus;
>
Another obvious option, i forgot to mention, is some array[2] access with
boolean indices:
eval += someSpecialBonus[ distance1 < distance2 ];
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.