} // namespace
+ namespace Endgames {
+
+ std::pair<Map<Value>, Map<ScaleFactor>> maps;
+
+ void init() {
+
+ add<KPK>("KPK");
+ add<KNNK>("KNNK");
+ add<KBNK>("KBNK");
+ add<KRKP>("KRKP");
+ add<KRKB>("KRKB");
+ add<KRKN>("KRKN");
+ add<KQKP>("KQKP");
+ add<KQKR>("KQKR");
+ add<KNNKP>("KNNKP");
+
++ // Fairy piece endgames
++ add<KNSK>("KNSK");
++ add<KNFK>("KNFK");
++ add<KNSFKR>("KNSFKR");
++ add<KSFK>("KSFK");
++
+ add<KNPK>("KNPK");
+ add<KNPKB>("KNPKB");
+ add<KRPKR>("KRPKR");
+ add<KRPKB>("KRPKB");
+ add<KBPKB>("KBPKB");
+ add<KBPKN>("KBPKN");
+ add<KBPPKB>("KBPPKB");
+ add<KRPPKRP>("KRPPKRP");
+ }
+ }
+
/// 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
// Score this pawn
if (support | phalanx)
{
- int v = (phalanx ? 3 : 2) * Connected[r] * (r == RANK_2 && pos.captures_to_hand() ? 3 : 1);
- int v = Connected[r] * (phalanx ? 3 : 2) / (opposed ? 2 : 1)
++ int v = Connected[r] * (phalanx ? 3 : 2) * (r == RANK_2 && pos.captures_to_hand() ? 3 : 1) / (opposed ? 2 : 1)
+ + 17 * popcount(support);
-
+ if (r >= RANK_4 && pos.count<PAWN>(Us) > popcount(pos.board_bb()) / 4)
- v = std::max(v, popcount(support | phalanx) * 100);
- v = 17 * popcount(support) + (v >> (opposed + 1));
++ v = std::max(v, popcount(support | phalanx) * 100) / (opposed ? 2 : 1);
score += make_score(v, v * (r - 2) / 4);
}
else if (!neighbours)