Last active
March 2, 2017 21:14
-
-
Save deque-blog/41cf1df3684d5bcffc4a88402bec22f8 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
(defn- sole-owner | |
"Indicates whether all positions are owned by the same player" | |
[board positions] | |
(let [owners (set (map #(board/get-owner-at board %) positions))] | |
(case owners | |
#{:owner/circle} :owner/circle | |
#{:owner/cross} :owner/cross | |
nil))) | |
(defn get-winner | |
"Return the winner, or nil if the game has none" | |
[{:keys [board]}] | |
(some #(sole-owner board %) winning-cell-sets)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment