Author: Robert Hyatt
Date: 09:47:55 12/03/99
Go up one level in this thread
On December 03, 1999 at 12:22:05, blass uri wrote:
>1)I am interested to know if bitboards help to do programs faster relative to
>arrays of attack.
>
>I started to try to write a chess program and
>I think to use arrays like rookattack[i]-the number of the attacking rooks of
>square i and I am interested to know if there is a way to be faster by
>bitboards.
>
>2)I found this piece of code in crafty at evaluate.c
>
>if (WhiteBishops) {
> if (WhiteBishops&mask_A7H7) {
> if (WhiteBishops&SetMask(A7) && SetMask(B6)&BlackPawns)
> score-=BISHOP_TRAPPED;
> else if (WhiteBishops&SetMask(H7) && SetMask(G6)&BlackPawns)
> score-=BISHOP_TRAPPED;
> }
> }
>
>a)is it possible to save time by avoiding the first line
>if (WhiteBishops)?
no. it first loads WhiteBishops in 2 32-bit registers and tests this. If the
result is zero, which happens a lot, nothing else is done. It will then use
these two values already loaded to make the next test which takes more time
(fetch another 64 bit mask and then AND the two together...
The savings isn't great, but it is measurable...
>
>b)I guess that whitebishops is a 64 digits number and that this number gets 1
>for every square with a white bishop.
yes...
>I guess that mask_a7h7 gets 1 only for WhiteBishops at a7 or h7 and that the
>other 62 digits of it are 0
>
>Am I right?
yes...
>
>c)what do the 64 bit numbers SetMask(A7),Setmask(B6) mean?
this macro turns into an array reference for set_mask[sq]. this array is
initialized so that (say) set_mask[28] has a 1 bit on square 28 (e4). If
you look at the enumerated data types you will find that E4 == 28, etc...
If I want to see if there is something on (say) E6, I just AND that something
with SetMask(E6) and if the result is non-zero, I know that square in the bitmap
is non-zero...
>
>d)Do bitboards help to evaluate the trapped bishop faster relative to evaluating
>the same information without bitboards?
hard to say. The good part is that I can test a7/h7 with one test. But
it probably doesn't save anything as it is really two AND/branch pairs.
Other questions are more efficient to ask, when you want to know something
about several squares at once... ie "is this pawn isolated?" (no pawns on
either adjacent file which tests 12 squares at one time) or "is this pawn
passed (no pawns on this or adjacent files in front of the candidate...)
Bob
>
>Uri
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.