Mercurial > vba-clojure
changeset 276:18336ab5d6ea
merge.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 27 Mar 2012 12:37:48 -0500 |
parents | 68f4e87c8f51 (diff) 69184558fcf3 (current diff) |
children | 710bfbb1e048 |
files | |
diffstat | 1 files changed, 146 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
1.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj Tue Mar 27 02:05:16 2012 -0500 1.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj Tue Mar 27 12:37:48 2012 -0500 1.3 @@ -18,8 +18,7 @@ 1.4 scroll-text 1.5 scroll-text 1.6 scroll-text 1.7 - scroll-text 1.8 - ))) 1.9 + scroll-text))) 1.10 1.11 (defn-memo name-rival-bootstrap 1.12 ([] (name-rival-bootstrap (to-rival-name))) 1.13 @@ -397,7 +396,6 @@ 1.14 (end-text) 1.15 (scroll-text 7) 1.16 (end-text) 1.17 - 1.18 (walk [← ← ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])))) 1.19 1.20 (defn-memo return-to-viridian-mart 1.21 @@ -406,4 +404,148 @@ 1.22 ([script] 1.23 (->> script 1.24 oaks-lab->pallet-town-edge 1.25 - (pallet-edge->viridian-mart false)))) 1.26 \ No newline at end of file 1.27 + (pallet-edge->viridian-mart false)))) 1.28 + 1.29 +(defn-memo walk-to-counter 1.30 + ([] (walk-to-counter 1.31 + (return-to-viridian-mart))) 1.32 + ([script] 1.33 + (->> script 1.34 + (walk [↑ ↑ ← ←])))) 1.35 + 1.36 +(defn buy-item 1.37 + "Assumes that the main item-screen is up, and buys 1.38 + quantity of the nth item in the list, assuming that you 1.39 + have enough money." 1.40 + [n quantity script] 1.41 + (if (= 0 quantity) 1.42 + script 1.43 + (let [after-initial-pause 1.44 + (do-nothing 20 script) 1.45 + move-to-item 1.46 + (reduce (fn [script _] 1.47 + (->> script 1.48 + (play-moves [[:d]]) 1.49 + (do-nothing 3))) 1.50 + after-initial-pause 1.51 + (range n)) 1.52 + select-item 1.53 + (play-moves [[:a]] move-to-item) 1.54 + request-items 1.55 + (reduce (fn [script _] 1.56 + (->> script 1.57 + (play-moves [[:u]]) 1.58 + (do-nothing 1))) 1.59 + select-item 1.60 + (range (dec quantity))) 1.61 + buy-items 1.62 + (->> request-items 1.63 + (do-nothing 3) 1.64 + (play-moves [[:a]]) 1.65 + (scroll-text) 1.66 + (scroll-text) 1.67 + (play-moves [[:a]]) 1.68 + (scroll-text))] 1.69 + buy-items))) 1.70 + 1.71 + 1.72 +(defn buy-items 1.73 + "Given a list of [item-no quantity], buys the quantity 1.74 + from the shop's list. Assumes that the item list is 1.75 + already up." 1.76 + [item-pairs script] 1.77 + (let [item-lookup (into {0 0 1 0 2 0 3 0 4 0} item-pairs) 1.78 + initial-purchase 1.79 + (->> script 1.80 + (buy-item 0 (item-lookup 0)) 1.81 + (buy-item 1 (item-lookup 1)) 1.82 + (buy-item 2 (item-lookup 2)))] 1.83 + (cond 1.84 + (and 1.85 + (not= 0 (item-lookup 3)) 1.86 + (not= 0 (item-lookup 4))) 1.87 + (->> initial-purchase 1.88 + (do-nothing 20) 1.89 + (play-moves [[:d]]) 1.90 + (do-nothing 3) 1.91 + (play-moves [[:d]]) 1.92 + (do-nothing 3) 1.93 + (play-moves [[:d]]) 1.94 + (do-nothing 10) 1.95 + (buy-item 0 (item-lookup 3)) 1.96 + (do-nothing 20) 1.97 + (play-moves [[:d]]) 1.98 + (do-nothing 3) 1.99 + (play-moves [[:d]]) 1.100 + (do-nothing 3) 1.101 + (play-moves [[:d]]) 1.102 + (do-nothing 10) 1.103 + (buy-item 0 (item-lookup 4))) 1.104 + (and (= 0 (item-lookup 3)) 1.105 + (not= 0 (item-lookup 4))) 1.106 + (->> initial-purchase 1.107 + (do-nothing 20) 1.108 + (play-moves [[:d]]) 1.109 + (do-nothing 3) 1.110 + (play-moves [[:d]]) 1.111 + (do-nothing 3) 1.112 + (play-moves [[:d]]) 1.113 + (do-nothing 10) 1.114 + (play-moves [[:d]]) 1.115 + (do-nothing 10) 1.116 + (buy-item 0 (item-lookup 4))) 1.117 + (and (not= 0 (item-lookup 3)) 1.118 + (= 0 (item-lookup 4))) 1.119 + (->> initial-purchase 1.120 + (do-nothing 20) 1.121 + (play-moves [[:d]]) 1.122 + (do-nothing 3) 1.123 + (play-moves [[:d]]) 1.124 + (do-nothing 3) 1.125 + (play-moves [[:d]]) 1.126 + (do-nothing 10) 1.127 + (buy-item 0 (item-lookup 3)))))) 1.128 + 1.129 + 1.130 +(defn test-buy-items 1.131 + ([] (test-buy-itemss 1.132 + (walk-to-counter))) 1.133 + ([script] 1.134 + (->> [(first script) (set-money (second script) 1.135 + 999999)] 1.136 + (play-moves 1.137 + [[] [:a] []]) 1.138 + (scroll-text) 1.139 + (do-nothing 100) 1.140 + (play-moves [[:a]]) 1.141 + (do-nothing 100) 1.142 + (buy-items 1.143 + [[0 1] 1.144 + [1 15] 1.145 + [2 1] 1.146 + [3 20] 1.147 + [4 95] 1.148 + ])))) 1.149 + 1.150 +(defn-memo buy-initial-items 1.151 + ([] (buy-initial-items 1.152 + (walk-to-counter))) 1.153 + ([script] 1.154 + (->> script 1.155 + (play-moves 1.156 + [[] [:a] []]) 1.157 + (scroll-text) 1.158 + (do-nothing 100) 1.159 + (play-moves [[:a]]) 1.160 + (do-nothing 100) 1.161 + (buy-items 1.162 + [[0 1] 1.163 + [1 1] 1.164 + [2 1] 1.165 + [3 1] 1.166 + [4 1] 1.167 + ])))) 1.168 + 1.169 + 1.170 + 1.171 + 1.172 \ No newline at end of file