- mi->mgValue = int16_t(mgValue);
- mi->egValue = int16_t(egValue);
- return mi;
-}
-
-
-/// EndgameFunctions member definitions. This class is used to store the maps
-/// of end game and scaling functions that MaterialInfoTable will query for
-/// each key. The maps are constant and are populated only at construction,
-/// but are per-thread instead of globals to avoid expensive locks.
-
-EndgameFunctions::EndgameFunctions() {
-
- KNNKMaterialKey = buildKey("KNNK");
- KKNNMaterialKey = buildKey("KKNN");
-
- add("KPK", &EvaluateKPK);
- add("KKP", &EvaluateKKP);
- add("KBNK", &EvaluateKBNK);
- add("KKBN", &EvaluateKKBN);
- add("KRKP", &EvaluateKRKP);
- add("KPKR", &EvaluateKPKR);
- add("KRKB", &EvaluateKRKB);
- add("KBKR", &EvaluateKBKR);
- add("KRKN", &EvaluateKRKN);
- add("KNKR", &EvaluateKNKR);
- add("KQKR", &EvaluateKQKR);
- add("KRKQ", &EvaluateKRKQ);
- add("KBBKN", &EvaluateKBBKN);
- add("KNKBB", &EvaluateKNKBB);
-
- add("KNPK", WHITE, &ScaleKNPK);
- add("KKNP", BLACK, &ScaleKKNP);
- add("KRPKR", WHITE, &ScaleKRPKR);
- add("KRKRP", BLACK, &ScaleKRKRP);
- add("KBPKB", WHITE, &ScaleKBPKB);
- add("KBKBP", BLACK, &ScaleKBKBP);
- add("KBPPKB", WHITE, &ScaleKBPPKB);
- add("KBKBPP", BLACK, &ScaleKBKBPP);
- add("KBPKN", WHITE, &ScaleKBPKN);
- add("KNKBP", BLACK, &ScaleKNKBP);
- add("KRPPKRP", WHITE, &ScaleKRPPKRP);
- add("KRPKRPP", BLACK, &ScaleKRPKRPP);
- add("KRPPKRP", WHITE, &ScaleKRPPKRP);
- add("KRPKRPP", BLACK, &ScaleKRPKRPP);
-}
-
-Key EndgameFunctions::buildKey(const string& keyCode) {
-
- assert(keyCode.length() > 0 && keyCode[0] == 'K');
- assert(keyCode.length() < 8);
-
- std::stringstream s;
- bool upcase = false;
-
- // Build up a fen substring with the given pieces, note
- // that the fen string could be of an illegal position.
- for (size_t i = 0; i < keyCode.length(); i++)
- {
- if (keyCode[i] == 'K')
- upcase = !upcase;