comparison clojure/com/aurellem/run/bootstrap_0.clj @ 264:0297d315b574

script: made it to viridian mart
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Mar 2012 22:45:27 -0500
parents 868783405ac2
children c85549460218
comparison
equal deleted inserted replaced
262:868783405ac2 264:0297d315b574
1 (ns com.aurellem.run.bootstrap-0 1 (ns com.aurellem.run.bootstrap-0
2 (:use (com.aurellem.gb gb-driver vbm characters)) 2 (:use (com.aurellem.gb gb-driver vbm characters))
3 (:use (com.aurellem.run title save-corruption)) 3 (:use (com.aurellem.run title save-corruption))
4 (:use (com.aurellem.exp item-bridge))) 4 (:use (com.aurellem.exp item-bridge))
5 5 (:import [com.aurellem.gb.gb_driver SaveState]))
6 6
7 (defn-memo boot-root [] 7 (defn-memo boot-root []
8 [ [] (root)]) 8 [ [] (root)])
9 9
10 (defn-memo to-rival-name 10 (defn-memo to-rival-name
238 (walk [← ← ← ← 238 (walk [← ← ← ←
239 ↑ ↑ ↑ ↑ 239 ↑ ↑ ↑ ↑
240 ↑ ↑ ↑ ↑ ↑ ↑ 240 ↑ ↑ ↑ ↑ ↑ ↑
241 → ↑])))) 241 → ↑]))))
242 242
243
244 (defn move-thru-grass
245 [direction script]
246 (loop [blanks 0]
247 (let [new-script
248 (->> script
249 (play-moves (repeat blanks []))
250 (move direction))
251
252 future-state
253 (run-moves (second new-script)
254 (repeat 600 []))
255
256 result (search-string (memory future-state)
257 "Wild")]
258 (if (nil? result)
259 new-script
260 (recur (inc blanks))))))
261
262 (defn walk-thru-grass
263 [directions script]
264 (reduce (fn [script direction]
265 (move-thru-grass direction script))
266 script directions))
267
268 (defn-memo pallet-edge->viridian-mart
269 ([] (pallet-edge->viridian-mart
270 (oaks-lab->pallet-town-edge)))
271 ([script]
272 (->> script
273 ;; leave straight grass
274 (walk-thru-grass
275 [↑ ↑ ↑ ↑ ↑])
276
277 (walk [↑ ↑ ↑ ↑])
278
279
280 (walk-thru-grass
281 [← ← ↑])
282 (walk [↑ ↑ ↑ ↑ → → → ])
283
284 (walk-thru-grass
285 [→ ↑ ↑ ←])
286
287 (walk
288 [← ←
289 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
290 → → → → ])
291
292 (walk-thru-grass
293 [→ →
294 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ])
295
296 (walk
297 [↑ ↑
298 ← ← ← ←
299 ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑
300 ← ←
301 ↑ ↑ ↑ ↑
302 → → → → → → → → → →
303 ↑ ↑ ↑ ↑ ↑ ↑]))))
304