remove piece2char/piece2string (global var instead)

This commit is contained in:
2021-10-31 13:44:08 +01:00
parent 2f701c4bd5
commit 16c0c06095
5 changed files with 36 additions and 131 deletions

View File

@@ -18,37 +18,15 @@
static pool_t *pieces_pool;
inline static char piece2char(piece_t p)
{
piece_t piece = PIECE(p);
char res;
//printf("%#x p=%#x\n", p, PIECE(p));
switch (piece) {
case PAWN:
res = CHAR_PAWN;
break;
case KNIGHT:
res = CHAR_KNIGHT;
break;
case BISHOP:
res = CHAR_BISHOP;
break;
case ROOK:
res = CHAR_ROOK;
break;
case QUEEN:
res = CHAR_QUEEN;
break;
case KING:
res = CHAR_KING;
break;
default:
res = CHAR_EMPTY;
}
return res;
}
struct piece_details piece_details[] = {
[EMPTY] = { ' ', ' ', " ", " ", "", 0 },
[PAWN] = { 'P', 'p', "", "", "Pawn", PAWN_VALUE },
[KNIGHT] = { 'N', 'n', "", "", "Knight", KNIGHT_VALUE },
[BISHOP] = { 'B', 'b', "", "", "Bishop", BISHOP_VALUE },
[ROOK] = { 'R', 'r', "", "", "Rook", ROOK_VALUE },
[QUEEN] = { 'Q', 'q', "", "", "Queen", QUEEN_VALUE },
[KING] = { 'K', 'k', "", "", "King", KING_VALUE }
};
void piece_list_print(struct list_head *list)
{
@@ -59,14 +37,9 @@ void piece_list_print(struct list_head *list)
list_for_each_safe(p_cur, tmp, list) {
piece = list_entry(p_cur, piece_list_t, list);
printf("%c%c%c ", piece2char(piece->piece),
printf("%s%c%c ", P_SYM(piece->piece),
FILE2C(GET_F(piece->square)),
RANK2C(GET_R(piece->square)));
/*printf("\t%d: %s on %c%c\n", i,
piece2string(piece->piece),
FILE2C(GET_F(piece->square)),
RANK2C(GET_R(piece->square)));
*/
i++;
}
printf("Total pieces = %d\n", i);