From 243fa483d7b329ad8512c86eb152cca7a0982674 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 23 Feb 2009 12:48:57 +0100 Subject: [PATCH] Small Position::clear() cleanup No functional change. Signed-off-by: Marco Costalba --- src/position.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 7c8399e0..cc0f42e9 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -23,8 +23,9 @@ //// #include -#include +#include #include +#include #include "mersenne.h" #include "movegen.h" @@ -1645,16 +1646,14 @@ int Position::see(Square from, Square to) const { void Position::clear() { st = &startState; - st->previous = NULL; // We should never dereference this + memset(st, 0, sizeof(StateInfo)); + st->epSquare = SQ_NONE; + + memset(index, 0, sizeof(int) * 64); + memset(byColorBB, 0, sizeof(Bitboard) * 2); for (int i = 0; i < 64; i++) - { board[i] = EMPTY; - index[i] = 0; - } - - for (int i = 0; i < 2; i++) - byColorBB[i] = EmptyBoardBB; for (int i = 0; i < 7; i++) { @@ -1664,21 +1663,11 @@ void Position::clear() { pieceList[0][i][j] = pieceList[1][i][j] = SQ_NONE; } - st->checkersBB = EmptyBoardBB; - for (Color c = WHITE; c <= BLACK; c++) - st->pinners[c] = st->pinned[c] = st->dcCandidates[c] = ~EmptyBoardBB; - sideToMove = WHITE; gamePly = 0; initialKFile = FILE_E; initialKRFile = FILE_H; initialQRFile = FILE_A; - - st->lastMove = MOVE_NONE; - st->castleRights = NO_CASTLES; - st->epSquare = SQ_NONE; - st->rule50 = 0; - st->previous = NULL; } -- 2.39.2