Moderator: Andres Valverde
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!" ?
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!" ?
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!" ?
Dieter wrote:To me it looks, as this would need quite a bit of overhead
No that list is not to be used (iterated) continuosly with speed.Sune Fischer wrote:Why not make a 2D array, won't that accomplish both?
like usual in a double linked list.Sune Fischer wrote:BTW how does a piece list work, when a piece is captured is the list rearanged to close the hole?
Sune Fischer wrote:Why not make a 2D array, won't that accomplish both?
Use the first index to loop the type of piece and the second index to loop pieces of that type.
Maybe even a 3D with first being the color?
BTW how does a piece list work, when a piece is captured is the list rearanged to close the hole?
unsigned *pl = piece_list[stm][num_pieces[stm]];
do
{
sq = *--pl;
piece = board[sq];
...
}
while (piece != KING); /* Assume King is always at the start */
Dieter B?r?ner wrote:To fill the gap left by a captured piece, just fill in the last piece of the list and decrement num_pieces[side].
typedef score_t (*score_func)(int, int);
static score_func score_func_array[8] =
{
NULL,
score_pawn,
score_knight,
score_bishop,
score_rook,
score_queen,
score_king,
NULL
};
unsigned *pl = piece_list[stm][num_pieces[stm]];
do
{
sq = *--pl;
piece = board[sq];
/* instead of switch */
score += (score_func_array[piece])(stm, sq);
}
while (piece != KING); /* Assume King is always at the start */
/* And a similar loop for the other side. Alternative would be an
outer loop over color and a branch for the sign of the score. */
Dieter B?r?ner wrote:With a 2d array you have 2 loops instead of one loop at typical places, like movegeneration and evaluation. I never tried it, but I guess, it could be some significant overhead in late endgame.
Dieter B?r?ner wrote:Note that very few variables will be needed. With a 2d array, you'd need quite a bit more code and variables. For my engine at the moment, the additional information available would not buy much. But this may well be, because much of the code is tuned around the data structures used. If I had that information availalbe, I'd probably code things a bit differently (and I am currently thinking about doing so).
To fill the gap left by a captured piece, just fill in the last piece of the list and decrement num_pieces[side].
Sune Fischer wrote:Dieter B?r?ner wrote:With a 2d array you have 2 loops instead of one loop at typical places, like movegeneration and evaluation. I never tried it, but I guess, it could be some significant overhead in late endgame.
Well I wouldn't suggest to loop over the entire 6x10 array. With a counter for each type of piece one would need max 5 redundant tests if the king is all alone.
Sune Fischer wrote:A="kqrbbnppp" or
A compact and ordered. Quick to navigate and use but how do you keep it sorted when adding and removing pieces?
Dieter wrote:I wonder why Reinhard is using doubly linked lists instead of single linked lists
Sune Fischer wrote:Hi Tord
I'm not a piecelist guy, but how do exactly do you mean, is it a list like
A="kqrbbnppp" or
B="k00000q00000r000000bb000000..." or
C="kpnbqppprb"?
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 2 guests