mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
changed tick-duration so it's a parameter passed into tick-world
This commit is contained in:
parent
9fc3a06e7e
commit
a56d210fe4
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue
Block a user