view 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
line wrap: on
line source
1 (ns com.aurellem.fragments
2 (:use (com.aurellem gb-driver vbm)))
10 (def start-frames 401)
13 (defn play-start [start n]
14 (let [moves
15 (concat (repeat n [])
16 [[:a]]
17 (repeat (- start-frames n 1) []))
18 moves (drop start moves)]
19 (goto start)
20 (dorun (map step moves))
21 (nth (registers) 2)))
24 (defn earliest-press
25 [start]
26 (print "determining bad program-counter...")
27 (let [bad-counter (play-start 0 0)]
28 (println bad-counter)
29 (loop [n start]
30 (print "trying" n "...")
31 (let [nth-counter (play-start n)]
32 (println "got" nth-counter)
33 (if (= nth-counter bad-counter)
34 (recur (inc n)) n)))))
38 (def start->menu
39 [
48 ])
52 (defn full-script [] (concat start->menu))
55 (defn test-script []
56 (reset)
57 (dorun (map step (full-script))))