Point 2 - opposite colored bishops seems to be a material question.
1.
Code: Select all
template<Color Us, bool HasPopCnt>
void init_eval_info(const Position& pos, EvalInfo& ei) {
const Color Them = (Us == WHITE ? BLACK : WHITE);
Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
if ( pos.piece_count(Us, QUEEN))
{
ei.kingZone[Us] = (b | (Us == WHITE ? b >> 8 : b << 8));
b &= ei.attackedBy[Us][PAWN];
ei.kingAttackersCount[Us] = b ? count_1s_max_15<HasPopCnt>(b) / 2 : 0;
}
else
{
ei.kingZone[Us] = EmptyBoardBB;
ei.kingAttackersCount[Us] = 0;
}
}
template<Color Us, bool HasPopCnt>
Score evaluate_king(const Position& pos, EvalInfo& ei, Value& margin)
// King safety. This is quite complicated, and is almost certainly far
// from optimally tuned.
if ( ei.kingAttackersCount[Them] >= 2
&& pos.non_pawn_material(Us) >= QueenValueMidgame + RookValueMidgame
&& ei.kingAdjacentZoneAttacksCount[Them])
template<PieceType Piece, Color Us, bool HasPopCnt>
void evaluate_pieces(const Position& pos, EvalInfo& ei, Bitboard no_mob_area)
// King attacks
if (b & ei.kingZone[Us])
// next lines are omitted if ei.kingZone[Us] = EmptyBoardBB;
Code: Select all
MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos)
// Compute the space weight
--
// Check for opposite colored bishop endgames
if (pos.opposite_colored_bishops()) // moved from evaluate.cpp and changed
{
ScaleFactor sf;
// Only the two bishops ?
if (pos.non_pawn_material(WHITE) == BishopValueMidgame
&& pos.non_pawn_material(BLACK) == BishopValueMidgame
&& pos.piece_count(WHITE, PAWN) + pos.piece_count(BLACK, PAWN) == 1)
sf = ScaleFactor(8);
else
{
// the closer only B+B endgame the beter
Value sfx = Value( 2 * BishopValueMidgame * 32
/ int(pos.non_pawn_material(WHITE) + pos.non_pawn_material(BLACK)));
sf = ScaleFactor(SCALE_FACTOR_NORMAL - sfx);
}
mi->factor[WHITE] = sf;
mi->factor[BLACK] = sf;
}
// Evaluate the material balance
Why is ?
// Evaluate space for both sides, only in middle-game.
if (phase > PHASE_ENDGAME && mi->space_weight() > 0)
and not:
// Evaluate space for both sides, only in middle-game.
if (mi->space_weight() > 0)