# HG changeset patch # User Robert McIntyre # Date 1333721392 18000 # Node ID ecff37d222932000db104639baae4dd8e94e858c # Parent a452deec28827743af5ef1ea5320f962689e6d53 made more progress, have burn heals and correct name for rival. diff -r a452deec2882 -r ecff37d22293 clojure/com/aurellem/exp/notes.txt --- a/clojure/com/aurellem/exp/notes.txt Fri Apr 06 07:22:18 2012 -0500 +++ b/clojure/com/aurellem/exp/notes.txt Fri Apr 06 09:09:52 2012 -0500 @@ -3,7 +3,7 @@ start game name rival "LU" -(0x8B 0xE1 0x94 0xE1 in character codes) +(0x8B 0xE1 0x94 0xE1 0xE1 0x in character codes) get pikachu, fight rival, deliver oak's parcel, go back to viridian poke mart. diff -r a452deec2882 -r ecff37d22293 clojure/com/aurellem/run/bootstrap_0.clj --- a/clojure/com/aurellem/run/bootstrap_0.clj Fri Apr 06 07:22:18 2012 -0500 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Fri Apr 06 09:09:52 2012 -0500 @@ -398,23 +398,25 @@ (defn set-quantity "Set the quantity of an item to buy or sell to the desired value using the fewest possible button presses." - [total-quantity desired-quantity [moves state :as script]] - (let [current-quantity (item-quantity-selected state) - loop-point (if (> total-quantity 99) 0xFF 99) - distance (- desired-quantity current-quantity) - loop-distance (int(* -1 (Math/signum (float distance)) - (- loop-point (Math/abs distance)))) - best-path (first (sort-by #(Math/abs %) - [distance loop-distance])) - direction (if (< 0 best-path) ↑ ↓)] - (println "best-path" best-path) - (reduce - (fn [script _] - (delayed-difference [] direction 200 item-quantity-selected - script)) - - script - (range (Math/abs best-path))))) + ([total-quantity desired-quantity [moves state :as script]] + (let [current-quantity (item-quantity-selected state) + loop-point (if (> total-quantity 99) 0xFF 99) + distance (- desired-quantity current-quantity) + loop-distance (int(* -1 (Math/signum (float distance)) + (- loop-point (Math/abs distance)))) + best-path (first (sort-by #(Math/abs %) + [distance loop-distance])) + direction (if (< 0 best-path) ↑ ↓)] + (println "best-path" best-path) + (reduce + (fn [script _] + (delayed-difference [] direction 5 item-quantity-selected + script)) + + script + (range (Math/abs best-path))))) + ([desired-quantity [moves state :as script]] + (set-quantity 99 desired-quantity script))) (defn-memo do-save-corruption ([] (do-save-corruption @@ -449,6 +451,43 @@ (def menu do-nothing ) +(defn close-menu [script] + (first-difference [] [:b] AF script)) + +(defn wait-until [script-fn script] + (let [wait-time + (- (dec (count (first (script-fn script)))) + (count (first script)))] + (println "wait-time" wait-time) + (do-nothing wait-time script))) + +;; (defn select-menu-entry* [script] +;; (let [wait-time +;; (- (dec (count (first (set-cursor-relative 1 script)))) +;; (count (first script)))] +;; (println "wait-time" wait-time) +;; (play-moves (concat (repeat wait-time []) [[:a] []]) script))) + +(defn select-menu-entry [script] + (->> script + (wait-until (partial set-cursor-relative 1)) + (play-moves [[:a] []]))) + +(defn purchase-item + "Assumes that the cursor is over the desired item, and purchases + quantity of that item." + [n script] + (->> script + select-menu-entry + (set-quantity n) + (first-difference [] [:a] AF) + scroll-text + select-menu-entry + scroll-text)) + +(defn activate-start-menu [script] + (first-difference [:b] [:b :start] AF script)) + (defn-memo corrupt-item-list "Corrupt the num-of-items variable by switching a corrupted pokemon into out-of-bounds memory." @@ -456,95 +495,111 @@ (corrupted-checkpoint))) ([script] (->> script - (first-difference [:a] [:a :start] AF) - (set-cursor 1) ; select "POKEMON" from - (first-difference [] [:a] AF) ; from main menu - (set-cursor 5) ; select 6th pokemon - (first-difference [] [:a] AF) + activate-start-menu + (set-cursor 1) ; select "POKEMON" from + select-menu-entry ; from main menu. + (set-cursor 5) ; select 6th pokemon + select-menu-entry (set-cursor 1) - (first-difference [] [:a] AF) + select-menu-entry (repeat-until-different [] list-offset) (set-cursor 9) - (first-difference [] [:a] AF) ; switch 6th with 10th - (first-difference [] [:b] AF) - (first-difference [] [:b] AF)))) + select-menu-entry ; switch 6th with 10th + close-menu + close-menu))) -(defn get-lots-of-money +(defn-memo get-lots-of-money "Sell 0xFE cancel buttons to make a tremendous amount of money." ([] (get-lots-of-money (corrupt-item-list))) ([script] (->> script - (first-difference [] [:a] AF) + (first-difference [] [:a] AF) ; talk to shopkeep (repeat-until-different [] list-offset) (set-cursor 1) - (first-difference [] [:a] AF) + select-menu-entry (repeat-until-different [] list-offset) - (first-difference [] [:a] AF) + select-menu-entry (set-quantity 0xFF 0xFE) - (do-nothing 1) - ))) + (scroll-text) + select-menu-entry))) +(defn note [str script] + (println str) script) - - -(def buy-items do-nothing) - -(defn-memo get-burn-heals - ([] (get-burn-heals - (corrupt-item-list))) +(defn-memo buy-bootstrapping-items + "Buy items that will become part of the bootstrapping + program." + ([] (buy-bootstrapping-items (get-lots-of-money))) ([script] (->> script - (menu [[:b] [:b]]) - (menu [[:a]]) - (do-nothing 100) - (menu [↓ [:a]]) - (do-nothing 100) - (menu [[:a] ↓ [:a]]) - (scroll-text) - (menu [[:b][:b]]) - (menu [[:a]]) + close-menu + select-menu-entry + (purchase-item 1) ; buying a pokeball overflows + ; the item-counter from 0xFF to 0x00 + ; repairing the item-list. + (set-cursor 1) + (purchase-item 1) ; these other items are here to + ; protect the burn heals when the + (set-cursor 2) ; item list is corrupted again. + (purchase-item 1) - (do-nothing 50) - (buy-items [[0 1]]) - (do-nothing 60) - (menu [[:a]]) - (scroll-text) - - (do-nothing 50) - (buy-items [[0 1]]) - (do-nothing 60) - ;;(menu [[:a]]) - ;;(scroll-text) - - ;;(do-nothing 300) - ;;(menu [[:b] [:b]]) - ;;(do-nothing 300) + (set-cursor 3) + (purchase-item 1) - (buy-items [[0 1] - [1 1] - [1 1] - [2 1] - [3 1] - [4 97]]) - - (do-nothing 10)))) + (set-cursor 4) ; 95 burn-heals spells out the + (purchase-item 96) ; return address to the pokemon + ; kernel. 96 so that they can be + ; deposited without causing a shift. -(defn-memo corrupt-item-list-again - ([] (corrupt-item-list-again (get-burn-heals))) + close-menu ; stop talking to shopkeep + (wait-until select-menu-entry) + (play-moves [[:b]]) + end-text))) + +(defn corrupt-item-list-again + ([] (corrupt-item-list-again (buy-bootstrapping-items))) ([script] (->> script - (do-nothing 10) - (play-moves [[:b]]) - (do-nothing 100) - (play-moves [[:b]]) - (do-nothing 40) - (play-moves [[:b]]) - (first-difference [:b] [:start :b] AF) - (menu [[:a] ↑ ↑ ↑ ↑ ↑ ; get fifth pokemon - [:a] ↓ [:a] ; and corrupt the - ↓ ↓ ↓ ↓ ↓ [:a]]) ; item list again by - ; switching it to - ))) ; tenth place. + + activate-start-menu + (set-cursor-relative 0) + select-menu-entry + + ;; repair list-offset for pokemon-list + (set-cursor-relative -1) + + + (set-cursor 4) ; switching it to + select-menu-entry ; tenth place. + (set-cursor 1) + select-menu-entry ; select "switch" on 5th + + (repeat-until-different [] list-offset) + (set-cursor 9) ; goto 10th pokemon + select-menu-entry ; do switch + close-menu + close-menu + + (do-nothing 1) + ;;select-menu-entry + ;; + ;;(set-cursor 9) + ;;select-menu-entry + ;;close-menu + + ))) + ;; (do-nothing 10) + ;; (play-moves [[:b]]) + ;; (do-nothing 100) + ;; (play-moves [[:b]]) + ;; (do-nothing 40) + ;; (play-moves [[:b]]) + ;; (first-difference [:b] [:start :b] AF) + ;; (menu [[:a] ↑ ↑ ↑ ↑ ↑ + ;; [:a] ↓ [:a] + ;; ↓ ↓ ↓ ↓ ↓ [:a]]) + ;; + ;; ))) (defn-memo viridian-store->viridian-poke-center ([] (viridian-store->viridian-poke-center