Detect stalemate in KXK endgames

Also, handle cases where there are 2 bishops of the same color.
This commit is contained in:
Gary Linscott
2012-02-05 10:24:53 -05:00
parent 40e939421f
commit 0347339970
2 changed files with 29 additions and 3 deletions

View File

@@ -189,6 +189,7 @@ public:
template<bool SkipRepetition> bool is_draw() const;
int startpos_ply_counter() const;
bool opposite_colored_bishops() const;
bool both_color_bishops(Color c) const;
bool has_pawn_on_7th(Color c) const;
bool is_chess960() const;
@@ -432,6 +433,12 @@ inline bool Position::opposite_colored_bishops() const {
&& opposite_colors(pieceList[WHITE][BISHOP][0], pieceList[BLACK][BISHOP][0]);
}
inline bool Position::both_color_bishops(Color c) const {
// Assumes that there are only two bishops
return pieceCount[c][BISHOP] >= 2 &&
opposite_colors(pieceList[c][BISHOP][0], pieceList[c][BISHOP][1]);
}
inline bool Position::has_pawn_on_7th(Color c) const {
return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7));
}