changeset 330:ecff37d22293

made more progress, have burn heals and correct name for rival.
author Robert McIntyre <rlm@mit.edu>
date Fri, 06 Apr 2012 09:09:52 -0500
parents a452deec2882
children 6ec288064d49
files clojure/com/aurellem/exp/notes.txt clojure/com/aurellem/run/bootstrap_0.clj
diffstat 2 files changed, 141 insertions(+), 86 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/exp/notes.txt	Fri Apr 06 07:22:18 2012 -0500
     1.2 +++ b/clojure/com/aurellem/exp/notes.txt	Fri Apr 06 09:09:52 2012 -0500
     1.3 @@ -3,7 +3,7 @@
     1.4  start game
     1.5  
     1.6  name rival "L<PK>U<PK><PK><any-character>" 
     1.7 -(0x8B 0xE1 0x94 0xE1 in character codes)
     1.8 +(0x8B 0xE1 0x94 0xE1 0xE1 0x<any> in character codes)
     1.9  
    1.10  get pikachu, fight rival, deliver oak's parcel, go back to
    1.11  viridian poke mart.
     2.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj	Fri Apr 06 07:22:18 2012 -0500
     2.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj	Fri Apr 06 09:09:52 2012 -0500
     2.3 @@ -398,23 +398,25 @@
     2.4  (defn set-quantity
     2.5    "Set the quantity of an item to buy or sell to the desired value
     2.6    using the fewest possible button presses."
     2.7 -  [total-quantity desired-quantity [moves state :as script]]
     2.8 -  (let [current-quantity (item-quantity-selected state)
     2.9 -        loop-point (if (> total-quantity 99) 0xFF 99)
    2.10 -        distance (- desired-quantity current-quantity)
    2.11 -        loop-distance (int(* -1 (Math/signum (float distance))
    2.12 -                             (- loop-point (Math/abs distance))))
    2.13 -        best-path (first (sort-by #(Math/abs %)
    2.14 -                                  [distance loop-distance]))
    2.15 -        direction (if (< 0 best-path) ↑ ↓)]
    2.16 -    (println "best-path" best-path)
    2.17 -    (reduce
    2.18 -     (fn [script _]
    2.19 -       (delayed-difference [] direction 200 item-quantity-selected
    2.20 -                               script))
    2.21 -     
    2.22 -     script
    2.23 -     (range (Math/abs best-path)))))
    2.24 +  ([total-quantity desired-quantity [moves state :as script]]
    2.25 +     (let [current-quantity (item-quantity-selected state)
    2.26 +           loop-point (if (> total-quantity 99) 0xFF 99)
    2.27 +           distance (- desired-quantity current-quantity)
    2.28 +           loop-distance (int(* -1 (Math/signum (float distance))
    2.29 +                                (- loop-point (Math/abs distance))))
    2.30 +           best-path (first (sort-by #(Math/abs %)
    2.31 +                                     [distance loop-distance]))
    2.32 +           direction (if (< 0 best-path) ↑ ↓)]
    2.33 +       (println "best-path" best-path)
    2.34 +       (reduce
    2.35 +        (fn [script _]
    2.36 +          (delayed-difference [] direction 5 item-quantity-selected
    2.37 +                              script))
    2.38 +        
    2.39 +        script
    2.40 +        (range (Math/abs best-path)))))
    2.41 +  ([desired-quantity [moves state :as script]]
    2.42 +     (set-quantity 99 desired-quantity script)))
    2.43  
    2.44  (defn-memo do-save-corruption
    2.45    ([] (do-save-corruption
    2.46 @@ -449,6 +451,43 @@
    2.47  
    2.48  (def menu do-nothing )
    2.49  
    2.50 +(defn close-menu [script]
    2.51 +  (first-difference [] [:b] AF script))
    2.52 +
    2.53 +(defn wait-until [script-fn script]
    2.54 +  (let [wait-time
    2.55 +        (- (dec (count (first (script-fn script))))
    2.56 +           (count (first script)))]
    2.57 +    (println "wait-time" wait-time)
    2.58 +    (do-nothing wait-time script)))
    2.59 +
    2.60 +;; (defn select-menu-entry* [script]
    2.61 +;;   (let [wait-time
    2.62 +;;         (- (dec (count (first (set-cursor-relative 1 script))))
    2.63 +;;            (count (first script)))]
    2.64 +;;     (println "wait-time" wait-time)
    2.65 +;;     (play-moves (concat (repeat wait-time []) [[:a] []]) script)))
    2.66 +
    2.67 +(defn select-menu-entry [script]
    2.68 +  (->> script
    2.69 +       (wait-until (partial set-cursor-relative 1))
    2.70 +       (play-moves [[:a] []])))
    2.71 +
    2.72 +(defn purchase-item
    2.73 +  "Assumes that the cursor is over the desired item, and purchases
    2.74 +   quantity of that item."
    2.75 +  [n script]
    2.76 +  (->> script
    2.77 +       select-menu-entry
    2.78 +       (set-quantity n)
    2.79 +       (first-difference [] [:a] AF)
    2.80 +       scroll-text
    2.81 +       select-menu-entry
    2.82 +       scroll-text))
    2.83 +
    2.84 +(defn activate-start-menu [script]
    2.85 +  (first-difference [:b] [:b :start] AF script))
    2.86 +
    2.87  (defn-memo corrupt-item-list
    2.88    "Corrupt the num-of-items variable by switching a corrupted pokemon
    2.89     into out-of-bounds memory."
    2.90 @@ -456,95 +495,111 @@
    2.91         (corrupted-checkpoint)))
    2.92    ([script]
    2.93       (->> script
    2.94 -          (first-difference [:a] [:a :start] AF)
    2.95 -          (set-cursor 1)                    ; select "POKEMON" from
    2.96 -          (first-difference [] [:a] AF)     ; from main menu
    2.97 -          (set-cursor 5)                    ; select 6th pokemon
    2.98 -          (first-difference [] [:a] AF)
    2.99 +          activate-start-menu
   2.100 +          (set-cursor 1)        ; select "POKEMON" from
   2.101 +          select-menu-entry     ; from main menu.
   2.102 +          (set-cursor 5)        ; select 6th pokemon
   2.103 +          select-menu-entry
   2.104            (set-cursor 1)
   2.105 -          (first-difference [] [:a] AF)     
   2.106 +          select-menu-entry     
   2.107            (repeat-until-different [] list-offset) 
   2.108            (set-cursor 9)
   2.109 -          (first-difference [] [:a] AF)     ; switch 6th with 10th
   2.110 -          (first-difference [] [:b] AF)
   2.111 -          (first-difference [] [:b] AF))))
   2.112 +          select-menu-entry     ; switch 6th with 10th
   2.113 +          close-menu
   2.114 +          close-menu)))
   2.115  
   2.116 -(defn get-lots-of-money
   2.117 +(defn-memo get-lots-of-money
   2.118    "Sell 0xFE cancel buttons to make a tremendous amount of money."
   2.119    ([] (get-lots-of-money (corrupt-item-list)))
   2.120    ([script]
   2.121       (->> script
   2.122 -          (first-difference [] [:a] AF)
   2.123 +          (first-difference [] [:a] AF) ; talk to shopkeep
   2.124            (repeat-until-different [] list-offset)
   2.125            (set-cursor 1)
   2.126 -          (first-difference [] [:a] AF)
   2.127 +          select-menu-entry
   2.128            (repeat-until-different [] list-offset)
   2.129 -          (first-difference [] [:a] AF)
   2.130 +          select-menu-entry
   2.131            (set-quantity 0xFF 0xFE)
   2.132 -          (do-nothing 1)
   2.133 -          )))
   2.134 +          (scroll-text)
   2.135 +          select-menu-entry)))
   2.136  
   2.137 +(defn note [str script]
   2.138 +  (println str) script)
   2.139  
   2.140 -
   2.141 -
   2.142 -(def buy-items do-nothing)
   2.143 -
   2.144 -(defn-memo get-burn-heals
   2.145 -  ([] (get-burn-heals
   2.146 -       (corrupt-item-list)))
   2.147 +(defn-memo buy-bootstrapping-items
   2.148 +  "Buy items that will become part of the bootstrapping
   2.149 +   program."
   2.150 +  ([] (buy-bootstrapping-items (get-lots-of-money)))
   2.151    ([script]
   2.152       (->> script
   2.153 -          (menu [[:b] [:b]])
   2.154 -          (menu [[:a]])
   2.155 -          (do-nothing 100)
   2.156 -          (menu [↓ [:a]])
   2.157 -          (do-nothing 100)
   2.158 -          (menu [[:a] ↓ [:a]])
   2.159 -          (scroll-text)
   2.160 -          (menu [[:b][:b]])
   2.161 -          (menu [[:a]])
   2.162 +          close-menu
   2.163 +          select-menu-entry
   2.164 +          (purchase-item 1)        ; buying a pokeball overflows
   2.165 +                                   ; the item-counter from 0xFF to 0x00
   2.166 +                                   ; repairing the item-list.
   2.167 +          (set-cursor 1)   
   2.168 +          (purchase-item 1)        ; these other items are here to 
   2.169 +                                   ; protect the burn heals when the 
   2.170 +          (set-cursor 2)           ; item list is corrupted again.
   2.171 +          (purchase-item 1)
   2.172  
   2.173 -          (do-nothing 50)
   2.174 -          (buy-items [[0 1]])
   2.175 -          (do-nothing 60)
   2.176 -          (menu [[:a]])
   2.177 -          (scroll-text)
   2.178 -          
   2.179 -          (do-nothing 50)
   2.180 -          (buy-items [[0 1]])
   2.181 -          (do-nothing 60)
   2.182 -          ;;(menu [[:a]])
   2.183 -          ;;(scroll-text)
   2.184 -          
   2.185 -          ;;(do-nothing 300)
   2.186 -          ;;(menu [[:b] [:b]])
   2.187 -          ;;(do-nothing 300)
   2.188 +          (set-cursor 3)
   2.189 +          (purchase-item 1)
   2.190  
   2.191 -          (buy-items [[0 1]
   2.192 -                      [1 1]
   2.193 -                      [1 1]
   2.194 -                      [2 1]
   2.195 -                      [3 1]
   2.196 -                      [4 97]])
   2.197 -                      
   2.198 -          (do-nothing 10))))
   2.199 +          (set-cursor 4)           ; 95 burn-heals spells out the
   2.200 +          (purchase-item 96)       ; return address to the pokemon
   2.201 +                                   ; kernel. 96 so that they can be
   2.202 +                                   ; deposited without causing a shift.
   2.203  
   2.204 -(defn-memo corrupt-item-list-again
   2.205 -  ([] (corrupt-item-list-again (get-burn-heals)))
   2.206 +          close-menu               ; stop talking to shopkeep
   2.207 +          (wait-until select-menu-entry)
   2.208 +          (play-moves [[:b]])
   2.209 +          end-text)))
   2.210 +
   2.211 +(defn corrupt-item-list-again
   2.212 +  ([] (corrupt-item-list-again (buy-bootstrapping-items)))
   2.213    ([script]
   2.214       (->> script
   2.215 -          (do-nothing 10)
   2.216 -          (play-moves [[:b]])
   2.217 -          (do-nothing 100)
   2.218 -          (play-moves [[:b]])
   2.219 -          (do-nothing 40)
   2.220 -          (play-moves [[:b]])
   2.221 -          (first-difference [:b] [:start :b] AF)
   2.222 -          (menu [[:a] ↑ ↑ ↑ ↑ ↑         ; get fifth pokemon
   2.223 -                 [:a] ↓ [:a]            ; and corrupt the
   2.224 -                 ↓ ↓ ↓ ↓ ↓ [:a]])       ; item list again by
   2.225 -                                        ; switching it to
   2.226 -          )))                           ; tenth place.
   2.227 +
   2.228 +          activate-start-menu             
   2.229 +          (set-cursor-relative 0)                   
   2.230 +          select-menu-entry               
   2.231 +
   2.232 +          ;; repair list-offset for pokemon-list
   2.233 +          (set-cursor-relative -1)
   2.234 +
   2.235 +          
   2.236 +          (set-cursor 4)                  ; switching it to    
   2.237 +          select-menu-entry               ; tenth place.       
   2.238 +          (set-cursor 1)
   2.239 +          select-menu-entry               ; select "switch" on 5th
   2.240 +
   2.241 +          (repeat-until-different [] list-offset)
   2.242 +          (set-cursor 9)                  ; goto 10th pokemon
   2.243 +          select-menu-entry               ; do switch
   2.244 +          close-menu
   2.245 +          close-menu                     
   2.246 +          
   2.247 +          (do-nothing 1)
   2.248 +          ;;select-menu-entry     
   2.249 +          ;;
   2.250 +          ;;(set-cursor 9)
   2.251 +          ;;select-menu-entry 
   2.252 +          ;;close-menu
   2.253 +         
   2.254 +          )))
   2.255 +          ;; (do-nothing 10)
   2.256 +          ;; (play-moves [[:b]])
   2.257 +          ;; (do-nothing 100)
   2.258 +          ;; (play-moves [[:b]])
   2.259 +          ;; (do-nothing 40)
   2.260 +          ;; (play-moves [[:b]])
   2.261 +          ;; (first-difference [:b] [:start :b] AF)
   2.262 +          ;; (menu [[:a] ↑ ↑ ↑ ↑ ↑         
   2.263 +          ;;        [:a] ↓ [:a]            
   2.264 +          ;;        ↓ ↓ ↓ ↓ ↓ [:a]])       
   2.265 +          ;;                               
   2.266 +          ;; )))                           
   2.267            
   2.268  (defn-memo viridian-store->viridian-poke-center
   2.269    ([] (viridian-store->viridian-poke-center