comparison 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
comparison
equal deleted inserted replaced
418:027707c75f39 419:dd40244255d4
239 (cond 239 (cond
240 (grand-circle? experiences) (println "Grand Circle") 240 (grand-circle? experiences) (println "Grand Circle")
241 (curled? experiences) (println "Curled") 241 (curled? experiences) (println "Curled")
242 (wiggling? experiences) (println "Wiggling") 242 (wiggling? experiences) (println "Wiggling")
243 (resting? experiences) (println "Resting"))) 243 (resting? experiences) (println "Resting")))
244
245
246 (defn debug-experience
247 [experiences]
248 ;; (println-repl
249 ;; (count (next-phi-states (:proprioception (peek experiences))
250 ;; phi-space phi-scan)))
251 (cond
252 (grand-circle? experiences) (println "Grand Circle")
253 (curled? experiences) (println "Curled")
254 (wiggling? experiences) (println "Wiggling")
255 (resting? experiences) (println "Resting"))
256 )
257
258
259
260 244
261 245
262 (def standard-world-view 246 (def standard-world-view
263 [(Vector3f. 4.207176, -3.7366982, 3.0816958) 247 [(Vector3f. 4.207176, -3.7366982, 3.0816958)
264 (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)]) 248 (Quaternion. 0.11118768, 0.87678415, 0.24434438, -0.3989771)])
384 (range (count phi-space)))) bin-keys) 368 (range (count phi-space)))) bin-keys)
385 lookups (map (fn [bin-key bin-map] 369 lookups (map (fn [bin-key bin-map]
386 (fn [proprio] (bin-map (bin-key proprio)))) 370 (fn [proprio] (bin-map (bin-key proprio))))
387 bin-keys bin-maps)] 371 bin-keys bin-maps)]
388 (fn lookup [proprio-data] 372 (fn lookup [proprio-data]
389 (some #(% proprio-data) lookups)))) 373 (set (some #(% proprio-data) lookups)))))
374
375
376 (defn longest-thread
377 "Find the longest thread from phi-index-sets. The index sets should
378 be ordered from most recent to least recent."
379 [phi-index-sets]
380 (loop [result '()
381 [thread-bases & remaining :as phi-index-sets] phi-index-sets]
382 (if (empty? phi-index-sets)
383 result
384 (let [threads
385 (for [thread-base thread-bases]
386 (loop [thread (list thread-base)
387 remaining remaining]
388 (let [next-index (dec (first thread))]
389 (cond (empty? remaining) thread
390 (contains? (first remaining) next-index)
391 (recur
392 (cons next-index thread) (rest remaining))
393 :else thread))))
394 longest-thread
395 (reduce (fn [thread-a thread-b]
396 (if (> (count thread-a) (count thread-b))
397 thread-a thread-b))
398 '(nil)
399 threads)]
400 (recur (concat longest-thread result)
401 (drop (count longest-thread) phi-index-sets))))))
402
390 403
391 (defn init [] 404 (defn init []
392 (def phi-space (generate-phi-space)) 405 (def phi-space (generate-phi-space))
393 (def phi-scan (gen-phi-scan phi-space)) 406 (def phi-scan (gen-phi-scan phi-space))
394 ) 407 )
395 408
409
410 (def ppp (atom ()))
411
412 (defn debug-experience-phi [experiences]
413 (let [phi-indices (phi-scan (:proprioception (peek experiences)))]
414 (swap! ppp (partial cons phi-indices))
415 (println-repl phi-indices))
416 (cond
417 (grand-circle? experiences) (println "Grand Circle")
418 (curled? experiences) (println "Curled")
419 (wiggling? experiences) (println "Wiggling")
420 (resting? experiences) (println "Resting"))
421 )