Author: Peter Fendrich
Date: 11:50:31 08/19/98
A while ago a Elisabeth van Aaaring raised the question about different methods
to count ones in a bitboard. She made som testings and among other things she
found a breakpoint between method A and B (see below) at about 6-7 bits. When
less ones, method A was the best otherwise method B was best.
I extended this test a bit by inserting the different methods in my program
Terra, not known to the world..., and meassuring the performance for 10
different positions.
Here are the results.
Method A (like Crafty):
.............................................
register unsigned __int64 a = TheBoard.all;
while( a ) {
c++;
a &= a - 1;
}
return c;
.............................................
Pos Time Iter Mve# Nodes N/S
d1 109 10 1 3387534 31078
d2 135 9 2 4527468 33536
d3 120 8 5 3001296 25010
d4 91 8 5 2733457 30037
d5 91 9 9 3804363 41806
N1 94 8 31 3887771 41359
N2 91 9 7 2786247 30618
N3 113 9 1 3388985 29991
N4 91 8 14 3323877 36526
N5 99 9 1 4546407 45923
---- -- -------- ------
Total: 1034 87 35387405
Mean: 103 9 34224
Method B ( A hybrid between an idea from Bruce M and Method A)
.............................................
register unsigned __int64 a = TheBoard.all;
if( !a )
return( 0 );
else if( !( a &= a - 1 ) )
return( 1 );
else if( !( a &= a - 1 ) )
return( 2 );
else if( !( a &= a - 1 ) )
return( 3 );
else if( !( a &= a - 1 ) )
return( 4 );
else if( !( a &= a - 1 ) )
return( 5 );
else
for( register UINT count = 6;; count++ ) {
if( !( a &= a - 1 ) )
return( count );
}
.................................................
File Time Iter Mve# Nodes N/S
d1 112 10 1 3395943 30320
d2 140 9 2 4464433 31888
d3 130 8 7 3106604 23896
d4 93 8 4 2690745 28932
d5 92 9 9 3618150 39327
N1 92 8 25 3659710 39779
N2 96 9 7 2819829 29373
N3 118 9 1 3382772 28667
N4 94 8 14 3313512 35250
N5 100 9 1 4456459 44564
---- -- -------- ------
Total: 1067 87 34908157
Mean: 107 9 32716
Will continue...
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.