 (defn- terrain-accessible? [terrain pos]
   (not (contains? terrain pos)))
 
+(defn- move-terrain [terrain current-pos action world-size]
+  (let [new-pos (get-position current-pos action)]
+    (if (and (in-world? world-size new-pos)
+             (terrain-accessible? terrain new-pos))
+      (-> terrain
+          (clojure.set/rename-keys {current-pos new-pos})
+          (update new-pos set-terrain-direction action))
+      terrain)))
+
 (defn- damage-terrain [terrain target attack]
   (if-let [health (get-in terrain [target :health])]
     (let [new-health (- health attack)]

          (and (= x-dist 0) (> y-dist 0)) :up
          (and (= x-dist 0) (< y-dist 0)) :down)))

(defn- move-zombie [terrain current-pos action]
  (let [new-pos (get-position current-pos action)]
    (if (terrain-accessible? terrain new-pos)
      (clojure.set/rename-keys terrain {current-pos new-pos})
      terrain)))

(defn run-zombie-action [{terrain    :terrain
                          player-pos :player-pos
                          :as        game}
                         current-pos]
  (if (in-weapon-range? terrain current-pos player-pos)
    (update game :terrain attack-target current-pos player-pos :player)
    (let [action (calculate-zombie-action current-pos player-pos)]
      (update game :terrain move-zombie current-pos action))))

;;
;; game

                                    ::weapon]))

(s/def ::world-size ::position)
(s/def ::terrain (s/map-of ::position ::character :min-count 1))

(s/def ::game (s/keys :req-un [::world-size
                               ::terrain]))

(s/def ::player-action (conj (s/describe ::direction) :fire))

