diff 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 diff
     1.1 --- a/clojure/com/aurellem/fragments.clj	Thu Mar 08 04:40:18 2012 -0600
     1.2 +++ b/clojure/com/aurellem/fragments.clj	Thu Mar 08 06:01:09 2012 -0600
     1.3 @@ -1,3 +1,58 @@
     1.4  (ns com.aurellem.fragments
     1.5    (:use (com.aurellem gb-driver vbm)))
     1.6  
     1.7 +
     1.8 +
     1.9 +
    1.10 +
    1.11 +  
    1.12 +
    1.13 +(def start-frames 401)
    1.14 +
    1.15 +
    1.16 +(defn play-start [start n]
    1.17 +  (let [moves
    1.18 +        (concat (repeat n [])
    1.19 +                [[:a]]
    1.20 +                (repeat (- start-frames n 1) []))
    1.21 +        moves (drop start moves)]
    1.22 +    (goto start)
    1.23 +    (dorun (map step moves))
    1.24 +    (nth (registers) 2)))
    1.25 +
    1.26 +
    1.27 +(defn earliest-press
    1.28 +  [start]
    1.29 +  (print "determining bad program-counter...")
    1.30 +  (let [bad-counter (play-start 0 0)]
    1.31 +    (println bad-counter)
    1.32 +    (loop [n start]
    1.33 +      (print "trying" n "...")
    1.34 +      (let [nth-counter (play-start n)]
    1.35 +        (println "got" nth-counter)
    1.36 +        (if (= nth-counter bad-counter)
    1.37 +          (recur (inc n)) n)))))
    1.38 +
    1.39 +
    1.40 +
    1.41 +(def start->menu
    1.42 +  [
    1.43 +
    1.44 +
    1.45 +
    1.46 +
    1.47 +
    1.48 +
    1.49 +
    1.50 +
    1.51 +   ])
    1.52 +
    1.53 +
    1.54 +
    1.55 +(defn full-script [] (concat start->menu))
    1.56 +
    1.57 +
    1.58 +(defn test-script []
    1.59 +  (reset)
    1.60 +  (dorun (map step (full-script))))
    1.61 +