3 Commits

Author SHA1 Message Date
d9f03acb02 fix piece color in move_do 2023-07-10 13:17:26 +02:00
683b6ad66b add debug_level_get 2023-07-10 13:11:38 +02:00
b1e6461f6f Add DEBUG_DEBUG_C 2023-07-10 13:10:53 +02:00
8 changed files with 136 additions and 64 deletions

View File

@@ -7,12 +7,15 @@ r3k2r/8/3B4/8/8/3b4/8/R3K2R w KQkq - 0 1
r3k2r/8/3BB3/8/8/3bb3/8/R3K2R w KQkq - 0 1 r3k2r/8/3BB3/8/8/3bb3/8/R3K2R w KQkq - 0 1
r2bkb1r/8/8/8/8/3bb3/8/R2BKB1R w KQkq - 0 1 r2bkb1r/8/8/8/8/3bb3/8/R2BKB1R w KQkq - 0 1
# 4 castle possible, only K+R
r3k2r/8/8/8/8/8/8/R3K2R w KQkq - 0 1
# illegal positions # illegal positions
4k3/8/8/8/7b/8/8/4K3 b - - 0 1 4k3/8/8/8/7b/8/8/4K3 b - - 0 1
2r1k3/3P4/8/8/8/8/8/4K3 w - - 0 1 2r1k3/3P4/8/8/8/8/8/4K3 w - - 0 1
# only kings on A1/H8 # only kings on A1/A8, white to play
k7/8/8/8/8/8/8/K7 b - - 0 1 k7/8/8/8/8/8/8/K7 w - - 0 1
# only one move possible (Pf2xBg3) # only one move possible (Pf2xBg3)
k7/8/8/1p1p4/pPpPp3/P1PpPpb1/NBNP1P2/KBB1B3 w - - 0 1 k7/8/8/1p1p4/pPpPp3/P1PpPpb1/NBNP1P2/KBB1B3 w - - 0 1

View File

@@ -56,6 +56,7 @@ CFLAGS += -Wmissing-declarations
CPPFLAGS := -I$(INCDIR) CPPFLAGS := -I$(INCDIR)
CPPFLAGS += -DDEBUG # global CPPFLAGS += -DDEBUG # global
CPPFLAGS += -DDEBUG_DEBUG # enable log() functions CPPFLAGS += -DDEBUG_DEBUG # enable log() functions
#CPPFLAGS += -DDEBUG_DEBUG_C # enable verbose log() settings
CPPFLAGS += -DDEBUG_POOL # memory pools management CPPFLAGS += -DDEBUG_POOL # memory pools management
CPPFLAGS += -DDEBUG_FEN # FEN decoding CPPFLAGS += -DDEBUG_FEN # FEN decoding
CPPFLAGS += -DDEBUG_MOVE # move generation CPPFLAGS += -DDEBUG_MOVE # move generation

View File

@@ -27,6 +27,7 @@
void debug_init(uint level, FILE *stream, bool flush); void debug_init(uint level, FILE *stream, bool flush);
void debug_level_set(uint level); void debug_level_set(uint level);
uint debug_level_get(void);
void debug_stream_set(FILE *stream); void debug_stream_set(FILE *stream);
void debug_flush_set(bool flush); void debug_flush_set(bool flush);
void _printf debug(uint level, bool timestamp, void _printf debug(uint level, bool timestamp,
@@ -38,6 +39,7 @@ static inline void debug_init(__unused uint level,
__unused FILE *stream, __unused FILE *stream,
_unused bool flush) {} _unused bool flush) {}
static inline void debug_level_set(__unused uint level) {} static inline void debug_level_set(__unused uint level) {}
static inline uint debug_level_get(void) {return 0;}
static inline void debug_stream_set(__unused FILE *stream) {} static inline void debug_stream_set(__unused FILE *stream) {}
static inline void debug_flush_set(__unused bool level) {} static inline void debug_flush_set(__unused bool level) {}
static inline void _printf debug(__unused uint level, __unused bool timestamp, static inline void _printf debug(__unused uint level, __unused bool timestamp,

View File

@@ -37,19 +37,34 @@ static FILE *stream = NULL;
void debug_level_set(uint level) void debug_level_set(uint level)
{ {
debug_level = level; debug_level = level;
# ifdef DEBUG_DEBUG_C
log(0, "debug level set to %u\n", level); log(0, "debug level set to %u\n", level);
# endif
}
/**
* debug_level_get() - get debug level.
* @return: current level debug (unsigned integer).
*/
uint debug_level_get(void)
{
return debug_level;
} }
void debug_stream_set(FILE *_stream) void debug_stream_set(FILE *_stream)
{ {
stream = _stream; stream = _stream;
# ifdef DEBUG_DEBUG_C
log(0, "stream set to %d\n", stream? fileno(stream): -1); log(0, "stream set to %d\n", stream? fileno(stream): -1);
# endif
} }
void debug_flush_set(bool flush) void debug_flush_set(bool flush)
{ {
debug_flush = flush; debug_flush = flush;
log(0, "debug flush set to %d\n", flush); # ifdef DEBUG_DEBUG_C
log(0, "debug flush %s.\n", flush? "set": "unset");
# endif
} }
void debug_init(uint level, FILE *_stream, bool flush) void debug_init(uint level, FILE *_stream, bool flush)

View File

@@ -297,15 +297,16 @@ int do_pos(pos_t *pos, __unused char *arg)
int do_genmoves(pos_t *pos, __unused char *arg) int do_genmoves(pos_t *pos, __unused char *arg)
{ {
log_f(1, "%s\n", arg);
moves_gen_all(pos); moves_gen_all(pos);
return 1; return 1;
} }
int do_prmoves(pos_t *pos, __unused char *arg) int do_prmoves(pos_t *pos, __unused char *arg)
{ {
log_f(1, "%s\n", arg); uint debug_level = debug_level_get();
moves_print(pos, M_PR_SEPARATE | M_PR_NUM); debug_level_set(1);
moves_print(pos, M_PR_SEPARATE | M_PR_NUM | M_PR_LONG);
debug_level_set(debug_level);
return 1; return 1;
} }
@@ -423,10 +424,14 @@ int do_depth(__unused pos_t *pos, char *arg)
int do_search(pos_t *pos, __unused char *arg) int do_search(pos_t *pos, __unused char *arg)
{ {
printf("++++++++\nnegamax=%d\n", negamax(pos, depth, pos->turn==WHITE? 1:-1)); int debug_level = debug_level_get();
printf("best=");
negamax(pos, depth, pos->turn == WHITE ? 1 : -1);
debug_level_set(1);
log(1, "best=");
move_print(0, pos->bestmove, 0); move_print(0, pos->bestmove, 0);
printf("score=%d\n", pos->bestmove->negamax); log(1, " negamax=%d\n", pos->bestmove->negamax);
debug_level_set(debug_level);
return 1; return 1;
} }

View File

@@ -90,13 +90,13 @@ typedef unsigned char square_t;
*/ */
typedef unsigned char castle_t; typedef unsigned char castle_t;
#define CASTLE_WK 1 /* 0x01 00000001 */ #define CASTLE_WK (1 << 0) /* 0x01 00000001 */
#define CASTLE_WQ (1 << 1) /* 0x02 00000010 */ #define CASTLE_WQ (1 << 1) /* 0x02 00000010 */
#define CASTLE_BK (1 << 2) /* 0x04 00000100 */ #define CASTLE_BK (1 << 2) /* 0x04 00000100 */
#define CASTLE_BQ (1 << 3) /* 0x08 00001000 */ #define CASTLE_BQ (1 << 3) /* 0x08 00001000 */
#define CASTLE_W 0x03 /* 00000011 W castle mask */ #define CASTLE_W (CASTLE_WK | CASTLE_WQ) /* 00000011 W castle mask */
#define CASTLE_B 0x0C /* 00001100 B castle mask */ #define CASTLE_B (CASTLE_BK | CASTLE_BQ) /* 00001100 B castle mask */
/* bitboard /* bitboard
*/ */

View File

@@ -92,36 +92,36 @@ int move_print(int movenum, move_t *move, move_flags_t flags)
return 0; return 0;
} }
if (flags & M_PR_NUM) if (flags & M_PR_NUM)
printf("%d:", movenum); log(1, "%d:", movenum);
if (move->flags & M_CASTLE_K) { if (move->flags & M_CASTLE_K) {
printf("O-O"); log(1, "O-O");
goto end; goto end;
} else if (move->flags & M_CASTLE_Q) { } else if (move->flags & M_CASTLE_Q) {
printf("O-O-O"); log(1, "O-O-O");
goto end; goto end;
} else { } else {
printf("%s%c%c", P_SYM(move->piece), log(1, "%s%c%c", P_SYM(move->piece),
FILE2C(F88(move->from)), FILE2C(F88(move->from)),
RANK2C(R88(move->from))); RANK2C(R88(move->from)));
if (move->flags & M_CAPTURE) { if (move->flags & M_CAPTURE) {
printf("x"); log(1, "x");
if (flags & M_PR_LONG) if (flags & M_PR_LONG)
printf("%s", P_SYM(move->capture)); log(1, "%s", P_SYM(move->capture));
} else { } else {
printf("-"); log(1, "-");
} }
printf("%c%c", log(1, "%c%c",
FILE2C(F88(move->to)), FILE2C(F88(move->to)),
RANK2C(R88(move->to))); RANK2C(R88(move->to)));
if (flags & M_PR_LONG && move->flags & M_EN_PASSANT) if (flags & M_PR_LONG && move->flags & M_EN_PASSANT)
printf("e.p."); log(1, "e.p.");
if (move->promotion) if (move->promotion)
printf("=%s", P_SYM(move->promotion)); log(1, "=%s", P_SYM(move->promotion));
end: end:
printf(" "); log(1, " ");
} }
if (flags & M_PR_NL) if (flags & M_PR_NL)
printf("\n"); log(1, "\n");
return 1; return 1;
} }
@@ -133,7 +133,7 @@ void moves_print(pos_t *pos, move_flags_t flags)
for (int color=WHITE; color <= BLACK; ++color) { for (int color=WHITE; color <= BLACK; ++color) {
int verif = 0; int verif = 0;
printf("%s pseudo-moves:\n\t", color == WHITE? "White": "Black"); log(1, "%s pseudo-moves:\n\t", color == WHITE? "White": "Black");
if (! (flags & M_PR_SEPARATE)) { if (! (flags & M_PR_SEPARATE)) {
movenum = 1; movenum = 1;
list_for_each_safe(p_cur, tmp, &pos->moves[color]) { list_for_each_safe(p_cur, tmp, &pos->moves[color]) {
@@ -141,20 +141,20 @@ void moves_print(pos_t *pos, move_flags_t flags)
verif += move_print(movenum++, move, flags); verif += move_print(movenum++, move, flags);
} }
} else { } else {
printf("captures: "); log(1, "captures: ");
movenum = 1; movenum = 1;
list_for_each_safe(p_cur, tmp, &pos->moves[color]) { list_for_each_safe(p_cur, tmp, &pos->moves[color]) {
move = list_entry(p_cur, move_t, list); move = list_entry(p_cur, move_t, list);
verif += move_print(movenum++, move, flags | M_PR_CAPT); verif += move_print(movenum++, move, flags | M_PR_CAPT);
} }
movenum = 1; movenum = 1;
printf("\n\tothers : "); log(1, "\n\tothers : ");
list_for_each_safe(p_cur, tmp, &pos->moves[color]) { list_for_each_safe(p_cur, tmp, &pos->moves[color]) {
move = list_entry(p_cur, move_t, list); move = list_entry(p_cur, move_t, list);
verif += move_print(movenum++, move, flags | M_PR_NCAPT); verif += move_print(movenum++, move, flags | M_PR_NCAPT);
} }
} }
printf("\n\tTotal moves = %d mobility=%u\n", verif, pos->mobility[color]); log(1, "\n\tTotal moves = %d mobility=%u\n", verif, pos->mobility[color]);
} }
} }
@@ -163,7 +163,7 @@ static move_t *move_add(pos_t *pos, piece_t piece, square_t from,
{ {
board_t *board = pos->board; board_t *board = pos->board;
move_t *move; move_t *move;
int color = COLOR(piece); int color = COLOR(pos->board[from].piece);
# ifdef DEBUG_MOVE # ifdef DEBUG_MOVE
log_i(3, "piece_color=%d turn=%d from=%c%c to=%c%c\n", log_i(3, "piece_color=%d turn=%d from=%c%c to=%c%c\n",
@@ -186,7 +186,7 @@ static move_t *move_add(pos_t *pos, piece_t piece, square_t from,
return NULL; return NULL;
list_add(&move->list, &pos->moves[color]); list_add(&move->list, &pos->moves[color]);
move->piece = piece; move->piece = piece | color;
move->from = from; move->from = from;
move->to = to; move->to = to;
move->capture = board[to].piece; move->capture = board[to].piece;
@@ -194,7 +194,9 @@ static move_t *move_add(pos_t *pos, piece_t piece, square_t from,
if (move->capture) if (move->capture)
move->flags |= M_CAPTURE; move->flags |= M_CAPTURE;
# ifdef DEBUG_MOVE # ifdef DEBUG_MOVE
log_i(3, "added move from %c%c to %c%c\n", log_i(3, "added %s %s move from %c%c to %c%c\n",
COLOR(move->piece)? "black": "white",
P_NAME(PIECE(move->piece)),
FILE2C(F88(move->from)), RANK2C(R88(move->from)), FILE2C(F88(move->from)), RANK2C(R88(move->from)),
FILE2C(F88(move->to)), RANK2C(R88(move->to))); FILE2C(F88(move->to)), RANK2C(R88(move->to)));
# endif # endif
@@ -615,8 +617,12 @@ int moves_gen(pos_t *pos, bool color, bool doit, bool do_king)
# ifdef DEBUG_MOVE # ifdef DEBUG_MOVE
log_f(2, "color:%s doit:%d\n", color? "Black": "White", doit); log_f(2, "color:%s doit:%d\n", color? "Black": "White", doit);
# endif # endif
piece_list = &pos->pieces[color];
/* do not generate moves if already done for color */
if (!list_empty(&pos->moves[color]))
doit = false;
piece_list = &pos->pieces[color];
pos->mobility[color] = 0; pos->mobility[color] = 0;
pos->controlled[color] = 0; pos->controlled[color] = 0;
count += pseudo_moves_castle(pos, color, doit, do_king); count += pseudo_moves_castle(pos, color, doit, do_king);
@@ -661,6 +667,7 @@ int moves_gen_king_moves(pos_t *pos, bool color, bool doit)
*/ */
void moves_gen_all(pos_t *pos) void moves_gen_all(pos_t *pos)
{ {
//log_f(1, "turn=%d opponent=%d\n", pos->turn, OPPONENT(pos->turn));
moves_gen(pos, OPPONENT(pos->turn), false, false); moves_gen(pos, OPPONENT(pos->turn), false, false);
moves_gen(pos, pos->turn, true, true); moves_gen(pos, pos->turn, true, true);
moves_gen_king_moves(pos, OPPONENT(pos->turn), false); moves_gen_king_moves(pos, OPPONENT(pos->turn), false);
@@ -676,88 +683,122 @@ void moves_gen_all(pos_t *pos)
pos_t *move_do(pos_t *pos, move_t *move) pos_t *move_do(pos_t *pos, move_t *move)
{ {
# ifdef DEBUG_MOVE # ifdef DEBUG_MOVE
printf("++++++++++ "); //log(1, "new move: ");
move_print(0, move, M_PR_NL | M_PR_LONG | M_PR_NUM); move_print(0, move, M_PR_NL | M_PR_LONG);
# endif # endif
pos_t *new = pos_dup(pos); pos_t *new = pos_dup(pos);
piece_t piece = PIECE(move->piece), newpiece = piece, captured = move->capture; piece_t piece = PIECE(move->piece), newpiece = piece, captured = move->capture;
int color = COLOR(piece); int color = COLOR(move->piece);
square_t from = move->from, to = move->to; square_t from = move->from, to = move->to;
u64 bb_from = SQ88_2_BB(from), bb_to = SQ88_2_BB(to);
if (move->capture || PIECE(piece) == PAWN) /* 50 moves */ //printf("Piece color=%d\n", color);
if (move->capture || piece == PAWN) /* 50 moves */
new->clock_50 = 0; new->clock_50 = 0;
else else
new->clock_50++; new->clock_50++;
if (move->flags & M_CAPTURE) { /* capture */ if (move->flags & M_CAPTURE) { /* capture */
if (!(move->flags & M_EN_PASSANT)) { if (move->flags & M_EN_PASSANT) {
piece_del(&new->board[to].s_piece->list);
new->board[to].piece = 0;
new->occupied[OPPONENT(color)] ^= SQ88_2_BB(to);
new->bb[OPPONENT(color)][PIECETOBB(captured)] ^= SQ88_2_BB(to);
} else {
uchar ep_file = F88(pos->en_passant); uchar ep_file = F88(pos->en_passant);
square_t ep_grab = color == WHITE ? SQ88(ep_file, 4): SQ88(ep_file, 3); square_t ep_grab = color == WHITE ? SQ88(ep_file, 4): SQ88(ep_file, 3);
log_f(1, "en-passant=%d,%d\n", ep_file, color == WHITE ? 4 : 3); u64 bb_ep_grab = SQ88_2_BB(ep_grab);
log_f(5, "en-passant=%d,%d\n", ep_file, color == WHITE ? 4 : 3);
piece_del(&new->board[ep_grab].s_piece->list); piece_del(&new->board[ep_grab].s_piece->list);
new->board[ep_grab].piece = 0; new->board[ep_grab].piece = 0;
new->occupied[OPPONENT(color)] ^= SQ88_2_BB(ep_grab); new->occupied[OPPONENT(color)] &= ~bb_ep_grab;
new->bb[OPPONENT(color)][BB_PAWN] ^= SQ88_2_BB(ep_grab); new->bb[OPPONENT(color)][BB_PAWN] &= ~bb_ep_grab;
} else {
piece_del(&new->board[to].s_piece->list);
new->board[to].piece = 0;
new->occupied[OPPONENT(color)] &= ~bb_to;
new->bb[OPPONENT(color)][PIECETOBB(captured)] &= ~bb_to;
} }
} else if (move->flags & M_CASTLE_Q) { } else if (move->flags & M_CASTLE_Q) {
uchar row = R88(from); uchar row = R88(from);
square_t rook_from = SQ88(0, row); square_t rook_from = SQ88(0, row);
square_t rook_to = SQ88(3, row); square_t rook_to = SQ88(3, row);
u64 bb_rook_from = SQ88_2_BB(rook_from);
u64 bb_rook_to = SQ88_2_BB(rook_to);
new->board[rook_to] = new->board[rook_from]; new->board[rook_to] = new->board[rook_from];
new->board[rook_to].s_piece->square = rook_to; new->board[rook_to].s_piece->square = rook_to;
new->occupied[color] ^= SQ88_2_BB(rook_from); new->occupied[color] &= ~bb_rook_from;
new->occupied[color] |= SQ88_2_BB(rook_to); new->occupied[color] |= bb_rook_to;
new->bb[color][PIECETOBB(BB_ROOK)] ^= SQ88_2_BB(rook_from); new->bb[color][PIECETOBB(BB_ROOK)] &= ~bb_rook_from;
new->bb[color][PIECETOBB(BB_ROOK)] |= SQ88_2_BB(rook_to); new->bb[color][PIECETOBB(BB_ROOK)] |= bb_rook_to;
new->board[rook_from].piece = 0; new->board[rook_from].piece = 0;
new->board[rook_from].s_piece = NULL; new->board[rook_from].s_piece = NULL;
//new->castle &= color == WHITE? ~CASTLE_W: ~CASTLE_B;
} else if (move->flags & M_CASTLE_K) { } else if (move->flags & M_CASTLE_K) {
uchar row = R88(from); uchar row = R88(from);
square_t rook_from = SQ88(7, row); square_t rook_from = SQ88(7, row);
square_t rook_to = SQ88(5, row); square_t rook_to = SQ88(5, row);
u64 bb_rook_from = SQ88_2_BB(rook_from);
u64 bb_rook_to = SQ88_2_BB(rook_to);
new->board[rook_to] = new->board[rook_from]; new->board[rook_to] = new->board[rook_from];
new->board[rook_to].s_piece->square = rook_to; new->board[rook_to].s_piece->square = rook_to;
new->occupied[color] ^= SQ88_2_BB(rook_from); new->occupied[color] &= ~bb_rook_from;
new->occupied[color] |= SQ88_2_BB(rook_to); new->occupied[color] |= bb_rook_to;
new->bb[color][PIECETOBB(BB_ROOK)] ^= SQ88_2_BB(rook_from); new->bb[color][PIECETOBB(BB_ROOK)] &= ~bb_rook_from;
new->bb[color][PIECETOBB(BB_ROOK)] |= SQ88_2_BB(rook_to); new->bb[color][PIECETOBB(BB_ROOK)] |= bb_rook_to;
new->board[rook_from].piece = 0; new->board[rook_from].piece = 0;
new->board[rook_from].s_piece = NULL; new->board[rook_from].s_piece = NULL;
// new->castle &= color == WHITE? ~CASTLE_W: ~CASTLE_B;
} }
new->board[to] = new->board[from]; new->board[to] = new->board[from];
/* fix dest square */ /* fix dest square */
new->board[to].s_piece->square = to; new->board[to].s_piece->square = to;
if (move->flags & M_PROMOTION) { if (move->flags & M_PROMOTION) {
log(2, "promotion to %s\n", P_SYM(move->promotion)); log_f(5, "promotion to %s\n", P_SYM(move->promotion));
printf("newpiece=%#x p=%#x\n", move->promotion, PIECE(move->promotion)); log_f(5, "newpiece=%#x p=%#x\n", move->promotion, PIECE(move->promotion));
newpiece = PIECE(move->promotion); newpiece = PIECE(move->promotion);
new->board[to].piece = move->promotion; new->board[to].piece = move->promotion;
new->board[to].s_piece->piece = move->promotion; new->board[to].s_piece->piece = move->promotion;
} }
/* replace old occupied bitboard by new one */ /* replace old occupied bitboard by new one */
new->occupied[color] ^= SQ88_2_BB(from); new->occupied[color] &= ~bb_from;
new->occupied[color] |= SQ88_2_BB(to); new->occupied[color] |= bb_to;
new->bb[color][PIECETOBB(piece)] ^= SQ88_2_BB(from); new->bb[color][PIECETOBB(piece)] &= ~bb_from;
new->bb[color][PIECETOBB(newpiece)] |= SQ88_2_BB(to); new->bb[color][PIECETOBB(newpiece)] |= bb_to;
if (move->flags & M_PROMOTION) { if (move->flags & M_PROMOTION) {
printf("color=%d bbpiece=%d\n", color, PIECETOBB(newpiece)); log_f(5, "promotion color=%d bbpiece=%d\n", color, PIECETOBB(newpiece));
bitboard_print(new->bb[color][PIECETOBB(newpiece)]); //bitboard_print(new->bb[color][PIECETOBB(newpiece)]);
}
/* set en_passant */
new->en_passant = 0;
if (piece == PAWN) {
if (R88(from) == 1 && R88(to) == 3)
pos->en_passant = SQ88(F88(from), 2);
else if (R88(from) == 6 && R88(to) == 4)
pos->en_passant = SQ88(F88(from), 5);
} }
/* always make "from" square empty */ /* always make "from" square empty */
new->board[from].piece = 0; new->board[from].piece = 0;
new->board[from].s_piece = NULL; new->board[from].s_piece = NULL;
//printf("old turn=%d ", color);
SET_COLOR(new->turn, OPPONENT(color)); /* pos color */ SET_COLOR(new->turn, OPPONENT(color)); /* pos color */
//printf("new turn=%d\n", new->turn);
//fflush(stdout);
/* adjust castling flags */
if ((bb_from | bb_to) & (A1 | E1))
new->castle &= ~CASTLE_WQ;
else if ((bb_from | bb_to) & (E1 | H1))
new->castle &= ~CASTLE_WK;
else if ((bb_from | bb_to) & (A8 | E8))
new->castle &= ~CASTLE_BQ;
else if ((bb_from | bb_to) & (E8 | H8))
new->castle &= ~CASTLE_BK;
return new; return new;
} }

View File

@@ -30,7 +30,7 @@ eval_t negamax(pos_t *pos, int depth, int color)
pos_t *newpos; pos_t *newpos;
eval_t best = EVAL_MIN, score; eval_t best = EVAL_MIN, score;
printf("depth=%d\n", depth); //printf("depth=%d\n", depth);
moves_gen_all(pos); moves_gen_all(pos);
//pos_check(pos); //pos_check(pos);
if (depth == 0) { if (depth == 0) {
@@ -40,9 +40,14 @@ eval_t negamax(pos_t *pos, int depth, int color)
//printf(" --> evalnega=%d\n", score); //printf(" --> evalnega=%d\n", score);
return score; return score;
} }
moves_print(pos, 0); //moves_print(pos, 0);
list_for_each_entry(move, &pos->moves[pos->turn], list) { list_for_each_entry(move, &pos->moves[pos->turn], list) {
log(1, "%.*s", 5 - depth, " ");
newpos = move_do(pos, move); newpos = move_do(pos, move);
//move_print(0, move, 0);
//printf("color piece = %d\n", COLOR(move->piece));
//printf("turns=%d/%d\n", pos->turn, newpos->turn);
//fflush(stdout);
score = -negamax(newpos, depth - 1, -color); score = -negamax(newpos, depth - 1, -color);
move->negamax = score; move->negamax = score;
//printf("move="); //printf("move=");