Permalink
Browse files

Merge pull request #6 from glinscott/undefended_pieces

Undefended pieces
  • Loading branch information...
2 parents eb28a68 + 8c8bd72 commit 6672b6ea8dec6f78a82daa8a97b06e925bae1b44 @mcostalba committed Mar 19, 2012
Showing with 13 additions and 5 deletions.
  1. +13 −5 src/evaluate.cpp
View
@@ -679,12 +679,20 @@ Value do_evaluate(const Position& pos, Value& margin) {
Bitboard b;
Score score = SCORE_ZERO;
- // Enemy pieces not defended by a pawn and under our attack
- Bitboard weakEnemies = pos.pieces(Them)
- & ~ei.attackedBy[Them][PAWN]
- & ei.attackedBy[Us][0];
+ // Enemy pieces not defended by a pawn
+ Bitboard weakEnemies = pos.pieces(Them) & ~ei.attackedBy[Them][PAWN];
+
+ // Undefended minors get penalized
+ const Bitboard undefended = weakEnemies
+ & ~ei.attackedBy[Them][0]
+ & (pos.pieces(BISHOP) | pos.pieces(KNIGHT));
+ if (undefended)
+ score += make_score(25, 10) * popcount<Max15>(undefended);
+
+ // Filter to enemy pieces attacked by us
+ weakEnemies &= ei.attackedBy[Us][0];
if (!weakEnemies)
- return SCORE_ZERO;
+ return score;
// Add bonus according to type of attacked enemy piece and to the
// type of attacking piece, from knights to queens. Kings are not

0 comments on commit 6672b6e

Please sign in to comment.