- // Get the material key of a Position out of the given endgame key code
- // like "KBPKN". The trick here is to first forge an ad-hoc fen string
- // and then let a Position object to do the work for us. Note that the
- // fen string could correspond to an illegal position.
+ // Pawn Rank based scaling factors used in KRPPKRP endgame
+ const int KRPPKRPScaleFactors[RANK_NB] = { 0, 9, 10, 14, 21, 44, 0, 0 };
+
+#ifndef NDEBUG
+ bool verify_material(const Position& pos, Color c, Value npm, int pawnsCnt) {
+ return pos.non_pawn_material(c) == npm && pos.count<PAWN>(c) == pawnsCnt;
+ }
+#endif
+
+ // Map the square as if strongSide is white and strongSide's only pawn
+ // is on the left half of the board.
+ Square normalize(const Position& pos, Color strongSide, Square sq) {
+
+ assert(pos.count<PAWN>(strongSide) == 1);
+
+ if (file_of(pos.square<PAWN>(strongSide)) >= FILE_E)
+ sq = Square(sq ^ 7); // Mirror SQ_H1 -> SQ_A1
+
+ if (strongSide == BLACK)
+ sq = ~sq;
+
+ return sq;
+ }
+
+ // Get the material key of Position out of the given endgame key code
+ // like "KBPKN". The trick here is to first forge an ad-hoc FEN string
+ // and then let a Position object do the work for us.