diff clojure/com/aurellem/items.clj @ 98:08cd8be1edc1

renamed inspect.clj to items.clj
author Robert McIntyre <rlm@mit.edu>
date Mon, 12 Mar 2012 00:31:10 -0500
parents
children 9fad96094950
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/items.clj	Mon Mar 12 00:31:10 2012 -0500
     1.3 @@ -0,0 +1,403 @@
     1.4 +(ns com.aurellem.items
     1.5 +  (:use (com.aurellem gb-driver vbm title))
     1.6 +  ;; this is fucking bullshit
     1.7 +  (:import [com.aurellem.gb_driver SaveState]))
     1.8 +
     1.9 +
    1.10 +
    1.11 +(defn game-name []
    1.12 +  (map char (subvec (vec (memory)) 0x134 0x142)))
    1.13 +
    1.14 +
    1.15 +
    1.16 +                    
    1.17 +
    1.18 +(defn current-items [^SaveState state]
    1.19 +  (set-state! state)
    1.20 +  
    1.21 +
    1.22 +  )
    1.23 +
    1.24 +
    1.25 +
    1.26 +;; try just buying five potions in sequence and see what changes
    1.27 +;; each time.
    1.28 +
    1.29 +(defn common-differences [& seqs]
    1.30 +  (let [backbone (range (count (first seqs)))]
    1.31 +    (filter
    1.32 +     (comp (partial apply distinct?) second)
    1.33 +     (zipmap backbone
    1.34 +             (apply (partial map list) seqs)))))
    1.35 +
    1.36 +;; trying to find how items are represented in memory
    1.37 +
    1.38 +(comment
    1.39 +  (def empty-inventory @current-state)
    1.40 +  
    1.41 +  (def one-potion @current-state)
    1.42 +  
    1.43 +  (def two-potions @current-state)
    1.44 +  
    1.45 +  (def three-potions @current-state)
    1.46 +  
    1.47 +  (def four-potions @current-state)
    1.48 +  
    1.49 +  (def five-potions @current-state)
    1.50 +  
    1.51 +  
    1.52 +  ;; result
    1.53 +  (def canidates
    1.54 +    (apply common-differences
    1.55 +           (map (comp vec memory)
    1.56 +                [empty-inventory one-potion two-potions three-potions
    1.57 +                 four-potions five-potions])))
    1.58 +
    1.59 +  [55875 (37 15 49 27 14 44)]
    1.60 +  [55876 (30 1 49 56 55 23)]
    1.61 +  [49158 (154 191 78 135 70 73)]
    1.62 +  [54087 (49 40 37 34 25 22)]
    1.63 +  [49160 (7 24 59 243 50 217)]
    1.64 +  [49704 (31 14 72 33 84 27)]
    1.65 +  [49162 (126 159 183 110 176 179)]
    1.66 +  [39984 (0 254 251 248 127 252)]
    1.67 +  [49904 (29 72 64 78 1 95)]
    1.68 +  [65491 (222 127 149 132 226 38)]
    1.69 +  [65492 (44 20 89 11 253 163)]
    1.70 +  [49335 (52 15 6 14 3 17)]
    1.71 +  [49720 (78 152 96 60 83 103)]
    1.72 +  [65304 (19 89 214 33 18 113)]
    1.73 +  [53561 (132 185 145 162 159 183)]
    1.74 +  [54046 (0 1 2 3 4 5)])
    1.75 +
    1.76 +;;; hmmmmmm...... I guess that the potion quantities are at 54046,
    1.77 +;;;huh?
    1.78 +
    1.79 +
    1.80 +
    1.81 +(def item-hack (read-state 7999))
    1.82 +
    1.83 +(def item-hack2 (read-state 75882))
    1.84 +
    1.85 +(defn get-mem []
    1.86 +  (subvec (vec (memory @current-state)) 54040 (+ 54046 100)))
    1.87 +
    1.88 +
    1.89 +;; potion -- 99
    1.90 +[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.91 +
    1.92 +;; potion -- 95
    1.93 +[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.94 +
    1.95 +;; potion -- 95
    1.96 +;; pokeball -- 1
    1.97 +[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.98 +
    1.99 +;; potion -- 95
   1.100 +;; pokeball -- 10
   1.101 +[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.102 +
   1.103 +
   1.104 +;; pokeball -- 10
   1.105 +;; potion -- 95
   1.106 +[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.107 +
   1.108 +;; pokeball -- 10
   1.109 +;; potion -- 95
   1.110 +;; antidote -- 1
   1.111 +
   1.112 +;;prediction
   1.113 +;;[0 16 0 0 3 4 10 20 95 ?? 1 255 0 0 0 0 0 ....]
   1.114 +  [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.115 +
   1.116 +
   1.117 +
   1.118 +;; now it's time to learn the item codes
   1.119 +
   1.120 +(def item-hack-3 (read-state 77557))
   1.121 +(defn show-item
   1.122 +  "Run a saved pokemon with the first item replaced by the item named
   1.123 +   by n."
   1.124 +  [n]
   1.125 +  (set-state! item-hack-3)
   1.126 +  (let [mem (memory)]
   1.127 +    (aset mem 54045 n)
   1.128 +    (write-memory! mem))
   1.129 +  (step)
   1.130 +  (->> [[] @current-state]
   1.131 +       (play-moves
   1.132 +        [[:a] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
   1.133 +         [] [] [] [] []])))
   1.134 +
   1.135 +
   1.136 +(defn get-item-names []
   1.137 +  (dorun (map (fn [n] (println n)
   1.138 +                (show-item n)
   1.139 +                (Thread/sleep 5000))
   1.140 +              (range 0x00 0xFF))))
   1.141 +
   1.142 +
   1.143 +
   1.144 +;; 0   garbage
   1.145 +;; 1   master-ball
   1.146 +;; 2   ultra-ball
   1.147 +;; 3   great-ball
   1.148 +;; 4   poke-ball
   1.149 +;; 5   town-map
   1.150 +;; 6   bicycle
   1.151 +;; 7   ?????
   1.152 +;; 8   safari-ball
   1.153 +;; 9   pokedex
   1.154 +;; 10  moon-stone 
   1.155 +;; 11   antidote
   1.156 +;; 12   burn-heal
   1.157 +;; 13   ice-heal
   1.158 +;; 14   awakening
   1.159 +;; 15   parlyz-heal
   1.160 +;; 16   full-restore
   1.161 +;; 17   max-potion
   1.162 +;; 18   hyper-potion
   1.163 +;; 19   super-potion
   1.164 +;; 20   potion
   1.165 +;; 21   boulderbadge
   1.166 +;; 22   cascadebadge
   1.167 +;; 23   thunderbadge
   1.168 +;; 24   rainbowbadge
   1.169 +;; 25   soulbadge
   1.170 +;; 26   marshbadge
   1.171 +;; 27   volcanobadge
   1.172 +;; 28   earthbadge
   1.173 +;; 29   escape-rope
   1.174 +;; 30   repel
   1.175 +;; 31   old amber
   1.176 +;; 32   fire-stone
   1.177 +;; 33   thunderstone
   1.178 +;; 34   water-stone
   1.179 +;; 35   hp-up
   1.180 +;; 36   protein
   1.181 +;; 37   iron
   1.182 +;; 38   carbos
   1.183 +;; 39   calcium
   1.184 +;; 40   rare-candy
   1.185 +;; 41   dome-fossil
   1.186 +;; 42   helix-fossil
   1.187 +;; 43   secret-key
   1.188 +;; 44   ?????
   1.189 +;; 45   bike-voucher
   1.190 +;; 46   x-accuracy
   1.191 +;; 47   leaf-stone
   1.192 +;; 48   card-key
   1.193 +;; 49   nugget
   1.194 +;; 50   pp-up
   1.195 +;; 51   poke-doll
   1.196 +;; 52   full-heal
   1.197 +;; 53   revive
   1.198 +;; 54   max-revive
   1.199 +;; 55   guard-spec.
   1.200 +;; 56   super-repel
   1.201 +;; 57   max-repel
   1.202 +;; 58   dire-hit
   1.203 +;; 59   coin
   1.204 +;; 60   fresh-water
   1.205 +;; 61   soda-pop
   1.206 +;; 62   lemonade
   1.207 +;; 63   s.s.ticket
   1.208 +;; 64   gold-teeth
   1.209 +;; 65   x-attach
   1.210 +;; 66   x-defend
   1.211 +;; 67   x-speed
   1.212 +;; 68   x-special
   1.213 +;; 69   coin-case
   1.214 +;; 70   oak's-parcel
   1.215 +;; 71   itemfinder
   1.216 +;; 72   silph-scope
   1.217 +;; 73   poke-flute
   1.218 +;; 74   lift-key
   1.219 +;; 75   exp.all
   1.220 +;; 76   old-rod
   1.221 +;; 77   good-rod
   1.222 +;; 78   super-rod
   1.223 +;; 79   pp-up
   1.224 +;; 80   ether
   1.225 +;; 81   max-ether
   1.226 +;; 82   elixer
   1.227 +;; 83   max-elixer
   1.228 +;; 84   B2F
   1.229 +;; 85   B1F
   1.230 +;; 86   1F
   1.231 +;; 87   2F
   1.232 +;; 88   3F
   1.233 +;; 89   4F
   1.234 +;; 90   5F
   1.235 +;; 91   6F
   1.236 +;; 92   7F
   1.237 +;; 93   8F
   1.238 +;; 94   9F
   1.239 +;; 95   10F
   1.240 +;; 96   11F
   1.241 +;; 97   B4F
   1.242 +;; 98   garbage
   1.243 +;; 99   garbage
   1.244 +;; 100   garbage
   1.245 +;; 101   garbage
   1.246 +;; 102   garbage
   1.247 +;; 103   garbage
   1.248 +;; 104   garbage
   1.249 +;; 105   garbage
   1.250 +;; 106   garbage
   1.251 +;; 107   garbage
   1.252 +;; 108   garbage
   1.253 +;; 109   garbage
   1.254 +;; 110   garbage
   1.255 +;; 111   garbage
   1.256 +;; 112   garbage
   1.257 +;; 113   garbage
   1.258 +;; 114   garbage
   1.259 +;; 115   garbage
   1.260 +;; 116   garbage
   1.261 +;; 117   garbage
   1.262 +;; 118   garbage
   1.263 +;; 119   4
   1.264 +;; 120   garbage
   1.265 +;; 121   garbage
   1.266 +;; 122   slow
   1.267 +;; 123   garbage
   1.268 +;; 124   garbage
   1.269 +;; 125   garbage
   1.270 +;; 126   garbage
   1.271 +;; 127   garbage
   1.272 +;; 128   garbage
   1.273 +;; 129   garbage
   1.274 +;; 130   garbage
   1.275 +;; 131   slow
   1.276 +;; 132   slow
   1.277 +;; 133   garbage
   1.278 +;; 134   slow
   1.279 +;; 135   garbage
   1.280 +;; 136   garbage
   1.281 +;; 137   slow
   1.282 +;; 138   garbage
   1.283 +;; 139   garbage
   1.284 +;; 140   garbage
   1.285 +;; 141   slow
   1.286 +;; 142   garbage
   1.287 +;; 143   garbage
   1.288 +;; 144   garbage
   1.289 +;; 145   garbage
   1.290 +;; 146   garbage
   1.291 +;; 147   garbage
   1.292 +;; 148   garbage
   1.293 +;; 149   garbage
   1.294 +;; 150   slow
   1.295 +;; 151   garbage
   1.296 +;; 152   Q
   1.297 +;; 153   garbage
   1.298 +;; 154   garbage
   1.299 +;; 155   garbage
   1.300 +;; 156   garbage
   1.301 +;; 157   garbage
   1.302 +;; 158   garbage
   1.303 +;; 159   garbage
   1.304 +;; 160   garbage (alaphabet)
   1.305 +;; 161   garbage
   1.306 +;; 162   garbage
   1.307 +;; 163   garbage
   1.308 +;; 164   rival's
   1.309 +;; 165   name?
   1.310 +;; 166   nickname?
   1.311 +;; 167   slow
   1.312 +;; 168   garbage
   1.313 +;; 169   slow
   1.314 +;; 170   garbage
   1.315 +;; 171   garbage
   1.316 +;; 172   garbage
   1.317 +;; 173   garbage
   1.318 +;; 174   garbage
   1.319 +;; 175   yellow
   1.320 +;; 176   ash
   1.321 +;; 177   jack
   1.322 +;; 178   new-name
   1.323 +;; 179   blue
   1.324 +;; 180   gary
   1.325 +;; 181   john
   1.326 +;; 182   garbage
   1.327 +;; 183   garbage
   1.328 +;; 184   garbage
   1.329 +;; 185   garbage
   1.330 +;; 186   slow
   1.331 +;; 187   garbage
   1.332 +;; 188   garbage
   1.333 +;; 189   garbage
   1.334 +;; 190   garbage
   1.335 +;; 191   garbage
   1.336 +;; 192   garbage
   1.337 +;; 193   garbage
   1.338 +;; 194   garbage
   1.339 +;; 195   slow
   1.340 +;; 196   HM01
   1.341 +;; 197   HM02
   1.342 +;; 198   HM03
   1.343 +;; 199   HM04
   1.344 +;; 200   HM05
   1.345 +;; 201   TM01
   1.346 +;; 202   TM02
   1.347 +;; 203   TM03
   1.348 +;; 204   TM04
   1.349 +;; 205   TM05
   1.350 +;; 206   TM06
   1.351 +;; 207   TM07
   1.352 +;; 208   TM08
   1.353 +;; 209   TM09
   1.354 +;; 210   TM10
   1.355 +;; 211   TM11
   1.356 +;; 212   TM12
   1.357 +;; 213   TM13
   1.358 +;; 214   TM13
   1.359 +;; 215   TM15
   1.360 +;; 216   TM16
   1.361 +;; 217   TM17
   1.362 +;; 218   TM18
   1.363 +;; 219   TM19
   1.364 +;; 220   TM20
   1.365 +;; 221   TM21
   1.366 +;; 222   TM22
   1.367 +;; 223   TM23
   1.368 +;; 224   TM24
   1.369 +;; 225   TM25
   1.370 +;; 226   TM26
   1.371 +;; 227   TM27
   1.372 +;; 228   TM28
   1.373 +;; 229   TM29
   1.374 +;; 230   TM30
   1.375 +;; 231   TM31
   1.376 +;; 232   TM32
   1.377 +;; 233   TM33
   1.378 +;; 234   TM34
   1.379 +;; 235   TM35
   1.380 +;; 236   TM36
   1.381 +;; 237   TM37
   1.382 +;; 238   TM38
   1.383 +;; 239   TM39
   1.384 +;; 240   TM40
   1.385 +;; 241   TM41
   1.386 +;; 242   TM42
   1.387 +;; 243   TM43
   1.388 +;; 244   TM44
   1.389 +;; 245   TM45
   1.390 +;; 246   TM46
   1.391 +;; 247   TM47
   1.392 +;; 248   TM48
   1.393 +;; 249   TM49
   1.394 +;; 250   TM50
   1.395 +;; 251   TM51
   1.396 +;; 252   TM52
   1.397 +;; 253   TM53
   1.398 +;; 254   TM54
   1.399 +;; 255   end-of-list-sentinel   
   1.400 +
   1.401 +
   1.402 +  
   1.403 +
   1.404 +  
   1.405 +  
   1.406 +