diff clojure/com/aurellem/run/bootstrap_0.clj @ 337:2dd40f6b6a1f

restore memoization.
author Robert McIntyre <rlm@mit.edu>
date Sat, 07 Apr 2012 07:43:17 -0500
parents 25b7bb7da3b1
children 92f0011925d2
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj	Sat Apr 07 07:31:59 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj	Sat Apr 07 07:43:17 2012 -0500
     1.3 @@ -432,31 +432,13 @@
     1.4         (play-moves [[:a] []])))
     1.5  
     1.6  (defn restart
     1.7 -  "Two button presses after a restart event are lost when converting to
     1.8 -   VBM format.  To compensate, step the state forward two steps."
     1.9 -  [[moves state :as script]]
    1.10 -  (->> [(concat moves [[:restart]])
    1.11 -        (run-moves state [[:restart]
    1.12 -
    1.13 -
    1.14 -                          ;;[] []
    1.15 -
    1.16 -                          ])]
    1.17 -       (do-nothing 2)))
    1.18 -
    1.19 -(defn restart
    1.20    "The two button presses after a restart event are converted to
    1.21     blanks. Due to weirdness with the VBM format. To compensate, ensure
    1.22     that the two button presses after restart are both blanks."
    1.23    [script]
    1.24    (play-moves [[:restart] [] []] script))
    1.25 -
    1.26 -(defn restart-wrong
    1.27 -  [[moves state :as script]]
    1.28 -  [(concat moves [[:restart] [] []])
    1.29 -   (run-moves state [[:restart]])])
    1.30      
    1.31 -(defn do-save-corruption
    1.32 +(defn-memo do-save-corruption
    1.33    ([] (do-save-corruption
    1.34         (walk-to-counter)))
    1.35    ([script]
    1.36 @@ -503,7 +485,7 @@
    1.37         select-menu-entry
    1.38         scroll-text))
    1.39  
    1.40 -(defn corrupt-item-list
    1.41 +(defn-memo corrupt-item-list
    1.42    "Corrupt the num-of-items variable by switching a corrupted pokemon
    1.43     into out-of-bounds memory."
    1.44    ([] (corrupt-item-list
    1.45 @@ -525,7 +507,7 @@
    1.46            close-menu
    1.47            close-menu)))
    1.48  
    1.49 -(defn get-lots-of-money
    1.50 +(defn-memo get-lots-of-money
    1.51    "Sell 0xFE cancel buttons to make a tremendous amount of money."
    1.52    ([] (get-lots-of-money (corrupt-item-list)))
    1.53    ([script]
    1.54 @@ -544,7 +526,7 @@
    1.55  (defn note [str script]
    1.56    (println str) script)
    1.57  
    1.58 -(defn buy-bootstrapping-items
    1.59 +(defn-memo buy-bootstrapping-items
    1.60    "Buy items that will become part of the bootstrapping
    1.61     program."
    1.62    ([] (buy-bootstrapping-items (get-lots-of-money)))
    1.63 @@ -574,7 +556,7 @@
    1.64            (play-moves [[:b]])
    1.65            end-text)))
    1.66  
    1.67 -(defn corrupt-item-list-again
    1.68 +(defn-memo corrupt-item-list-again
    1.69    ([] (corrupt-item-list-again (buy-bootstrapping-items)))
    1.70    ([script]
    1.71       (->> script
    1.72 @@ -596,7 +578,7 @@
    1.73            close-menu
    1.74            close-menu)))
    1.75  
    1.76 -(defn leave-viridian-store
    1.77 +(defn-memo leave-viridian-store
    1.78    ([] (leave-viridian-store (corrupt-item-list-again)))
    1.79    ([script]
    1.80       (->> script
    1.81 @@ -609,7 +591,7 @@
    1.82     #(search-string % "Wild")
    1.83     (partial move direction) script))
    1.84                                  
    1.85 -(defn fight-wild-pokemon
    1.86 +(defn-memo fight-wild-pokemon
    1.87    ([] (fight-wild-pokemon (leave-viridian-store)))
    1.88    ([script]
    1.89       (->> script
    1.90 @@ -618,7 +600,7 @@
    1.91                   ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓])
    1.92            (force-encounter →))))
    1.93  
    1.94 -(defn run-from-pokemon
    1.95 +(defn-memo run-from-pokemon
    1.96    ([] (run-from-pokemon (fight-wild-pokemon)))
    1.97    ([script]
    1.98       (->> script
    1.99 @@ -630,9 +612,7 @@
   1.100            (scroll-text)
   1.101            (scroll-text))))
   1.102  
   1.103 -29952
   1.104 -
   1.105 -(defn to-poke-center-computer
   1.106 +(defn-memo to-poke-center-computer
   1.107    ([] (to-poke-center-computer
   1.108         (run-from-pokemon)))
   1.109    ([script]