diff org/worm_learn.clj @ 417:f689967c2545

modified phi-space lookup to return indices.
author Robert McIntyre <rlm@mit.edu>
date Wed, 19 Mar 2014 22:47:13 -0400
parents 9e52b6730fd0
children 027707c75f39
line wrap: on
line diff
     1.1 --- a/org/worm_learn.clj	Wed Mar 19 22:02:06 2014 -0400
     1.2 +++ b/org/worm_learn.clj	Wed Mar 19 22:47:13 2014 -0400
     1.3 @@ -299,9 +299,6 @@
     1.4                experiences {:touch touch-data
     1.5                             :proprioception proprioception-data
     1.6                             :muscle muscle-data})
     1.7 -             (if-let [res (phi-scan proprioception-data)]
     1.8 -               (println-repl "lookup successful --" (count res))
     1.9 -               (println-repl "lookup failed"))
    1.10               (cond
    1.11                (grand-circle? @experiences) (println "Grand Circle")
    1.12                (curled? @experiences)       (println "Curled")
    1.13 @@ -350,15 +347,28 @@
    1.14  (defn gen-phi-scan [phi-space]
    1.15    (let [bin-keys (map bin [3 2 1])
    1.16          bin-maps
    1.17 -        (map (fn [bin-key phi-space]
    1.18 -               (group-by (comp bin-key :proprioception) phi-space))
    1.19 -             bin-keys (repeat phi-space))
    1.20 +        (map (fn [bin-key]
    1.21 +               (group-by
    1.22 +                (comp bin-key :proprioception phi-space)
    1.23 +                (range (count phi-space)))) bin-keys)
    1.24          lookups (map (fn [bin-key bin-map]
    1.25                        (fn [proprio] (bin-map (bin-key proprio))))
    1.26                      bin-keys bin-maps)]
    1.27      (fn lookup [proprio-data]
    1.28        (some #(% proprio-data) lookups))))
    1.29  
    1.30 +;; (defn gen-phi-scan [phi-space]
    1.31 +;;   (let [bin-keys (map bin [3 2 1])
    1.32 +;;         bin-maps
    1.33 +;;         (map (fn [bin-key phi-space]
    1.34 +;;                (group-by (comp bin-key :proprioception) phi-space))
    1.35 +;;              bin-keys (repeat phi-space))
    1.36 +;;         lookups (map (fn [bin-key bin-map]
    1.37 +;;                        (fn [proprio] (bin-map (bin-key proprio))))
    1.38 +;;                      bin-keys bin-maps)]
    1.39 +;;     (fn lookup [proprio-data]
    1.40 +;;       (some #(% proprio-data) lookups))))
    1.41 +
    1.42  (defn init []
    1.43    (def phi-space (generate-phi-space))
    1.44    (def phi-scan (gen-phi-scan phi-space))