From 48b542083037c61562b613366dc1f75be4406e51 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Tue, 25 Jul 2023 06:54:33 +0200 Subject: [PATCH] Add check array in position structure --- src/eval.h | 4 ++-- src/move.c | 5 +++++ src/position.c | 2 ++ src/position.h | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/eval.h b/src/eval.h index 39dd577..de16353 100644 --- a/src/eval.h +++ b/src/eval.h @@ -21,12 +21,12 @@ /* max pieces eval is KING_VALUE + 9*QUEEN_VALUE + 2*ROOK_VALUE + 2*BISHOP_VALUE * + 2*KNIGHT_VALUE which around 30000. - * We are on secure sire with -50000/+50000 + * We are on secure side with -50000/+50000 */ - #define EVAL_MAX (50000) #define EVAL_MIN (-EVAL_MAX) #define EVAL_INVALID INT_MIN +#define EVAL_MATE EVAL_MAX eval_t eval_material(pos_t *pos, bool color); eval_t eval_mobility(pos_t *pos, bool color); diff --git a/src/move.c b/src/move.c index 2a24eb5..dd5251c 100644 --- a/src/move.c +++ b/src/move.c @@ -198,6 +198,9 @@ static move_t *move_add(pos_t *pos, piece_t piece, square_t from, move->from = from; move->to = to; move->capture = board[to].piece; + if (PIECE(move->capture) == KING) + pos->check[color]++; + move->flags = M_NORMAL; if (move->capture) move->flags |= M_CAPTURE; @@ -386,6 +389,8 @@ int pseudo_moves_pawn(pos_t *pos, piece_list_t *ppiece, bool doit) continue; pos->controlled[color] |= SQ88_2_BB(new); if (board[new].piece && COLOR(board[new].piece) != color) { + if (PIECE(board[new].piece) == KING) + pos->check[color]++; //log_f(2, "pawn capture mobility\n"); pos->mobility[color]++; count++; diff --git a/src/position.c b/src/position.c index 88e9936..051d174 100644 --- a/src/position.c +++ b/src/position.c @@ -271,6 +271,7 @@ pos_t *pos_get() * - nodecount is set to zero * - eval is set to EVAL_INVALID * - moves_generated ans moves_counted are unset + * - check is set to zero * * @return: The new position. * @@ -303,6 +304,7 @@ pos_t *pos_dup(pos_t *pos) new->eval = EVAL_INVALID; new->moves_generated = false; new->moves_counted = false; + new->check[WHITE] = new->check[BLACK] = 0; } return new; } diff --git a/src/position.h b/src/position.h index 6486c7f..c39200e 100644 --- a/src/position.h +++ b/src/position.h @@ -29,6 +29,7 @@ typedef struct pos_s { u16 clock_50; u16 curmove; eval_t eval; + int check[2]; int eval_simple_phase; eval_t eval_simple; move_t *bestmove;