Mercurial > cortex
diff org/worm_learn.clj @ 419:dd40244255d4
implemented phi-space threading... almost done!
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 20 Mar 2014 20:54:37 -0400 |
parents | 027707c75f39 |
children | 7f3581dc58ff |
line wrap: on
line diff
1.1 --- a/org/worm_learn.clj Thu Mar 20 00:24:46 2014 -0400 1.2 +++ b/org/worm_learn.clj Thu Mar 20 20:54:37 2014 -0400 1.3 @@ -243,22 +243,6 @@ 1.4 (resting? experiences) (println "Resting"))) 1.5 1.6 1.7 -(defn debug-experience 1.8 - [experiences] 1.9 - ;; (println-repl 1.10 - ;; (count (next-phi-states (:proprioception (peek experiences)) 1.11 - ;; phi-space phi-scan))) 1.12 - (cond 1.13 - (grand-circle? experiences) (println "Grand Circle") 1.14 - (curled? experiences) (println "Curled") 1.15 - (wiggling? experiences) (println "Wiggling") 1.16 - (resting? experiences) (println "Resting")) 1.17 - ) 1.18 - 1.19 - 1.20 - 1.21 - 1.22 - 1.23 (def standard-world-view 1.24 [(Vector3f. 4.207176, -3.7366982, 3.0816958) 1.25 (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)]) 1.26 @@ -386,10 +370,52 @@ 1.27 (fn [proprio] (bin-map (bin-key proprio)))) 1.28 bin-keys bin-maps)] 1.29 (fn lookup [proprio-data] 1.30 - (some #(% proprio-data) lookups)))) 1.31 + (set (some #(% proprio-data) lookups))))) 1.32 + 1.33 + 1.34 +(defn longest-thread 1.35 + "Find the longest thread from phi-index-sets. The index sets should 1.36 + be ordered from most recent to least recent." 1.37 + [phi-index-sets] 1.38 + (loop [result '() 1.39 + [thread-bases & remaining :as phi-index-sets] phi-index-sets] 1.40 + (if (empty? phi-index-sets) 1.41 + result 1.42 + (let [threads 1.43 + (for [thread-base thread-bases] 1.44 + (loop [thread (list thread-base) 1.45 + remaining remaining] 1.46 + (let [next-index (dec (first thread))] 1.47 + (cond (empty? remaining) thread 1.48 + (contains? (first remaining) next-index) 1.49 + (recur 1.50 + (cons next-index thread) (rest remaining)) 1.51 + :else thread)))) 1.52 + longest-thread 1.53 + (reduce (fn [thread-a thread-b] 1.54 + (if (> (count thread-a) (count thread-b)) 1.55 + thread-a thread-b)) 1.56 + '(nil) 1.57 + threads)] 1.58 + (recur (concat longest-thread result) 1.59 + (drop (count longest-thread) phi-index-sets)))))) 1.60 + 1.61 1.62 (defn init [] 1.63 (def phi-space (generate-phi-space)) 1.64 (def phi-scan (gen-phi-scan phi-space)) 1.65 ) 1.66 1.67 + 1.68 +(def ppp (atom ())) 1.69 + 1.70 +(defn debug-experience-phi [experiences] 1.71 + (let [phi-indices (phi-scan (:proprioception (peek experiences)))] 1.72 + (swap! ppp (partial cons phi-indices)) 1.73 + (println-repl phi-indices)) 1.74 + (cond 1.75 + (grand-circle? experiences) (println "Grand Circle") 1.76 + (curled? experiences) (println "Curled") 1.77 + (wiggling? experiences) (println "Wiggling") 1.78 + (resting? experiences) (println "Resting")) 1.79 + )