1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Score unopposed weak pawns only if majors

Do not use the opposed flag for scoring backward and isolated pawns
in pawns.cpp, instead give a S(5,25) bonus for each opponent unopposed
weak pawns when we have a rook or a queen on the board.

STC run stopped after 113188 games:
LLR: 1.63 (-2.94,2.94) [0.00,5.00]
Total: 113188 W: 20804 L: 20251 D: 72133
http://tests.stockfishchess.org/tests/view/59b58e4d0ebc5916ff64b12e

LTC:
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 66673 W: 8672 L: 8341 D: 49660
http://tests.stockfishchess.org/tests/view/59b902580ebc5916ff64b231

This is Alain Savard's idea, just with a different bonus.
Original patch there:

green STC, http://tests.stockfishchess.org/tests/view/597dcd2b0ebc5916ff64a09b
yellow LTC, http://tests.stockfishchess.org/tests/view/597ea69e0ebc5916ff64a0e6

Bench: 6259498
This commit is contained in:
Stéphane Nicolet 2017-09-16 14:07:41 +02:00 committed by Marco Costalba
parent 21926ce2d8
commit 043a469f83
4 changed files with 17 additions and 10 deletions

View file

@ -162,8 +162,8 @@ namespace {
// supported by a pawn. If the minor piece occupies an outpost square // supported by a pawn. If the minor piece occupies an outpost square
// then score is doubled. // then score is doubled.
const Score Outpost[][2] = { const Score Outpost[][2] = {
{ S(22, 6), S(33, 9) }, // Knight { S(22, 6), S(36,12) }, // Knight
{ S( 9, 2), S(14, 4) } // Bishop { S( 9, 2), S(15, 5) } // Bishop
}; };
// RookOnFile[semiopen/open] contains bonuses for each rook when there is no // RookOnFile[semiopen/open] contains bonuses for each rook when there is no
@ -214,6 +214,7 @@ namespace {
const Score ThreatBySafePawn = S(182,175); const Score ThreatBySafePawn = S(182,175);
const Score ThreatByRank = S( 16, 3); const Score ThreatByRank = S( 16, 3);
const Score Hanging = S( 48, 27); const Score Hanging = S( 48, 27);
const Score WeakUnopposedPawn = S( 5, 25);
const Score ThreatByPawnPush = S( 38, 22); const Score ThreatByPawnPush = S( 38, 22);
const Score HinderPassedPawn = S( 7, 0); const Score HinderPassedPawn = S( 7, 0);
const Score TrappedBishopA1H1 = S( 50, 50); const Score TrappedBishopA1H1 = S( 50, 50);
@ -593,6 +594,10 @@ namespace {
score += ThreatByKing[more_than_one(b)]; score += ThreatByKing[more_than_one(b)];
} }
// Bonus for opponent unopposed weak pawns
if (pos.pieces(Us, ROOK, QUEEN))
score += WeakUnopposedPawn * pe->weak_unopposed(Them);
// Find squares where our pawns can push on the next move // Find squares where our pawns can push on the next move
b = shift<Up>(pos.pieces(Us, PAWN)) & ~pos.pieces(); b = shift<Up>(pos.pieces(Us, PAWN)) & ~pos.pieces();
b |= shift<Up>(b & TRank3BB) & ~pos.pieces(); b |= shift<Up>(b & TRank3BB) & ~pos.pieces();

View file

@ -31,11 +31,11 @@ namespace {
#define V Value #define V Value
#define S(mg, eg) make_score(mg, eg) #define S(mg, eg) make_score(mg, eg)
// Isolated pawn penalty by opposed flag // Isolated pawn penalty
const Score Isolated[] = { S(27, 30), S(13, 18) }; const Score Isolated = S(13, 18);
// Backward pawn penalty by opposed flag // Backward pawn penalty
const Score Backward[] = { S(40, 26), S(24, 12) }; const Score Backward = S(24, 12);
// Connected pawn bonus by opposed, phalanx, #support and rank // Connected pawn bonus by opposed, phalanx, #support and rank
Score Connected[2][2][3][RANK_NB]; Score Connected[2][2][3][RANK_NB];
@ -109,7 +109,7 @@ namespace {
Bitboard ourPawns = pos.pieces( Us, PAWN); Bitboard ourPawns = pos.pieces( Us, PAWN);
Bitboard theirPawns = pos.pieces(Them, PAWN); Bitboard theirPawns = pos.pieces(Them, PAWN);
e->passedPawns[Us] = e->pawnAttacksSpan[Us] = 0; e->passedPawns[Us] = e->pawnAttacksSpan[Us] = e->weakUnopposed[Us] = 0;
e->semiopenFiles[Us] = 0xFF; e->semiopenFiles[Us] = 0xFF;
e->kingSquares[Us] = SQ_NONE; e->kingSquares[Us] = SQ_NONE;
e->pawnAttacks[Us] = shift<Right>(ourPawns) | shift<Left>(ourPawns); e->pawnAttacks[Us] = shift<Right>(ourPawns) | shift<Left>(ourPawns);
@ -177,10 +177,10 @@ namespace {
score += Connected[opposed][!!phalanx][popcount(supported)][relative_rank(Us, s)]; score += Connected[opposed][!!phalanx][popcount(supported)][relative_rank(Us, s)];
else if (!neighbours) else if (!neighbours)
score -= Isolated[opposed]; score -= Isolated, e->weakUnopposed[Us] += !opposed;
else if (backward) else if (backward)
score -= Backward[opposed]; score -= Backward, e->weakUnopposed[Us] += !opposed;
if (doubled && !supported) if (doubled && !supported)
score -= Doubled; score -= Doubled;

View file

@ -37,6 +37,7 @@ struct Entry {
Bitboard pawn_attacks(Color c) const { return pawnAttacks[c]; } Bitboard pawn_attacks(Color c) const { return pawnAttacks[c]; }
Bitboard passed_pawns(Color c) const { return passedPawns[c]; } Bitboard passed_pawns(Color c) const { return passedPawns[c]; }
Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; } Bitboard pawn_attacks_span(Color c) const { return pawnAttacksSpan[c]; }
int weak_unopposed(Color c) const { return weakUnopposed[c]; }
int pawn_asymmetry() const { return asymmetry; } int pawn_asymmetry() const { return asymmetry; }
int open_files() const { return openFiles; } int open_files() const { return openFiles; }
@ -71,6 +72,7 @@ struct Entry {
Bitboard pawnAttacksSpan[COLOR_NB]; Bitboard pawnAttacksSpan[COLOR_NB];
Square kingSquares[COLOR_NB]; Square kingSquares[COLOR_NB];
Score kingSafety[COLOR_NB]; Score kingSafety[COLOR_NB];
int weakUnopposed[COLOR_NB];
int castlingRights[COLOR_NB]; int castlingRights[COLOR_NB];
int semiopenFiles[COLOR_NB]; int semiopenFiles[COLOR_NB];
int pawnsOnSquares[COLOR_NB][COLOR_NB]; // [color][light/dark squares] int pawnsOnSquares[COLOR_NB][COLOR_NB]; // [color][light/dark squares]

View file

@ -111,7 +111,7 @@ void Thread::idle_loop() {
/// ThreadPool::init() creates and launches the threads that will go /// ThreadPool::init() creates and launches the threads that will go
/// immediately to sleep in idle_loop. We cannot use the c'tor because /// immediately to sleep in idle_loop. We cannot use the constructor because
/// Threads is a static object and we need a fully initialized engine at /// Threads is a static object and we need a fully initialized engine at
/// this point due to allocation of Endgames in the Thread constructor. /// this point due to allocation of Endgames in the Thread constructor.