# HG changeset patch # User Robert McIntyre # Date 1395289486 14400 # Node ID 027707c75f396cdca38c4a9286caef68617463f6 # Parent f689967c254593d24201c8a578226105910c6db9 saving progress for the night. diff -r f689967c2545 -r 027707c75f39 org/worm_learn.clj --- a/org/worm_learn.clj Wed Mar 19 22:47:13 2014 -0400 +++ b/org/worm_learn.clj Thu Mar 20 00:24:46 2014 -0400 @@ -222,6 +222,43 @@ (and (< 0.55 (contact worm-segment-bottom-tip tail-touch)) (< 0.55 (contact worm-segment-top-tip head-touch)))))) + +(declare phi-space phi-scan) + +(defn next-phi-states + "Given proprioception data, determine the most likely next sensory + pattern from previous experience." + [proprio phi-space phi-scan] + (if-let [results (phi-scan proprio)] + (mapv phi-space + (filter (partial > (count phi-space)) + (map inc results))))) + +(defn debug-experience + [experiences] + (cond + (grand-circle? experiences) (println "Grand Circle") + (curled? experiences) (println "Curled") + (wiggling? experiences) (println "Wiggling") + (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)]) @@ -240,7 +277,8 @@ :motor-control (:motor-control direct-control) :keybindings (:keybindings direct-control) :record nil - :experiences nil + :experiences (atom []) + :experience-watch debug-experience :worm-model worm-model :end-frame nil})) @@ -252,15 +290,11 @@ (defn record-experience! [experiences data] (swap! experiences #(conj % data))) - - -(declare phi-space phi-scan) - (defn worm-world [& {:keys [record motor-control keybindings view experiences - worm-model end-frame] :as settings}] + worm-model end-frame experience-watch] :as settings}] (let [{:keys [record motor-control keybindings view experiences - worm-model end-frame]} + worm-model end-frame experience-watch]} (merge (worm-world-defaults) settings) worm (doto (worm-model) (body!)) touch (touch! worm) @@ -298,13 +332,9 @@ (record-experience! experiences {:touch touch-data :proprioception proprioception-data - :muscle muscle-data}) - (cond - (grand-circle? @experiences) (println "Grand Circle") - (curled? @experiences) (println "Curled") - (wiggling? @experiences) (println "Wiggling") - (resting? @experiences) (println "Resting")) - ) + :muscle muscle-data})) + (when experience-watch + (experience-watch @experiences)) (muscle-display muscle-data (if record (dir! (File. record "muscle")))) @@ -333,7 +363,6 @@ (motor-control-program worm-muscle-labels do-all-the-things) :experiences experiences}))) @experiences)) - (defn bin [digits] (fn [angles] @@ -343,7 +372,9 @@ (flatten) (mapv #(Math/round (* % (Math/pow 10 (dec digits)))))))) -;; k-nearest neighbors with spatial binning. +;; k-nearest neighbors with spatial binning. Only returns a result if +;; the propriceptive data is within 10% of a previously recorded +;; result in all dimensions. (defn gen-phi-scan [phi-space] (let [bin-keys (map bin [3 2 1]) bin-maps @@ -357,19 +388,8 @@ (fn lookup [proprio-data] (some #(% proprio-data) lookups)))) -;; (defn gen-phi-scan [phi-space] -;; (let [bin-keys (map bin [3 2 1]) -;; bin-maps -;; (map (fn [bin-key phi-space] -;; (group-by (comp bin-key :proprioception) phi-space)) -;; bin-keys (repeat phi-space)) -;; lookups (map (fn [bin-key bin-map] -;; (fn [proprio] (bin-map (bin-key proprio)))) -;; bin-keys bin-maps)] -;; (fn lookup [proprio-data] -;; (some #(% proprio-data) lookups)))) - (defn init [] (def phi-space (generate-phi-space)) (def phi-scan (gen-phi-scan phi-space)) ) + diff -r f689967c2545 -r 027707c75f39 thesis/org/roadmap.org --- a/thesis/org/roadmap.org Wed Mar 19 22:47:13 2014 -0400 +++ b/thesis/org/roadmap.org Thu Mar 20 00:24:46 2014 -0400 @@ -208,8 +208,8 @@ *** DONE implement proprioception based movement lookup in phi-space CLOSED: [2014-03-19 Wed 22:04] SCHEDULED: <2014-03-19 Wed> CLOCK: [2014-03-19 Wed 19:32]--[2014-03-19 Wed 22:04] => 2:32 -*** TODO make proprioception reference phi-space indexes - SCHEDULED: <2014-03-19 Wed> +*** DONE make proprioception reference phi-space indexes + CLOSED: [2014-03-19 Wed 22:47] SCHEDULED: <2014-03-19 Wed> CLOCK: [2014-03-19 Wed 22:07]