]> git.sesse.net Git - stockfish/blobdiff - src/evaluate.cpp
Sync static null conditions with real one
[stockfish] / src / evaluate.cpp
index 71f6cf79afaa594af2e6245285816e7b44898d37..6c4e927ac804b4fa5296f7ecf06e529c0f81bea9 100644 (file)
@@ -1,7 +1,7 @@
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
   Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2009 Marco Costalba
+  Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
 
   Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -251,9 +251,10 @@ namespace {
   // in init_safety().
   Value SafetyTable[100];
 
-  // Pawn and material hash tables, indexed by the current thread id
-  MaterialInfoTable* MaterialTable[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-  PawnInfoTable* PawnTable[8] = {0, 0, 0, 0, 0, 0, 0, 0};
+  // Pawn and material hash tables, indexed by the current thread id.
+  // Note that they will be initialized at 0 being global variables.
+  MaterialInfoTable* MaterialTable[MAX_THREADS];
+  PawnInfoTable* PawnTable[MAX_THREADS];
 
   // Sizes of pawn and material hash tables
   const int PawnTableSize = 16384;
@@ -304,7 +305,7 @@ template<bool HasPopCnt>
 Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
   assert(pos.is_ok());
-  assert(threadID >= 0 && threadID < THREAD_MAX);
+  assert(threadID >= 0 && threadID < MAX_THREADS);
   assert(!pos.is_check());
 
   memset(&ei, 0, sizeof(EvalInfo));
@@ -435,28 +436,13 @@ Value do_evaluate(const Position& pos, EvalInfo& ei, int threadID) {
 
 } // namespace
 
-/// quick_evaluate() does a very approximate evaluation of the current position.
-/// It currently considers only material and piece square table scores. Perhaps
-/// we should add scores from the pawn and material hash tables?
-
-Value quick_evaluate(const Position &pos) {
-
-  assert(pos.is_ok());
-
-  static const ScaleFactor sf[2] = {SCALE_FACTOR_NORMAL, SCALE_FACTOR_NORMAL};
-
-  Value v = scale_by_game_phase(pos.value(), MaterialInfoTable::game_phase(pos), sf);
-  return (pos.side_to_move() == WHITE ? v : -v);
-}
-
-
 /// init_eval() initializes various tables used by the evaluation function
 
 void init_eval(int threads) {
 
-  assert(threads <= THREAD_MAX);
+  assert(threads <= MAX_THREADS);
 
-  for (int i = 0; i < THREAD_MAX; i++)
+  for (int i = 0; i < MAX_THREADS; i++)
   {
     if (i >= threads)
     {
@@ -478,7 +464,7 @@ void init_eval(int threads) {
 
 void quit_eval() {
 
-  for (int i = 0; i < THREAD_MAX; i++)
+  for (int i = 0; i < MAX_THREADS; i++)
   {
       delete PawnTable[i];
       delete MaterialTable[i];
@@ -874,11 +860,8 @@ namespace {
       // capturing a single attacking piece can therefore result in a score
       // change far bigger than the value of the captured piece.
       Score v = apply_weight(make_score(SafetyTable[attackUnits], 0), WeightKingSafety[Us]);
-
       ei.value -= Sign[Us] * v;
-
-      if (Us == pos.side_to_move())
-          ei.futilityMargin += mg_value(v);
+      ei.futilityMargin[Us] += mg_value(v);
     }
   }