Skip to content

Instantly share code, notes, and snippets.

@mistercam
Created April 29, 2012 13:16
Show Gist options
  • Save mistercam/2550403 to your computer and use it in GitHub Desktop.
Save mistercam/2550403 to your computer and use it in GitHub Desktop.
Functions to determine if the Reversi game is over
(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