diff clojure/com/aurellem/exp/items.clj @ 145:412ca096a9ba

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