comparison org/movement.org @ 321:702b5c78c2de

gathered all the tests into (run-suite), which should make testing vastly easier.
author Robert McIntyre <rlm@mit.edu>
date Tue, 08 May 2012 08:22:19 -0500
parents bb3f8a4af87f
children 4f5a5d5f1613
comparison
equal deleted inserted replaced
320:52de8a36edde 321:702b5c78c2de
121 pool-integral (reductions + pool) 121 pool-integral (reductions + pool)
122 forces 122 forces
123 (vec (map #(float (* strength (/ % (last pool-integral)))) 123 (vec (map #(float (* strength (/ % (last pool-integral))))
124 pool-integral)) 124 pool-integral))
125 control (.getControl target RigidBodyControl)] 125 control (.getControl target RigidBodyControl)]
126 (println-repl (.getName target) axis) 126 ;;(println-repl (.getName target) axis)
127 (fn [n] 127 (fn [n]
128 (let [pool-index (max 0 (min n (dec (count pool)))) 128 (let [pool-index (max 0 (min n (dec (count pool))))
129 force (forces pool-index)] 129 force (forces pool-index)]
130 (.applyTorque control (.mult axis force)) 130 (.applyTorque control (.mult axis force))
131 (float (/ force strength)))))) 131 (float (/ force strength))))))
184 [[../images/worm-with-muscle.png]] 184 [[../images/worm-with-muscle.png]]
185 185
186 #+name: test-movement 186 #+name: test-movement
187 #+begin_src clojure 187 #+begin_src clojure
188 (defn test-worm-movement 188 (defn test-worm-movement
189 "Testing movement:
190 You should see the worm suspended in mid air and a display on the
191 right which shows the current relative power being exerted by the
192 muscle. As you increase muscle strength, the bar should fill with
193 red, and the worm's upper segment should move.
194
195 Keys:
196 h : increase muscle exertion
197 n : decrease muscle exertion"
189 ([] (test-worm-movement false)) 198 ([] (test-worm-movement false))
190 ([record?] 199 ([record?]
191 (let [creature (doto (worm) (body!)) 200 (let [creature (doto (worm) (body!))
192 201
193 muscle-exertion (atom 0) 202 muscle-exertion (atom 0)