diff clojure/com/aurellem/run/util.clj @ 320:9637a0f52e7b

located item-list related addresses.
author Robert McIntyre <rlm@mit.edu>
date Tue, 03 Apr 2012 23:17:33 -0500
parents 92c47a9cdaea
children fe6fd2323264
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/util.clj	Tue Apr 03 04:16:20 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/util.clj	Tue Apr 03 23:17:33 2012 -0500
     1.3 @@ -107,19 +107,21 @@
     1.4              (move dir script)) script directions))
     1.5  
     1.6  (defn search-string
     1.7 -  [^SaveState state string]
     1.8 -  (let [codes
     1.9 -        (str->character-codes string)
    1.10 -        codes-length (count codes)
    1.11 -        mem (vec (memory state))
    1.12 -        mem-length (count mem)]
    1.13 -    (loop [idx 0]
    1.14 -      (if (< (- mem-length idx) codes-length)
    1.15 -        nil
    1.16 -        (if (= (subvec mem idx (+ idx codes-length))
    1.17 -               codes)
    1.18 -          idx
    1.19 -          (recur (inc idx)))))))
    1.20 +  ([^SaveState state string]
    1.21 +     (let [codes
    1.22 +           (str->character-codes string)
    1.23 +           codes-length (count codes)
    1.24 +           mem (vec (memory state))
    1.25 +           mem-length (count mem)]
    1.26 +       (loop [idx 0]
    1.27 +         (if (< (- mem-length idx) codes-length)
    1.28 +           nil
    1.29 +           (if (= (subvec mem idx (+ idx codes-length))
    1.30 +                  codes)
    1.31 +             idx
    1.32 +             (recur (inc idx)))))))
    1.33 +  ([string]
    1.34 +     (search-string @current-state string)))
    1.35  
    1.36  (def text-address 0x9DC1)
    1.37  
    1.38 @@ -143,8 +145,10 @@
    1.39  
    1.40  (defn end-text
    1.41    ([script]
    1.42 -     (->> (do-nothing 150)
    1.43 -          (play-moves [[:b]]))))
    1.44 +     (->>
    1.45 +      script
    1.46 +      (do-nothing 150)
    1.47 +      (play-moves [[:b]]))))
    1.48  
    1.49  (defn do-nothing [n script]
    1.50    (->> script