diff 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
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/bootstrap_1.clj	Sun Apr 08 21:21:39 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/bootstrap_1.clj	Mon Apr 09 05:36:56 2012 -0500
     1.3 @@ -200,46 +200,60 @@
     1.4            (set-cursor 1)
     1.5            select-menu-entry)))
     1.6  
     1.7 +(defn wait-for-quantity
     1.8 +  [[moves state :as script]]
     1.9 +  (if (not= (item-quantity-selected state) 1)
    1.10 +    (repeat-until-different [] item-quantity-selected script)
    1.11 +    script))
    1.12 +
    1.13 +(defn wait-for-cursor
    1.14 +  [[moves state :as script]]
    1.15 +  (if (not= (list-offset state) 0)
    1.16 +    (repeat-until-different [] list-offset script)
    1.17 +    script))
    1.18 +
    1.19  (defn deposit-held-item [n quantity [moves state :as script]]
    1.20    (let [total-quantity (second (nth-item state n))]
    1.21      (println "total-quantity" total-quantity)
    1.22      (->> script
    1.23           (set-cursor n)
    1.24           (select-menu-entry 1)
    1.25 -         ((fn [[moves state :as script]]
    1.26 -            (if (not= (item-quantity-selected state) 1)
    1.27 -              (repeat-until-different [] item-quantity-selected script)
    1.28 -              script)))
    1.29 +         (wait-for-quantity)
    1.30           (set-quantity total-quantity quantity)
    1.31           (delayed-difference [] [:a] 100 #(search-string % "stored"))
    1.32           (scroll-text))))
    1.33  
    1.34 +(defn sell-held-item [n quantity [moves state :as script]]
    1.35 +  (let [total-quantity (second (nth-item state n))]
    1.36 +    (->> script
    1.37 +         (wait-for-cursor)  ;; when selling, the cursor always
    1.38 +         (set-cursor n)     ;; returns to the top of the list.
    1.39 +         (select-menu-entry 1)
    1.40 +         (wait-for-quantity)
    1.41 +         (set-quantity total-quantity quantity)
    1.42 +         (delayed-difference [] [:a] 100 current-depth)
    1.43 +         (play-moves (repeat 20 [:b]))
    1.44 +         (delayed-difference [] [:a] 100 #(search-string % "What"))
    1.45 +         )))
    1.46 +
    1.47  (defn widthdraw-pc-item [n quantity [moves state :as script]]
    1.48    (let [total-quantity (second (nth-pc-item state n))]
    1.49      (->> script
    1.50           (set-cursor n)
    1.51           (select-menu-entry 1)
    1.52 -         ((fn [[moves state :as script]]
    1.53 -            (if (not= (item-quantity-selected state) 1)
    1.54 -              (repeat-until-different [] item-quantity-selected
    1.55 -                                      script)
    1.56 -              script)))
    1.57 +         (wait-for-quantity)
    1.58           (set-quantity total-quantity quantity)
    1.59           (delayed-difference [] [:a] 100 #(search-string % "Withdrew"))
    1.60           (scroll-text))))
    1.61  
    1.62  (defn toss-held-item [n quantity [moves state :as script]]
    1.63 -   (let [total-quantity (second (nth-item state n))]
    1.64 +  (let [total-quantity (second (nth-item state n))]
    1.65      (->> script
    1.66           (set-cursor n)
    1.67           (select-menu-entry 1)
    1.68           (set-cursor-relative 1)
    1.69           (select-menu-entry -1)
    1.70 -         ((fn [[moves state :as script]]
    1.71 -            (if (not= (item-quantity-selected state) 1)
    1.72 -              (repeat-until-different [] item-quantity-selected
    1.73 -                                      script)
    1.74 -              script)))
    1.75 +         (wait-for-quantity)
    1.76           (set-quantity total-quantity quantity)
    1.77           (play-moves [[:a]])
    1.78           (scroll-text)
    1.79 @@ -256,13 +270,12 @@
    1.80    ([] (initial-deposits (begin-initial-deposits)))
    1.81    ([script]
    1.82       (->> script
    1.83 -          (deposit-held-item 0 0xFE)
    1.84 -          (deposit-held-item 1 0xFE)
    1.85 +          (deposit-held-item 1 0x2)
    1.86            ((fn [script]
    1.87               (reduce 
    1.88                (fn [script item] (deposit-held-item item 0xFF script))
    1.89                script
    1.90 -              (range 2 (+ 12 2)))))
    1.91 +              (range 3 (+ 12 3)))))
    1.92            close-all-menus)))
    1.93  
    1.94  
    1.95 @@ -290,18 +303,21 @@
    1.96            (scroll-text)
    1.97            (select-menu-entry)
    1.98            (widthdraw-pc-item 0 1)
    1.99 -          (widthdraw-pc-item 3 99)
   1.100 -          (widthdraw-pc-item 3 99)
   1.101 -          (widthdraw-pc-item 3 57)
   1.102 -          (widthdraw-pc-item 2 99)
   1.103 -          (widthdraw-pc-item 2 99)
   1.104 -          (widthdraw-pc-item 2 56)
   1.105 -          (widthdraw-pc-item 1 99)
   1.106 -          (widthdraw-pc-item 1 99)
   1.107 -          (widthdraw-pc-item 1 56)
   1.108            (widthdraw-pc-item 0 99)
   1.109 -          (widthdraw-pc-item 0 99)
   1.110 -          (widthdraw-pc-item 0 57)
   1.111 +          (widthdraw-pc-item 1 1)
   1.112 +          (widthdraw-pc-item 2 5)
   1.113 +          ;; (widthdraw-pc-item 3 99)
   1.114 +          ;; (widthdraw-pc-item 3 99)
   1.115 +          ;; (widthdraw-pc-item 3 57)  ;; take all
   1.116 +          ;; (widthdraw-pc-item 2 99)
   1.117 +          ;; (widthdraw-pc-item 2 99)
   1.118 +          ;; (widthdraw-pc-item 2 56)  ;; take all
   1.119 +          ;; (widthdraw-pc-item 1 99)
   1.120 +          ;; (widthdraw-pc-item 1 99)
   1.121 +          ;; (widthdraw-pc-item 1 55)  ;; leave one
   1.122 +          ;; (widthdraw-pc-item 0 99)
   1.123 +          ;; (widthdraw-pc-item 0 99)
   1.124 +          ;; (widthdraw-pc-item 0 57)  ;; leave one
   1.125            (close-all-menus))))
   1.126  
   1.127  (defn-memo to-celadon
   1.128 @@ -358,7 +374,7 @@
   1.129  ;; Lemonade :)        TM49 (tri-attack)
   1.130  
   1.131  
   1.132 -(defn go-to-floor-two
   1.133 +(defn-memo go-to-floor-two
   1.134    ([] (go-to-floor-two (to-celadon)))
   1.135    ([script]
   1.136       (->> script
   1.137 @@ -369,8 +385,34 @@
   1.138                   ← ←])
   1.139            (first-difference [] ↑ AF))))
   1.140  
   1.141 +(defn talk
   1.142 +  "Assumes that you are facing a person and engages in conversation"
   1.143 +  [[moves state :as script]]
   1.144 +  (delayed-difference [] [:a] 100
   1.145 +                      #(aget (memory %) text-address)
   1.146 +                      script))
   1.147 +  
   1.148 +
   1.149  (defn get-money-floor-two
   1.150 -  [])
   1.151 +  ([] (get-money-floor-two (go-to-floor-two)))
   1.152 +  ([script]
   1.153 +     (->> script
   1.154 +          talk
   1.155 +          (set-cursor 1)
   1.156 +          (select-menu-entry)
   1.157 +          (sell-held-item 2 1)
   1.158 +          (sell-held-item 2 1)
   1.159 +          
   1.160 +          ;; (sell-held-item 11)
   1.161 +          ;; (sell-held-item 10)
   1.162 +          ;; (sell-held-item 9)
   1.163 +          ;; (sell-held-item 8)
   1.164 +          ;; (sell-held-item 7)
   1.165 +          ;; (sell-held-item 6)
   1.166 +          (do-nothing 40))))
   1.167 +          
   1.168 +          
   1.169 +     
   1.170  
   1.171  (defn floor-two-TMs
   1.172    [])