                 unit (Unit. unit-id unit-type player-id mass radius x y vx vy extra extra2)]
             (swap! units conj unit)
             (recur (dec i)))))
-      (let [wrecks (filter #(= (:unit-type %) :wreck) @units)
+      (let [reapers (filter #(= (:unit-type %) :reaper) @units)
+            destroyers (filter #(= (:unit-type %) :destroyer) @units)
+            doofs (filter #(= (:unit-type %) :doof) @units)
+            tankers (filter #(= (:unit-type %) :tanker) @units)
+            wrecks (filter #(= (:unit-type %) :wreck) @units)
             wrecks-with-water (filter #(> (:extra %) 0) wrecks)
-            tankers (filter #(= (:unit-type %) :tanker) @units)
-            reapers (filter #(= (:unit-type %) :reaper) @units)
-            destroyers (filter #(= (:unit-type %) :destroyer) @units)
             enemy-reapers (filter #(not= (:player-id %) 0) reapers)
             enemy-destroyers (filter #(not= (:player-id %) 0) destroyers)
+            enemy-doofs (filter #(not= (:player-id %) 0) doofs)
             my-reaper (first (filter #(= (:player-id %) 0) reapers))
             my-destroyer (first (filter #(= (:player-id %) 0) destroyers))
+            my-doof (first (filter #(= (:player-id %) 0) doofs))
             next-wreck (first (sort-by #(distance (:x my-reaper) (:y my-reaper) (:x %) (:y %)) wrecks-with-water))
-            next-tanker (first (sort-by #(distance (:x my-destroyer) (:y my-destroyer) (:x %) (:y %)) tankers))]
+            tankers-sorted-by-distance (sort-by #(distance (:x my-destroyer) (:y my-destroyer) (:x %) (:y %)) tankers)
+            next-tanker (first tankers-sorted-by-distance)]
         (binding [*out* *err*] (println "wrecks : " (string/join " " (map #(into {} %) wrecks)))
                                (println "wrecks with water: " (string/join " " (map #(into {} %) wrecks-with-water)))
                                (println "tankers : " (string/join " " (map #(into {} %) tankers)))

    (near my-reaper next-wreck) (str (:x next-wreck) " " (:y next-wreck) " 150")
    true (str (:x next-wreck) " " (:y next-wreck) " 300")))

(defn compute-destroyer-action [my-destroyer next-tanker]
  (cond
    (nil? next-tanker) "WAIT"
    (in my-destroyer next-tanker) (str (:x next-tanker) " " (:y next-tanker) " 0")
    true (str (:x next-tanker) " " (:y next-tanker) " 300")))

(defn -main [& args]
  (while true


(require '[clojure.string :as string])

;;unitType 0 (Reaper), 1 (Destroyer), 2 (Doof), 3 (Tanker), 4 (Wreck)
(def unit-types [:reaper :destroyer :doof :tanker :wreck])

(defrecord Unit
  [unit-id unit-type player-id mass radius x y vx vy extra extra2])
