changed tick-duration so it's a parameter passed into tick-world

This commit is contained in:
Richard Harrington 2013-08-12 00:13:13 -04:00
parent 9fc3a06e7e
commit a56d210fe4
4 changed files with 6 additions and 15 deletions

View File

@ -8,7 +8,7 @@
(def world
(world/init-world 256.0 256.0 [test-programs/multi-use-program]))
(def worlds (world/iterate-worlds world))
(def worlds (world/iterate-worlds world 1.0))
(def robots (:robots world))
(def robot (robots 0))

View File

@ -2,12 +2,6 @@
(:use [clojure.string :only [join]])
(:require [robotwar.robot :as robot]))
(def TICK_DURATION 1.0)
; TODO: pass in tick-duration to world from somewhere else.
;
(defn init-world
"initialize all the variables for a robot world."
[width height programs]
@ -31,15 +25,15 @@
(where each robot gets to go) rather than just a stream of worlds, one for
each robot. Because otherwise, do we step the shells after every
single robot has their turn?"
[{:keys [robots robot-idx] :as world}]
(assoc (robot/step-robot (robots robot-idx) world TICK_DURATION)
[{:keys [robots robot-idx] :as world} tick-duration]
(assoc (robot/step-robot (robots robot-idx) world tick-duration)
:robot-idx
(mod (inc robot-idx) (count robots))))
(defn iterate-worlds
"convenience function for creating a sequence of worlds"
[world]
(iterate tick-world world))
[world tick-duration]
(iterate #(tick-world % tick-duration) world))
(defn get-world
"convenience function for identifying a world in a sequence of worlds

View File

@ -9,7 +9,7 @@
(def initial-world
(world/init-world 256.0 256.0 [test-programs/multi-use-program]))
(def worlds (iterate world/tick-world initial-world))
(def worlds (world/iterate-worlds initial-world 1.0))
(deftest branching-test
(testing "comparison statement should cause jump in instr-ptr"

View File

@ -37,6 +37,3 @@
robotwar.core=>
TODO: Change the function so that the TICK_DURATION comes from the world, not from
a constant in the file. This way, we can easily set it to 1 for tests, and adjust it
appropriately for actual game play.