1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-12 03:59:15 +00:00

Rename pawn chain to connected

The flag raises also in case of a pawn duo, i.e.
when we have two adjacent pawns on the same rank,
and not only in case of a chain, i.e. when the two
pawns are on a diagonal line.

See this for a reference:
http://en.wikipedia.org/wiki/Connected_pawns

Renaming suggested by Ralph.

No functional change.
This commit is contained in:
Marco Costalba 2014-01-01 10:50:30 +01:00
parent 9b1d594456
commit c5d478b923

View file

@ -49,8 +49,8 @@ namespace {
{ S(20, 28), S(29, 31), S(33, 31), S(33, 31), { S(20, 28), S(29, 31), S(33, 31), S(33, 31),
S(33, 31), S(33, 31), S(29, 31), S(20, 28) } }; S(33, 31), S(33, 31), S(29, 31), S(20, 28) } };
// Pawn chain membership bonus by file and rank (initialized by formula) // Connected pawn bonus by file and rank (initialized by formula)
Score ChainMember[FILE_NB][RANK_NB]; Score Connected[FILE_NB][RANK_NB];
// Candidate passed pawn bonus by rank // Candidate passed pawn bonus by rank
const Score CandidatePassed[RANK_NB] = { const Score CandidatePassed[RANK_NB] = {
@ -89,7 +89,7 @@ namespace {
Bitboard b; Bitboard b;
Square s; Square s;
File f; File f;
bool passed, isolated, doubled, opposed, chain, backward, candidate; bool passed, isolated, doubled, opposed, connected, backward, candidate;
Score value = SCORE_ZERO; Score value = SCORE_ZERO;
const Square* pl = pos.list<PAWN>(Us); const Square* pl = pos.list<PAWN>(Us);
@ -113,22 +113,22 @@ namespace {
// This file cannot be semi-open // This file cannot be semi-open
e->semiopenFiles[Us] &= ~(1 << f); e->semiopenFiles[Us] &= ~(1 << f);
// Our rank plus previous one. Used for chain detection // Our rank plus previous one
b = rank_bb(s) | rank_bb(s - pawn_push(Us)); b = rank_bb(s) | rank_bb(s - pawn_push(Us));
// Flag the pawn as passed, isolated, doubled or member of a pawn // Flag the pawn as passed, isolated, doubled or
// chain (but not the backward one). // connected (but not the backward one).
chain = ourPawns & adjacent_files_bb(f) & b; connected = ourPawns & adjacent_files_bb(f) & b;
isolated = !(ourPawns & adjacent_files_bb(f)); isolated = !(ourPawns & adjacent_files_bb(f));
doubled = ourPawns & forward_bb(Us, s); doubled = ourPawns & forward_bb(Us, s);
opposed = theirPawns & forward_bb(Us, s); opposed = theirPawns & forward_bb(Us, s);
passed = !(theirPawns & passed_pawn_mask(Us, s)); passed = !(theirPawns & passed_pawn_mask(Us, s));
// Test for backward pawn. // Test for backward pawn.
// If the pawn is passed, isolated, or member of a pawn chain it cannot // If the pawn is passed, isolated, or connected it cannot be
// be backward. If there are friendly pawns behind on adjacent files // backward. If there are friendly pawns behind on adjacent files
// or if it can capture an enemy pawn it cannot be backward either. // or if it can capture an enemy pawn it cannot be backward either.
if ( (passed | isolated | chain) if ( (passed | isolated | connected)
|| (ourPawns & pawn_attack_span(Them, s)) || (ourPawns & pawn_attack_span(Them, s))
|| (pos.attacks_from<PAWN>(s, Us) & theirPawns)) || (pos.attacks_from<PAWN>(s, Us) & theirPawns))
backward = false; backward = false;
@ -172,8 +172,8 @@ namespace {
if (backward) if (backward)
value -= Backward[opposed][f]; value -= Backward[opposed][f];
if (chain) if (connected)
value += ChainMember[f][relative_rank(Us, s)]; value += Connected[f][relative_rank(Us, s)];
if (candidate) if (candidate)
{ {
@ -203,14 +203,14 @@ namespace Pawns {
void init() { void init() {
const int chainByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 }; const int bonusesByFile[8] = { 1, 3, 3, 4, 4, 3, 3, 1 };
int bonus; int bonus;
for (Rank r = RANK_1; r < RANK_8; ++r) for (Rank r = RANK_1; r < RANK_8; ++r)
for (File f = FILE_A; f <= FILE_H; ++f) for (File f = FILE_A; f <= FILE_H; ++f)
{ {
bonus = r * (r-1) * (r-2) + chainByFile[f] * (r/2 + 1); bonus = r * (r-1) * (r-2) + bonusesByFile[f] * (r/2 + 1);
ChainMember[f][r] = make_score(bonus, bonus); Connected[f][r] = make_score(bonus, bonus);
} }
} }