           (kind (:cells (om/root-cursor app-state))))))
 
 (defn highlight-tile [e]
+  ;(om/transact! (om/root-cursor app-state) [:cells (]
  (set! (.. e -target -style -background) "gray"))
 
 (defn tile-view [cursor owner]

        (if-let [ball (unit? :balls coords)]
          (dom/div #js {:className "ball"}))
        (if-let [red-player (unit? :red-team coords)]
          (dom/div #js {:onClick #(highlight-tile %) :className "red-team"}))
        (if-let [blue-player (unit? :blue-team coords)]
          (dom/div #js {:className "blue-team"}))))))



(defn board-view [app owner]
  (reify
    om/IInitState
    (init-state [_]
      {:move (chan)})

    om/IWillMount
    (will-mount [_]
     (let [move (om/get-state owner :move)]
       (go (loop []
          (let [selected (:coords (<! move))
                target (:coords (<! move))]
            (if (unit? :red-team target)
              (println "CAN'T MOVE THERE")
              (om/transact! app [:cells :red-team]
                (fn [units]
                  (map
                   #(if (and
                         (= selected (:coords %))
                         (<= (reduce + (map (fn [a b] (Math/abs (- b a))) (vals target) (vals selected))) (:distance %)))
                      (conj % {:coords target})
                      %)
                   units)))))
          (recur)))))

    om/IRenderState
    (render-state [this {:keys [move]}]
      (dom/div #js {:className "container"}
        (bench)
        (apply dom/table nil
          (vec (for [y board-size]

(defonce app-state (atom
                    {:cells
                        {:blue-team
                         [{:coords {:x 0, :y 0}}
                          {:coords {:x 2, :y 0}}
                          {:coords {:x 4, :y 0}}
                          {:coords {:x 6, :y 0}}
                          {:coords {:x 8, :y 0}}]
                        :red-team
                         [{:coords {:x 0, :y 8}}
                          {:coords {:x 2, :y 8}}
                          {:coords {:x 4, :y 8}}
                          {:coords {:x 6, :y 8}}
                          {:coords {:x 8, :y 8}}]
                        :balls
                         [{:coords {:x 0, :y 4}}
                          {:coords {:x 2, :y 4}}
                          {:coords {:x 4, :y 4}}
                          {:coords {:x 6, :y 4}}
                          {:coords {:x 8, :y 4}}]}
                     :turn :blue-team
                     :actions 0}))

(def board-size (range 0 9))
(def bench-size 4)
(def move-range 6)

(defn border-top [y]
  (cond
