Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Compact attacks in Crafty

Author: Robert Hyatt

Date: 19:52:36 05/23/03

Go up one level in this thread


On May 22, 2003 at 22:52:27, Russell Reagan wrote:

>On May 22, 2003 at 22:14:42, Robert Hyatt wrote:
>
>>Yes.  The compact attack stuff compresses this quite a bit, so that the
>>"endpoints" are not needed in an index (IE there is no need for 8 bit indices
>>for an entire rank/file/long diagonal since the endpoints are known already.)
>
>Do you mean, the endpoints are known at compile time to compute a smaller lookup
>table, or the endpoints are known at runtime? If at runtime, where is this
>information stored?

Think about this:

you have a rank with 8 squares.  You shift/and the board to isolate the
8 bits for that rank and use it as an index.  However, you will _always_
be able to attack the two end squares if the thing is "open" so you could
exclude the last bit in each direction, leaving a 6-bit index rather than the
full 8 bits.  You then modify the table so that the look-up still works
correctly because the two endpoints are not needed for an index since they
will "stop" the attacks whether they are occupied or not since an attack
can't go past the end of the rank on either end...


>
>>This cuts one dimension to 2^6 rather than 2^8, a 3/4 reduction.  It also makes
>>use of the fact that doing extra work is much faster than doing memory
>>references,
>>so that some of the computation is faster than the corresponding table lookups
>>would be.
>
>So the compact attacks use around 64 KB (1/4th of 512 KB)? Looking at your code,
>it looks more like only about 8 KB.

I was only explaining the endpoint exclusion trick.  There are others.  For
example the normal attacks have 256 entries even for short diagonals.  The
new version does not, which reduces things further.


>
># if defined(COMPACT_ATTACKS)
>    struct at    at;                                       //           1588
>    BITBOARD     diag_attack_bitboards[NDIAG_ATTACKS];     // 296 * 8 = 2368
>    BITBOARD     anti_diag_attack_bitboards[NDIAG_ATTACKS];// 296 * 8 = 2368
>    DIAG_INFO    diag_info[64];                            // 28 * 64 = 1792
>                                                           //  #bytes = 8116



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.