ebonus += Value(square_distance(theirKingSq, blockSq) * 6 * tr);
// If the pawn is free to advance, increase bonus
- if (pos.square_is_empty(blockSq))
+ if (tr != 0 && pos.square_is_empty(blockSq))
{
b2 = squares_in_front_of(us, s);
b3 = b2 & ei.attacked_by(them);
// value if the other side has a rook or queen.
if (square_file(s) == FILE_A || square_file(s) == FILE_H)
{
- if( pos.non_pawn_material(them) == KnightValueMidgame // FIXME should be <= ???
- && pos.piece_count(them, KNIGHT) == 1)
+ if( pos.non_pawn_material(them) <= KnightValueMidgame
+ && pos.piece_count(them, KNIGHT) <= 1)
ebonus += ebonus / 4;
else if(pos.rooks_and_queens(them))
ebonus -= ebonus / 4;
void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
EvalInfo &ei) {
-
assert(square_is_ok(s));
assert(pos.piece_on(s) == bishop_of_color(us));
assert(square_is_ok(s));
assert(pos.piece_on(s) == bishop_of_color(us));
- if(square_file(s) == FILE_A) {
- b2 = relative_square(us, SQ_B2);
- b3 = relative_square(us, SQ_B3);
- c3 = relative_square(us, SQ_C3);
+ if (square_file(s) == FILE_A)
+ {
+ b2 = relative_square(us, SQ_B2);
+ b3 = relative_square(us, SQ_B3);
+ c3 = relative_square(us, SQ_C3);
}
- else {
- b2 = relative_square(us, SQ_G2);
- b3 = relative_square(us, SQ_G3);
- c3 = relative_square(us, SQ_F3);
+ else
+ {
+ b2 = relative_square(us, SQ_G2);
+ b3 = relative_square(us, SQ_G3);
+ c3 = relative_square(us, SQ_F3);
}
- if(pos.piece_on(b2) == pawn) {
- Value penalty;
+ if (pos.piece_on(b2) == pawn)
+ {
+ Value penalty;
- if(!pos.square_is_empty(b3))
- penalty = 2*TrappedBishopA1H1Penalty;
- else if(pos.piece_on(c3) == pawn)
- penalty = TrappedBishopA1H1Penalty;
- else
- penalty = TrappedBishopA1H1Penalty / 2;
+ if (!pos.square_is_empty(b3))
+ penalty = 2*TrappedBishopA1H1Penalty;
+ else if (pos.piece_on(c3) == pawn)
+ penalty = TrappedBishopA1H1Penalty;
+ else
+ penalty = TrappedBishopA1H1Penalty / 2;
- ei.mgValue -= Sign[us] * penalty;
- ei.egValue -= Sign[us] * penalty;
+ ei.mgValue -= Sign[us] * penalty;
+ ei.egValue -= Sign[us] * penalty;
}
-
}
Color them = opposite_color(us);
// Find the safe squares for our pieces inside the area defined by
- // SpaceMask[us]. A square is unsafe it is attacked by an enemy
+ // SpaceMask[us]. A square is unsafe it is attacked by an enemy
// pawn, or if it is undefended and attacked by an enemy piece.
- Bitboard safeSquares =
- SpaceMask[us] & ~pos.pawns(us) & ~ei.attacked_by(them, PAWN)
- & ~(~ei.attacked_by(us) & ei.attacked_by(them));
+ Bitboard safeSquares = SpaceMask[us]
+ & ~pos.pawns(us)
+ & ~ei.attacked_by(them, PAWN)
+ & ~(~ei.attacked_by(us) & ei.attacked_by(them));
// Find all squares which are at most three squares behind some friendly
// pawn.
Bitboard behindFriendlyPawns = pos.pawns(us);
- if(us == WHITE) {
- behindFriendlyPawns |= (behindFriendlyPawns >> 8);
- behindFriendlyPawns |= (behindFriendlyPawns >> 16);
+ if (us == WHITE)
+ {
+ behindFriendlyPawns |= (behindFriendlyPawns >> 8);
+ behindFriendlyPawns |= (behindFriendlyPawns >> 16);
}
- else {
- behindFriendlyPawns |= (behindFriendlyPawns << 8);
- behindFriendlyPawns |= (behindFriendlyPawns << 16);
+ else
+ {
+ behindFriendlyPawns |= (behindFriendlyPawns << 8);
+ behindFriendlyPawns |= (behindFriendlyPawns << 16);
}
- int space =
- count_1s_max_15(safeSquares)
- + count_1s_max_15(behindFriendlyPawns & safeSquares);
+ int space = count_1s_max_15(safeSquares)
+ + count_1s_max_15(behindFriendlyPawns & safeSquares);
- ei.mgValue += Sign[us] *
- apply_weight(Value(space * ei.mi->space_weight()), WeightSpace);
+ ei.mgValue += Sign[us] * apply_weight(Value(space * ei.mi->space_weight()), WeightSpace);
}
// an UCI-configurable weight with an internal weight.
int compute_weight(int uciWeight, int internalWeight) {
+
uciWeight = (uciWeight * 0x100) / 100;
return (uciWeight * internalWeight) / 0x100;
}
SafetyTable[i] = Value(peak);
}
}
-
}