// Function prototypes
template<bool HasPopCnt>
- Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID);
+ Value do_evaluate(const Position& pos, EvalInfo& ei);
template<Color Us, bool HasPopCnt>
void init_attack_tables(const Position& pos, EvalInfo& ei);
/// evaluate() is the main evaluation function. It always computes two
/// values, an endgame score and a middle game score, and interpolates
/// between them based on the remaining material.
-Value evaluate(const Position& pos, EvalInfo& ei, int threadID) {
+Value evaluate(const Position& pos, EvalInfo& ei) {
- return CpuHasPOPCNT ? do_evaluate<true>(pos, ei, threadID)
- : do_evaluate<false>(pos, ei, threadID);
+ return CpuHasPOPCNT ? do_evaluate<true>(pos, ei)
+ : do_evaluate<false>(pos, ei);
}
namespace {
template<bool HasPopCnt>
-Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
+Value do_evaluate(const Position& pos, EvalInfo& ei) {
ScaleFactor factor[2];
assert(pos.is_ok());
- assert(threadID >= 0 && threadID < MAX_THREADS);
+ assert(pos.thread() >= 0 && pos.thread() < MAX_THREADS);
assert(!pos.is_check());
memset(&ei, 0, sizeof(EvalInfo));
ei.value = pos.value();
// Probe the material hash table
- ei.mi = MaterialTable[threadID]->get_material_info(pos);
+ ei.mi = MaterialTable[pos.thread()]->get_material_info(pos);
ei.value += ei.mi->material_value();
// If we have a specialized evaluation function for the current material
factor[BLACK] = ei.mi->scale_factor(pos, BLACK);
// Probe the pawn hash table
- ei.pi = PawnTable[threadID]->get_pawn_info(pos);
+ ei.pi = PawnTable[pos.thread()]->get_pawn_info(pos);
ei.value += apply_weight(ei.pi->pawns_value(), Weights[PawnStructure]);
// Initialize attack bitboards with pawns evaluation
{
Square s = pop_1st_bit(&b);
- assert(pos.piece_on(s) == piece_of_color_and_type(Us, PAWN));
assert(pos.pawn_is_passed(Us, s));
int r = int(relative_rank(Us, s) - RANK_2);
squaresToQueen = squares_in_front_of(Us, s);
defendedSquares = squaresToQueen & ei.attacked_by(Us);
- // There are no enemy pawns in the pawn's path
- assert(!(squaresToQueen & pos.pieces(PAWN, Them)));
-
// If there is an enemy rook or queen attacking the pawn from behind,
// add all X-ray attacks by the rook or queen. Otherwise consider only
// the squares in the pawn's path attacked or occupied by the enemy.
Square s = pop_1st_bit(&b);
Square queeningSquare = relative_square(c, make_square(square_file(s), RANK_8));
int d = square_distance(s, queeningSquare)
+ - (relative_rank(c, s) == RANK_2) // Double pawn push
- square_distance(pos.king_square(opposite_color(c)), queeningSquare)
+ int(c != pos.side_to_move());