Author: Tom Likens
Date: 10:57:23 12/01/03
Go up one level in this thread
On December 01, 2003 at 08:57:55, Sune Fischer wrote: >On December 01, 2003 at 08:19:50, Tord Romstad wrote: > >>On December 01, 2003 at 07:33:51, Tom Likens wrote: >> >>>I'm toying with adding full attack tables to my engine. Do you incrementally >>>update your attack tables or do you generate them from scratch? >> >>It's funny that you ask this question right now, because I posted my new >>attack table generation code just a couple of hours ago. :-) I don't want >>to show you the old code, partly because it is too embarassing to show, >>and partly because it is so mind-bogglingly ugly that the memory of having >>seen it would probably give you nightmares for the rest of your life. >> >>I have always generated the attack tables from scratch at every node. The >>complexity of updating them incrementally scares me, and those who have tried >>usually claim that it is slower than generating them from scratch anyway. > >That will probably depend on the design of the table. > >I stored attack to and attack from information which can be used to do >incremental updates. > >When moving a piece you take all the sliding pieces attacking the affected >squares (that's just a few masks with bitboards) and invalidate their attack >boards along with the moving piece and the one it might have captured. > >Now you have a list of pieces who's attack boards may be invalid. >You run through this list and generate their new attack boards, you xor the new >attack board with their old attack board (which is stored in the attack table) >to get the squares which changed attack status, these you update. > >Hope that made sense :) > >I posted the code once, here is the main loop > >inline void BOARD::GenAttackers(uint32 affected,uint co) { > register BITBOARD xors; > register uint ix; > > while (affected) { > ix = FirstBit32(affected); > xors = attack_ix[ix]; > attack_ix[ix] = GenAttack(ty_ix[ix],sq_ix[ix],co); > xors ^= attack_ix[ix]; > while (xors) > attack_sq[GetFirstBitAndClear64(xors)] ^=(1<<ix); > affected &= affected-1; > } >} > >affected is a 32 bit piece list >attack_ix stores the attack board of piece with index ix >attack_sq stores attackers to sq > >-S. >>Tord Hello Sune, This looks interesting. It seems to me that you could do the same thing with simply bitboards, *but* I'm guessing you use unsigned ints because they are faster (i.e. more cache friendly). --tom
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.