# HG changeset patch # User Robert McIntyre # Date 1395370626 14400 # Node ID 7f3581dc58ff9b5d804d6efa19f0b6330ec1ea6e # Parent dd40244255d4e2d3aacd63d398e8f36e88bcb85d completed phi-space tests; beginning main thesis pdf. diff -r dd40244255d4 -r 7f3581dc58ff org/worm_learn.clj --- a/org/worm_learn.clj Thu Mar 20 20:54:37 2014 -0400 +++ b/org/worm_learn.clj Thu Mar 20 22:57:06 2014 -0400 @@ -215,7 +215,7 @@ (defn grand-circle? "Does the worm form a majestic circle (one end touching the other)?" [experiences] - (and true;; (curled? experiences) + (and (curled? experiences) (let [worm-touch (:touch (peek experiences)) tail-touch (worm-touch 0) head-touch (worm-touch 4)] @@ -380,7 +380,7 @@ (loop [result '() [thread-bases & remaining :as phi-index-sets] phi-index-sets] (if (empty? phi-index-sets) - result + (vec result) (let [threads (for [thread-base thread-bases] (loop [thread (list thread-base) @@ -407,15 +407,58 @@ ) -(def ppp (atom ())) -(defn debug-experience-phi [experiences] - (let [phi-indices (phi-scan (:proprioception (peek experiences)))] - (swap! ppp (partial cons phi-indices)) - (println-repl phi-indices)) - (cond - (grand-circle? experiences) (println "Grand Circle") - (curled? experiences) (println "Curled") - (wiggling? experiences) (println "Wiggling") - (resting? experiences) (println "Resting")) - ) + + +(defn infer-nils + "Replace nils with the next available non-nil element in the + sequence, or barring that, 0." + [s] + (loop [i (dec (count s)) v (transient s)] + (if (= i 0) (persistent! v) + (let [cur (v i)] + (if cur + (if (get v (dec i) 0) + (recur (dec i) v) + (recur (dec i) (assoc! v (dec i) cur))) + (recur i (assoc! v i 0))))))) + +;; tests + +;;(infer-nils [1 nil 1 1]) [1 1 1 1] +;;(infer-nils [1 1 1 nil]) [1 1 1 0] +;;(infer-nils [nil 2 1 1]) [2 2 1 1] + + +(defn debug-experience-phi [] + (let [proprio (atom ())] + (fn + [experiences] + (let [phi-indices (phi-scan (:proprioception (peek experiences)))] + (swap! proprio (partial cons phi-indices)) + (let [exp-thread (longest-thread (take 300 @proprio)) + phi-loop (mapv phi-space (infer-nils exp-thread))] + (println-repl (vector:last-n exp-thread 22)) + (cond + (grand-circle? phi-loop) (println "Grand Circle") + (curled? phi-loop) (println "Curled") + (wiggling? phi-loop) (println "Wiggling") + (resting? phi-loop) (println "Resting") + :else (println "Unknown"))))))) + + +(defn init-interactive [] + (def phi-space + (let [experiences (atom [])] + (run-world + (apply-map + worm-world + (merge + (worm-world-defaults) + {:experiences experiences}))) + @experiences)) + (def phi-scan (gen-phi-scan phi-space))) + + +(defn run-experiment-1 [] + (.start (worm-world :experience-watch (debug-experience-phi)))) \ No newline at end of file diff -r dd40244255d4 -r 7f3581dc58ff thesis/org/roadmap.org --- a/thesis/org/roadmap.org Thu Mar 20 20:54:37 2014 -0400 +++ b/thesis/org/roadmap.org Thu Mar 20 22:57:06 2014 -0400 @@ -213,11 +213,8 @@ CLOCK: [2014-03-19 Wed 22:07] - -*** TODO create test videos, also record positions of worm segments - SCHEDULED: <2014-03-19 Wed> - - +*** DONE create test videos, also record positions of worm segments + CLOSED: [2014-03-20 Thu 22:02] SCHEDULED: <2014-03-19 Wed> *** TODO Collect intro, worm-learn and cortex creation into draft thesis.