From: Marco Costalba Date: Sat, 9 Oct 2010 12:20:49 +0000 (+0100) Subject: Rearrange pawn penalities arrays X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=a0474a72a658d59c7e2b3b8171b737dec71b624c Rearrange pawn penalities arrays A clean up that is also a prerequisite for next patches. No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/pawns.cpp b/src/pawns.cpp index 9a0059dc..4cd1a316 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -40,23 +40,26 @@ namespace { #define S(mg, eg) make_score(mg, eg) - // Doubled pawn penalty by file - const Score DoubledPawnPenalty[8] = { - S(13, 43), S(20, 48), S(23, 48), S(23, 48), - S(23, 48), S(23, 48), S(20, 48), S(13, 43) - }; - - // Isolated pawn penalty by file - const Score IsolatedPawnPenalty[8] = { - S(25, 30), S(36, 35), S(40, 35), S(40, 35), - S(40, 35), S(40, 35), S(36, 35), S(25, 30) - }; - - // Backward pawn penalty by file - const Score BackwardPawnPenalty[8] = { - S(20, 28), S(29, 31), S(33, 31), S(33, 31), - S(33, 31), S(33, 31), S(29, 31), S(20, 28) - }; + // Doubled pawn penalty by opposed flag and file + const Score DoubledPawnPenalty[2][8] = { + { S(13, 43), S(20, 48), S(23, 48), S(23, 48), + S(23, 48), S(23, 48), S(20, 48), S(13, 43) }, + { S(13, 43), S(20, 48), S(23, 48), S(23, 48), + S(23, 48), S(23, 48), S(20, 48), S(13, 43) }}; + + // Isolated pawn penalty by opposed flag and file + const Score IsolatedPawnPenalty[2][8] = { + { S(37, 45), S(54, 52), S(60, 52), S(60, 52), + S(60, 52), S(60, 52), S(54, 52), S(37, 45) }, + { S(25, 30), S(36, 35), S(40, 35), S(40, 35), + S(40, 35), S(40, 35), S(36, 35), S(25, 30) }}; + + // Backward pawn penalty by opposed flag and file + const Score BackwardPawnPenalty[2][8] = { + { S(30, 42), S(43, 46), S(49, 46), S(49, 46), + S(49, 46), S(49, 46), S(43, 46), S(30, 42) }, + { S(20, 28), S(29, 31), S(33, 31), S(33, 31), + S(33, 31), S(33, 31), S(29, 31), S(20, 28) }}; // Pawn chain membership bonus by file const Score ChainBonus[8] = { @@ -223,20 +226,14 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, // Score this pawn if (isolated) - { - value -= IsolatedPawnPenalty[f]; - if (!opposed) - value -= IsolatedPawnPenalty[f] / 2; - } + value -= IsolatedPawnPenalty[opposed][f]; + if (doubled) - value -= DoubledPawnPenalty[f]; + value -= DoubledPawnPenalty[opposed][f]; if (backward) - { - value -= BackwardPawnPenalty[f]; - if (!opposed) - value -= BackwardPawnPenalty[f] / 2; - } + value -= BackwardPawnPenalty[opposed][f]; + if (chain) value += ChainBonus[f]; @@ -246,4 +243,3 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, return value; } -