comparison clojure/com/aurellem/world/practice.clj @ 259:b2f9a0cb13e3

Added hardcoded evolution data.
author Dylan Holmes <ocsenave@gmail.com>
date Mon, 26 Mar 2012 18:34:06 -0500
parents d5dddf33543c
children a44a2c459aeb
comparison
equal deleted inserted replaced
258:2a46422902be 259:b2f9a0cb13e3
1 (ns com.aurellem.world.practice 1 (ns com.aurellem.world.practice
2 (:use (com.aurellem.gb gb-driver))
3
4 (:use (com.aurellem.gb saves util constants gb-driver vbm items assembly characters)) 2 (:use (com.aurellem.gb saves util constants gb-driver vbm items assembly characters))
5 (:use (com.aurellem.run title)) 3 (:use (com.aurellem.run title))
6 (:use (com.aurellem.exp pokemon)) 4 (:use (com.aurellem.exp pokemon))
7 (:use (com.aurellem.exp item-bridge)) 5 (:use (com.aurellem.exp item-bridge))
8 (:import [com.aurellem.gb.gb_driver SaveState])) 6 (:import [com.aurellem.gb.gb_driver SaveState]))
16 (defn nstep [state n] 14 (defn nstep [state n]
17 (if (zero? n) state 15 (if (zero? n) state
18 (recur (step state) (dec n)))) 16 (recur (step state) (dec n))))
19 17
20 18
21 (defn view-memory* [state start length] 19 (defn view-memory*
20 "View a region of indexable memory in the given state."
21 [state start length]
22 ((comp vec map) 22 ((comp vec map)
23 #((comp aget) (memory state) %) 23 #((comp aget) (memory state) %)
24 (range start (+ start length)))) 24 (range start (+ start length))))
25 25
26 26
179 (map (partial + (inc m)) 179 (map (partial + (inc m))
180 (find-sublists 180 (find-sublists
181 (drop (inc m) list) 181 (drop (inc m) list)
182 sub)))))) 182 sub))))))
183 183
184
185
186 (defn search-rom
187 "Search for the given codes in ROM, returning short snippets of
188 text around the results."
189 ([codes k]
190 (search-rom com.aurellem.gb.gb-driver/original-rom codes k))
191 ([rom codes k]
192 (map
193 (fn [n]
194 [(hex n)
195 (take k (drop n rom))])
196
197 (find-sublists
198 rom
199 codes))))
200
184 (defn spelling-bee 201 (defn spelling-bee
185 "Search for the given string in ROM, returning short snippets of 202 "Search for the given string in ROM, returning short snippets of
186 text around the results." 203 text around the results."
187 [str k] 204 ([str k]
188 (let [rom (rom(root))] 205 (spelling-bee com.aurellem.gb.gb-driver/original-rom str k))
189 (map 206 ([rom str k]
190 (fn [n] 207 (map
191 [(hex n) 208 (fn [[address snip]]
192 (character-codes->str (take k (drop n rom)))]) 209 [address (character-codes->str snip)]
210 (search-rom rom (str->character-codes str) k)))))
193 211
194 (find-sublists
195 rom
196 (str->character-codes str)))))
197 212
198 213
199 214
200 215
201 (defn change-speech 216 (defn change-speech