# HG changeset patch # User Robert McIntyre # Date 1395363277 14400 # Node ID dd40244255d4e2d3aacd63d398e8f36e88bcb85d # Parent 027707c75f396cdca38c4a9286caef68617463f6 implemented phi-space threading... almost done! diff -r 027707c75f39 -r dd40244255d4 org/worm_learn.clj --- a/org/worm_learn.clj Thu Mar 20 00:24:46 2014 -0400 +++ b/org/worm_learn.clj Thu Mar 20 20:54:37 2014 -0400 @@ -243,22 +243,6 @@ (resting? experiences) (println "Resting"))) -(defn debug-experience - [experiences] - ;; (println-repl - ;; (count (next-phi-states (:proprioception (peek experiences)) - ;; phi-space phi-scan))) - (cond - (grand-circle? experiences) (println "Grand Circle") - (curled? experiences) (println "Curled") - (wiggling? experiences) (println "Wiggling") - (resting? experiences) (println "Resting")) - ) - - - - - (def standard-world-view [(Vector3f. 4.207176, -3.7366982, 3.0816958) (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)]) @@ -386,10 +370,52 @@ (fn [proprio] (bin-map (bin-key proprio)))) bin-keys bin-maps)] (fn lookup [proprio-data] - (some #(% proprio-data) lookups)))) + (set (some #(% proprio-data) lookups))))) + + +(defn longest-thread + "Find the longest thread from phi-index-sets. The index sets should + be ordered from most recent to least recent." + [phi-index-sets] + (loop [result '() + [thread-bases & remaining :as phi-index-sets] phi-index-sets] + (if (empty? phi-index-sets) + result + (let [threads + (for [thread-base thread-bases] + (loop [thread (list thread-base) + remaining remaining] + (let [next-index (dec (first thread))] + (cond (empty? remaining) thread + (contains? (first remaining) next-index) + (recur + (cons next-index thread) (rest remaining)) + :else thread)))) + longest-thread + (reduce (fn [thread-a thread-b] + (if (> (count thread-a) (count thread-b)) + thread-a thread-b)) + '(nil) + threads)] + (recur (concat longest-thread result) + (drop (count longest-thread) phi-index-sets)))))) + (defn init [] (def phi-space (generate-phi-space)) (def phi-scan (gen-phi-scan phi-space)) ) + +(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")) + )