Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Attack Tables

Author: Roberto Waldteufel

Date: 14:35:39 10/23/98

Go up one level in this thread



On October 22, 1998 at 13:22:45, Robert Hyatt wrote:

>On October 22, 1998 at 03:12:32, Roberto Waldteufel wrote:
>
>>
>>On October 21, 1998 at 04:28:43, Ernst A. Heinz wrote:
>>
>>>On October 20, 1998 at 18:13:24, Robert Hyatt wrote:
>>>>
>>>>The main idea of rotated bitmaps is that it eliminates that incremental >updating
>>>>of the attack bitmaps as pieces are moved.
>>>
>>>If I understood Roberto correctly, he is primarily concerned about the full
>>>"attack tables" which is obviously different from what you call "attack
>>>bitmaps". Without incremental updating the whole bitboard stuff (normal &
>>>rotated) allows *only* for the quick detection of the "attack-from" relation,
>>>i.e., which squares does a piece attack when it resides on location X. The
>>>bitboard stuff answers this question by means of pre-computed attack bitboards
>>>and some masking operations to account for other pieces on the board.
>>>
>>>Unfortunately, however, the bitboard stuff does not fundamentally simplify the
>>>calculation of the "attack-to" relation (i.e., which pieces attack location X).
>>>Without incrementally updated "attack-to" tables you still need to loop in
>>>order to determine the relation. As usual it therefore depends on your specific
>>>program if incrementally updated "attack-to" tables are to be preferred or not.
>>>
>>>=Ernst=
>>
>>Hi Ernst,
>>
>>Yes, you see my dilemma. At present my incremental updating is very fast on the
>>attack-from maps, but slower on the attack-to maps. I think this is also the
>>case with attack detection using the rotated bitboards and no attack tables. I
>>intend to try the rotated bitboard method to see if I can make the search
>>faster. Only trouble is, my present code uses the attack tables everywhere, so
>>it will be a big job to rewrite it for the new data structure.
>>
>>Best wishes,
>>Roberto
>
>A simple bit of software engineering advice...  for *any* data structure that
>might change, rather than referencing it explicitly, use a C macro instead.
>
>IE I have macros like AttacksRank(square), AttacksFile(square) and so forth.
>When I changed from normal bitmaps to rotated, I changed these macros and
>was ready to go.  I do this for *anything* that might change later, so I can
>change it in one place only.  This is called "design for change"...  and works
>well, not to mention that the macros can make the code more readable...

Yes, this makes perfect sense to me now, because I have somewhere between 10000
and 15000 lines of code that was *not* designed for change! But thanks for the
tip - I will try to keep it in mind in future. Well, I guess I learned my lesson
the hard way. Very often I have sections of code that appear many times in the
program, but with minor differences each time, so that when I wrote it I tended
to use cut and paste, editing the minor differences by hand, rather than macros.
Now I have to live with this monster!

Best wishes,
Roberto



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.