Author: Daniel Clausen
Date: 11:38:34 03/03/03
Go up one level in this thread
On March 03, 2003 at 14:11:20, Dann Corbit wrote: >On March 03, 2003 at 14:01:58, Andreas Guettinger wrote: > >>On March 03, 2003 at 13:27:24, Dann Corbit wrote: >> >>>On March 03, 2003 at 13:18:41, Andreas Guettinger wrote: >>> >>>>On March 03, 2003 at 11:44:29, Albert Bertilsson wrote: >>>> >>>>>Here is how I do it: >>>>> >>>>>Have a piece list per side, one counter for each side telling the number of >>>>>pieces. >>>>> >>>>>If you make a capture, swap the piece last in the array with the captured piece >>>>>and decrease the counter for that list. >>>>> >>>>>For the captured piece in the list you need to store is original list position. >>>>> >>>>>In undo move you can just increase the counter and swap the piece back. >>>>> >>>>>/Regards Albert >>>> >>>>I have a similar piece list. Because I want it sorted from the highest to the >>>>lowest valued piece (for SEE/MVA), some small sorting is needed during >>>>promotion. Recently I thought if it would not be faster to just copy the whole >>>>picelist before domove() and restore it after undomove(). Any ideas? >>> >>>Have a separate piece list for every piece type. Then it is always sorted >>>without any work. >> >> >>But then, when I have to scan to the piecelist, I have to scan through 12 lists. >>I don't like that. > >12 checks for a count of zero, compared to sorting. Which do you like better? You could also use a linked list. Sorting is not that slow then (if you know where to re-insert a captured piece again, that is) and it's always sorted. I you want to know where the knight-squares etc start, you'd need additional counters/pointers, which makes it a bit more complicated. In this case, I'd also use multiple piecelists. Surprisingly, the optimal representation depends on your goals. :) Sargon
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.