Last active
March 1, 2017 20:26
-
-
Save deque-blog/ec53a53df965c2610c44e455f066fb4f 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 get-owner-at | |
"Get the owner associated to the cell" | |
[board coord] | |
{:pre [(coordinates? coord)]} | |
(get board coord)) | |
(defn has-owner? | |
"Check whether the coord has an owner associated to it" | |
[board coord] | |
{:pre [(coordinates? coord)]} | |
(not= (get-owner-at board coord) :owner/none)) | |
(defn convert-cell | |
"Assign the cell [x y] to a new player" | |
[board player coord] | |
{:pre [(coordinates? coord) | |
(not (has-owner? board coord))]} | |
(assoc board coord player)) | |
(defn full-board? | |
"Verifies whether the board has any empty cell left" | |
[board] | |
(not-any? #{:owner/none} (vals board))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment