Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: expensive attack information

Author: Dann Corbit

Date: 18:13:05 03/28/03

Go up one level in this thread


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][128]; // reused for queen
BITBOARD BishopAttacksDu[64][128]; // reused for queen
BITBOARD BishopAttacksDd[64][128]; // reused for queen

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.