From e67def979d95a6375134a58c3978496bd325205a Mon Sep 17 00:00:00 2001 From: Andrey Sofronov Date: Thu, 4 Nov 2010 06:06:53 +0200 Subject: [PATCH] evaluation: fixed again (I hope!) a bug in candidate passers --- evaluate.c | 50 ++++++++++++++++++++++++-------------------------- extensions.c | 3 +-- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/evaluate.c b/evaluate.c index f21dc8c..9f115f1 100644 --- a/evaluate.c +++ b/evaluate.c @@ -341,6 +341,8 @@ evaluate_pawns(int side) int xside; int passed; + int next_square; + int candidate; int side_defenders, xside_attackers; struct pawn_hash_entry_t *phe; @@ -372,7 +374,7 @@ evaluate_pawns(int side) score_op += passer_score_op[rank_flip[side][_RANK(square)]]; score_eg += passer_score_eg[rank_flip[side][_RANK(square)]]; - int next_square = side? square - 8 : square + 8; + next_square = side? square - 8 : square + 8; if ((BIT(next_square) & complete) || (pawn_moves[side][next_square] & PAWNS(xside))) score_eg -= passer_score_eg[rank_flip[side][_RANK(square)]] / 3; @@ -383,31 +385,28 @@ evaluate_pawns(int side) } else if (!(forward_ray[side][square] & PAWNS(xside))) { /* no opponent's pawns on the same file */ + candidate = TRUE; + uint64_t candidate_way = forward_ray[side][square] | + BIT(square); + + while (candidate_way) { + next_square = bit_scan_clear(&candidate_way); + + if (rank_flip[side][_RANK(next_square)] == 7) + break; + + if (popcount(pawn_moves[xside][next_square] & PAWNS(xside)) > + popcount(pawn_moves[side][next_square] & PAWNS(side))) { + candidate = FALSE; + break; + } + } + + if (candidate) { + score_op += can_passed_score_op[rank_flip[side][_RANK(square)]]; + score_eg += can_passed_score_eg[rank_flip[side][_RANK(square)]]; + } - /* how many pawns defend our candidate */ - side_defenders = popcount(pawn_moves[side][square] & - PAWNS(xside)); - /* how many pawns attack our candidate */ - xside_attackers = popcount(pawn_moves[side][square] & \ - PAWNS(xside)); - - if (xside_attackers <= side_defenders) { - /* pawn is well protected */ - - /* how many pawns can support our candidate */ - side_defenders = popcount((passer_mask[xside][square - \ - (side == WHITE? 8 : -8)] & \ - isolated_mask[_FILE(square)]) & PAWNS(side)); - /* how many pawns can stop our candidate */ - xside_attackers = popcount(passer_mask[side][square] & \ - PAWNS(xside)); - - if (xside_attackers <= side_defenders) { - /* true passed pawn candidate */ - score_op += can_passed_score_op[rank_flip[side][_RANK(square)]]; - score_eg += can_passed_score_eg[rank_flip[side][_RANK(square)]]; - } - } } } if (isolated_mask[_FILE(square)] & PAWNS(side)) { @@ -592,7 +591,6 @@ evaluate_knights(int side) if (pawn_moves[xside][square] & PAWNS(side)) { /* knight is supported by our pawn */ position_score[OPENING][side] += knight_outpost[side][square]; - position_score[ENDGAME][side] += knight_outpost[side][square]; } /* calculate mobility */ diff --git a/extensions.c b/extensions.c index 7b98cf4..2f8db11 100644 --- a/extensions.c +++ b/extensions.c @@ -45,8 +45,7 @@ get_extensions(int move, int in_check, int move_is_check, int depth, int ply) /* don't reduce passed pawn moves */ if (square64[GET_TO(move)] == PAWN) - if (!(PAWNS(brd.wtm) & passer_mask[1 ^ brd.wtm][GET_TO(move) + \ - (brd.wtm ? -8 : 8)])) + if (!(PAWNS(brd.wtm) & passer_mask[1 ^ brd.wtm][GET_TO(move)])) return 0; #ifdef STATISTIC_COUNTERS -- 2.11.4.GIT