Created
April 29, 2012 13:16
-
-
Save mistercam/2550403 to your computer and use it in GitHub Desktop.
Functions to determine if the Reversi game is over
This file contains 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
(defn valid-moves [board piece] | |
"Returns the set of valid moves for the given piece" | |
(for [r (range 8) c (range 8) ; for each permutation of r and c | |
:let [move [r c]] | |
:when (move-valid? board piece move)] | |
move)) | |
(defn game-over? [board] | |
"Returns true if there are no more moves to be made on the board, else returns false" | |
(and | |
(empty? (valid-moves board :w )) | |
(empty? (valid-moves board :b )))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment