comparison clojure/com/aurellem/run/bootstrap_1.clj @ 353:a9e7507379e9

adjusting run to use 0x00 items for money since they are worth a half million each.
author Robert McIntyre <rlm@mit.edu>
date Mon, 09 Apr 2012 05:36:56 -0500
parents 82e3ba144773
children 4141489d1406
comparison
equal deleted inserted replaced
352:82e3ba144773 353:a9e7507379e9
198 (first-difference [] [:a] AF) 198 (first-difference [] [:a] AF)
199 (scroll-text) 199 (scroll-text)
200 (set-cursor 1) 200 (set-cursor 1)
201 select-menu-entry))) 201 select-menu-entry)))
202 202
203 (defn wait-for-quantity
204 [[moves state :as script]]
205 (if (not= (item-quantity-selected state) 1)
206 (repeat-until-different [] item-quantity-selected script)
207 script))
208
209 (defn wait-for-cursor
210 [[moves state :as script]]
211 (if (not= (list-offset state) 0)
212 (repeat-until-different [] list-offset script)
213 script))
214
203 (defn deposit-held-item [n quantity [moves state :as script]] 215 (defn deposit-held-item [n quantity [moves state :as script]]
204 (let [total-quantity (second (nth-item state n))] 216 (let [total-quantity (second (nth-item state n))]
205 (println "total-quantity" total-quantity) 217 (println "total-quantity" total-quantity)
206 (->> script 218 (->> script
207 (set-cursor n) 219 (set-cursor n)
208 (select-menu-entry 1) 220 (select-menu-entry 1)
209 ((fn [[moves state :as script]] 221 (wait-for-quantity)
210 (if (not= (item-quantity-selected state) 1)
211 (repeat-until-different [] item-quantity-selected script)
212 script)))
213 (set-quantity total-quantity quantity) 222 (set-quantity total-quantity quantity)
214 (delayed-difference [] [:a] 100 #(search-string % "stored")) 223 (delayed-difference [] [:a] 100 #(search-string % "stored"))
215 (scroll-text)))) 224 (scroll-text))))
225
226 (defn sell-held-item [n quantity [moves state :as script]]
227 (let [total-quantity (second (nth-item state n))]
228 (->> script
229 (wait-for-cursor) ;; when selling, the cursor always
230 (set-cursor n) ;; returns to the top of the list.
231 (select-menu-entry 1)
232 (wait-for-quantity)
233 (set-quantity total-quantity quantity)
234 (delayed-difference [] [:a] 100 current-depth)
235 (play-moves (repeat 20 [:b]))
236 (delayed-difference [] [:a] 100 #(search-string % "What"))
237 )))
216 238
217 (defn widthdraw-pc-item [n quantity [moves state :as script]] 239 (defn widthdraw-pc-item [n quantity [moves state :as script]]
218 (let [total-quantity (second (nth-pc-item state n))] 240 (let [total-quantity (second (nth-pc-item state n))]
219 (->> script 241 (->> script
220 (set-cursor n) 242 (set-cursor n)
221 (select-menu-entry 1) 243 (select-menu-entry 1)
222 ((fn [[moves state :as script]] 244 (wait-for-quantity)
223 (if (not= (item-quantity-selected state) 1)
224 (repeat-until-different [] item-quantity-selected
225 script)
226 script)))
227 (set-quantity total-quantity quantity) 245 (set-quantity total-quantity quantity)
228 (delayed-difference [] [:a] 100 #(search-string % "Withdrew")) 246 (delayed-difference [] [:a] 100 #(search-string % "Withdrew"))
229 (scroll-text)))) 247 (scroll-text))))
230 248
231 (defn toss-held-item [n quantity [moves state :as script]] 249 (defn toss-held-item [n quantity [moves state :as script]]
232 (let [total-quantity (second (nth-item state n))] 250 (let [total-quantity (second (nth-item state n))]
233 (->> script 251 (->> script
234 (set-cursor n) 252 (set-cursor n)
235 (select-menu-entry 1) 253 (select-menu-entry 1)
236 (set-cursor-relative 1) 254 (set-cursor-relative 1)
237 (select-menu-entry -1) 255 (select-menu-entry -1)
238 ((fn [[moves state :as script]] 256 (wait-for-quantity)
239 (if (not= (item-quantity-selected state) 1)
240 (repeat-until-different [] item-quantity-selected
241 script)
242 script)))
243 (set-quantity total-quantity quantity) 257 (set-quantity total-quantity quantity)
244 (play-moves [[:a]]) 258 (play-moves [[:a]])
245 (scroll-text) 259 (scroll-text)
246 (delayed-difference [] [:a] 100 #(search-string % "Threw")) 260 (delayed-difference [] [:a] 100 #(search-string % "Threw"))
247 (scroll-text) 261 (scroll-text)
254 268
255 (defn-memo initial-deposits 269 (defn-memo initial-deposits
256 ([] (initial-deposits (begin-initial-deposits))) 270 ([] (initial-deposits (begin-initial-deposits)))
257 ([script] 271 ([script]
258 (->> script 272 (->> script
259 (deposit-held-item 0 0xFE) 273 (deposit-held-item 1 0x2)
260 (deposit-held-item 1 0xFE)
261 ((fn [script] 274 ((fn [script]
262 (reduce 275 (reduce
263 (fn [script item] (deposit-held-item item 0xFF script)) 276 (fn [script item] (deposit-held-item item 0xFF script))
264 script 277 script
265 (range 2 (+ 12 2))))) 278 (range 3 (+ 12 3)))))
266 close-all-menus))) 279 close-all-menus)))
267 280
268 281
269 (defn-memo prepare-celadon-warp 282 (defn-memo prepare-celadon-warp
270 ([] (prepare-celadon-warp (initial-deposits))) 283 ([] (prepare-celadon-warp (initial-deposits)))
288 (->> script 301 (->> script
289 (first-difference [] [:a] AF) 302 (first-difference [] [:a] AF)
290 (scroll-text) 303 (scroll-text)
291 (select-menu-entry) 304 (select-menu-entry)
292 (widthdraw-pc-item 0 1) 305 (widthdraw-pc-item 0 1)
293 (widthdraw-pc-item 3 99)
294 (widthdraw-pc-item 3 99)
295 (widthdraw-pc-item 3 57)
296 (widthdraw-pc-item 2 99)
297 (widthdraw-pc-item 2 99)
298 (widthdraw-pc-item 2 56)
299 (widthdraw-pc-item 1 99)
300 (widthdraw-pc-item 1 99)
301 (widthdraw-pc-item 1 56)
302 (widthdraw-pc-item 0 99) 306 (widthdraw-pc-item 0 99)
303 (widthdraw-pc-item 0 99) 307 (widthdraw-pc-item 1 1)
304 (widthdraw-pc-item 0 57) 308 (widthdraw-pc-item 2 5)
309 ;; (widthdraw-pc-item 3 99)
310 ;; (widthdraw-pc-item 3 99)
311 ;; (widthdraw-pc-item 3 57) ;; take all
312 ;; (widthdraw-pc-item 2 99)
313 ;; (widthdraw-pc-item 2 99)
314 ;; (widthdraw-pc-item 2 56) ;; take all
315 ;; (widthdraw-pc-item 1 99)
316 ;; (widthdraw-pc-item 1 99)
317 ;; (widthdraw-pc-item 1 55) ;; leave one
318 ;; (widthdraw-pc-item 0 99)
319 ;; (widthdraw-pc-item 0 99)
320 ;; (widthdraw-pc-item 0 57) ;; leave one
305 (close-all-menus)))) 321 (close-all-menus))))
306 322
307 (defn-memo to-celadon 323 (defn-memo to-celadon
308 ([] (to-celadon (restore-items))) 324 ([] (to-celadon (restore-items)))
309 ([script] 325 ([script]
356 ;; Fresh Water TM13 (ice-beam) 372 ;; Fresh Water TM13 (ice-beam)
357 ;; Soda Pop TM48 (rock-slide) 373 ;; Soda Pop TM48 (rock-slide)
358 ;; Lemonade :) TM49 (tri-attack) 374 ;; Lemonade :) TM49 (tri-attack)
359 375
360 376
361 (defn go-to-floor-two 377 (defn-memo go-to-floor-two
362 ([] (go-to-floor-two (to-celadon))) 378 ([] (go-to-floor-two (to-celadon)))
363 ([script] 379 ([script]
364 (->> script 380 (->> script
365 (walk [↑ → → → → → → → → → → → 381 (walk [↑ → → → → → → → → → → →
366 ↑ ↑ ↑ ↑ ↑ ↑ 382 ↑ ↑ ↑ ↑ ↑ ↑
367 ← ← ← ← 383 ← ← ← ←
368 ↓ ↓ ↓ 384 ↓ ↓ ↓
369 ← ←]) 385 ← ←])
370 (first-difference [] ↑ AF)))) 386 (first-difference [] ↑ AF))))
371 387
388 (defn talk
389 "Assumes that you are facing a person and engages in conversation"
390 [[moves state :as script]]
391 (delayed-difference [] [:a] 100
392 #(aget (memory %) text-address)
393 script))
394
395
372 (defn get-money-floor-two 396 (defn get-money-floor-two
373 []) 397 ([] (get-money-floor-two (go-to-floor-two)))
398 ([script]
399 (->> script
400 talk
401 (set-cursor 1)
402 (select-menu-entry)
403 (sell-held-item 2 1)
404 (sell-held-item 2 1)
405
406 ;; (sell-held-item 11)
407 ;; (sell-held-item 10)
408 ;; (sell-held-item 9)
409 ;; (sell-held-item 8)
410 ;; (sell-held-item 7)
411 ;; (sell-held-item 6)
412 (do-nothing 40))))
413
414
415
374 416
375 (defn floor-two-TMs 417 (defn floor-two-TMs
376 []) 418 [])
377 419
378 (defn floor-two-items 420 (defn floor-two-items