Author: Dann Corbit
Date: 20:44:21 03/28/03
Go up one level in this thread
On March 28, 2003 at 21:13:05, Dann Corbit wrote:
>On March 28, 2003 at 20:35:57, Matthias Gemuh wrote:
>
>>
>>
>> BITBOARD AttacksTo[64], AttacksFrom[64];
>>
>>
>>My engine (BigLion) sux.
>>The reason is partly because I calculate the above infos (AttacksTo and
>>AttacksFrom) for each square at all nodes from scratch. I hit 100 kN/s in
>>middlegame on 1.8GHz, with pruning and extensions switched on.
>>Attempts to update the above attack infos incrementally failed (too buggy).
>>
>>Who can help with some nice pseudo code, based on MOVE(nFrom, nTo) ?
>>
>>Castling and en passant will always be calculated from scratch.
>
>Why not calculate them once and save them by piece type?
>
>Only like this:
>
>BITBOARD KnightAttacks[64]; // A knight on any square attacks 8 or less squares
>BITBOARD KingAttacks[64]; // A king on any square attacks 8 or less squares
>BITBOARD WhitePawnAttacks[64]; // A pawn always attacks 1 or 2 squares
>BITBOARD BlackPawnAttacks[64]; // A pawn always attacks 1 or 2 squares
>// For any row a horizontal slider sits on,
>// there are 7 bits besides the one it sits on that can have a chessman on it
>// Hence, there are 127 possibilities for attacks on any row, column, or
>diagonal
>BITBOARD RookAttacksRow[64][127]; // reused for queen
>BITBOARD RookAttacksCol[64][127]; // reused for queen {cough 127}
>BITBOARD BishopAttacksDu[64][127]; // reused for queen {cough 127}
>BITBOARD BishopAttacksDd[64][127]; // reused for queen {cough 127}
Consider this rook:
[D]4k3/8/8/2R5/8/8/8/4K3 w - -
When the board is like this:
[D]4k3/8/8/1pR3p1/8/8/8/4K3 w - -
Or the board is like this:
[D]4k3/8/8/ppR3pp/8/8/8/4K3 w - -
or the board is like this:
[D]4k3/8/8/pPR3pP/8/8/8/4K3 w - -
The attacks are the same on rank 5: b5 & g5 are in direct line of fire for the
rook. In the last one, b5 is actually a "defend" rather than an attack.
If you want to keep shadow/skewer/x-ray information then a5 and h5 are under the
shadow of the rook.
So the "byte" of the rook row bitmap that contains information holds:
r
-+--------
5|01000010
-+--------
f|ABCDEFGH
and if you hold the shadow data, it looks like this:
r
-+--------
5|10000001
-+--------
f|ABCDEFGH
>Precompute the answers and then just do a lookup.
>You will have to mask with white pieces to see if your attack is really a
>defense of your own piece.
>To find out the enemy piece you attack, you will need to do a few or's.
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.