Alessandro Scotti wrote:Hi folks,
I'm trying to compare these two kinds of piece-list:
1) all pieces in a single list;
2) separate lists for each piece type (knight, bishop, etc.).
I've no experience with this (Kiwi uses bitboards) and currently tend to favor #1 (packed into an array) because it's simpler. However, many strong engines are using #2. After reading many old posts from the CCC forum I've still a couple of questions for you guys, regardless which representation you are using:
- do you sometimes miss something the other representation has?
- are there points in the program where you could really say: "aha! do that with the *other* representation!"
![Wink :wink:](./images/smilies/icon_wink.gif)
?
In Current version (v0.12) of Natwarlal:
(a) I use an array of size 16 for for storing pieces, one for each side.
Advantages:
Faster and simpler make move/ unmake move. When a piece is captured, I let the array slot remain as it is, I just change the piece type to PNONE. when I unmake the move, I simply change the piece type back to what it originally was. Similarly, making & unmaking pawn promotions etc is easy.
Edit: Also, this method of storing pieces lead to deterministic move generation. Whatever be the order of piece captures/moves be, when you unmake the moves, they end up in exactly the same location in the array. (I recalled this after seeing Dieters post, he seems to have written his post even as I was typing mine).
Disadvantages:
I have to loop over the whole array to generate moves, and I have to do the same thing in evaluation. when evaluating pawns, I have to loop over the array (again) and separate out the pawns. Because of this, I believe this data structure is slower overall. Probably much slower.
I now think that having a separate piece list for different pieces would be better.
Pallav