From bb13eae0b843e28b5397a16798711ba7080aa1a4 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Fri, 28 Jun 2024 11:44:38 +0200 Subject: [PATCH] move-do: save move in state, pos-print: print last move --- src/move-do.c | 2 ++ src/position.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/move-do.c b/src/move-do.c index 9f57160..16cf79c 100644 --- a/src/move-do.c +++ b/src/move-do.c @@ -70,6 +70,7 @@ pos_t *move_do(pos_t *pos, const move_t move, state_t *state) pos->en_passant = SQUARE_NONE; pos->turn = them; pos->captured = captured; + pos->move = move; bug_on(COLOR(piece) != us); @@ -237,6 +238,7 @@ pos_t *move_do_alt(pos_t *pos, const move_t move, state_t *state) pos->en_passant = SQUARE_NONE; pos->turn = them; pos->captured = captured; + pos->move = move; bug_on(COLOR(piece) != us); diff --git a/src/position.c b/src/position.c index a91112f..aa1d839 100644 --- a/src/position.c +++ b/src/position.c @@ -108,6 +108,7 @@ pos_t *pos_clear(pos_t *pos) pos->castle = 0; pos->clock_50 = 0; pos->plycount = 0; + pos->move = MOVE_NONE; pos->captured = NO_PIECE; for (square_t sq = A1; sq <= H8; ++sq) @@ -430,8 +431,9 @@ void pos_print(const pos_t *pos) char str[128]; board_print(pos->board); - printf("key:%lx (#%lx)", pos->key, hash_short(pos->key)); printf("fen: %s\n", pos2fen(pos, str)); + printf("last move:%s ", move_to_str(str, pos->move, 0)); + printf("key:%lx", pos->key); printf("checkers:%s ", pos_checkers2str(pos, str, sizeof(str))); printf("pinners: %s ", pos_pinners2str(pos, str, sizeof(str))); printf("blockers: %s\n", pos_blockers2str(pos, str, sizeof(str)));