Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 1, 2017 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/ec53a53df965c2610c44e455f066fb4f to your computer and use it in GitHub Desktop.
Save deque-blog/ec53a53df965c2610c44e455f066fb4f to your computer and use it in GitHub Desktop.
(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