Skip to content

Commit

Permalink
Further simplification in evaluate
Browse files Browse the repository at this point in the history
No functional change
  • Loading branch information
mcostalba committed Apr 11, 2014
1 parent e3b5423 commit ce6b7a1
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/evaluate.cpp
Expand Up @@ -319,22 +319,15 @@ Value do_evaluate(const Position& pos) {
init_eval_info<WHITE>(pos, ei);
init_eval_info<BLACK>(pos, ei);

ei.attackedBy[WHITE][ALL_PIECES] |= ei.attackedBy[WHITE][KING];
ei.attackedBy[BLACK][ALL_PIECES] |= ei.attackedBy[BLACK][KING];

// Do not include in mobility squares protected by enemy pawns or occupied by our pieces
Bitboard mobilityArea[] = { ~(ei.attackedBy[BLACK][PAWN] | pos.pieces(WHITE, PAWN, KING)),
~(ei.attackedBy[WHITE][PAWN] | pos.pieces(BLACK, PAWN, KING)) };

// Evaluate pieces and mobility
score += evaluate_pieces<KNIGHT, WHITE, Trace>(pos, ei, mobility, mobilityArea);

// Sum up all attacked squares (updated in evaluate_pieces)
ei.attackedBy[WHITE][ALL_PIECES] = ei.attackedBy[WHITE][PAWN] | ei.attackedBy[WHITE][KNIGHT]
| ei.attackedBy[WHITE][BISHOP] | ei.attackedBy[WHITE][ROOK]
| ei.attackedBy[WHITE][QUEEN] | ei.attackedBy[WHITE][KING];

ei.attackedBy[BLACK][ALL_PIECES] = ei.attackedBy[BLACK][PAWN] | ei.attackedBy[BLACK][KNIGHT]
| ei.attackedBy[BLACK][BISHOP] | ei.attackedBy[BLACK][ROOK]
| ei.attackedBy[BLACK][QUEEN] | ei.attackedBy[BLACK][KING];

score += apply_weight(mobility[WHITE] - mobility[BLACK], Weights[Mobility]);

// Evaluate kings after all other pieces because we need complete attack
Expand Down Expand Up @@ -422,7 +415,7 @@ Value do_evaluate(const Position& pos) {
ei.pinnedPieces[Us] = pos.pinned_pieces(Us);

Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
ei.attackedBy[Us][ALL_PIECES] = ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);

// Init king safety tables only if we are going to use them
if (pos.count<QUEEN>(Us) && pos.non_pawn_material(Us) > QueenValueMg + PawnValueMg)
Expand Down Expand Up @@ -488,7 +481,7 @@ Value do_evaluate(const Position& pos) {
if (ei.pinnedPieces[Us] & s)
b &= LineBB[pos.king_square(Us)][s];

ei.attackedBy[Us][Pt] |= b;
ei.attackedBy[Us][ALL_PIECES] |= ei.attackedBy[Us][Pt] |= b;

if (b & ei.kingRing[Them])
{
Expand Down

0 comments on commit ce6b7a1

Please sign in to comment.