changeset 255:d9e0752da684

unicode walking :)
author Robert McIntyre <rlm@mit.edu>
date Mon, 26 Mar 2012 06:00:30 -0500
parents 5dafe6188ca5
children c7b002525041
files clojure/com/aurellem/run/bootstrap_0.clj clojure/com/aurellem/run/save_corruption.clj
diffstat 2 files changed, 85 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/run/bootstrap_0.clj	Mon Mar 26 04:17:10 2012 -0500
     1.2 +++ b/clojure/com/aurellem/run/bootstrap_0.clj	Mon Mar 26 06:00:30 2012 -0500
     1.3 @@ -5,7 +5,70 @@
     1.4  
     1.5  
     1.6  (defn-memo boot-root []
     1.7 -  [(root) []])
     1.8 +  [ [] (root)])
     1.9    
    1.10 +(defn-memo to-rival-name
    1.11 +  ([] (to-rival-name (boot-root)))
    1.12 +  ([script]
    1.13 +     (-> script
    1.14 +         title
    1.15 +         oak
    1.16 +         name-entry-rlm
    1.17 +         scroll-text
    1.18 +         scroll-text
    1.19 +         scroll-text
    1.20 +         scroll-text
    1.21 +         scroll-text
    1.22 +         )))
    1.23  
    1.24 +(defn-memo name-rival-bootstrap
    1.25 +  ([] (name-rival-bootstrap (to-rival-name)))
    1.26 +  ([script]
    1.27 +     (->> script
    1.28 +         (advance [] [:a])
    1.29 +         (advance [] [:r] DE)
    1.30 +         (play-moves
    1.31 +          [[]
    1.32 +           [:r] [] [:r] [] [:r] [] [:r] []
    1.33 +           [:r] [] [:r] [] [:r] [] [:d] []
    1.34 +           [:d] [:a]                         ;; space
    1.35 +           [:l] [] [:d] [:a]                 ;; [PK]
    1.36 +           [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
    1.37 +           [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
    1.38 +           [:u] [] [:u] [] [:u] [] [:l] [:a] ;; G
    1.39 +           [:d] [] [:d] [] [:d] [] [:r] [:a] ;; [PK]
    1.40  
    1.41 +           [:d] [] [:r] [:a]                 ;; finish
    1.42 +           ]))))
    1.43 +
    1.44 +(defn walk
    1.45 +  "Move the character along the given directions."
    1.46 +  [directions script]
    1.47 +  (reduce (fn [script direction]
    1.48 +            (move direction script))
    1.49 +          script directions))
    1.50 +
    1.51 +(def ↑ [:u])
    1.52 +(def ↓ [:d])
    1.53 +(def ← [:l])
    1.54 +(def → [:r])
    1.55 +
    1.56 +(defn-memo leave-house
    1.57 +  ([] (leave-house (name-rival-bootstrap)))
    1.58 +  ([script]
    1.59 +     (->> script
    1.60 +          finish-title
    1.61 +          start-walking
    1.62 +          walk-to-stairs
    1.63 +          walk-to-door
    1.64 +          (walk [↓ ↓]))))
    1.65 +
    1.66 +(defn-memo to-pallet-town-edge
    1.67 +  ([] (to-pallet-town-edge (leave-house)))
    1.68 +  ([script]
    1.69 +     (->> script
    1.70 +          start-walking
    1.71 +          (walk [→ → → → →
    1.72 +                 ↑ ↑ ↑ ↑ ↑ ↑]))))
    1.73 +     
    1.74 +
     2.1 --- a/clojure/com/aurellem/run/save_corruption.clj	Mon Mar 26 04:17:10 2012 -0500
     2.2 +++ b/clojure/com/aurellem/run/save_corruption.clj	Mon Mar 26 06:00:30 2012 -0500
     2.3 @@ -10,35 +10,37 @@
     2.4            (advance [:b] [:b :r])))
     2.5    ([] (start-walking (finish-title))))
     2.6  
     2.7 -(def walk (partial advance []))
     2.8 +
     2.9 +(def move
    2.10 +  (partial advance []))
    2.11  
    2.12  (defn-memo walk-to-stairs
    2.13    ([] (walk-to-stairs (start-walking)))
    2.14    ([script]
    2.15       (->> script
    2.16 -          (walk [:u])
    2.17 -          (walk [:u])
    2.18 -          (walk [:u])
    2.19 -          (walk [:u])
    2.20 -          (walk [:u])
    2.21 -          (walk [:r])
    2.22 -          (walk [:r])
    2.23 -          (walk [:r]))))
    2.24 +          (move [:u])
    2.25 +          (move [:u])
    2.26 +          (move [:u])
    2.27 +          (move [:u])
    2.28 +          (move [:u])
    2.29 +          (move [:r])
    2.30 +          (move [:r])
    2.31 +          (move [:r]))))
    2.32  
    2.33  (defn-memo walk-to-door
    2.34    ([] (walk-to-door (walk-to-stairs)))
    2.35    ([script]
    2.36       (->> script
    2.37 -          (walk [:d])
    2.38 -          (walk [:d])
    2.39 -          (walk [:d])
    2.40 -          (walk [:d])
    2.41 -          (walk [:d])
    2.42 -          (walk [:d])
    2.43 -          (walk [:l])
    2.44 -          (walk [:l])
    2.45 -          (walk [:l])
    2.46 -          (walk [:l]))))
    2.47 +          (move [:d])
    2.48 +          (move [:d])
    2.49 +          (move [:d])
    2.50 +          (move [:d])
    2.51 +          (move [:d])
    2.52 +          (move [:d])
    2.53 +          (move [:l])
    2.54 +          (move [:l])
    2.55 +          (move [:l])
    2.56 +          (move [:l]))))
    2.57  
    2.58  (defn-memo activate-menu
    2.59    ([] (activate-menu (walk-to-door)))