Mercurial > vba-clojure
changeset 99:9fad96094950
can now read and set the inventory of a state
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 12 Mar 2012 09:59:26 -0500 |
parents | 08cd8be1edc1 |
children | 2090bcb78f44 |
files | clojure/com/aurellem/experiments/items.clj clojure/com/aurellem/gb_driver.clj clojure/com/aurellem/items.clj |
diffstat | 3 files changed, 575 insertions(+), 384 deletions(-) [+] |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/clojure/com/aurellem/experiments/items.clj Mon Mar 12 09:59:26 2012 -0500 1.3 @@ -0,0 +1,374 @@ 1.4 +;; try just buying five potions in sequence and see what changes 1.5 +;; each time. 1.6 + 1.7 +(defn common-differences [& seqs] 1.8 + (let [backbone (range (count (first seqs)))] 1.9 + (filter 1.10 + (comp (partial apply distinct?) second) 1.11 + (zipmap backbone 1.12 + (apply (partial map list) seqs))))) 1.13 + 1.14 +;; trying to find how items are represented in memory 1.15 + 1.16 +(comment 1.17 + (def empty-inventory @current-state) 1.18 + 1.19 + (def one-potion @current-state) 1.20 + 1.21 + (def two-potions @current-state) 1.22 + 1.23 + (def three-potions @current-state) 1.24 + 1.25 + (def four-potions @current-state) 1.26 + 1.27 + (def five-potions @current-state) 1.28 + 1.29 + 1.30 + ;; result 1.31 + (def canidates 1.32 + (apply common-differences 1.33 + (map (comp vec memory) 1.34 + [empty-inventory one-potion two-potions three-potions 1.35 + four-potions five-potions]))) 1.36 + 1.37 + [55875 (37 15 49 27 14 44)] 1.38 + [55876 (30 1 49 56 55 23)] 1.39 + [49158 (154 191 78 135 70 73)] 1.40 + [54087 (49 40 37 34 25 22)] 1.41 + [49160 (7 24 59 243 50 217)] 1.42 + [49704 (31 14 72 33 84 27)] 1.43 + [49162 (126 159 183 110 176 179)] 1.44 + [39984 (0 254 251 248 127 252)] 1.45 + [49904 (29 72 64 78 1 95)] 1.46 + [65491 (222 127 149 132 226 38)] 1.47 + [65492 (44 20 89 11 253 163)] 1.48 + [49335 (52 15 6 14 3 17)] 1.49 + [49720 (78 152 96 60 83 103)] 1.50 + [65304 (19 89 214 33 18 113)] 1.51 + [53561 (132 185 145 162 159 183)] 1.52 + [54046 (0 1 2 3 4 5)]) 1.53 + 1.54 +;;; hmmmmmm...... I guess that the potion quantities are at 54046, 1.55 +;;;huh? 1.56 + 1.57 + 1.58 + 1.59 +(def item-hack (read-state 7999)) 1.60 + 1.61 +(def item-hack2 (read-state 75882)) 1.62 + 1.63 +(defn get-mem [] 1.64 + (subvec (vec (memory @current-state)) 54040 (+ 54046 100))) 1.65 + 1.66 + 1.67 +;; potion -- 99 1.68 +[0 16 0 0 1 20 99 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.69 + 1.70 +;; potion -- 95 1.71 +[0 16 0 0 1 20 95 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.72 + 1.73 +;; potion -- 95 1.74 +;; pokeball -- 1 1.75 +[0 16 0 0 2 20 95 4 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.76 + 1.77 +;; potion -- 95 1.78 +;; pokeball -- 10 1.79 +[0 16 0 0 2 20 95 4 10 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.80 + 1.81 + 1.82 +;; pokeball -- 10 1.83 +;; potion -- 95 1.84 +[0 16 0 0 2 4 10 20 95 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.85 + 1.86 +;; pokeball -- 10 1.87 +;; potion -- 95 1.88 +;; antidote -- 1 1.89 + 1.90 +;;prediction 1.91 +;;[0 16 0 0 3 4 10 20 95 ?? 1 255 0 0 0 0 0 ....] 1.92 + [0 16 0 0 3 4 10 20 95 11 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 1.93 + 1.94 + 1.95 + 1.96 +;; now it's time to learn the item codes 1.97 + 1.98 +(def item-hack-3 (read-state 77557)) 1.99 +(defn show-item 1.100 + "Run a saved pokemon with the first item replaced by the item named 1.101 + by n." 1.102 + [n] 1.103 + (set-state! item-hack-3) 1.104 + (let [mem (memory)] 1.105 + (aset mem 54045 n) 1.106 + (write-memory! mem)) 1.107 + (step) 1.108 + (->> [[] @current-state] 1.109 + (play-moves 1.110 + [[:a] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] 1.111 + [] [] [] [] []]))) 1.112 + 1.113 + 1.114 +(defn get-item-names [] 1.115 + (dorun (map (fn [n] (println n) 1.116 + (show-item n) 1.117 + (Thread/sleep 5000)) 1.118 + (range 0x00 0xFF)))) 1.119 + 1.120 +;; results (took about 10 minutes to generate) 1.121 + 1.122 +;; 0 garbage 1.123 +;; 1 master-ball 1.124 +;; 2 ultra-ball 1.125 +;; 3 great-ball 1.126 +;; 4 poke-ball 1.127 +;; 5 town-map 1.128 +;; 6 bicycle 1.129 +;; 7 ????? 1.130 +;; 8 safari-ball 1.131 +;; 9 pokedex 1.132 +;; 10 moon-stone 1.133 +;; 11 antidote 1.134 +;; 12 burn-heal 1.135 +;; 13 ice-heal 1.136 +;; 14 awakening 1.137 +;; 15 parlyz-heal 1.138 +;; 16 full-restore 1.139 +;; 17 max-potion 1.140 +;; 18 hyper-potion 1.141 +;; 19 super-potion 1.142 +;; 20 potion 1.143 +;; 21 boulderbadge 1.144 +;; 22 cascadebadge 1.145 +;; 23 thunderbadge 1.146 +;; 24 rainbowbadge 1.147 +;; 25 soulbadge 1.148 +;; 26 marshbadge 1.149 +;; 27 volcanobadge 1.150 +;; 28 earthbadge 1.151 +;; 29 escape-rope 1.152 +;; 30 repel 1.153 +;; 31 old amber 1.154 +;; 32 fire-stone 1.155 +;; 33 thunderstone 1.156 +;; 34 water-stone 1.157 +;; 35 hp-up 1.158 +;; 36 protein 1.159 +;; 37 iron 1.160 +;; 38 carbos 1.161 +;; 39 calcium 1.162 +;; 40 rare-candy 1.163 +;; 41 dome-fossil 1.164 +;; 42 helix-fossil 1.165 +;; 43 secret-key 1.166 +;; 44 ????? 1.167 +;; 45 bike-voucher 1.168 +;; 46 x-accuracy 1.169 +;; 47 leaf-stone 1.170 +;; 48 card-key 1.171 +;; 49 nugget 1.172 +;; 50 pp-up 1.173 +;; 51 poke-doll 1.174 +;; 52 full-heal 1.175 +;; 53 revive 1.176 +;; 54 max-revive 1.177 +;; 55 guard-spec. 1.178 +;; 56 super-repel 1.179 +;; 57 max-repel 1.180 +;; 58 dire-hit 1.181 +;; 59 coin 1.182 +;; 60 fresh-water 1.183 +;; 61 soda-pop 1.184 +;; 62 lemonade 1.185 +;; 63 s.s.ticket 1.186 +;; 64 gold-teeth 1.187 +;; 65 x-attach 1.188 +;; 66 x-defend 1.189 +;; 67 x-speed 1.190 +;; 68 x-special 1.191 +;; 69 coin-case 1.192 +;; 70 oak's-parcel 1.193 +;; 71 itemfinder 1.194 +;; 72 silph-scope 1.195 +;; 73 poke-flute 1.196 +;; 74 lift-key 1.197 +;; 75 exp.all 1.198 +;; 76 old-rod 1.199 +;; 77 good-rod 1.200 +;; 78 super-rod 1.201 +;; 79 pp-up 1.202 +;; 80 ether 1.203 +;; 81 max-ether 1.204 +;; 82 elixer 1.205 +;; 83 max-elixer 1.206 +;; 84 B2F 1.207 +;; 85 B1F 1.208 +;; 86 1F 1.209 +;; 87 2F 1.210 +;; 88 3F 1.211 +;; 89 4F 1.212 +;; 90 5F 1.213 +;; 91 6F 1.214 +;; 92 7F 1.215 +;; 93 8F 1.216 +;; 94 9F 1.217 +;; 95 10F 1.218 +;; 96 11F 1.219 +;; 97 B4F 1.220 +;; 98 garbage 1.221 +;; 99 garbage 1.222 +;; 100 garbage 1.223 +;; 101 garbage 1.224 +;; 102 garbage 1.225 +;; 103 garbage 1.226 +;; 104 garbage 1.227 +;; 105 garbage 1.228 +;; 106 garbage 1.229 +;; 107 garbage 1.230 +;; 108 garbage 1.231 +;; 109 garbage 1.232 +;; 110 garbage 1.233 +;; 111 garbage 1.234 +;; 112 garbage 1.235 +;; 113 garbage 1.236 +;; 114 garbage 1.237 +;; 115 garbage 1.238 +;; 116 garbage 1.239 +;; 117 garbage 1.240 +;; 118 garbage 1.241 +;; 119 4 1.242 +;; 120 garbage 1.243 +;; 121 garbage 1.244 +;; 122 slow 1.245 +;; 123 garbage 1.246 +;; 124 garbage 1.247 +;; 125 garbage 1.248 +;; 126 garbage 1.249 +;; 127 garbage 1.250 +;; 128 garbage 1.251 +;; 129 garbage 1.252 +;; 130 garbage 1.253 +;; 131 slow 1.254 +;; 132 slow 1.255 +;; 133 garbage 1.256 +;; 134 slow 1.257 +;; 135 garbage 1.258 +;; 136 garbage 1.259 +;; 137 slow 1.260 +;; 138 garbage 1.261 +;; 139 garbage 1.262 +;; 140 garbage 1.263 +;; 141 slow 1.264 +;; 142 garbage 1.265 +;; 143 garbage 1.266 +;; 144 garbage 1.267 +;; 145 garbage 1.268 +;; 146 garbage 1.269 +;; 147 garbage 1.270 +;; 148 garbage 1.271 +;; 149 garbage 1.272 +;; 150 slow 1.273 +;; 151 garbage 1.274 +;; 152 Q 1.275 +;; 153 garbage 1.276 +;; 154 garbage 1.277 +;; 155 garbage 1.278 +;; 156 garbage 1.279 +;; 157 garbage 1.280 +;; 158 garbage 1.281 +;; 159 garbage 1.282 +;; 160 garbage (alaphabet) 1.283 +;; 161 garbage 1.284 +;; 162 garbage 1.285 +;; 163 garbage 1.286 +;; 164 rival's 1.287 +;; 165 name? 1.288 +;; 166 nickname? 1.289 +;; 167 slow 1.290 +;; 168 garbage 1.291 +;; 169 slow 1.292 +;; 170 garbage 1.293 +;; 171 garbage 1.294 +;; 172 garbage 1.295 +;; 173 garbage 1.296 +;; 174 garbage 1.297 +;; 175 yellow 1.298 +;; 176 ash 1.299 +;; 177 jack 1.300 +;; 178 new-name 1.301 +;; 179 blue 1.302 +;; 180 gary 1.303 +;; 181 john 1.304 +;; 182 garbage 1.305 +;; 183 garbage 1.306 +;; 184 garbage 1.307 +;; 185 garbage 1.308 +;; 186 slow 1.309 +;; 187 garbage 1.310 +;; 188 garbage 1.311 +;; 189 garbage 1.312 +;; 190 garbage 1.313 +;; 191 garbage 1.314 +;; 192 garbage 1.315 +;; 193 garbage 1.316 +;; 194 garbage 1.317 +;; 195 slow 1.318 +;; 196 HM01 1.319 +;; 197 HM02 1.320 +;; 198 HM03 1.321 +;; 199 HM04 1.322 +;; 200 HM05 1.323 +;; 201 TM01 1.324 +;; 202 TM02 1.325 +;; 203 TM03 1.326 +;; 204 TM04 1.327 +;; 205 TM05 1.328 +;; 206 TM06 1.329 +;; 207 TM07 1.330 +;; 208 TM08 1.331 +;; 209 TM09 1.332 +;; 210 TM10 1.333 +;; 211 TM11 1.334 +;; 212 TM12 1.335 +;; 213 TM13 1.336 +;; 214 TM13 1.337 +;; 215 TM15 1.338 +;; 216 TM16 1.339 +;; 217 TM17 1.340 +;; 218 TM18 1.341 +;; 219 TM19 1.342 +;; 220 TM20 1.343 +;; 221 TM21 1.344 +;; 222 TM22 1.345 +;; 223 TM23 1.346 +;; 224 TM24 1.347 +;; 225 TM25 1.348 +;; 226 TM26 1.349 +;; 227 TM27 1.350 +;; 228 TM28 1.351 +;; 229 TM29 1.352 +;; 230 TM30 1.353 +;; 231 TM31 1.354 +;; 232 TM32 1.355 +;; 233 TM33 1.356 +;; 234 TM34 1.357 +;; 235 TM35 1.358 +;; 236 TM36 1.359 +;; 237 TM37 1.360 +;; 238 TM38 1.361 +;; 239 TM39 1.362 +;; 240 TM40 1.363 +;; 241 TM41 1.364 +;; 242 TM42 1.365 +;; 243 TM43 1.366 +;; 244 TM44 1.367 +;; 245 TM45 1.368 +;; 246 TM46 1.369 +;; 247 TM47 1.370 +;; 248 TM48 1.371 +;; 249 TM49 1.372 +;; 250 TM50 1.373 +;; 251 TM51 1.374 +;; 252 TM52 1.375 +;; 253 TM53 1.376 +;; 254 TM54 1.377 +;; 255 end-of-list-sentinel
2.1 --- a/clojure/com/aurellem/gb_driver.clj Mon Mar 12 00:31:10 2012 -0500 2.2 +++ b/clojure/com/aurellem/gb_driver.clj Mon Mar 12 09:59:26 2012 -0500 2.3 @@ -99,6 +99,11 @@ 2.4 2.5 (defrecord Move [keys state]) 2.6 2.7 +(defn update-state [] 2.8 + (reset! current-state 2.9 + (SaveState. (:frame @current-state) 2.10 + (Gb/saveState)))) 2.11 + 2.12 (defn step 2.13 ([^SaveState state buttons] 2.14 (set-state! state)
3.1 --- a/clojure/com/aurellem/items.clj Mon Mar 12 00:31:10 2012 -0500 3.2 +++ b/clojure/com/aurellem/items.clj Mon Mar 12 09:59:26 2012 -0500 3.3 @@ -1,403 +1,215 @@ 3.4 (ns com.aurellem.items 3.5 (:use (com.aurellem gb-driver vbm title)) 3.6 - ;; this is fucking bullshit 3.7 + ;; this is bullshit 3.8 (:import [com.aurellem.gb_driver SaveState])) 3.9 3.10 - 3.11 - 3.12 (defn game-name [] 3.13 (map char (subvec (vec (memory)) 0x134 0x142))) 3.14 3.15 +(def item-list-start 0xD31C) 3.16 3.17 - 3.18 - 3.19 - 3.20 -(defn current-items [^SaveState state] 3.21 - (set-state! state) 3.22 - 3.23 - 3.24 - ) 3.25 - 3.26 - 3.27 - 3.28 -;; try just buying five potions in sequence and see what changes 3.29 -;; each time. 3.30 - 3.31 -(defn common-differences [& seqs] 3.32 - (let [backbone (range (count (first seqs)))] 3.33 - (filter 3.34 - (comp (partial apply distinct?) second) 3.35 - (zipmap backbone 3.36 - (apply (partial map list) seqs))))) 3.37 - 3.38 -;; trying to find how items are represented in memory 3.39 - 3.40 -(comment 3.41 - (def empty-inventory @current-state) 3.42 - 3.43 - (def one-potion @current-state) 3.44 - 3.45 - (def two-potions @current-state) 3.46 - 3.47 - (def three-potions @current-state) 3.48 - 3.49 - (def four-potions @current-state) 3.50 - 3.51 - (def five-potions @current-state) 3.52 - 3.53 - 3.54 - ;; result 3.55 - (def canidates 3.56 - (apply common-differences 3.57 - (map (comp vec memory) 3.58 - [empty-inventory one-potion two-potions three-potions 3.59 - four-potions five-potions]))) 3.60 - 3.61 - [55875 (37 15 49 27 14 44)] 3.62 - [55876 (30 1 49 56 55 23)] 3.63 - [49158 (154 191 78 135 70 73)] 3.64 - [54087 (49 40 37 34 25 22)] 3.65 - [49160 (7 24 59 243 50 217)] 3.66 - [49704 (31 14 72 33 84 27)] 3.67 - [49162 (126 159 183 110 176 179)] 3.68 - [39984 (0 254 251 248 127 252)] 3.69 - [49904 (29 72 64 78 1 95)] 3.70 - [65491 (222 127 149 132 226 38)] 3.71 - [65492 (44 20 89 11 253 163)] 3.72 - [49335 (52 15 6 14 3 17)] 3.73 - [49720 (78 152 96 60 83 103)] 3.74 - [65304 (19 89 214 33 18 113)] 3.75 - [53561 (132 185 145 162 159 183)] 3.76 - [54046 (0 1 2 3 4 5)]) 3.77 - 3.78 -;;; hmmmmmm...... I guess that the potion quantities are at 54046, 3.79 -;;;huh? 3.80 - 3.81 - 3.82 - 3.83 -(def item-hack (read-state 7999)) 3.84 - 3.85 -(def item-hack2 (read-state 75882)) 3.86 - 3.87 -(defn get-mem [] 3.88 - (subvec (vec (memory @current-state)) 54040 (+ 54046 100))) 3.89 - 3.90 - 3.91 -;; potion -- 99 3.92 -[0 16 0 0 1 20 99 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.93 - 3.94 -;; potion -- 95 3.95 -[0 16 0 0 1 20 95 255 0 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.96 - 3.97 -;; potion -- 95 3.98 -;; pokeball -- 1 3.99 -[0 16 0 0 2 20 95 4 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.100 - 3.101 -;; potion -- 95 3.102 -;; pokeball -- 10 3.103 -[0 16 0 0 2 20 95 4 10 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.104 - 3.105 - 3.106 -;; pokeball -- 10 3.107 -;; potion -- 95 3.108 -[0 16 0 0 2 4 10 20 95 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.109 - 3.110 -;; pokeball -- 10 3.111 -;; potion -- 95 3.112 -;; antidote -- 1 3.113 - 3.114 -;;prediction 3.115 -;;[0 16 0 0 3 4 10 20 95 ?? 1 255 0 0 0 0 0 ....] 3.116 - [0 16 0 0 3 4 10 20 95 11 1 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 117 129 139 148 132 80 134 128 145 152 80 137 3 0 0 1 191 223 189 2 0 42 8 199 5 2 1 0 1 20 2 4 4 93 77 23 77 122 76 0 255 208 65 240 198 10 10 71 246 41 201 255 252 64 18 201 10 10] 3.117 - 3.118 - 3.119 - 3.120 -;; now it's time to learn the item codes 3.121 +(defn item-list [^SaveState state] 3.122 + (subvec 3.123 + (vec (memory state)) 3.124 + item-list-start 3.125 + (+ item-list-start 60))) 3.126 3.127 (def item-hack-3 (read-state 77557)) 3.128 -(defn show-item 3.129 - "Run a saved pokemon with the first item replaced by the item named 3.130 - by n." 3.131 - [n] 3.132 - (set-state! item-hack-3) 3.133 - (let [mem (memory)] 3.134 - (aset mem 54045 n) 3.135 - (write-memory! mem)) 3.136 - (step) 3.137 - (->> [[] @current-state] 3.138 - (play-moves 3.139 - [[:a] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] 3.140 - [] [] [] [] []]))) 3.141 3.142 +(def item-code->item-name 3.143 + (hash-map 3.144 + 1 :master-ball 3.145 + 2 :ultra-ball 3.146 + 3 :great-ball 3.147 + 4 :poke-ball 3.148 + 5 :town-map 3.149 + 6 :bicycle 3.150 + 8 :safari-ball 3.151 + 9 :pokedex 3.152 + 10 :moon-stone 3.153 + 11 :antidote 3.154 + 12 :burn-heal 3.155 + 13 :ice-heal 3.156 + 14 :awakening 3.157 + 15 :parlyz-heal 3.158 + 16 :full-restore 3.159 + 17 :max-potion 3.160 + 18 :hyper-potion 3.161 + 19 :super-potion 3.162 + 20 :potion 3.163 + 21 :boulderbadge 3.164 + 22 :cascadebadge 3.165 + 23 :thunderbadge 3.166 + 24 :rainbowbadge 3.167 + 25 :soulbadge 3.168 + 26 :marshbadge 3.169 + 27 :volcanobadge 3.170 + 28 :earthbadge 3.171 + 29 :escape-rope 3.172 + 30 :repel 3.173 + 31 :old-amber 3.174 + 32 :fire-stone 3.175 + 33 :thunderstone 3.176 + 34 :water-stone 3.177 + 35 :hp-up 3.178 + 36 :protein 3.179 + 37 :iron 3.180 + 38 :carbos 3.181 + 39 :calcium 3.182 + 40 :rare-candy 3.183 + 41 :dome-fossil 3.184 + 42 :helix-fossil 3.185 + 43 :secret-key 3.186 + 45 :bike-voucher 3.187 + 46 :x-accuracy 3.188 + 47 :leaf-stone 3.189 + 48 :card-key 3.190 + 49 :nugget 3.191 + 50 :pp-up 3.192 + 51 :poke-doll 3.193 + 52 :full-heal 3.194 + 53 :revive 3.195 + 54 :max-revive 3.196 + 55 :guard-spec 3.197 + 56 :super-repel 3.198 + 57 :max-repel 3.199 + 58 :dire-hit 3.200 + 59 :coin 3.201 + 60 :fresh-water 3.202 + 61 :soda-pop 3.203 + 62 :lemonade 3.204 + 63 :s.s.ticket 3.205 + 64 :gold-teeth 3.206 + 65 :x-attach 3.207 + 66 :x-defend 3.208 + 67 :x-speed 3.209 + 68 :x-special 3.210 + 69 :coin-case 3.211 + 70 :oaks-parcel 3.212 + 71 :itemfinder 3.213 + 72 :silph-scope 3.214 + 73 :poke-flute 3.215 + 74 :lift-key 3.216 + 75 :exp.all 3.217 + 76 :old-rod 3.218 + 77 :good-rod 3.219 + 78 :super-rod 3.220 + 79 :pp-up 3.221 + 80 :ether 3.222 + 81 :max-ether 3.223 + 82 :elixer 3.224 + 83 :max-elixer 3.225 + 196 :HM01 3.226 + 197 :HM02 3.227 + 198 :HM03 3.228 + 199 :HM04 3.229 + 200 :HM05 3.230 + 201 :TM01 3.231 + 202 :TM02 3.232 + 203 :TM03 3.233 + 204 :TM04 3.234 + 205 :TM05 3.235 + 206 :TM06 3.236 + 207 :TM07 3.237 + 208 :TM08 3.238 + 209 :TM09 3.239 + 210 :TM10 3.240 + 211 :TM11 3.241 + 212 :TM12 3.242 + 213 :TM13 3.243 + 214 :TM13 3.244 + 215 :TM15 3.245 + 216 :TM16 3.246 + 217 :TM17 3.247 + 218 :TM18 3.248 + 219 :TM19 3.249 + 220 :TM20 3.250 + 221 :TM21 3.251 + 222 :TM22 3.252 + 223 :TM23 3.253 + 224 :TM24 3.254 + 225 :TM25 3.255 + 226 :TM26 3.256 + 227 :TM27 3.257 + 228 :TM28 3.258 + 229 :TM29 3.259 + 230 :TM30 3.260 + 231 :TM31 3.261 + 232 :TM32 3.262 + 233 :TM33 3.263 + 234 :TM34 3.264 + 235 :TM35 3.265 + 236 :TM36 3.266 + 237 :TM37 3.267 + 238 :TM38 3.268 + 239 :TM39 3.269 + 240 :TM40 3.270 + 241 :TM41 3.271 + 242 :TM42 3.272 + 243 :TM43 3.273 + 244 :TM44 3.274 + 245 :TM45 3.275 + 246 :TM46 3.276 + 247 :TM47 3.277 + 248 :TM48 3.278 + 249 :TM49 3.279 + 250 :TM50 3.280 + 251 :TM51 3.281 + 252 :TM52 3.282 + 253 :TM53 3.283 + 254 :TM54 3.284 + 255 :end-of-list-sentinel)) 3.285 3.286 -(defn get-item-names [] 3.287 - (dorun (map (fn [n] (println n) 3.288 - (show-item n) 3.289 - (Thread/sleep 5000)) 3.290 - (range 0x00 0xFF)))) 3.291 +(def item-name->item-code 3.292 + (zipmap (vals item-code->item-name) 3.293 + (keys item-code->item-name))) 3.294 3.295 +(defn inventory [^SaveState state] 3.296 + (let [items (item-list state)] 3.297 + (map 3.298 + (fn [[item-code quantity]] 3.299 + [(item-code->item-name item-code) 3.300 + quantity]) 3.301 + (partition 3.302 + 2 3.303 + (next (take-while (partial not= 255) items)))))) 3.304 3.305 +(defn print-inventory [^SaveState state] 3.306 + (println 3.307 + (let [inv (inventory state)] 3.308 + (reduce 3.309 + str 3.310 + (concat 3.311 + ["+-------------------+----------+\n" 3.312 + "|##| Item | Quantity |\n" 3.313 + "+--+----------------+----------+\n"] 3.314 3.315 -;; 0 garbage 3.316 -;; 1 master-ball 3.317 -;; 2 ultra-ball 3.318 -;; 3 great-ball 3.319 -;; 4 poke-ball 3.320 -;; 5 town-map 3.321 -;; 6 bicycle 3.322 -;; 7 ????? 3.323 -;; 8 safari-ball 3.324 -;; 9 pokedex 3.325 -;; 10 moon-stone 3.326 -;; 11 antidote 3.327 -;; 12 burn-heal 3.328 -;; 13 ice-heal 3.329 -;; 14 awakening 3.330 -;; 15 parlyz-heal 3.331 -;; 16 full-restore 3.332 -;; 17 max-potion 3.333 -;; 18 hyper-potion 3.334 -;; 19 super-potion 3.335 -;; 20 potion 3.336 -;; 21 boulderbadge 3.337 -;; 22 cascadebadge 3.338 -;; 23 thunderbadge 3.339 -;; 24 rainbowbadge 3.340 -;; 25 soulbadge 3.341 -;; 26 marshbadge 3.342 -;; 27 volcanobadge 3.343 -;; 28 earthbadge 3.344 -;; 29 escape-rope 3.345 -;; 30 repel 3.346 -;; 31 old amber 3.347 -;; 32 fire-stone 3.348 -;; 33 thunderstone 3.349 -;; 34 water-stone 3.350 -;; 35 hp-up 3.351 -;; 36 protein 3.352 -;; 37 iron 3.353 -;; 38 carbos 3.354 -;; 39 calcium 3.355 -;; 40 rare-candy 3.356 -;; 41 dome-fossil 3.357 -;; 42 helix-fossil 3.358 -;; 43 secret-key 3.359 -;; 44 ????? 3.360 -;; 45 bike-voucher 3.361 -;; 46 x-accuracy 3.362 -;; 47 leaf-stone 3.363 -;; 48 card-key 3.364 -;; 49 nugget 3.365 -;; 50 pp-up 3.366 -;; 51 poke-doll 3.367 -;; 52 full-heal 3.368 -;; 53 revive 3.369 -;; 54 max-revive 3.370 -;; 55 guard-spec. 3.371 -;; 56 super-repel 3.372 -;; 57 max-repel 3.373 -;; 58 dire-hit 3.374 -;; 59 coin 3.375 -;; 60 fresh-water 3.376 -;; 61 soda-pop 3.377 -;; 62 lemonade 3.378 -;; 63 s.s.ticket 3.379 -;; 64 gold-teeth 3.380 -;; 65 x-attach 3.381 -;; 66 x-defend 3.382 -;; 67 x-speed 3.383 -;; 68 x-special 3.384 -;; 69 coin-case 3.385 -;; 70 oak's-parcel 3.386 -;; 71 itemfinder 3.387 -;; 72 silph-scope 3.388 -;; 73 poke-flute 3.389 -;; 74 lift-key 3.390 -;; 75 exp.all 3.391 -;; 76 old-rod 3.392 -;; 77 good-rod 3.393 -;; 78 super-rod 3.394 -;; 79 pp-up 3.395 -;; 80 ether 3.396 -;; 81 max-ether 3.397 -;; 82 elixer 3.398 -;; 83 max-elixer 3.399 -;; 84 B2F 3.400 -;; 85 B1F 3.401 -;; 86 1F 3.402 -;; 87 2F 3.403 -;; 88 3F 3.404 -;; 89 4F 3.405 -;; 90 5F 3.406 -;; 91 6F 3.407 -;; 92 7F 3.408 -;; 93 8F 3.409 -;; 94 9F 3.410 -;; 95 10F 3.411 -;; 96 11F 3.412 -;; 97 B4F 3.413 -;; 98 garbage 3.414 -;; 99 garbage 3.415 -;; 100 garbage 3.416 -;; 101 garbage 3.417 -;; 102 garbage 3.418 -;; 103 garbage 3.419 -;; 104 garbage 3.420 -;; 105 garbage 3.421 -;; 106 garbage 3.422 -;; 107 garbage 3.423 -;; 108 garbage 3.424 -;; 109 garbage 3.425 -;; 110 garbage 3.426 -;; 111 garbage 3.427 -;; 112 garbage 3.428 -;; 113 garbage 3.429 -;; 114 garbage 3.430 -;; 115 garbage 3.431 -;; 116 garbage 3.432 -;; 117 garbage 3.433 -;; 118 garbage 3.434 -;; 119 4 3.435 -;; 120 garbage 3.436 -;; 121 garbage 3.437 -;; 122 slow 3.438 -;; 123 garbage 3.439 -;; 124 garbage 3.440 -;; 125 garbage 3.441 -;; 126 garbage 3.442 -;; 127 garbage 3.443 -;; 128 garbage 3.444 -;; 129 garbage 3.445 -;; 130 garbage 3.446 -;; 131 slow 3.447 -;; 132 slow 3.448 -;; 133 garbage 3.449 -;; 134 slow 3.450 -;; 135 garbage 3.451 -;; 136 garbage 3.452 -;; 137 slow 3.453 -;; 138 garbage 3.454 -;; 139 garbage 3.455 -;; 140 garbage 3.456 -;; 141 slow 3.457 -;; 142 garbage 3.458 -;; 143 garbage 3.459 -;; 144 garbage 3.460 -;; 145 garbage 3.461 -;; 146 garbage 3.462 -;; 147 garbage 3.463 -;; 148 garbage 3.464 -;; 149 garbage 3.465 -;; 150 slow 3.466 -;; 151 garbage 3.467 -;; 152 Q 3.468 -;; 153 garbage 3.469 -;; 154 garbage 3.470 -;; 155 garbage 3.471 -;; 156 garbage 3.472 -;; 157 garbage 3.473 -;; 158 garbage 3.474 -;; 159 garbage 3.475 -;; 160 garbage (alaphabet) 3.476 -;; 161 garbage 3.477 -;; 162 garbage 3.478 -;; 163 garbage 3.479 -;; 164 rival's 3.480 -;; 165 name? 3.481 -;; 166 nickname? 3.482 -;; 167 slow 3.483 -;; 168 garbage 3.484 -;; 169 slow 3.485 -;; 170 garbage 3.486 -;; 171 garbage 3.487 -;; 172 garbage 3.488 -;; 173 garbage 3.489 -;; 174 garbage 3.490 -;; 175 yellow 3.491 -;; 176 ash 3.492 -;; 177 jack 3.493 -;; 178 new-name 3.494 -;; 179 blue 3.495 -;; 180 gary 3.496 -;; 181 john 3.497 -;; 182 garbage 3.498 -;; 183 garbage 3.499 -;; 184 garbage 3.500 -;; 185 garbage 3.501 -;; 186 slow 3.502 -;; 187 garbage 3.503 -;; 188 garbage 3.504 -;; 189 garbage 3.505 -;; 190 garbage 3.506 -;; 191 garbage 3.507 -;; 192 garbage 3.508 -;; 193 garbage 3.509 -;; 194 garbage 3.510 -;; 195 slow 3.511 -;; 196 HM01 3.512 -;; 197 HM02 3.513 -;; 198 HM03 3.514 -;; 199 HM04 3.515 -;; 200 HM05 3.516 -;; 201 TM01 3.517 -;; 202 TM02 3.518 -;; 203 TM03 3.519 -;; 204 TM04 3.520 -;; 205 TM05 3.521 -;; 206 TM06 3.522 -;; 207 TM07 3.523 -;; 208 TM08 3.524 -;; 209 TM09 3.525 -;; 210 TM10 3.526 -;; 211 TM11 3.527 -;; 212 TM12 3.528 -;; 213 TM13 3.529 -;; 214 TM13 3.530 -;; 215 TM15 3.531 -;; 216 TM16 3.532 -;; 217 TM17 3.533 -;; 218 TM18 3.534 -;; 219 TM19 3.535 -;; 220 TM20 3.536 -;; 221 TM21 3.537 -;; 222 TM22 3.538 -;; 223 TM23 3.539 -;; 224 TM24 3.540 -;; 225 TM25 3.541 -;; 226 TM26 3.542 -;; 227 TM27 3.543 -;; 228 TM28 3.544 -;; 229 TM29 3.545 -;; 230 TM30 3.546 -;; 231 TM31 3.547 -;; 232 TM32 3.548 -;; 233 TM33 3.549 -;; 234 TM34 3.550 -;; 235 TM35 3.551 -;; 236 TM36 3.552 -;; 237 TM37 3.553 -;; 238 TM38 3.554 -;; 239 TM39 3.555 -;; 240 TM40 3.556 -;; 241 TM41 3.557 -;; 242 TM42 3.558 -;; 243 TM43 3.559 -;; 244 TM44 3.560 -;; 245 TM45 3.561 -;; 246 TM46 3.562 -;; 247 TM47 3.563 -;; 248 TM48 3.564 -;; 249 TM49 3.565 -;; 250 TM50 3.566 -;; 251 TM51 3.567 -;; 252 TM52 3.568 -;; 253 TM53 3.569 -;; 254 TM54 3.570 -;; 255 end-of-list-sentinel 3.571 + (map 3.572 + (fn [index [item-name quantity]] 3.573 + (str 3.574 + (format "|%-2d| %-14s | %3d |\n" index 3.575 + (apply str (rest (str item-name))) 3.576 + quantity))) 3.577 + (range 0 (count inv)) inv) 3.578 + ["+--+----------------+----------+\n"]))))) 3.579 3.580 - 3.581 +(defn inventory-codes [inventory] 3.582 + (flatten 3.583 + (concat [(count inventory)] 3.584 + (map (fn [[item-name quantity]] 3.585 + [(item-name->item-code item-name) 3.586 + quantity]) inventory) 3.587 + [(item-name->item-code :end-of-list-sentinel)]))) 3.588 3.589 - 3.590 +(defn set-inventory [^SaveState state new-inventory] 3.591 + (set-state! state) 3.592 + (let [mem (memory state) 3.593 + inv (inventory-codes new-inventory)] 3.594 3.595 + (dorun (map (fn [index val] 3.596 + (aset mem index val)) 3.597 + (range item-list-start 3.598 + (+ item-list-start (count inv))) inv)) 3.599 + (write-memory! mem) 3.600 + (update-state))) 3.601 3.602 -