Author: Bas Hamstra
Date: 06:51:07 09/02/99
Go up one level in this thread
On September 01, 1999 at 14:20:59, Steve Maughan wrote:
>Bas
>
>Facinating stuff!! A couple of quick questions
>
>>>>
>>>>All these methods can see if a piece is attacked by another piece very fast,
>>>>without scanning the board.
>>
>>You can download the source of KnightCap. I have no idea how complicated that
>>source is. KnightCap keeps a "real" attackmap, which is harder (and I think
>>slower) than keeping a "pseudo" attackmap. Here is how I do it:
>>
>>Suppose your want to "know" at any moment by which pieces a square is
>>pseudo-attacked. Pseudo attacks are simply blocked AND non blocked attacks by
>>sliding pieces and attacks by non sliding pieces.
>
>How would you do Check detection with only pseudo attacks? I assume you would
>test for a pseudo attacker of a king. If one does not exist then InCheck=false.
> Otherwise, if one does exist then if it is NOT a sliding piece then
>InCheck=true. If it is a sliding piece then do the hard work of checking to see
>if there is a block.
>
>Is this sort of correct?
Yes, that's it.
>>If you want to do SEE you have all attackers neatly sorted already at any time
>>and can just pop em out with lastone(). You HAVE to have a fast lastone of
>>course, preferably one that relies on a single CPU instruction (intel has that).
>>
>>Critical: a fast lastone and a fast way to update (sliding) attacks.
>>
>
>I understand what SEE is but what do you mean by lastone()? Do you mean the
>last bit set?
Yes. The last 1. The gcc compiler has a c function for it: ffs(). If your
compiler has no such function, but you have a intel cpu, you can make that
function easily in assembler: there is an assembler instruction BSF that returns
the last bit set (another for the first bit).
>>I hope this all made sense. Disclaimer: I have not seen many other programs do
>>this. So draw your own conclusions.
>>
>
>Doesn't Commet do something similar?
I have really no idea, got the idea from what Don Daily once said to me. I don't
think I have found the ultra fastest way to update sliding attacks yet.
Currently I have the squares to update in code like this:
OrQueen(int Square, unsigned long Mask)
{ switch(Square)
case 0:
Attacks[1] |= Mask;
Attacks[2] |= Mask;
.
.
.
break;
case 1:
.
.
}
that way the minimum number of assembly instructions is used and you have no
loop overhead.
However maybe in some cases it is faster to delete attacks from the captured
piece and the PieceFromSquare (so the 2 pieces you want to delete from the
attacks in case of a capture) in one run by combining masks:
Attacks[0] &= ~Mask;
.
.
Attacks[63] &= ~Mask;
Especially so when the moving piece and the capture are both sliders.
>Interesting discussion!
>
>>
>>Regards,
>>Bas Hamstra.
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.