Author: martin fierz
Date: 18:42:49 02/04/02
aloha!
my question is related to checkers, but it would be the same in computer chess
with bitboards:
i represent a board with 4 32-bit ints (checkers has 4 piece types, 32 squares).
in my evaluation i would like to add some patterns, which crop up every now and
then. let's say, i want to find all positions with the property that a specific
subset of every bitboard is present:
p is a position structure with the elements bm, bk, wm, wk for black men, kings
and their white counterparts.
my program looks like this:
// version I
if( ((p.bm&pattern.bm)==pattern.bm) &&
((p.bm&pattern.bk)==pattern.bk) &&
((p.bm&pattern.wm)==pattern.wm) &&
((p.bm&pattern.wk)==pattern.wk) )
eval += value;
is this any good? i thought of an alternative, let's say,
my total pattern consists of 7 stones. so i define the array
// version II
int seven[8] = {0,0,0,0,0,0,0,1};
and do
x = p.bm&pattern.bm | p.bk&pattern.bk | p.wm&pattern.wm | p.wk&pattern.wk;
eval += value*bitcount(x);
// version III
or, last alternative:
x = p.bm&pattern.bm | p.bk&pattern.bk | p.wm&pattern.wm | p.wk&pattern.wk;
if( x == pattern.bm|pattern.bk|pattern.wm|pattern.wk)
eval+=value;
any ideas on these? looking at them now, version 3 looks best to me. is there
any difference on different processors? e.g. version II needs no if, thus no
branches, and i think different processors have different penalties for branch
misprediction? or does anybody have a suggestion for a more efficient version to
solve this? real patterns usually include only 3 bitboards (black men, white
men, and unoccupied squares).
any thoughts are appreciated :-)
cheers
martin
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.