+template<>
+ScaleFactor Endgame<KRPKB>::operator()(const Position& pos) const {
+
+ assert(verify_material(pos, strongSide, RookValueMg, 1));
+ assert(verify_material(pos, weakSide, BishopValueMg, 0));
+
+ // Test for a rook pawn
+ if (pos.pieces(PAWN) & (FileABB | FileHBB))
+ {
+ Square ksq = pos.square<KING>(weakSide);
+ Square bsq = pos.square<BISHOP>(weakSide);
+ Square psq = pos.square<PAWN>(strongSide);
+ Rank rk = relative_rank(strongSide, psq);
+ Square push = pawn_push(strongSide);
+
+ // If the pawn is on the 5th rank and the pawn (currently) is on
+ // the same color square as the bishop then there is a chance of
+ // a fortress. Depending on the king position give a moderate
+ // reduction or a stronger one if the defending king is near the
+ // corner but not trapped there.
+ if (rk == RANK_5 && !opposite_colors(bsq, psq))
+ {
+ int d = distance(psq + 3 * push, ksq);