changeset 420:7f3581dc58ff

completed phi-space tests; beginning main thesis pdf.
author Robert McIntyre <rlm@mit.edu>
date Thu, 20 Mar 2014 22:57:06 -0400
parents dd40244255d4
children c2c28c3e27c4
files org/worm_learn.clj thesis/org/roadmap.org
diffstat 2 files changed, 58 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/org/worm_learn.clj	Thu Mar 20 20:54:37 2014 -0400
     1.2 +++ b/org/worm_learn.clj	Thu Mar 20 22:57:06 2014 -0400
     1.3 @@ -215,7 +215,7 @@
     1.4  (defn grand-circle?
     1.5    "Does the worm form a majestic circle (one end touching the other)?"
     1.6    [experiences]
     1.7 -  (and true;; (curled? experiences)
     1.8 +  (and (curled? experiences)
     1.9         (let [worm-touch (:touch (peek experiences))
    1.10               tail-touch (worm-touch 0)
    1.11               head-touch (worm-touch 4)]
    1.12 @@ -380,7 +380,7 @@
    1.13    (loop [result '()
    1.14           [thread-bases & remaining :as phi-index-sets] phi-index-sets]
    1.15      (if (empty? phi-index-sets)
    1.16 -      result
    1.17 +      (vec result)
    1.18        (let [threads
    1.19              (for [thread-base thread-bases]
    1.20                (loop [thread (list thread-base)
    1.21 @@ -407,15 +407,58 @@
    1.22    )
    1.23  
    1.24  
    1.25 -(def ppp (atom ()))
    1.26  
    1.27 -(defn debug-experience-phi [experiences]
    1.28 -  (let [phi-indices (phi-scan (:proprioception (peek experiences)))]
    1.29 -    (swap! ppp (partial cons phi-indices))
    1.30 -    (println-repl phi-indices))
    1.31 -  (cond
    1.32 -   (grand-circle? experiences) (println "Grand Circle")
    1.33 -   (curled? experiences)       (println "Curled")
    1.34 -   (wiggling? experiences)     (println "Wiggling")
    1.35 -   (resting? experiences)      (println "Resting"))
    1.36 -  )
    1.37 +
    1.38 +
    1.39 +(defn infer-nils
    1.40 +  "Replace nils with the next available non-nil element in the
    1.41 +   sequence, or barring that, 0."
    1.42 +  [s]
    1.43 +  (loop [i (dec (count s)) v (transient s)]
    1.44 +    (if (= i 0) (persistent! v)
    1.45 +        (let [cur (v i)]
    1.46 +          (if cur
    1.47 +            (if (get v (dec i) 0)
    1.48 +              (recur (dec i) v)
    1.49 +              (recur (dec i) (assoc! v (dec i) cur)))
    1.50 +            (recur i (assoc! v i 0)))))))
    1.51 +
    1.52 +;; tests
    1.53 +
    1.54 +;;(infer-nils [1 nil 1 1]) [1 1 1 1]
    1.55 +;;(infer-nils [1 1 1 nil]) [1 1 1 0]
    1.56 +;;(infer-nils [nil 2 1 1]) [2 2 1 1]       
    1.57 +  
    1.58 +
    1.59 +(defn debug-experience-phi []
    1.60 +  (let [proprio (atom ())]
    1.61 +    (fn
    1.62 +      [experiences]
    1.63 +      (let [phi-indices (phi-scan (:proprioception (peek experiences)))]
    1.64 +        (swap! proprio (partial cons phi-indices))
    1.65 +        (let [exp-thread (longest-thread (take 300 @proprio))
    1.66 +              phi-loop (mapv phi-space (infer-nils exp-thread))]
    1.67 +          (println-repl (vector:last-n exp-thread 22))
    1.68 +          (cond
    1.69 +           (grand-circle? phi-loop) (println "Grand Circle")
    1.70 +           (curled? phi-loop)       (println "Curled")
    1.71 +           (wiggling? phi-loop)     (println "Wiggling")
    1.72 +           (resting? phi-loop)      (println "Resting")
    1.73 +           :else                    (println "Unknown")))))))
    1.74 +
    1.75 +
    1.76 +(defn init-interactive []
    1.77 +  (def phi-space
    1.78 +    (let [experiences (atom [])]
    1.79 +      (run-world
    1.80 +       (apply-map 
    1.81 +        worm-world
    1.82 +        (merge
    1.83 +         (worm-world-defaults)
    1.84 +         {:experiences experiences})))
    1.85 +      @experiences))
    1.86 +  (def phi-scan (gen-phi-scan phi-space)))
    1.87 +    
    1.88 +
    1.89 +(defn run-experiment-1 []
    1.90 +  (.start (worm-world :experience-watch (debug-experience-phi))))
    1.91 \ No newline at end of file
     2.1 --- a/thesis/org/roadmap.org	Thu Mar 20 20:54:37 2014 -0400
     2.2 +++ b/thesis/org/roadmap.org	Thu Mar 20 22:57:06 2014 -0400
     2.3 @@ -213,11 +213,8 @@
     2.4      CLOCK: [2014-03-19 Wed 22:07]
     2.5  
     2.6  
     2.7 -
     2.8 -*** TODO create test videos, also record positions of worm segments
     2.9 -    SCHEDULED: <2014-03-19 Wed>
    2.10 -
    2.11 -
    2.12 +*** DONE create test videos, also record positions of worm segments
    2.13 +    CLOSED: [2014-03-20 Thu 22:02] SCHEDULED: <2014-03-19 Wed>
    2.14  
    2.15  *** TODO Collect intro, worm-learn and cortex creation into draft thesis. 
    2.16