Last active
August 29, 2015 13:56
-
-
Save tarynsauer/9316443 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
| (def player-types ["human" "computer" "ai"]) | |
| (defmulti get-move (fn [current-player board] (:player-type current-player))) | |
| (defmethod get-move "human" [current-player board] | |
| (get-human-move)) | |
| (defmethod get-move "computer" [current-player board] | |
| (get-random-move board)) | |
| (defmethod get-move "ai" [current-player board] | |
| (get-ai-move (:piece current-player) board)) | |
| ;; current-player methods | |
| (defn current-player [board player-x player-o] | |
| (if (even? (count (filter string? board))) | |
| player-x | |
| player-o)) | |
| (defn current-piece [board] | |
| (if (even? (count (filter string? board))) | |
| (first piece) | |
| (second piece))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment