+/// EndgameFunctions member definitions.
+
+EndgameFunctions::EndgameFunctions() {
+
+ add<EvaluationFunction<KNNK> >("KNNK");
+ add<EvaluationFunction<KPK> >("KPK");
+ add<EvaluationFunction<KBNK> >("KBNK");
+ add<EvaluationFunction<KRKP> >("KRKP");
+ add<EvaluationFunction<KRKB> >("KRKB");
+ add<EvaluationFunction<KRKN> >("KRKN");
+ add<EvaluationFunction<KQKR> >("KQKR");
+ add<EvaluationFunction<KBBKN> >("KBBKN");
+
+ add<ScalingFunction<KNPK> >("KNPK");
+ add<ScalingFunction<KRPKR> >("KRPKR");
+ add<ScalingFunction<KBPKB> >("KBPKB");
+ add<ScalingFunction<KBPPKB> >("KBPPKB");
+ add<ScalingFunction<KBPKN> >("KBPKN");
+ add<ScalingFunction<KRPPKRP> >("KRPPKRP");
+}
+
+EndgameFunctions::~EndgameFunctions() {
+
+ for (map<Key, EF*>::iterator it = maps.first.begin(); it != maps.first.end(); ++it)
+ delete (*it).second;
+
+ for (map<Key, SF*>::iterator it = maps.second.begin(); it != maps.second.end(); ++it)
+ delete (*it).second;
+}
+
+Key EndgameFunctions::buildKey(const string& keyCode) {
+
+ assert(keyCode.length() > 0 && keyCode[0] == 'K');
+ assert(keyCode.length() < 8);
+
+ stringstream s;
+ bool upcase = false;
+
+ // Build up a fen string with the given pieces, note that
+ // the fen string could be of an illegal position.
+ for (size_t i = 0; i < keyCode.length(); i++)