diff 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
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/world/practice.clj	Mon Mar 26 18:01:39 2012 -0500
     1.2 +++ b/clojure/com/aurellem/world/practice.clj	Mon Mar 26 18:34:06 2012 -0500
     1.3 @@ -1,6 +1,4 @@
     1.4  (ns com.aurellem.world.practice
     1.5 -  (:use (com.aurellem.gb gb-driver))
     1.6 -
     1.7   (:use (com.aurellem.gb saves util constants gb-driver vbm items assembly characters))
     1.8   (:use (com.aurellem.run title))
     1.9   (:use (com.aurellem.exp pokemon))
    1.10 @@ -18,7 +16,9 @@
    1.11        (recur (step state) (dec n))))
    1.12  
    1.13  
    1.14 -(defn view-memory* [state start length]
    1.15 +(defn view-memory*
    1.16 +  "View a region of indexable memory in the given state."
    1.17 +  [state start length]
    1.18    ((comp vec map)
    1.19     #((comp  aget) (memory state) %)
    1.20     (range start (+ start length))))
    1.21 @@ -181,19 +181,34 @@
    1.22                      (drop (inc m) list)
    1.23                      sub))))))
    1.24  
    1.25 +
    1.26 +
    1.27 +(defn search-rom
    1.28 +  "Search for the given codes in ROM, returning short snippets of
    1.29 +text around the results."
    1.30 +  ([codes k]
    1.31 +     (search-rom com.aurellem.gb.gb-driver/original-rom codes k))
    1.32 +  ([rom codes k]
    1.33 +     (map
    1.34 +      (fn [n]
    1.35 +        [(hex n)
    1.36 +         (take k (drop n rom))])
    1.37 +      
    1.38 +      (find-sublists
    1.39 +       rom
    1.40 +       codes))))
    1.41 +
    1.42  (defn spelling-bee
    1.43    "Search for the given string in ROM, returning short snippets of
    1.44 -text around the results."
    1.45 -  [str k]
    1.46 -  (let [rom (rom(root))]
    1.47 -    (map
    1.48 -     (fn [n]
    1.49 -       [(hex n)
    1.50 -        (character-codes->str (take k (drop n rom)))])
    1.51 +  text around the results."
    1.52 +  ([str k]
    1.53 +     (spelling-bee com.aurellem.gb.gb-driver/original-rom str k))
    1.54 +  ([rom str k]
    1.55 +     (map
    1.56 +      (fn [[address snip]]
    1.57 +        [address (character-codes->str snip)]
    1.58 +        (search-rom rom (str->character-codes str) k)))))
    1.59       
    1.60 -     (find-sublists
    1.61 -      rom
    1.62 -      (str->character-codes str)))))
    1.63  
    1.64  
    1.65