by H.G.Muller » 10 Jan 2016, 23:30
In its simplest form a 'piece list' is just a table that tells you for every piece on which square it is standing. This saves you from scanning through the board every time to locate your own pieces. It could be a simple array, indexed by the 'piece number'. You could then run through the part of that array containg your own pieces when you ned them. You might even organie the list such that different piece types are in different 'sections', so that when you are interested in a specific piece type (say Rooks, for giving Rook on open-file or Rook on 7th-rank bonuses) you have to loop through the Rook section only to find all your Rooks.
One problem is that in the process of searching pieces get captured, so you would have to think about how to add or remove pieces from the piece list. You could simply mark them as absent through some invalid square number when they are captured. Then the list would always stay equally long, but it would be at most 16 entries, and runnning through it to find all your pieces would still be 4 times less work than scanning through a board of 64 squares. If something is captured at game level, you could squeeze out the piece that is now gone, as it will never come back (in normal Chess; in Crazyhouse that is of course different).
You could try to save time on running through the array by making it a linked list, so that following the links would make you skip over (and thus not waste time on) captured pieces. You would have to update the links whenever something is captured though. An alternative is to use a one-word 'presence mask' that contains one bit for every piece to tell if it is captured or not, and use bit-extraction techniques to only loop over uncaptured pieces.
If you have organized the piece list by piece type, you would have to make sure on promotion that everything is still in the right section. This might involve assigning a new number to the promoted piece, because it must be elsewhere in the table as the Pawn it came from.