comparison clojure/com/aurellem/run/bootstrap_1.clj @ 354:4141489d1406

script: bought TMs on second floor.
author Robert McIntyre <rlm@mit.edu>
date Mon, 09 Apr 2012 06:09:49 -0500
parents a9e7507379e9
children 639db56f2670
comparison
equal deleted inserted replaced
353:a9e7507379e9 354:4141489d1406
259 (scroll-text) 259 (scroll-text)
260 (delayed-difference [] [:a] 100 #(search-string % "Threw")) 260 (delayed-difference [] [:a] 100 #(search-string % "Threw"))
261 (scroll-text) 261 (scroll-text)
262 ))) 262 )))
263 263
264 (defn buy-item [n quantity [moves state :as script]]
265 (->> script
266 (set-cursor n)
267 (purchase-item quantity)))
268
264 269
265 (def desired-zero-quantities 270 (def desired-zero-quantities
266 (map second (filter (comp (partial = 0) first) 271 (map second (filter (comp (partial = 0) first)
267 (partition 2 (pc-item-writer-program))))) 272 (partition 2 (pc-item-writer-program)))))
268 273
269 (defn-memo initial-deposits 274 (defn-memo initial-deposits
270 ([] (initial-deposits (begin-initial-deposits))) 275 ([] (initial-deposits (begin-initial-deposits)))
271 ([script] 276 ([script]
272 (->> script 277 (->> script
273 (deposit-held-item 1 0x2) 278 (deposit-held-item 0 0x1)
274 ((fn [script] 279 ((fn [script]
275 (reduce 280 (reduce
276 (fn [script item] (deposit-held-item item 0xFF script)) 281 (fn [script item] (deposit-held-item item 0xFF script))
277 script 282 script
278 (range 3 (+ 12 3))))) 283 (range 3 (+ 12 3)))))
301 (->> script 306 (->> script
302 (first-difference [] [:a] AF) 307 (first-difference [] [:a] AF)
303 (scroll-text) 308 (scroll-text)
304 (select-menu-entry) 309 (select-menu-entry)
305 (widthdraw-pc-item 0 1) 310 (widthdraw-pc-item 0 1)
306 (widthdraw-pc-item 0 99) 311 ;;(widthdraw-pc-item 0 99)
307 (widthdraw-pc-item 1 1) 312 ;;(widthdraw-pc-item 1 1)
308 (widthdraw-pc-item 2 5) 313 (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
321 (close-all-menus)))) 314 (close-all-menus))))
322 315
323 (defn-memo to-celadon 316 (defn-memo to-celadon
324 ([] (to-celadon (restore-items))) 317 ([] (to-celadon (restore-items)))
325 ([script] 318 ([script]
391 (delayed-difference [] [:a] 100 384 (delayed-difference [] [:a] 100
392 #(aget (memory %) text-address) 385 #(aget (memory %) text-address)
393 script)) 386 script))
394 387
395 388
396 (defn get-money-floor-two 389 (defn-memo get-money-floor-two
397 ([] (get-money-floor-two (go-to-floor-two))) 390 ([] (get-money-floor-two (go-to-floor-two)))
398 ([script] 391 ([script]
399 (->> script 392 (->> script
400 talk 393 talk
401 (set-cursor 1) 394 (set-cursor 1)
402 (select-menu-entry) 395 (select-menu-entry)
403 (sell-held-item 2 1) 396 (sell-held-item 0 1)
404 (sell-held-item 2 1) 397 (sell-held-item 0 1)
405 398 (close-menu))))
406 ;; (sell-held-item 11) 399
407 ;; (sell-held-item 10) 400 (defn-memo floor-two-TMs
408 ;; (sell-held-item 9) 401 ([] (floor-two-TMs (get-money-floor-two)))
409 ;; (sell-held-item 8) 402 ([script]
410 ;; (sell-held-item 7) 403 (->> script
411 ;; (sell-held-item 6) 404 (wait-for-cursor)
412 (do-nothing 40)))) 405 (select-menu-entry)
413 406 (buy-item 2 98) ;; TM02 (razor-wind)
414 407 (buy-item 4 71) ;; TM37 (doubleteam)
415 408 (buy-item 5 63) ;; TM01 (mega-punch)
416 409 (buy-item 6 1) ;; TM05 (mega-kick)
417 (defn floor-two-TMs 410 (buy-item 7 56) ;; TM09 (take-down)
418 []) 411 (close-menu))))
412
413 (defn end-shop-conversation
414 [script]
415 (->> script
416 (wait-until scroll-text [:b])
417 (play-moves [[] [:b]])
418 close-menu))
419
420 (defn-memo floor-two-more-money
421 ([] (floor-two-more-money (floor-two-TMs)))
422 ([script]
423 (->> script
424 (wait-for-cursor)
425 (set-cursor 1)
426 (select-menu-entry)
427 (sell-held-item 0 1)
428 (sell-held-item 0 1)
429 close-menu
430 end-shop-conversation)))
431
432 (defn turn [direction script]
433 (->> script
434 (first-difference [] direction AF)))
419 435
420 (defn floor-two-items 436 (defn floor-two-items
421 []) 437 [])
438
422 439
423 (defn go-to-floor-three 440 (defn go-to-floor-three
424 []) 441 [])
425 442
426 (defn get-TM18 443 (defn get-TM18