Author: Roberto Waldteufel
Date: 08:55:01 10/06/98
Go up one level in this thread
On October 06, 1998 at 09:50:07, Frank Schneider wrote: >Hi John, > >On October 05, 1998 at 16:49:07, John Coffey wrote: > >>Like most chess programs, I have a data structure that represents the current >>state of the board. Some programs have bitboards, but instead I use information >>for each square. My data structure could easily grow into 300 to 500 bytes. >> >>I am just now starting to write my search routines. If I am in my routine >>"SearchForWhite()" and it tries a move and then calls "SearchForBlack()" (These >>names are hypothetical at this point) then it needs to pass the current state >>of the board to "SearchForBlack()." >> >>Question: >> >>Is it more efficient to .... >> >>1. Only have one copy of the current state, and have "SearchForBlack()" >>restore the board back to its previous state before returning to >>"SearchforWhite()"? >> >>or >> >>2. "SearchForWhite" passes the whole data structure on the stack as a copy of >>the original so that "SearchForBlack()" doesn't have to restore the board? >> >>John Coffey >Gromit uses your method 2. It currently searches about 20K nps on K6/200 and >the copying of the datastructures (about 1KB per move) takes 10-15% of total >cpu-time. It may take more if you take into account the cache-effects. > >Just to give you an idea how expensive it roughly is. > >Frank Hi Frank, Have you tried both methods for comparison and chosen method 2, or have you not tried method 1? I use method 1 and always have - I just assumed without testing that passing the whole board data structure on the stack would be too expensive. Maybe I should have tested this out. Method 2 is cetainly easier to program because you never need to unmake any moves. The question really is whether it is quicker to unmake moves or copy data. In Rabbit I avoid a lot of the overhead involved in move retraction by a trick I use in my move generation. Whenever two successive moves have the same from-square, I don't retract the move, but just move the piece from the old to-square to the new to-square. Also, if two successive moves share the same to-square, then there is no need to recalculate attack maps of sliding pieces through the to-square between the moves. Best wishes, Roberto
This page took 0.01 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.