diff clojure/com/aurellem/run/bootstrap_0.clj @ 332:5c2041d1cdda

solving problem with rival name becomming a key item.
author Robert McIntyre <rlm@mit.edu>
date Fri, 06 Apr 2012 13:52:08 -0500
parents 6ec288064d49
children 61a096a53330
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj	Fri Apr 06 12:18:58 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj	Fri Apr 06 13:52:08 2012 -0500
     1.3 @@ -28,15 +28,38 @@
     1.4             [] [] [:r] [] [:d] [:a]           ;; L
     1.5             [:r] [] [:r] [] [:r] [] [:r] [] 
     1.6             [:r] [] [:d] [] [:d] [:a]         ;; [PK]
     1.7 -           [:u] [] [:l] [] [:l] []
     1.8 -           [:l] [] [:l] [] [:l] [:a]         ;; U
     1.9 -           [:r] [] [:r] [] [:r] []
    1.10 -           [:r] [] [:r] [] [:d] [:a]         ;; [PK]
    1.11 +           [:u] [] [:l] [] [:l] [] [:l] []
    1.12 +           [:l] [] [:l] [] [:a]              ;; U
    1.13 +           [:r] [] [:r] [] [:r] [] [:r] []
    1.14 +           [:r] [] [] [:d] [:a]              ;; [PK]
    1.15             [] [:a]                           ;; [PK]
    1.16             [] [:a]                           ;; [PK]
    1.17             [:r] [] [:d] [:a]                 ;; END
    1.18             ]))))
    1.19  
    1.20 +;; (defn-memo name-rival-bootstrap
    1.21 +;;   ([] (name-rival-bootstrap (to-rival-name)))
    1.22 +;;   ([script]
    1.23 +;;      (->> script
    1.24 +;;          (first-difference [] [:a] AF)
    1.25 +;;          (first-difference [] [:r] DE)
    1.26 +;;          (play-moves
    1.27 +;;           [[]
    1.28 +;;            [] [] [:r] []           
    1.29 +;;            [:r] [] [:r] [] [:r] [] [:r] []
    1.30 +;;            [:r] [] [:d] [] [:d] [] [:d] [:a];; PK
    1.31 +;;            [] [:a]                          ;; PK
    1.32 +;;            [:u] [] [:l] [] [:l] [] [:l] []
    1.33 +;;            [:l] [] [:l] [:a]                ;; U
    1.34 +;;            [:d] [] [:r] [] [:r] [] [:r] []
    1.35 +;;            [:r] [] [:r] [:a]                ;; PK
    1.36 +;;            [:u] [] [:l] [] [:l] [] [:l] []
    1.37 +;;            [:l] [] [:l] [] [:u] [:a]        ;; L
    1.38 +;;            [:d] [] [:r] [] [:r] [] [:r] []
    1.39 +;;            [:r] [] [:r] [] [:d] [:a]        ;; PK
    1.40 +;;            [:r] [] [:d] [:a]                ;; END
    1.41 +;;            ]))))
    1.42 +
    1.43  (defn-memo leave-house
    1.44    ([] (leave-house (name-rival-bootstrap)))
    1.45    ([script]
    1.46 @@ -270,9 +293,9 @@
    1.47              → → → ↓])
    1.48  
    1.49            (walk-thru-grass
    1.50 -           [↓ ↓ ↓])
    1.51 +           [↓ ↓ ↓ ↓])
    1.52  
    1.53 -          (walk [↓ ← ← ↓ ↓ ↓ ↓ ↓ ↓])
    1.54 +          (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓])
    1.55            
    1.56            (walk-thru-grass
    1.57             [↓ ↓ ↓ ↓ ↓ ↓])
    1.58 @@ -352,8 +375,6 @@
    1.59            (aget mem list-cursor-offset-address))))
    1.60    ([] (list-offset @current-state)))
    1.61  
    1.62 -
    1.63 -
    1.64  (defn exp-item-selection []
    1.65    (clojure.pprint/pprint
    1.66     (apply memory-compare
    1.67 @@ -421,6 +442,18 @@
    1.68  (defn activate-start-menu [script]
    1.69    (first-difference [:b] [:b :start] AF script))
    1.70  
    1.71 +(defn wait-until [script-fn script]
    1.72 +  (let [wait-time
    1.73 +        (- (dec (count (first (script-fn script))))
    1.74 +           (count (first script)))]
    1.75 +    (println "wait-time" wait-time)
    1.76 +    (do-nothing wait-time script)))
    1.77 +
    1.78 +(defn select-menu-entry [script]
    1.79 +  (->> script
    1.80 +       (wait-until (partial set-cursor-relative 1))
    1.81 +       (play-moves [[:a] []])))
    1.82 +
    1.83  (defn-memo do-save-corruption
    1.84    ([] (do-save-corruption
    1.85         (walk-to-counter)))
    1.86 @@ -455,12 +488,7 @@
    1.87  (defn close-menu [script]
    1.88    (first-difference [] [:b] AF script))
    1.89  
    1.90 -(defn wait-until [script-fn script]
    1.91 -  (let [wait-time
    1.92 -        (- (dec (count (first (script-fn script))))
    1.93 -           (count (first script)))]
    1.94 -    (println "wait-time" wait-time)
    1.95 -    (do-nothing wait-time script)))
    1.96 +
    1.97  
    1.98  ;; (defn select-menu-entry* [script]
    1.99  ;;   (let [wait-time
   1.100 @@ -469,10 +497,6 @@
   1.101  ;;     (println "wait-time" wait-time)
   1.102  ;;     (play-moves (concat (repeat wait-time []) [[:a] []]) script)))
   1.103  
   1.104 -(defn select-menu-entry [script]
   1.105 -  (->> script
   1.106 -       (wait-until (partial set-cursor-relative 1))
   1.107 -       (play-moves [[:a] []])))
   1.108  
   1.109  (defn purchase-item
   1.110    "Assumes that the cursor is over the desired item, and purchases
   1.111 @@ -506,7 +530,7 @@
   1.112            (set-cursor 9)
   1.113            select-menu-entry     ; switch 6th with 10th
   1.114            close-menu
   1.115 -          close-menu)))
   1.116 +          close-menu )))
   1.117  
   1.118  (defn-memo get-lots-of-money
   1.119    "Sell 0xFE cancel buttons to make a tremendous amount of money."
   1.120 @@ -519,9 +543,12 @@
   1.121            select-menu-entry
   1.122            (repeat-until-different [] list-offset)
   1.123            select-menu-entry
   1.124 -          (set-quantity 0xFF 0xFE)
   1.125 -          (scroll-text)
   1.126 -          select-menu-entry)))
   1.127 +          (set-quantity 0xFF 0xF7)
   1.128 +          (first-difference [] [:a] AF)
   1.129 +          select-menu-entry
   1.130 +          close-menu
   1.131 +          )))
   1.132 +          
   1.133  
   1.134  (defn note [str script]
   1.135    (println str) script)
   1.136 @@ -705,9 +732,9 @@
   1.137  
   1.138           [;; first part of item manipulation program
   1.139            0x00
   1.140 -          0x21   ;; load target into HL
   1.141 +          0x21   ;; load target + 1  into HL
   1.142  
   1.143 -          0x94   ;; this is the target address
   1.144 +          0x95   ;; this is the target address + 1
   1.145            0xD5
   1.146  
   1.147            0x00   ;; relative jump back to first part