view clojure/com/aurellem/run/bootstrap_0.clj @ 257:8d1a354f7471

continued work on unoptimized script
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Mar 2012 07:20:30 -0500
parents d9e0752da684
children 2a46422902be
line wrap: on
line source
1 (ns com.aurellem.run.bootstrap-0
2 (:use (com.aurellem.gb gb-driver vbm))
3 (:use (com.aurellem.run title save-corruption))
4 (:use (com.aurellem.exp item-bridge)))
7 (defn-memo boot-root []
8 [ [] (root)])
10 (defn-memo to-rival-name
11 ([] (to-rival-name (boot-root)))
12 ([script]
13 (-> script
14 title
15 oak
16 name-entry-rlm
17 scroll-text
18 scroll-text
19 scroll-text
20 scroll-text
21 scroll-text
22 )))
24 (defn-memo name-rival-bootstrap
25 ([] (name-rival-bootstrap (to-rival-name)))
26 ([script]
27 (->> script
28 (advance [] [:a])
29 (advance [] [:r] DE)
30 (play-moves
31 [[]
32 [:r] [] [:r] [] [:r] [] [:r] []
33 [:r] [] [:r] [] [:r] [] [:d] []
34 [:d] [:a] ;; space
35 [:l] [] [:d] [:a] ;; [PK]
36 [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
37 [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
38 [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
39 [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
41 [:d] [] [:r] [:a] ;; finish
42 ]))))
44 (defn walk
45 "Move the character along the given directions."
46 [directions script]
47 (reduce (fn [script direction]
48 (move direction script))
49 script directions))
51 (def ↑ [:u])
52 (def ↓ [:d])
53 (def ← [:l])
54 (def → [:r])
56 (defn-memo leave-house
57 ([] (leave-house (name-rival-bootstrap)))
58 ([script]
59 (->> script
60 finish-title
61 start-walking
62 walk-to-stairs
63 walk-to-door
64 (walk [↓ ↓]))))
66 (defn-memo to-pallet-town-edge
67 ([] (to-pallet-town-edge (leave-house)))
68 ([script]
69 (->> script
70 start-walking
71 (walk [→ → → → →
72 ↑ ↑ ↑ ↑ ↑ ↑]))))
74 (defn end-text [script]
75 (->> script
76 (scroll-text)
77 (play-moves [[] [:a]])))
79 (defn-memo start-pikachu-battle
80 ([] (start-pikachu-battle
81 (to-pallet-town-edge)))
82 ([script]
83 (->> script
84 (advance [:b] [:b :a] DE)
85 (scroll-text)
86 (play-moves [[:b]])
87 (scroll-text)
88 (end-text) ;; battle begins
89 (scroll-text))))
91 (defn-memo capture-pikachu
92 ([] (capture-pikachu (start-pikachu-battle)))
93 ([script]
94 (->> script
95 (scroll-text 2)
96 (end-text))))
98 (defn-memo go-to-lab
99 ([] (go-to-lab (capture-pikachu)))
100 ([script]
101 (->> script
102 (scroll-text 5)
103 (end-text)
104 (scroll-text)
105 (end-text)
106 (scroll-text 8)
107 (end-text)
108 (scroll-text)
109 (end-text))))
111 (defn-memo obtain-pikachu
112 ([] (obtain-pikachu (go-to-lab)))
113 ([script]
114 (->> script
115 (scroll-text)
116 (play-moves
117 (concat
118 (repeat 51 [])
119 [[:a] []]))
120 (walk [↓ ↓ → → ↑])
121 (play-moves [[:a]]))))