diff clojure/com/aurellem/experiments/items.clj @ 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
children 3a60bb14a64a
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