void cEval::FullPawnEval(POS * p, int use_hash) {

  // Try to retrieve score from pawn hashtable

  int addr = p->pawn_key % PAWN_HASH_SIZE;

  if (PawnTT[addr].key == p->pawn_key && use_hash) {
    mg[WC][F_PAWNS]   = PawnTT[addr].mg_pawns;
    eg[WC][F_PAWNS]   = PawnTT[addr].eg_pawns;
    return;
  }

  // Single pawn eval

  ScorePawns(p, WC);
  ScorePawns(p, BC);

  // King's pawn shield and pawn storm on enemy king,
  // including pawn chains

  ScoreKing(p, WC);
  ScoreKing(p, BC);

  // Save stuff in pawn hashtable

  PawnTT[addr].key = p->pawn_key;
  PawnTT[addr].mg_pawns = mg[WC][F_PAWNS] - mg[BC][F_PAWNS];
  PawnTT[addr].eg_pawns = eg[WC][F_PAWNS] - eg[BC][F_PAWNS];
}
Esempio n. 2
0
void cEval::FullPawnEval(POS * p, eData *e, int use_hash) {

  // Try to retrieve score from pawn hashtable

  int addr = p->pawn_key % PAWN_HASH_SIZE;

  if (PawnTT[addr].key == p->pawn_key && use_hash) {
    e->mg[WC][F_PAWNS]   = PawnTT[addr].mg_pawns;
    e->eg[WC][F_PAWNS]   = PawnTT[addr].eg_pawns;
    return;
  }

  // Single pawn eval

  ScorePawns(p, e, WC);
  ScorePawns(p, e, BC);

  // King's pawn shield and pawn storm on enemy king,
  // including pawn chains

  ScoreKing(p, e, WC);
  ScoreKing(p, e, BC);

  // King on a wing without pawns

  U64 bbAllPawns = p->Pawns(WC) | p->Pawns(BC);

  if (bbAllPawns) {
    if (!(bbAllPawns & bbKingSide)) {
      Add(e, WC, F_PAWNS, empty_ks[p->king_sq[WC]]);
      Add(e, BC, F_PAWNS, empty_ks[p->king_sq[BC]]);
    }

    if (!(bbAllPawns & bbQueenSide)) {
      Add(e, WC, F_PAWNS, empty_qs[p->king_sq[WC]]);
      Add(e, BC, F_PAWNS, empty_qs[p->king_sq[BC]]);
    }
  }
  
  // Save stuff in pawn hashtable

  PawnTT[addr].key = p->pawn_key;
  PawnTT[addr].mg_pawns = e->mg[WC][F_PAWNS] - e->mg[BC][F_PAWNS];
  PawnTT[addr].eg_pawns = e->eg[WC][F_PAWNS] - e->eg[BC][F_PAWNS];
}