Skip to content

Commit

Permalink
Bench: 3511579
Browse files Browse the repository at this point in the history
  • Loading branch information
ElbertoOne committed Jan 24, 2019
1 parent d20458f commit 5a7f074
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,16 +626,25 @@ namespace {
int r = relative_rank(Us, s);

Score bonus = PassedRank[r];
Square blockSq = s + Up;

if (r > RANK_3)
{
int w = (r-2) * (r-2) + 2;
Square blockSq = s + Up;

// Adjust bonus based on the king's proximity
bonus += make_score(0, ( king_proximity(Them, blockSq) * 5
- king_proximity(Us, blockSq) * 2) * w);

bool supportingMinors = pos.count<KNIGHT>(Us) > 0 || pos.count<BISHOP>(Us) == 2;
if (!supportingMinors && pos.count<BISHOP>(Us) == 1)
{
File f = file_of(blockSq);
Square queeningSq = make_square(f, Us == WHITE ? RANK_8 : RANK_1);
Square sb = pos.square<BISHOP>(Us);
supportingMinors = !opposite_colors(queeningSq, sb);
}

// If blockSq is not the queening square then consider also a second push
if (r != RANK_7)
bonus -= make_score(0, king_proximity(Us, blockSq + Up) * w);
Expand Down Expand Up @@ -668,8 +677,13 @@ namespace {
else if (defendedSquares & blockSq)
k += 4;

if (k > 0 && !supportingMinors)
k -= 2;

bonus += make_score(k * w, k * w);
}
else if (!supportingMinors) //block square is occupied and there are no minors to help reach the queening square
bonus = bonus / 2;
} // rank > RANK_3


Expand All @@ -678,23 +692,6 @@ namespace {
if ( !pos.pawn_passed(Us, s + Up)
|| (pos.pieces(PAWN) & forward_file_bb(Us, s)))
bonus = bonus / 2;
// Scale down bonus if queening square is defended and there are no minors that could help with queening
else if (r == RANK_7 && !pos.pieces(Us, KNIGHT) && ((attackedBy[Them][ALL_PIECES] | pos.pieces(Them)) & blockSq))
{
bool hasBishops = false;
Bitboard bbs = pos.pieces(Us, BISHOP);
while (bbs)
{
Square sb = pop_lsb(&bbs);
if (!opposite_colors(blockSq, sb))
{
hasBishops = true;
break;
}
}
if (!hasBishops)
bonus = bonus / 2;
}

score += bonus + PassedFile[file_of(s)];
}
Expand Down

0 comments on commit 5a7f074

Please sign in to comment.