mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Final space inflate of evaluatio.cpp
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
e236a0c652
commit
90585a8a36
1 changed files with 38 additions and 36 deletions
|
@ -1067,7 +1067,6 @@ namespace {
|
||||||
|
|
||||||
void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
|
void evaluate_trapped_bishop_a7h7(const Position &pos, Square s, Color us,
|
||||||
EvalInfo &ei) {
|
EvalInfo &ei) {
|
||||||
|
|
||||||
assert(square_is_ok(s));
|
assert(square_is_ok(s));
|
||||||
assert(pos.piece_on(s) == bishop_of_color(us));
|
assert(pos.piece_on(s) == bishop_of_color(us));
|
||||||
|
|
||||||
|
@ -1098,23 +1097,26 @@ namespace {
|
||||||
assert(square_is_ok(s));
|
assert(square_is_ok(s));
|
||||||
assert(pos.piece_on(s) == bishop_of_color(us));
|
assert(pos.piece_on(s) == bishop_of_color(us));
|
||||||
|
|
||||||
if(square_file(s) == FILE_A) {
|
if (square_file(s) == FILE_A)
|
||||||
|
{
|
||||||
b2 = relative_square(us, SQ_B2);
|
b2 = relative_square(us, SQ_B2);
|
||||||
b3 = relative_square(us, SQ_B3);
|
b3 = relative_square(us, SQ_B3);
|
||||||
c3 = relative_square(us, SQ_C3);
|
c3 = relative_square(us, SQ_C3);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
b2 = relative_square(us, SQ_G2);
|
b2 = relative_square(us, SQ_G2);
|
||||||
b3 = relative_square(us, SQ_G3);
|
b3 = relative_square(us, SQ_G3);
|
||||||
c3 = relative_square(us, SQ_F3);
|
c3 = relative_square(us, SQ_F3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pos.piece_on(b2) == pawn) {
|
if (pos.piece_on(b2) == pawn)
|
||||||
|
{
|
||||||
Value penalty;
|
Value penalty;
|
||||||
|
|
||||||
if(!pos.square_is_empty(b3))
|
if (!pos.square_is_empty(b3))
|
||||||
penalty = 2*TrappedBishopA1H1Penalty;
|
penalty = 2*TrappedBishopA1H1Penalty;
|
||||||
else if(pos.piece_on(c3) == pawn)
|
else if (pos.piece_on(c3) == pawn)
|
||||||
penalty = TrappedBishopA1H1Penalty;
|
penalty = TrappedBishopA1H1Penalty;
|
||||||
else
|
else
|
||||||
penalty = TrappedBishopA1H1Penalty / 2;
|
penalty = TrappedBishopA1H1Penalty / 2;
|
||||||
|
@ -1122,7 +1124,6 @@ namespace {
|
||||||
ei.mgValue -= Sign[us] * penalty;
|
ei.mgValue -= Sign[us] * penalty;
|
||||||
ei.egValue -= Sign[us] * penalty;
|
ei.egValue -= Sign[us] * penalty;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1141,28 +1142,29 @@ namespace {
|
||||||
// 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.
|
// pawn, or if it is undefended and attacked by an enemy piece.
|
||||||
|
|
||||||
Bitboard safeSquares =
|
Bitboard safeSquares = SpaceMask[us]
|
||||||
SpaceMask[us] & ~pos.pawns(us) & ~ei.attacked_by(them, PAWN)
|
& ~pos.pawns(us)
|
||||||
|
& ~ei.attacked_by(them, PAWN)
|
||||||
& ~(~ei.attacked_by(us) & ei.attacked_by(them));
|
& ~(~ei.attacked_by(us) & ei.attacked_by(them));
|
||||||
|
|
||||||
// Find all squares which are at most three squares behind some friendly
|
// Find all squares which are at most three squares behind some friendly
|
||||||
// pawn.
|
// pawn.
|
||||||
Bitboard behindFriendlyPawns = pos.pawns(us);
|
Bitboard behindFriendlyPawns = pos.pawns(us);
|
||||||
if(us == WHITE) {
|
if (us == WHITE)
|
||||||
|
{
|
||||||
behindFriendlyPawns |= (behindFriendlyPawns >> 8);
|
behindFriendlyPawns |= (behindFriendlyPawns >> 8);
|
||||||
behindFriendlyPawns |= (behindFriendlyPawns >> 16);
|
behindFriendlyPawns |= (behindFriendlyPawns >> 16);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
behindFriendlyPawns |= (behindFriendlyPawns << 8);
|
behindFriendlyPawns |= (behindFriendlyPawns << 8);
|
||||||
behindFriendlyPawns |= (behindFriendlyPawns << 16);
|
behindFriendlyPawns |= (behindFriendlyPawns << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
int space =
|
int space = count_1s_max_15(safeSquares)
|
||||||
count_1s_max_15(safeSquares)
|
|
||||||
+ count_1s_max_15(behindFriendlyPawns & safeSquares);
|
+ count_1s_max_15(behindFriendlyPawns & safeSquares);
|
||||||
|
|
||||||
ei.mgValue += Sign[us] *
|
ei.mgValue += Sign[us] * apply_weight(Value(space * ei.mi->space_weight()), WeightSpace);
|
||||||
apply_weight(Value(space * ei.mi->space_weight()), WeightSpace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1203,6 +1205,7 @@ namespace {
|
||||||
// an UCI-configurable weight with an internal weight.
|
// an UCI-configurable weight with an internal weight.
|
||||||
|
|
||||||
int compute_weight(int uciWeight, int internalWeight) {
|
int compute_weight(int uciWeight, int internalWeight) {
|
||||||
|
|
||||||
uciWeight = (uciWeight * 0x100) / 100;
|
uciWeight = (uciWeight * 0x100) / 100;
|
||||||
return (uciWeight * internalWeight) / 0x100;
|
return (uciWeight * internalWeight) / 0x100;
|
||||||
}
|
}
|
||||||
|
@ -1255,5 +1258,4 @@ namespace {
|
||||||
SafetyTable[i] = Value(peak);
|
SafetyTable[i] = Value(peak);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue