Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards !! :)

Author: Vincent Diepeveen

Date: 05:42:38 07/01/04

Go up one level in this thread


On July 01, 2004 at 04:39:24, Gerd Isenberg wrote:

>On July 01, 2004 at 02:50:35, Tony Werten wrote:
>
>>Hi all,
>>
>>although I like the principle of bitboards, it really bothers me that I can't
>>seem to find a decent/fast way to evaluate weighted safe squares.
>>
>>Suppose I want to (simple) evaluate a rook, I generate a bitboard with all
>>reachable squares and mask off the squares attacked by lower pieces (that's no
>>problem).
>>
>>(This doesn't exacly generate safe squares, only the ones that aren't attacked
>>at all by opponents pieces are, for the remaining squares one would need a SEE,
>>but that's not the point )
>>
>>Now I can use this bitboard ( say rook on e4 ), mask the rank state, and look in
>>a precomputed table how this rankstate scores on an e rank. No problem.
>>
>>But how to do the files ? If I use the rotated board, I need to have the
>>opponents attackboard in this rotated board as well, wich would be very costly
>>to compute (ie also for the bishops,queens ) and very complicated.
>>
>>Any ideas ? Am I missing something ?
>>
>>BTW, doing a popcount isn't a solution, since it violates the elegance of
>>bitboards ( and is slow ?)
>
>Ok, bitscan traversing and psq-lookup is a even more violation IMHO ;-)
>
>For safe rook attacks one may look for boolean pattern/properties (depending on
>the game state). Intersect the attack set with several small areas of the board,
>like center, remaining extended center, squares near opposite or own king,
>passers, squares behind passers or other movable pawns e.g. to support a
>minority attack, squares on open/halfopen files, squares on some rook
>trajetories to opposite king and what ever else.
>
>With those sets, look whether they are empty and if not, probably look whether
>the population count is greater one.
>
>That may be implemented loopless and with some preconditions:
>
>if ( safeRookAttacks )
>{
>   set = safeRookAttacks & someAreaOfInterest;
>   bunus += f1*(set!=0) + f2*((set&(set-1))!=0);

2 times a 64 bits multiply AUCH. That's slow.

>   ...
>}
>

I assume Tony isn't doing such simple things as you propose here.

Basically Tony might want to use some chessknowledge evaluating each square.

And the reality is that scanning in bitboards is just too slow.

>Of course such statements "cry" for MMX,SSE2,Itanium or AltiVec SIMD
>instructions like pcmpeq to build -1|0 masks to "and" with. Itanium has popcnt
>instruction, and there are rumors that AMD64 has undocumented popcnt too,
>somewhere in the bt opcode range.

So in a 32/64 bits programs you can execute with 3 instructions a cycle without
any problems using 16 registers and skip complex patterns with a single 'if',
and with your 'advanced SSE code' for the opteron you can do 1 multiply+add per
cycle (note a multiply eats 2 cycles) in the meantime you must convert back and
forth from SSE to normal registers.

In short you cripple your program to something doing 1 instruction a cycle at
maximum and you extensivly use 64 bits multiplications to achieve your goal and
all kind of fancy tricks.

But even the simplest pattern in C like asked by Tony you write unreadable code
like :

   set = safeRookAttacks & someAreaOfInterest;
   bonus += f1*(set!=0) + f2*((set&(set-1))!=0);

How do you plan to debug thousands of patterns?

Another question, when do you get parallel with Isichess?

>SIMD within a register (SWAR) popcount looks relative expensive, but up to four
>or even more popcounts may be processed simultaniously, only with a little more
>time than one, by keeping all units busy. One may combine attack sets, e.g. from
>knights(2)/bishops(1) to "odd" and "atLeasstTwo" bitboards with five bitwise
>operations to safe one additional popcount per disjoint set too.
>
>Gerd
>
>>
>>Tony



This page took 0.01 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.