- const Value BishopPairMidgameBonus = Value(100);
- const Value BishopPairEndgameBonus = Value(100);
-
- Key KRPKRMaterialKey, KRKRPMaterialKey;
- Key KNNKMaterialKey, KKNNMaterialKey;
- Key KBPKBMaterialKey, KBKBPMaterialKey;
- Key KBPKNMaterialKey, KNKBPMaterialKey;
- Key KNPKMaterialKey, KKNPMaterialKey;
- Key KPKPMaterialKey;
- Key KRPPKRPMaterialKey, KRPKRPPMaterialKey;
-
- std::map<Key, EndgameEvaluationFunction*> EEFmap;
-
- void EEFAdd(Key k, EndgameEvaluationFunction* f) {
-
- EEFmap.insert(std::pair<Key, EndgameEvaluationFunction*>(k, f));
+ // Values modified by Joona Kiiski
+ const Value MidgameLimit = Value(15581);
+ const Value EndgameLimit = Value(3998);
+
+ // Scale factors used when one side has no more pawns
+ const int NoPawnsSF[4] = { 6, 12, 32 };
+
+ // Polynomial material balance parameters
+ const Value RedundantQueen = Value(320);
+ const Value RedundantRook = Value(554);
+
+ // pair pawn knight bishop rook queen
+ const int LinearCoefficients[6] = { 1617, -162, -1172, -190, 105, 26 };
+
+ const int QuadraticCoefficientsSameColor[][PIECE_TYPE_NB] = {
+ // pair pawn knight bishop rook queen
+ { 7 }, // Bishop pair
+ { 39, 2 }, // Pawn
+ { 35, 271, -4 }, // Knight
+ { 7, 105, 4, 7 }, // Bishop
+ { -27, -2, 46, 100, 56 }, // Rook
+ { 58, 29, 83, 148, -3, -25 } // Queen
+ };
+
+ const int QuadraticCoefficientsOppositeColor[][PIECE_TYPE_NB] = {
+ // THEIR PIECES
+ // pair pawn knight bishop rook queen
+ { 41 }, // Bishop pair
+ { 37, 41 }, // Pawn
+ { 10, 62, 41 }, // Knight OUR PIECES
+ { 57, 64, 39, 41 }, // Bishop
+ { 50, 40, 23, -22, 41 }, // Rook
+ { 106, 101, 3, 151, 171, 41 } // Queen
+ };
+
+ // Endgame evaluation and scaling functions accessed direcly and not through
+ // the function maps because correspond to more then one material hash key.
+ Endgame<KmmKm> EvaluateKmmKm[] = { Endgame<KmmKm>(WHITE), Endgame<KmmKm>(BLACK) };
+ Endgame<KXK> EvaluateKXK[] = { Endgame<KXK>(WHITE), Endgame<KXK>(BLACK) };
+
+ Endgame<KBPsK> ScaleKBPsK[] = { Endgame<KBPsK>(WHITE), Endgame<KBPsK>(BLACK) };
+ Endgame<KQKRPs> ScaleKQKRPs[] = { Endgame<KQKRPs>(WHITE), Endgame<KQKRPs>(BLACK) };
+ Endgame<KPsK> ScaleKPsK[] = { Endgame<KPsK>(WHITE), Endgame<KPsK>(BLACK) };
+ Endgame<KPKP> ScaleKPKP[] = { Endgame<KPKP>(WHITE), Endgame<KPKP>(BLACK) };
+
+ // Helper templates used to detect a given material distribution
+ template<Color Us> bool is_KXK(const Position& pos) {
+ const Color Them = (Us == WHITE ? BLACK : WHITE);
+ return !pos.count<PAWN>(Them)
+ && pos.non_pawn_material(Them) == VALUE_ZERO
+ && pos.non_pawn_material(Us) >= RookValueMg;