     (doseq [image-count samples
             run runs]
       (if verbose
-        (println (format "Simulating %d retinas with %d samples from cache %s (run = %d)..."
-                         (count my-retinas) image-count hs-cache-filename run)))
+        (println (format "Simulating %d retinas with %d samples from cache %s (run = %s)..."
+                         (count my-retinas) image-count hs-cache-filename (str run))))
       (let [[inits analfns finfns] (make-analysis save-every
                                                   output-dir
                                                   (when verbose print-every)

                 :S-cone-flags [:human]
                 :samples [2500000]
                 :runs [0]
                 :save-every 100000}})

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; create a list of retinas from a simulation plan
(defn retinas-from-plan [plan]
  (for [surround (get plan :surrounds [[0.25 3.0]])
        L-to-M (get plan :L-to-Ms [[1 1]])
        M-lambda-max (get plan :M-lambda-maxs [530.3])
        L-lambda-max (get plan :L-lambda-maxs [558.9])
        S-lambda-max (get plan :S-lambda-maxs [420.7])
        S-cone-flags (get plan :S-cone-flags [:human])
        retina-size (get plan :sizes [20])]
    (retina :surround surround
            :mosaic (mosaic :size retina-size)
            :cones [:L :M :S]
            :cone-makeup (cond (= S-cone-flags :human)
                               {:L (first L-to-M)
                                :M (fnext L-to-M)
                                :S {:even-spacing true, :fraction 0.06}}
                               (= S-cone-flags :none)
                               {:L (first L-to-M)
                                :M (fnext L-to-M)}
                               :else (throw (IllegalArgumentException. "invalid s-cone flag")))
            :lambda-max {:L L-lambda-max, :M M-lambda-max, :S S-lambda-max})))

;; yields a filename for writing out a simulation
(defn simulation-filename [r image-count run-id]
  (let [params (:params r)
        Mlm (Math/round (double (:M (let [lm (:lambda-max params)]
                                      (if (= lm :automatic)
                                        human-lambda-max
                                        lm)))))
        cone-makeup (:cone-makeup params)
        L-M (str (:L cone-makeup) ":" (:M cone-makeup))
        surr (let [ss (:surround params)
                   s (if (= ss :automatic) [0.25 3.0] ss)]
               (if s

         ",samples=" image-count
         ",run=" run-id
         (let [tt (:type (:params r))]
           (cond (= tt :tetrachromat)
                 (str ",tetrachromat[" (:A cone-makeup)
                      "," (Math/round (double (:A (:lambda-max params)))) "]")
                 (= tt :dichromat) ",dichromat"
                 :else ""))
         "].bin")))
