From 93f3c1e2ca701a9058cec9b5c3c102db4f2202e7 Mon Sep 17 00:00:00 2001 From: ProgramciDusunur Date: Sat, 1 Feb 2025 21:42:25 +0300 Subject: [PATCH 1/2] add winnable heuristic --- src/evaluation.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/evaluation.c b/src/evaluation.c index 6ab52f56..8c9b6a26 100644 --- a/src/evaluation.c +++ b/src/evaluation.c @@ -276,6 +276,9 @@ int evaluate(board* position) { // penalties //int double_pawns = 0; + // passer pawn count + int passedPawnCount = 0; + // loop over piece bitboards for (int bb_piece = P; bb_piece <= k; bb_piece++) { // init piece bitboard copy @@ -351,6 +354,7 @@ int evaluate(board* position) { if ((whitePassedMasks[square] & position->bitboards[p]) == 0) { // give passed pawn bonus if (game_phase == endgame) { + passedPawnCount += 1; int whiteKingDistance = (getLS1BIndex(position->bitboards[K]) - square) / 8; int blackKingDistance = (getLS1BIndex(position->bitboards[k]) - square) / 8; @@ -508,6 +512,8 @@ int evaluate(board* position) { if ((blackPassedMasks[square] & position->bitboards[P]) == 0) { // give passed pawn bonus if (game_phase == endgame) { + passedPawnCount -= 1; + int whiteKingDistance = (getLS1BIndex(position->bitboards[K]) - square) / 8; int blackKingDistance = (getLS1BIndex(position->bitboards[k]) - square) / 8; int kingDistance = whiteKingDistance - blackKingDistance; @@ -631,6 +637,21 @@ int evaluate(board* position) { popBit(bitboard, square); } } + + int infiltriation = 0; + if (!position->side && get_rank[getLS1BIndex(position->bitboards[K])] > 5) { + infiltriation = 20; + } else if (position->side && get_rank[getLS1BIndex(position->bitboards[k])] < 2) { + infiltriation = -20; + } + // winnable + int winnableScore = 6 * passedPawnCount + + 8 * (countBits(position->bitboards[P]) - countBits(position->bitboards[p])) + + infiltriation + ; + score += winnableScore; + + int tempo = 10; // return final evaluation based on side return (position->side == white) ? score + tempo : -(score - tempo); From 7267114cc6272b083bc151a4e6d0de612d2b8cb9 Mon Sep 17 00:00:00 2001 From: ProgramciDusunur Date: Sat, 1 Feb 2025 21:42:31 +0300 Subject: [PATCH 2/2] bench: 10738152 --- src/evaluation.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/evaluation.c b/src/evaluation.c index 8c9b6a26..d30944b1 100644 --- a/src/evaluation.c +++ b/src/evaluation.c @@ -651,7 +651,6 @@ int evaluate(board* position) { ; score += winnableScore; - int tempo = 10; // return final evaluation based on side return (position->side == white) ? score + tempo : -(score - tempo);