+ if ( opposite_colors(queeningSq, bishopSq)
+ && square_distance(queeningSq, kingSq) <= 1)
+ return SCALE_FACTOR_DRAW;
+ }
+
+ // If all the pawns are on the same B or G file, then it's potentially a draw
+ if ( (pawnFile == FILE_B || pawnFile == FILE_G)
+ && !(pos.pieces(PAWN) & ~file_bb(pawnFile))
+ && pos.non_pawn_material(weakSide) == 0
+ && pos.count<PAWN>(weakSide) >= 1)
+ {
+ // Get weakSide pawn that is closest to the home rank
+ Square weakPawnSq = backmost_sq(weakSide, pos.pieces(weakSide, PAWN));
+
+ Square strongKingSq = pos.king_square(strongSide);
+ Square weakKingSq = pos.king_square(weakSide);
+ Square bishopSq = pos.list<BISHOP>(strongSide)[0];
+
+ // There's potential for a draw if our pawn is blocked on the 7th rank,
+ // the bishop cannot attack it or they only have one pawn left
+ if ( relative_rank(strongSide, weakPawnSq) == RANK_7
+ && (pos.pieces(strongSide, PAWN) & (weakPawnSq + pawn_push(weakSide)))
+ && (opposite_colors(bishopSq, weakPawnSq) || pos.count<PAWN>(strongSide) == 1))