   (for [i (range board-size)] [i (- (dec board-size) i)]))
 
 (defn all-lines-coords []
-  (concat  [(diagonal-down board) (diagonal-up board)]
-    (for [i (range board-size)] (horizontal board i))
-    (for [i (range board-size)] (vertical board i))))
+  (concat  [(diagonal-down-coords) (diagonal-up-coords)]
+    (for [i (range board-size)] (horizontal-coords i))
+    (for [i (range board-size)] (vertical-coords i))))
+
+(defn get-coords [board coords]
+  (map #(get-in board %) coords))
+
+(defn all-lines [board]
+   (map #(get-coords board %)  (all-lines-coords)))
 
 (defn winning-by? [player line]
   (every? #(= % player) (take winning-k line)))
 
 (defn winning? [board player]
   (some (partial winning-by? player) (all-lines board) ))
+
+(defn threat-by? [line]
+  (and (= 0 (count (filter #(= % "O") line))) 
+   (= (dec winning-k) (count (filter #(= % "X") line)))))
+
+(defn threat-lines [board]
+  (filter #(threat-by? (get-coords board %)) (all-lines-coords)))
+
+(defn free-spot [board line-coords]
+  (first (filter #(= "B" (get-in board %)) line-coords )))
 
 (defn game-status []
   (let [board (:board @app-state)]


(def board-size 3)
(def winning-k 3)
; (def player "X")
; (def computer "O")
; (def blank "B")

(defn new-board
  [n]

(defn draw? [board]
  (empty? (free-spots board)))

(defn vertical-coords [y]
  (map #(vector % y) (range board-size)))

