diff clojure/com/aurellem/gb_funs.clj @ 85:3f4fdd270059

more progress with the title
author Robert McIntyre <rlm@mit.edu>
date Sat, 10 Mar 2012 00:32:11 -0600
parents 26f002f2868c
children 9864032ef3c8
line wrap: on
line diff
     1.1 --- a/clojure/com/aurellem/gb_funs.clj	Fri Mar 09 23:28:07 2012 -0600
     1.2 +++ b/clojure/com/aurellem/gb_funs.clj	Sat Mar 10 00:32:11 2012 -0600
     1.3 @@ -90,6 +90,7 @@
     1.4  
     1.5  
     1.6  (defn set-state! [^SaveState state]
     1.7 +  (assert (:data state) "Not a valid state!")
     1.8    (if (not @on?) (restart!))
     1.9    (if (not= @current-state state)
    1.10      (Gb/loadState (:data state)))
    1.11 @@ -113,10 +114,17 @@
    1.12  
    1.13  
    1.14  (defn play
    1.15 -  ([state n]
    1.16 +  ([^SaveState state n]
    1.17       (reduce (fn [s _] (step s)) state (range n)))
    1.18 -  ([state]
    1.19 -     (dorun (iterate step state))))
    1.20 +  ([n]
    1.21 +     (play @current-state n)))
    1.22 +
    1.23 +(defn play-moves
    1.24 +  ([state moves]
    1.25 +     
    1.26 +  ([moves]
    1.27 +     (dorun (map (fn [move] (step @current-state move)) moves))))
    1.28 +  
    1.29  ;;;;;;;;;;;
    1.30  
    1.31  
    1.32 @@ -153,6 +161,7 @@
    1.33  (defn BC [state]
    1.34    (nth (registers state) 3))
    1.35  
    1.36 -        
    1.37 +(defn DE [state]
    1.38 +  (nth (registers state) 4))
    1.39              
    1.40    
    1.41 \ No newline at end of file