annotate 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
rev   line source
rlm@95 1 (ns com.aurellem.inspect
rlm@95 2 (:use (com.aurellem gb-driver vbm))
rlm@95 3 ;; this is fucking bullshit
rlm@95 4 (:import [com.aurellem.gb_driver SaveState]))
rlm@95 5
rlm@95 6
rlm@95 7
rlm@95 8 (defn game-name []
rlm@95 9 (map char (subvec (vec (memory)) 0x134 0x142)))
rlm@95 10
rlm@95 11
rlm@95 12
rlm@95 13
rlm@95 14
rlm@95 15 (defn current-items [^SaveState state]
rlm@95 16 (set-state! state)
rlm@95 17
rlm@95 18
rlm@95 19 )
rlm@95 20
rlm@95 21
rlm@95 22
rlm@95 23
rlm@95 24
rlm@95 25
rlm@95 26
rlm@95 27
rlm@95 28 ;; try just buying five potions in sequence and see what changes
rlm@95 29 ;; each time.
rlm@95 30
rlm@95 31 (defn common-differences [& seqs]
rlm@95 32 (let [backbone (range (count (first seqs)))]
rlm@95 33 (filter
rlm@95 34 (comp (partial apply distinct?) second)
rlm@95 35 (zipmap backbone
rlm@95 36 (apply (partial map list) seqs)))))
rlm@95 37
rlm@95 38 ;; trying to find how items are represented in memory
rlm@95 39
rlm@95 40 (def empty-inventory @current-state)
rlm@95 41
rlm@95 42 (def one-potion @current-state)
rlm@95 43
rlm@95 44 (def two-potions @current-state)
rlm@95 45
rlm@95 46 (def three-potions @current-state)
rlm@95 47
rlm@95 48 (def four-potions @current-state)
rlm@95 49
rlm@95 50 (def five-potions @current-state)
rlm@95 51
rlm@95 52
rlm@95 53 ;; result
rlm@95 54 (def canidates
rlm@95 55 (apply common-differences
rlm@95 56 (map (comp vec memory)
rlm@95 57 [empty-inventory one-potion two-potions three-potions
rlm@95 58 four-potions five-potions])))
rlm@95 59
rlm@95 60 (comment
rlm@95 61 [55875 (37 15 49 27 14 44)]
rlm@95 62 [55876 (30 1 49 56 55 23)]
rlm@95 63 [49158 (154 191 78 135 70 73)]
rlm@95 64 [54087 (49 40 37 34 25 22)]
rlm@95 65 [49160 (7 24 59 243 50 217)]
rlm@95 66 [49704 (31 14 72 33 84 27)]
rlm@95 67 [49162 (126 159 183 110 176 179)]
rlm@95 68 [39984 (0 254 251 248 127 252)]
rlm@95 69 [49904 (29 72 64 78 1 95)]
rlm@95 70 [65491 (222 127 149 132 226 38)]
rlm@95 71 [65492 (44 20 89 11 253 163)]
rlm@95 72 [49335 (52 15 6 14 3 17)]
rlm@95 73 [49720 (78 152 96 60 83 103)]
rlm@95 74 [65304 (19 89 214 33 18 113)]
rlm@95 75 [53561 (132 185 145 162 159 183)]
rlm@95 76 [54046 (0 1 2 3 4 5)])
rlm@95 77
rlm@95 78 ;;; hmmmmmm...... I guess that the potion quantities are at 54046, huh?