 (defn adjust-directional-vel-to-bounds
   "adjust velocity if it is too fast or goes outside of view area"
   [vel pos max-speed min-pos max-pos bounce-vel size]
-  (cond 
+  (cond
     (> (+ pos vel (/ size 2)) max-pos)
     (- 0 bounce-vel)
 

        state (if (= (:frames-to-wait search-state) 1)
                (x-first-search (assoc-in state [:search-state :frames-to-wait] frames-between-visits))
                (update-in state [:search-state :frames-to-wait] dec))
        collection (get-in state [:search-state :collection]) 
        state (if (empty? collection) 
                ;; when x-first-search returns empty collection, search finished, so start fresh with the other search alg
                (infer-new-search-state (if (= :bfs (get-in state [:search-state :search-type])) :dfs :bfs) (:nodes state))
                state)]
    state))

(defn update-state
  "quil update-state step"
  [state]
  (update-colors 
    (update-movement state)))

(defn draw-state 
  "quil draw-state step"
  [state]
  (q/background 0 0 0 0)
  (q/no-stroke)
  (let [nodes (:nodes state)
        edges (extract-edges (vals nodes))
        visiting (peek (get-in state [:search-state :collection]))] 
    (q/fill (:edge colors)) ; set fill as edge color
    ;; draw each edge as a quad. Determine points using some mathematical math.
    (doseq [ks edges]
      (let [ks (into [] ks)
            n1 ((nth ks 0) nodes)
            n2 ((nth ks 1) nodes)
            n1-pos (:pos n1)
            n2-pos (:pos n2)
            x1 (:x n1-pos)

            x2-b (- x2 (* size2-adj x-delta-2))
            y2-a (- y2 (* size2-adj y-delta-2))
            y2-b (+ y2 (* size2-adj y-delta-2))]
        (q/quad x1-a y1-a x1-b y1-b x2-b y2-b x2-a y2-a)))))

(defn draw-nodes [state]
  (let [{:keys [nodes colors search-state]} state
        visiting (peek (:collection search-state))]
    ;; draw each node
    (doseq [n (vals nodes)]
      (q/fill ((:color-key n) colors))
      (if (= visiting (:label n)) ; use a stroke for the node at the front of the stack/queue
        (q/stroke (:visiting colors))
        (q/no-stroke))
      (q/ellipse (:x (:pos n)) (:y (:pos n)) (:size n) (:size n)))))

(defn draw-state
  "quil draw-state step"
  [state]
  (q/background 255)
  (q/no-stroke)
  (draw-edges state)
  (draw-nodes state))

(defn run-sketch [host size] ;DELETE
  (q/sketch
