Created
March 8, 2017 23:14
-
-
Save deque-blog/3e82c446131ebf242c20d33b10864d3a 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
;; Partitioning by owner of the board gives contiguous sequences | |
(let [first-line (map vector (repeat 0) (range 0 16))] | |
(partition-by #(board/get-owner-at board %) first-line)) | |
;; Contiguous sequences of coordinates | |
=> | |
(([0 0]) ([0 1] [0 2] [0 3] [0 4]) ([0 5]) | |
([0 6]) ([0 7]) ([0 8] [0 9]) ([0 10]) | |
([0 11] [0 12] [0 13] [0 14] [0 15])) | |
;; Making some windows out of it | |
(partition 3 1 *1) | |
=> | |
((([0 0]) ([0 1] [0 2] [0 3] [0 4]) ([0 5])) ;; First window | |
(([0 1] [0 2] [0 3] [0 4]) ([0 5]) ([0 6])) ;; Second window | |
(([0 5]) ([0 6]) ([0 7])) | |
(([0 6]) ([0 7]) ([0 8] [0 9])) | |
(([0 7]) ([0 8] [0 9]) ([0 10])) | |
(([0 8] [0 9]) ([0 10]) ([0 11] [0 12] [0 13] [0 14] [0 15]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment