Skip to content

Commit

Permalink
Merge pull request official-stockfish#530 from IIvec/master
Browse files Browse the repository at this point in the history
Good bishops on the main diagonals
  • Loading branch information
IIvec authored Oct 4, 2017
2 parents 0295b37 + 452e515 commit d3324b7
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@

namespace {

const Bitboard LongDiagonals = 0x8142241818244281ULL; // A1..H8 | H1..A8
const Bitboard Center = (FileDBB | FileEBB) & (Rank4BB | Rank5BB);
const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
const Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB;
const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;

const Bitboard KingFlank[FILE_NB] = {
QueenSide, QueenSide, QueenSide, CenterFiles, CenterFiles, KingSide, KingSide, KingSide
};

namespace Trace {

enum Tracing {NO_TRACE, TRACE};
Expand Down Expand Up @@ -204,6 +214,7 @@ namespace {
// Assorted bonuses and penalties used by evaluation
const Score MinorBehindPawn = S( 16, 0);
const Score BishopPawns = S( 8, 12);
const Score LongRangedBishop = S( 22, 0);
const Score RookOnPawn = S( 8, 24);
const Score TrappedRook = S( 92, 0);
const Score WeakQueen = S( 50, 10);
Expand Down Expand Up @@ -338,10 +349,18 @@ namespace {
&& (pos.pieces(PAWN) & (s + pawn_push(Us))))
score += MinorBehindPawn;

// Penalty for pawns on the same color square as the bishop
if (Pt == BISHOP)
{
// Penalty for pawns on the same color square as the bishop
score -= BishopPawns * pe->pawns_on_same_color_squares(Us, s);

// Bonus for bishop on a long diagonal without pawns in the center
if ( (LongDiagonals & s)
&& !(attackedBy[Them][PAWN] & s)
&& !(Center & PseudoAttacks[BISHOP][s] & pos.pieces(PAWN)))
score += LongRangedBishop;
}

// An important Chess960 pattern: A cornered bishop blocked by a friendly
// pawn diagonally in front of it is a very serious problem, especially
// when that pawn is also blocked.
Expand Down Expand Up @@ -396,14 +415,6 @@ namespace {

// evaluate_king() assigns bonuses and penalties to a king of a given color

const Bitboard QueenSide = FileABB | FileBBB | FileCBB | FileDBB;
const Bitboard CenterFiles = FileCBB | FileDBB | FileEBB | FileFBB;
const Bitboard KingSide = FileEBB | FileFBB | FileGBB | FileHBB;

const Bitboard KingFlank[FILE_NB] = {
QueenSide, QueenSide, QueenSide, CenterFiles, CenterFiles, KingSide, KingSide, KingSide
};

template<Tracing T> template<Color Us>
Score Evaluation<T>::evaluate_king() {

Expand Down

0 comments on commit d3324b7

Please sign in to comment.