// weights read from UCI parameters. The purpose is to be able to change
// the evaluation weights while keeping the default values of the UCI
// parameters at 100, which looks prettier.
// weights read from UCI parameters. The purpose is to be able to change
// the evaluation weights while keeping the default values of the UCI
// parameters at 100, which looks prettier.
- const int WeightMobilityMidgameInternal = 0x100;
- const int WeightMobilityEndgameInternal = 0x100;
- const int WeightPawnStructureMidgameInternal = 0x100;
- const int WeightPawnStructureEndgameInternal = 0x100;
- const int WeightPassedPawnsMidgameInternal = 0x100;
- const int WeightPassedPawnsEndgameInternal = 0x100;
- const int WeightKingSafetyInternal = 0x110;
- const int WeightKingOppSafetyInternal = 0x110;
- const int WeightSpaceInternal = 0x30;
+ //
+ // Values modified by Joona Kiiski
+ const int WeightMobilityMidgameInternal = 0x0FA;
+ const int WeightMobilityEndgameInternal = 0x10A;
+ const int WeightPawnStructureMidgameInternal = 0x0EC;
+ const int WeightPawnStructureEndgameInternal = 0x0CD;
+ const int WeightPassedPawnsMidgameInternal = 0x108;
+ const int WeightPassedPawnsEndgameInternal = 0x109;
+ const int WeightKingSafetyInternal = 0x0F7;
+ const int WeightKingOppSafetyInternal = 0x101;
+ const int WeightSpaceInternal = 0x02F;
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0) // 8
};
V(0), V(0), V(0), V(0), V(0), V(0), V(0), V(0) // 8
};
- // Rooks and queens on the 7th rank:
- const Value MidgameRookOn7thBonus = Value(50);
- const Value EndgameRookOn7thBonus = Value(100);
- const Value MidgameQueenOn7thBonus = Value(25);
- const Value EndgameQueenOn7thBonus = Value(50);
+ // Rooks and queens on the 7th rank
+ const Value MidgameRookOn7thBonus = Value(47);
+ const Value EndgameRookOn7thBonus = Value(98);
+ const Value MidgameQueenOn7thBonus = Value(27);
+ const Value EndgameQueenOn7thBonus = Value(54);
- // Rooks on open files:
- const Value RookOpenFileBonus = Value(40);
- const Value RookHalfOpenFileBonus = Value(20);
+
+ // Rooks on open files
+ const Value RookOpenFileBonus = Value(43);
+ const Value RookHalfOpenFileBonus = Value(19);
evaluate_trapped_bishop_a1h1(pos, s, us, ei);
}
evaluate_trapped_bishop_a1h1(pos, s, us, ei);
}
- if (Piece != ROOK && Piece != QUEEN)
- continue;
-
- // Queen or rook on 7th rank
- them = opposite_color(us);
-
- if ( relative_rank(us, s) == RANK_7
- && relative_rank(us, pos.king_square(them)) == RANK_8)
+ if (Piece == ROOK || Piece == QUEEN)
- ei.mgValue += Sign[us] * (Piece == ROOK ? MidgameRookOn7thBonus : MidgameQueenOn7thBonus);
- ei.egValue += Sign[us] * (Piece == ROOK ? EndgameRookOn7thBonus : EndgameQueenOn7thBonus);
+ // Queen or rook on 7th rank
+ them = opposite_color(us);
+
+ if ( relative_rank(us, s) == RANK_7
+ && relative_rank(us, pos.king_square(them)) == RANK_8)
+ {
+ ei.mgValue += Sign[us] * (Piece == ROOK ? MidgameRookOn7thBonus : MidgameQueenOn7thBonus);
+ ei.egValue += Sign[us] * (Piece == ROOK ? EndgameRookOn7thBonus : EndgameQueenOn7thBonus);
+ }
- ei.mgValue += Sign[us] * RookOpenFileBonus;
- ei.egValue += Sign[us] * RookOpenFileBonus;
- }
- else
- {
- ei.mgValue += Sign[us] * RookHalfOpenFileBonus;
- ei.egValue += Sign[us] * RookHalfOpenFileBonus;
+ if (ei.pi->file_is_half_open(them, f))
+ {
+ ei.mgValue += Sign[us] * RookOpenFileBonus;
+ ei.egValue += Sign[us] * RookOpenFileBonus;
+ }
+ else
+ {
+ ei.mgValue += Sign[us] * RookHalfOpenFileBonus;
+ ei.egValue += Sign[us] * RookHalfOpenFileBonus;
+ }
- // Penalize rooks which are trapped inside a king. Penalize more if
- // king has lost right to castle.
- if (mob > 6 || ei.pi->file_is_half_open(us, f))
- continue;
+ // Penalize rooks which are trapped inside a king. Penalize more if
+ // king has lost right to castle.
+ if (mob > 6 || ei.pi->file_is_half_open(us, f))
+ continue;
- if ( square_file(ksq) >= FILE_E
- && square_file(s) > square_file(ksq)
- && (relative_rank(us, ksq) == RANK_1 || square_rank(ksq) == square_rank(s)))
- {
- // Is there a half-open file between the king and the edge of the board?
- if (!ei.pi->has_open_file_to_right(us, square_file(ksq)))
- ei.mgValue -= pos.can_castle(us)? Sign[us] * ((TrappedRookPenalty - mob * 16) / 2)
- : Sign[us] * (TrappedRookPenalty - mob * 16);
- }
- else if ( square_file(ksq) <= FILE_D
- && square_file(s) < square_file(ksq)
- && (relative_rank(us, ksq) == RANK_1 || square_rank(ksq) == square_rank(s)))
- {
- // Is there a half-open file between the king and the edge of the board?
- if (!ei.pi->has_open_file_to_left(us, square_file(ksq)))
- ei.mgValue -= pos.can_castle(us)? Sign[us] * ((TrappedRookPenalty - mob * 16) / 2)
- : Sign[us] * (TrappedRookPenalty - mob * 16);
+ if ( square_file(ksq) >= FILE_E
+ && square_file(s) > square_file(ksq)
+ && (relative_rank(us, ksq) == RANK_1 || square_rank(ksq) == square_rank(s)))
+ {
+ // Is there a half-open file between the king and the edge of the board?
+ if (!ei.pi->has_open_file_to_right(us, square_file(ksq)))
+ ei.mgValue -= pos.can_castle(us)? Sign[us] * ((TrappedRookPenalty - mob * 16) / 2)
+ : Sign[us] * (TrappedRookPenalty - mob * 16);
+ }
+ else if ( square_file(ksq) <= FILE_D
+ && square_file(s) < square_file(ksq)
+ && (relative_rank(us, ksq) == RANK_1 || square_rank(ksq) == square_rank(s)))
+ {
+ // Is there a half-open file between the king and the edge of the board?
+ if (!ei.pi->has_open_file_to_left(us, square_file(ksq)))
+ ei.mgValue -= pos.can_castle(us)? Sign[us] * ((TrappedRookPenalty - mob * 16) / 2)
+ : Sign[us] * (TrappedRookPenalty - mob * 16);
+ }
if ( bit_is_set(p.piece_attacks<QUEEN>(from), to)
&& !bit_is_set(p.pinned_pieces(them), from)
&& !(rook_attacks_bb(to, occ & ClearMaskBB[from]) & p.rooks_and_queens(us))
if ( bit_is_set(p.piece_attacks<QUEEN>(from), to)
&& !bit_is_set(p.pinned_pieces(them), from)
&& !(rook_attacks_bb(to, occ & ClearMaskBB[from]) & p.rooks_and_queens(us))