annotate clojure/com/aurellem/fragments.clj @ 75:eb7d4efe0f34

added play command
author Robert McIntyre <rlm@mit.edu>
date Thu, 08 Mar 2012 06:01:09 -0600
parents 8a895ed4c0f9
children d7c38ce83421
rev   line source
rlm@73 1 (ns com.aurellem.fragments
rlm@73 2 (:use (com.aurellem gb-driver vbm)))
rlm@73 3
rlm@75 4
rlm@75 5
rlm@75 6
rlm@75 7
rlm@75 8
rlm@75 9
rlm@75 10 (def start-frames 401)
rlm@75 11
rlm@75 12
rlm@75 13 (defn play-start [start n]
rlm@75 14 (let [moves
rlm@75 15 (concat (repeat n [])
rlm@75 16 [[:a]]
rlm@75 17 (repeat (- start-frames n 1) []))
rlm@75 18 moves (drop start moves)]
rlm@75 19 (goto start)
rlm@75 20 (dorun (map step moves))
rlm@75 21 (nth (registers) 2)))
rlm@75 22
rlm@75 23
rlm@75 24 (defn earliest-press
rlm@75 25 [start]
rlm@75 26 (print "determining bad program-counter...")
rlm@75 27 (let [bad-counter (play-start 0 0)]
rlm@75 28 (println bad-counter)
rlm@75 29 (loop [n start]
rlm@75 30 (print "trying" n "...")
rlm@75 31 (let [nth-counter (play-start n)]
rlm@75 32 (println "got" nth-counter)
rlm@75 33 (if (= nth-counter bad-counter)
rlm@75 34 (recur (inc n)) n)))))
rlm@75 35
rlm@75 36
rlm@75 37
rlm@75 38 (def start->menu
rlm@75 39 [
rlm@75 40
rlm@75 41
rlm@75 42
rlm@75 43
rlm@75 44
rlm@75 45
rlm@75 46
rlm@75 47
rlm@75 48 ])
rlm@75 49
rlm@75 50
rlm@75 51
rlm@75 52 (defn full-script [] (concat start->menu))
rlm@75 53
rlm@75 54
rlm@75 55 (defn test-script []
rlm@75 56 (reset)
rlm@75 57 (dorun (map step (full-script))))
rlm@75 58