Skip to content

Instantly share code, notes, and snippets.

@u6f6o
Created March 16, 2016 20:31
Show Gist options
  • Select an option

  • Save u6f6o/279dddeb75ff9096c661 to your computer and use it in GitHub Desktop.

Select an option

Save u6f6o/279dddeb75ff9096c661 to your computer and use it in GitHub Desktop.
(defn init
[board start-idx]
(if-not (started? board)
(init-game board start-idx)
board))
(defn explore
[board idx]
(if-not (or (pos? (nth (:flags board) idx))
(pos? (nth (:explored board) idx))
(won? board)
(lost? board))
(explore-cell board idx)
board))
(defn flag
[board idx]
(if-not (or (pos? (nth (:explored board) idx))
(not (started? board))
(won? board)
(lost? board))
(toggle-flag board idx)
board))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment