# HG changeset patch # User Mike Becker # Date 1786962128 -7200 # Node ID 18dbb0dc9cd6aec26694b4d682315293e67389c4 # Parent ef8c39362342b9d0c903d986a4aada1b647d7284 fix FEN being off by one diff -r ef8c39362342 -r 18dbb0dc9cd6 src/chess/rules.c --- a/src/chess/rules.c Mon Aug 17 12:14:51 2026 +0200 +++ b/src/chess/rules.c Mon Aug 17 12:22:08 2026 +0200 @@ -397,11 +397,6 @@ Move *melem = &gamestate->moves[gamestate->movecount]; *melem = *move; - /* calculate the FEN and store it in the FEN array */ - char fen[FEN_MAX_LENGTH]; - fen_compute(fen, gamestate); - gamestate->fen[gamestate->movecount] = strdup(fen); - /* only if move has no time info, compute it */ if (melem->movetime.tv_sec == 0 && melem->movetime.tv_usec == 0) { calc_movetime(gamestate, melem); @@ -409,6 +404,11 @@ /* important: only "add" the move after calculating the time! */ gamestate->movecount++; + + /* calculate the FEN of the new position and store it in the FEN array */ + char fen[FEN_MAX_LENGTH]; + fen_compute(fen, gamestate); + gamestate->fen[gamestate->movecount - 1] = strdup(fen); } void apply_move(GameState *gamestate, Move *move) {