Created
October 27, 2015 23:05
-
-
Save flugsio/9c57439fe6c364f0181d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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