                 :else c)))
 
 (defn rule-avoid-collisions [c cs]
-    (let [  collisions      (filter #(critter-collision? % c) cs)
+    (let [  collisions      (filter #(near-points? c % 20) cs)
             collision-area  (center-of-points collisions)
             no-collision?   (empty? collisions)]
         (cond   



(defn translate [x y] (str "translate(" x "px," y "px)"))
(defn wrap-map [f xs] 
    (map-indexed (fn [idx it] [:g {:key idx} [f it]]) xs))


(defn module-critter [critter] 
    (let [{:keys [x y]} critter]
        [:g.module-critter 
            {:style {:transition "transform 500ms"
                     :transform (translate x y)}}
            [:circle {:r 20 :style {:fill "brown"}}]]))

(defn module-critter-pen []
    (let [{:keys [width height critters]} @app-state]
        [:svg.module-critter-pen 
            {:width width :height height}
            [:rect {:width width :height height 
                :style {:fill "gray"}}]
            [:g.critters (wrap-map module-critter critters)]]))

(defn module-app-root []
    [:section.module-app-root

            :else   (move-towards -10 c collision-area))))

(defn rule-match-velocity [c cs]
    (let [  avg-velocity    (average-velocity cs)
            r               (:r avg-velocity)
            velocity        (assoc avg-velocity :r (/ r 2))
            with-v          (assoc c :velocity velocity)
            diff            (polar->cartesian velocity)]
        (subtract-point with-v diff)))

(defn rule-avoid-mouse [c mouse]
    (let [ near-mouse?  (near-points? c mouse 100)]
        (cond near-mouse? (move-towards -50 c mouse) :else c)))

(defn critter-destination [c state]
    (let [  other-critters  (exclude c (:critters state))]
        (-> c
            (rule-to-center other-critters)
            (rule-avoid-walls (:width state) (:height state))
            (rule-avoid-collisions other-critters)
            (rule-match-velocity other-critters)
            (rule-avoid-mouse (:mouse state))
            )))


