comparison 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
comparison
equal deleted inserted replaced
74:aaddd7b72a0e 75:eb7d4efe0f34
1 (ns com.aurellem.fragments 1 (ns com.aurellem.fragments
2 (:use (com.aurellem gb-driver vbm))) 2 (:use (com.aurellem gb-driver vbm)))
3 3
4
5
6
7
8
9
10 (def start-frames 401)
11
12
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)))
22
23
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)))))
35
36
37
38 (def start->menu
39 [
40
41
42
43
44
45
46
47
48 ])
49
50
51
52 (defn full-script [] (concat start->menu))
53
54
55 (defn test-script []
56 (reset)
57 (dorun (map step (full-script))))
58