diff clojure/com/aurellem/inspect.clj @ 95:b74a578d0c88

working on inventory analysis
author Robert McIntyre <rlm@mit.edu>
date Sun, 11 Mar 2012 23:10:44 -0500
parents
children cb487c4ce5c0
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/clojure/com/aurellem/inspect.clj	Sun Mar 11 23:10:44 2012 -0500
     1.3 @@ -0,0 +1,78 @@
     1.4 +(ns com.aurellem.inspect
     1.5 +  (:use (com.aurellem gb-driver vbm))
     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 +
    1.27 +
    1.28 +
    1.29 +
    1.30 +
    1.31 +;; try just buying five potions in sequence and see what changes
    1.32 +;; each time.
    1.33 +
    1.34 +(defn common-differences [& seqs]
    1.35 +  (let [backbone (range (count (first seqs)))]
    1.36 +    (filter
    1.37 +     (comp (partial apply distinct?) second)
    1.38 +     (zipmap backbone
    1.39 +             (apply (partial map list) seqs)))))
    1.40 +
    1.41 +;; trying to find how items are represented in memory
    1.42 +
    1.43 +(def empty-inventory @current-state)
    1.44 +
    1.45 +(def one-potion @current-state)
    1.46 +
    1.47 +(def two-potions @current-state)
    1.48 +
    1.49 +(def three-potions @current-state)
    1.50 +
    1.51 +(def four-potions @current-state)
    1.52 +
    1.53 +(def five-potions @current-state)
    1.54 +  
    1.55 +
    1.56 +;; result
    1.57 +(def canidates
    1.58 +  (apply common-differences
    1.59 +         (map (comp vec memory)
    1.60 +              [empty-inventory one-potion two-potions three-potions
    1.61 +               four-potions five-potions])))
    1.62 +
    1.63 +(comment
    1.64 +  [55875 (37 15 49 27 14 44)]
    1.65 +  [55876 (30 1 49 56 55 23)]
    1.66 +  [49158 (154 191 78 135 70 73)]
    1.67 +  [54087 (49 40 37 34 25 22)]
    1.68 +  [49160 (7 24 59 243 50 217)]
    1.69 +  [49704 (31 14 72 33 84 27)]
    1.70 +  [49162 (126 159 183 110 176 179)]
    1.71 +  [39984 (0 254 251 248 127 252)]
    1.72 +  [49904 (29 72 64 78 1 95)]
    1.73 +  [65491 (222 127 149 132 226 38)]
    1.74 +  [65492 (44 20 89 11 253 163)]
    1.75 +  [49335 (52 15 6 14 3 17)]
    1.76 +  [49720 (78 152 96 60 83 103)]
    1.77 +  [65304 (19 89 214 33 18 113)]
    1.78 +  [53561 (132 185 145 162 159 183)]
    1.79 +  [54046 (0 1 2 3 4 5)])
    1.80 +
    1.81 +;;; hmmmmmm...... I guess that the potion quantities are at 54046, huh?
    1.82 \ No newline at end of file