Skip to content

Instantly share code, notes, and snippets.

@flugsio
Created October 27, 2015 23:05
Show Gist options
  • Save flugsio/9c57439fe6c364f0181d to your computer and use it in GitHub Desktop.
Save flugsio/9c57439fe6c364f0181d to your computer and use it in GitHub Desktop.
/**
* Returns true when the only non-king pieces that remain are bishops that cannot
* capture each other.
*/
def bishopsOnDifferentColor(board: Board) = {
val notKingPieces = nonKingPieces(board)
def pieceSquareColorsFor(color: Color) = notKingPieces.filter(_._2.color == color).map(_._1.color)
notKingPieces.map(_._2.role).distinct match {
case List(Bishop) => {
(pieceSquareColorsFor(Color.White) intersect pieceSquareColorsFor(Color.Black)).isEmpty
}
case _ => false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment