]> git.sesse.net Git - stockfish/commitdiff
Use template for endgame scaling functions
authorMarco Costalba <mcostalba@gmail.com>
Thu, 12 Feb 2009 13:59:46 +0000 (14:59 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Fri, 13 Feb 2009 19:55:29 +0000 (20:55 +0100)
Also integrate scaling and evaluation in a
single base class.

Nice use of templates here :-)

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/endgame.cpp
src/endgame.h
src/material.cpp
src/material.h

index f01f75a0171ff2df2b41f888e489531b5d65aef0..01f4101ed8866ce63748d72cd8da177b78a229e1 100644 (file)
@@ -51,41 +51,15 @@ EvaluationFunction<KBBKN> EvaluateKBBKN(WHITE), EvaluateKNKBB(BLACK); // KBB vs
 
 /// Scaling functions
 
 
 /// Scaling functions
 
-// KBP vs K
-KBPKScalingFunction ScaleKBPK = KBPKScalingFunction(WHITE);
-KBPKScalingFunction ScaleKKBP = KBPKScalingFunction(BLACK);
-
-// KQ vs KRP
-KQKRPScalingFunction ScaleKQKRP = KQKRPScalingFunction(WHITE);
-KQKRPScalingFunction ScaleKRPKQ = KQKRPScalingFunction(BLACK);
-
-// KRP vs KR
-KRPKRScalingFunction ScaleKRPKR = KRPKRScalingFunction(WHITE);
-KRPKRScalingFunction ScaleKRKRP = KRPKRScalingFunction(BLACK);
-
-// KRPP vs KRP
-KRPPKRPScalingFunction ScaleKRPPKRP = KRPPKRPScalingFunction(WHITE);
-KRPPKRPScalingFunction ScaleKRPKRPP = KRPPKRPScalingFunction(BLACK);
-
-// King and pawns vs king
-KPsKScalingFunction ScaleKPsK = KPsKScalingFunction(WHITE);
-KPsKScalingFunction ScaleKKPs = KPsKScalingFunction(BLACK);
-
-// KBP vs KB
-KBPKBScalingFunction ScaleKBPKB = KBPKBScalingFunction(WHITE);
-KBPKBScalingFunction ScaleKBKBP = KBPKBScalingFunction(BLACK);
-
-// KBP vs KN
-KBPKNScalingFunction ScaleKBPKN = KBPKNScalingFunction(WHITE);
-KBPKNScalingFunction ScaleKNKBP = KBPKNScalingFunction(BLACK);
-
-// KNP vs K
-KNPKScalingFunction ScaleKNPK = KNPKScalingFunction(WHITE);
-KNPKScalingFunction ScaleKKNP = KNPKScalingFunction(BLACK);
-
-// KPKP
-KPKPScalingFunction ScaleKPKPw = KPKPScalingFunction(WHITE);
-KPKPScalingFunction ScaleKPKPb = KPKPScalingFunction(BLACK);
+ScalingFunction<KBPK> ScaleKBPK(WHITE), ScaleKKBP(BLACK);    // KBP vs K
+ScalingFunction<KQKRP> ScaleKQKRP(WHITE), ScaleKRPKQ(BLACK); // KQ vs KRP
+ScalingFunction<KRPKR> ScaleKRPKR(WHITE), ScaleKRKRP(BLACK); // KRP vs KR
+ScalingFunction<KRPPKRP> ScaleKRPPKRP(WHITE), ScaleKRPKRPP(BLACK); // KRPP vs KRP
+ScalingFunction<KPsK> ScaleKPsK(WHITE), ScaleKKPs(BLACK);    // King and pawns vs king
+ScalingFunction<KBPKB> ScaleKBPKB(WHITE), ScaleKBKBP(BLACK); // KBP vs KB
+ScalingFunction<KBPKN> ScaleKBPKN(WHITE), ScaleKNKBP(BLACK); // KBP vs KN
+ScalingFunction<KNPK> ScaleKNPK(WHITE), ScaleKKNP(BLACK);    // KNP vs K
+ScalingFunction<KPKP> ScaleKPKPw(WHITE), ScaleKPKPb(BLACK);  // KPKP
 
 
 ////
 
 
 ////
@@ -158,27 +132,6 @@ namespace {
 //// Functions
 ////
 
 //// Functions
 ////
 
-/// Constructors
-
-EndgameEvaluationFunction::EndgameEvaluationFunction(Color c) : strongerSide(c) {
-  weakerSide = opposite_color(strongerSide);
-}
-
-ScalingFunction::ScalingFunction(Color c) : strongerSide(c) {
-  weakerSide = opposite_color(c);
-}
-
-KBPKScalingFunction::KBPKScalingFunction(Color c)       : ScalingFunction(c) {}
-KQKRPScalingFunction::KQKRPScalingFunction(Color c)     : ScalingFunction(c) {}
-KRPKRScalingFunction::KRPKRScalingFunction(Color c)     : ScalingFunction(c) {}
-KRPPKRPScalingFunction::KRPPKRPScalingFunction(Color c) : ScalingFunction(c) {}
-KPsKScalingFunction::KPsKScalingFunction(Color c)       : ScalingFunction(c) {}
-KBPKBScalingFunction::KBPKBScalingFunction(Color c)     : ScalingFunction(c) {}
-KBPKNScalingFunction::KBPKNScalingFunction(Color c)     : ScalingFunction(c) {}
-KNPKScalingFunction::KNPKScalingFunction(Color c)       : ScalingFunction(c) {}
-KPKPScalingFunction::KPKPScalingFunction(Color c)       : ScalingFunction(c) {}
-
-
 /// Mate with KX vs K. This function is used to evaluate positions with
 /// King and plenty of material vs a lone king. It simply gives the
 /// attacking side a bonus for driving the defending king towards the edge
 /// Mate with KX vs K. This function is used to evaluate positions with
 /// King and plenty of material vs a lone king. It simply gives the
 /// attacking side a bonus for driving the defending king towards the edge
@@ -439,8 +392,8 @@ Value EvaluationFunction<KmmKm>::apply(const Position &pos) {
 /// bishop of the wrong color. If such a draw is detected, ScaleFactor(0) is
 /// returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling
 /// will be used.
 /// bishop of the wrong color. If such a draw is detected, ScaleFactor(0) is
 /// returned. If not, the return value is SCALE_FACTOR_NONE, i.e. no scaling
 /// will be used.
-
-ScaleFactor KBPKScalingFunction::apply(const Position& pos) {
+template<>
+ScaleFactor ScalingFunction<KBPK>::apply(const Position& pos) {
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
@@ -494,8 +447,8 @@ ScaleFactor KBPKScalingFunction::apply(const Position& pos) {
 /// king and queen, while the weaker side has at least a rook and a pawn.
 /// It tests for fortress draws with a rook on the third rank defended by
 /// a pawn.
 /// king and queen, while the weaker side has at least a rook and a pawn.
 /// It tests for fortress draws with a rook on the third rank defended by
 /// a pawn.
-
-ScaleFactor KQKRPScalingFunction::apply(const Position& pos) {
+template<>
+ScaleFactor ScalingFunction<KQKRP>::apply(const Position& pos) {
 
   assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
   assert(pos.piece_count(strongerSide, QUEEN) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == QueenValueMidgame);
   assert(pos.piece_count(strongerSide, QUEEN) == 1);
@@ -525,8 +478,8 @@ ScaleFactor KQKRPScalingFunction::apply(const Position& pos) {
 ///
 /// It would also be nice to rewrite the actual code for this function,
 /// which is mostly copied from Glaurung 1.x, and not very pretty.
 ///
 /// It would also be nice to rewrite the actual code for this function,
 /// which is mostly copied from Glaurung 1.x, and not very pretty.
-
-ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KRPKR>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
   assert(pos.piece_count(strongerSide, PAWN) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
   assert(pos.piece_count(strongerSide, PAWN) == 1);
@@ -643,8 +596,8 @@ ScaleFactor KRPKRScalingFunction::apply(const Position &pos) {
 /// KRPPKRPScalingFunction scales KRPP vs KRP endgames. There is only a
 /// single pattern: If the stronger side has no pawns and the defending king
 /// is actively placed, the position is drawish.
 /// KRPPKRPScalingFunction scales KRPP vs KRP endgames. There is only a
 /// single pattern: If the stronger side has no pawns and the defending king
 /// is actively placed, the position is drawish.
-
-ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KRPPKRP>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
   assert(pos.piece_count(strongerSide, PAWN) == 2);
 
   assert(pos.non_pawn_material(strongerSide) == RookValueMidgame);
   assert(pos.piece_count(strongerSide, PAWN) == 2);
@@ -682,8 +635,8 @@ ScaleFactor KRPPKRPScalingFunction::apply(const Position &pos) {
 /// KPsKScalingFunction scales endgames with king and two or more pawns
 /// against king. There is just a single rule here: If all pawns are on
 /// the same rook file and are blocked by the defending king, it's a draw.
 /// KPsKScalingFunction scales endgames with king and two or more pawns
 /// against king. There is just a single rule here: If all pawns are on
 /// the same rook file and are blocked by the defending king, it's a draw.
-
-ScaleFactor KPsKScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KPsK>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == Value(0));
   assert(pos.piece_count(strongerSide, PAWN) >= 2);
 
   assert(pos.non_pawn_material(strongerSide) == Value(0));
   assert(pos.piece_count(strongerSide, PAWN) >= 2);
@@ -728,8 +681,8 @@ ScaleFactor KPsKScalingFunction::apply(const Position &pos) {
 /// square of the king is not of the same color as the stronger side's bishop,
 /// it's a draw. If the two bishops have opposite color, it's almost always
 /// a draw.
 /// square of the king is not of the same color as the stronger side's bishop,
 /// it's a draw. If the two bishops have opposite color, it's almost always
 /// a draw.
-
-ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KBPKB>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
@@ -783,8 +736,8 @@ ScaleFactor KBPKBScalingFunction::apply(const Position &pos) {
 /// If the defending king is somewhere along the path of the pawn, and the
 /// square of the king is not of the same color as the stronger side's bishop,
 /// it's a draw.
 /// If the defending king is somewhere along the path of the pawn, and the
 /// square of the king is not of the same color as the stronger side's bishop,
 /// it's a draw.
-
-ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KBPKN>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == BishopValueMidgame);
   assert(pos.piece_count(strongerSide, BISHOP) == 1);
@@ -810,8 +763,8 @@ ScaleFactor KBPKNScalingFunction::apply(const Position &pos) {
 /// KNPKScalingFunction scales KNP vs K endgames. There is a single rule:
 /// If the pawn is a rook pawn on the 7th rank and the defending king prevents
 /// the pawn from advancing, the position is drawn.
 /// KNPKScalingFunction scales KNP vs K endgames. There is a single rule:
 /// If the pawn is a rook pawn on the 7th rank and the defending king prevents
 /// the pawn from advancing, the position is drawn.
-
-ScaleFactor KNPKScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KNPK>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);
   assert(pos.piece_count(strongerSide, KNIGHT) == 1);
 
   assert(pos.non_pawn_material(strongerSide) == KnightValueMidgame);
   assert(pos.piece_count(strongerSide, KNIGHT) == 1);
@@ -840,8 +793,8 @@ ScaleFactor KNPKScalingFunction::apply(const Position &pos) {
 /// the pawn as well. The exception is when the stronger side's pawn is far
 /// advanced and not on a rook file; in this case it is often possible to win
 /// (e.g. 8/4k3/3p4/3P4/6K1/8/8/8 w - - 0 1).
 /// the pawn as well. The exception is when the stronger side's pawn is far
 /// advanced and not on a rook file; in this case it is often possible to win
 /// (e.g. 8/4k3/3p4/3P4/6K1/8/8/8 w - - 0 1).
-
-ScaleFactor KPKPScalingFunction::apply(const Position &pos) {
+template<>
+ScaleFactor ScalingFunction<KPKP>::apply(const Position &pos) {
 
   assert(pos.non_pawn_material(strongerSide) == Value(0));
   assert(pos.non_pawn_material(weakerSide) == Value(0));
 
   assert(pos.non_pawn_material(strongerSide) == Value(0));
   assert(pos.non_pawn_material(weakerSide) == Value(0));
index 21e8ab6d6e5b6d249a765f0c4381c9cf7465f93a..cb087b4b4cfe0e3686081f2543c3a31c5c4d2d3d 100644 (file)
 //// Types
 ////
 
 //// Types
 ////
 
-/// Abstract base class for all special endgame evaluation functions
-
-class EndgameEvaluationFunction {
-public:
-  EndgameEvaluationFunction(Color c);
-  virtual ~EndgameEvaluationFunction() { }
-
-  virtual Value apply(const Position &pos) = 0;
-
-protected:
-  Color strongerSide, weakerSide;
-};
-
-
-/// Template subclass for various concrete endgames
-
 enum EndgameType {
 enum EndgameType {
+
+    // Evaluation functions
     KXK,   // Generic "mate lone king" eval
     KBNK,  // KBN vs K
     KPK,   // KP vs K
     KXK,   // Generic "mate lone king" eval
     KBNK,  // KBN vs K
     KPK,   // KP vs K
@@ -59,93 +45,49 @@ enum EndgameType {
     KRKN,  // KR vs KN
     KQKR,  // KQ vs KR
     KBBKN, // KBB vs KN
     KRKN,  // KR vs KN
     KQKR,  // KQ vs KR
     KBBKN, // KBB vs KN
-    KmmKm  // K and two minors vs K and one or two minors
+    KmmKm, // K and two minors vs K and one or two minors
+
+    // Scaling functions
+    KBPK,    // KBP vs K
+    KQKRP,   // KQ vs KRP
+    KRPKR,   // KRP vs KR
+    KRPPKRP, // KRPP vs KRP
+    KPsK,    // King and pawns vs king
+    KBPKB,   // KBP vs KB
+    KBPKN,   // KBP vs KN
+    KNPK,    // KNP vs K
+    KPKP     // KP vs KP
 };
 
 };
 
-template<EndgameType>
-class EvaluationFunction : public EndgameEvaluationFunction {
-public:
-  explicit EvaluationFunction(Color c): EndgameEvaluationFunction(c) {}
-  Value apply(const Position& pos);
-};
-
-/// Abstract base class for all evaluation scaling functions:
+/// Template abstract base class for all special endgame functions
 
 
-class ScalingFunction {
+template<typename T>
+class EndgameFunctionBase {
 public:
 public:
-  ScalingFunction(Color c);
-  virtual ~ScalingFunction() { }
-
-  virtual ScaleFactor apply(const Position &pos) =0;
+  EndgameFunctionBase(Color c) : strongerSide(c) { weakerSide = opposite_color(strongerSide); }
+  virtual ~EndgameFunctionBase() {}
+  virtual T apply(const Position&) = 0;
 
 protected:
   Color strongerSide, weakerSide;
 };
 
 
 protected:
   Color strongerSide, weakerSide;
 };
 
+typedef EndgameFunctionBase<Value> EndgameEvaluationFunctionBase;
+typedef EndgameFunctionBase<ScaleFactor> EndgameScalingFunctionBase;
 
 
-/// Subclasses for various concrete endgames:
-
-// KBP vs K:
-class KBPKScalingFunction : public ScalingFunction {
-public:
-  KBPKScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
-
-// KQ vs KRP:
-class KQKRPScalingFunction: public ScalingFunction {
-public:
-  KQKRPScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
 
 
-// KRP vs KR:
-class KRPKRScalingFunction : public ScalingFunction {
-public:
-  KRPKRScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
+/// Templates subclass for various concrete endgames
 
 
-// KRPP vs KRP:
-class KRPPKRPScalingFunction : public ScalingFunction {
-public:
-  KRPPKRPScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
-
-// King and pawns vs king:
-class KPsKScalingFunction : public ScalingFunction {
-public:
-  KPsKScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
-
-// KBP vs KB:
-class KBPKBScalingFunction : public ScalingFunction {
-public:
-  KBPKBScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
-
-// KBP vs KN:
-class KBPKNScalingFunction : public ScalingFunction {
-public:
-  KBPKNScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
-};
-
-// KNP vs K:
-class KNPKScalingFunction : public ScalingFunction {
-public:
-  KNPKScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
+template<EndgameType>
+struct EvaluationFunction : public EndgameEvaluationFunctionBase {
+  explicit EvaluationFunction(Color c): EndgameEvaluationFunctionBase(c) {}
+  Value apply(const Position&);
 };
 
 };
 
-// KP vs KP:
-class KPKPScalingFunction : public ScalingFunction {
-public:
-  KPKPScalingFunction(Color c);
-  ScaleFactor apply(const Position &pos);
+template<EndgameType>
+struct ScalingFunction : public EndgameScalingFunctionBase {
+  explicit ScalingFunction(Color c) : EndgameScalingFunctionBase(c) {}
+  ScaleFactor apply(const Position&);
 };
 
 
 };
 
 
@@ -163,33 +105,15 @@ extern EvaluationFunction<KQKR> EvaluateKQKR, EvaluateKRKQ;    // KQ vs KR
 extern EvaluationFunction<KBBKN> EvaluateKBBKN, EvaluateKNKBB; // KBB vs KN
 extern EvaluationFunction<KmmKm> EvaluateKmmKm; // K and two minors vs K and one or two minors:
 
 extern EvaluationFunction<KBBKN> EvaluateKBBKN, EvaluateKNKBB; // KBB vs KN
 extern EvaluationFunction<KmmKm> EvaluateKmmKm; // K and two minors vs K and one or two minors:
 
-// KBP vs K:
-extern KBPKScalingFunction ScaleKBPK, ScaleKKBP;
-
-// KQ vs KRP:
-extern KQKRPScalingFunction ScaleKQKRP, ScaleKRPKQ;
-
-// KRP vs KR:
-extern KRPKRScalingFunction ScaleKRPKR, ScaleKRKRP;
-
-// KRPP vs KRP:
-extern KRPPKRPScalingFunction ScaleKRPPKRP, ScaleKRPKRPP;
-
-// King and pawns vs king:
-extern KPsKScalingFunction ScaleKPsK, ScaleKKPs;
-
-// KBP vs KB:
-extern KBPKBScalingFunction ScaleKBPKB, ScaleKBKBP;
-
-// KBP vs KN:
-extern KBPKNScalingFunction ScaleKBPKN, ScaleKNKBP;
-
-// KNP vs K:
-extern KNPKScalingFunction ScaleKNPK, ScaleKKNP;
-
-// KP vs KP:
-extern KPKPScalingFunction ScaleKPKPw, ScaleKPKPb;
-
+extern ScalingFunction<KBPK> ScaleKBPK, ScaleKKBP;    // KBP vs K
+extern ScalingFunction<KQKRP> ScaleKQKRP, ScaleKRPKQ; // KQ vs KRP
+extern ScalingFunction<KRPKR> ScaleKRPKR, ScaleKRKRP; // KRP vs KR
+extern ScalingFunction<KRPPKRP> ScaleKRPPKRP, ScaleKRPKRPP; // KRPP vs KRP
+extern ScalingFunction<KPsK> ScaleKPsK, ScaleKKPs;    // King and pawns vs king
+extern ScalingFunction<KBPKB> ScaleKBPKB, ScaleKBKBP; // KBP vs KB
+extern ScalingFunction<KBPKN> ScaleKBPKN, ScaleKNKBP; // KBP vs KN
+extern ScalingFunction<KNPK> ScaleKNPK, ScaleKKNP;    // KNP vs K
+extern ScalingFunction<KPKP> ScaleKPKPw, ScaleKPKPb;  // KP vs KP
 
 ////
 //// Prototypes
 
 ////
 //// Prototypes
index b180f797b56032c74d122c5cd236755b27be9909..845bc90df6e0207deb5cf12c3007ed7a51064bd0 100644 (file)
@@ -54,20 +54,20 @@ class EndgameFunctions {
 
 public:
   EndgameFunctions();
 
 public:
   EndgameFunctions();
-  EndgameEvaluationFunction* getEEF(Key key) const;
-  ScalingFunction* getESF(Key key, Color* c) const;
+  EndgameEvaluationFunctionBase* getEEF(Key key) const;
+  EndgameScalingFunctionBase* getESF(Key key, Color* c) const;
 
 private:
 
 private:
-  void add(Key k, EndgameEvaluationFunction* f);
-  void add(Key k, Color c, ScalingFunction* f);
+  void add(Key k, EndgameEvaluationFunctionBase* f);
+  void add(Key k, Color c, EndgameScalingFunctionBase* f);
 
   struct ScalingInfo
   {
       Color col;
 
   struct ScalingInfo
   {
       Color col;
-      ScalingFunction* fun;
+      EndgameScalingFunctionBase* fun;
   };
 
   };
 
-  std::map<Key, EndgameEvaluationFunction*> EEFmap;
+  std::map<Key, EndgameEvaluationFunctionBase*> EEFmap;
   std::map<Key, ScalingInfo> ESFmap;
 };
 
   std::map<Key, ScalingInfo> ESFmap;
 };
 
@@ -187,7 +187,7 @@ MaterialInfo* MaterialInfoTable::get_material_info(const Position& pos) {
   // are several conflicting applicable scaling functions and we need to
   // decide which one to use.
   Color c;
   // are several conflicting applicable scaling functions and we need to
   // decide which one to use.
   Color c;
-  ScalingFunction* sf;
+  EndgameScalingFunctionBase* sf;
 
   if ((sf = funcs->getESF(key, &c)) != NULL)
   {
 
   if ((sf = funcs->getESF(key, &c)) != NULL)
   {
@@ -355,24 +355,24 @@ EndgameFunctions::EndgameFunctions() {
   add(z[W][ROOK][1] ^ z[W][PAWN][1] ^ z[B][ROOK][1] ^ z[B][PAWN][1] ^ z[B][PAWN][2], B, &ScaleKRPKRPP);
 }
 
   add(z[W][ROOK][1] ^ z[W][PAWN][1] ^ z[B][ROOK][1] ^ z[B][PAWN][1] ^ z[B][PAWN][2], B, &ScaleKRPKRPP);
 }
 
-void EndgameFunctions::add(Key k, EndgameEvaluationFunction* f) {
+void EndgameFunctions::add(Key k, EndgameEvaluationFunctionBase* f) {
 
 
-  EEFmap.insert(std::pair<Key, EndgameEvaluationFunction*>(k, f));
+  EEFmap.insert(std::pair<Key, EndgameEvaluationFunctionBase*>(k, f));
 }
 
 }
 
-void EndgameFunctions::add(Key k, Color c, ScalingFunction* f) {
+void EndgameFunctions::add(Key k, Color c, EndgameScalingFunctionBase* f) {
 
   ScalingInfo s = {c, f};
   ESFmap.insert(std::pair<Key, ScalingInfo>(k, s));
 }
 
 
   ScalingInfo s = {c, f};
   ESFmap.insert(std::pair<Key, ScalingInfo>(k, s));
 }
 
-EndgameEvaluationFunction* EndgameFunctions::getEEF(Key key) const {
+EndgameEvaluationFunctionBase* EndgameFunctions::getEEF(Key key) const {
 
 
-  std::map<Key, EndgameEvaluationFunction*>::const_iterator it(EEFmap.find(key));
+  std::map<Key, EndgameEvaluationFunctionBase*>::const_iterator it(EEFmap.find(key));
   return (it != EEFmap.end() ? it->second : NULL);
 }
 
   return (it != EEFmap.end() ? it->second : NULL);
 }
 
-ScalingFunction* EndgameFunctions::getESF(Key key, Color* c) const {
+EndgameScalingFunctionBase* EndgameFunctions::getESF(Key key, Color* c) const {
 
   std::map<Key, ScalingInfo>::const_iterator it(ESFmap.find(key));
   if (it == ESFmap.end())
 
   std::map<Key, ScalingInfo>::const_iterator it(ESFmap.find(key));
   if (it == ESFmap.end())
index 5877cd755ff87db8b502a94f1ad6554835c4b04a..7ba3b7de00c4760fe16fa51df00d3d1bef7d4fd3 100644 (file)
@@ -63,8 +63,8 @@ private:
   int16_t mgValue;
   int16_t egValue;
   uint8_t factor[2];
   int16_t mgValue;
   int16_t egValue;
   uint8_t factor[2];
-  EndgameEvaluationFunction* evaluationFunction;
-  ScalingFunction* scalingFunction[2];
+  EndgameEvaluationFunctionBase* evaluationFunction;
+  EndgameScalingFunctionBase* scalingFunction[2];
   uint8_t spaceWeight;
 };
 
   uint8_t spaceWeight;
 };