What you describe is nearly exactly how I do it in my problem solver "Chest".
I mark the entry as "unused" by storing a 0 as the position of the piece. I do NOT move down the other pieces in the piece list. That avoids changing the piecelist indexes stored in the board... and I have lots more of them than most everybody else.AndrewShort wrote: The internal board could simply contain indeces into the piecelist array, so that when MakeMove moves a piece, you directly know which record in the piecelist to update. You move a pawn - easy - move the index in the interal board, and use that index to update the piecelist to reflect the new sq for the pawn. [side note: I am opting for now to use indeces rather than pointers, even though pointers are undoubtedly faster]
2 questions:
(1) how to handle captures? When undoing a capture move, how to know which index of the piecelist to use to restore the captured piece? My brain is fried, I can't think of an efficient way to do this...
It also avoids the problems with "undo" not exactly restoring the original piece list order (others explained that already).
I start with a compressed version (per side) and an additional (per side) number of initial slots used at most. You may compress your piece lists top level (between searches, not inside a search).AndrewShort wrote: (2) how to manage the piece list efficiently so that if side to move has only 3 pieces, you are looping 3 times in the piece list instead of 16?
thanks in advance...
Scanning at most 15 unused slots does not sound THAT expensive to me.