changed TICK_DURATION from a constant to a parameter that we pass into robot

This commit is contained in:
Richard Harrington
2013-08-11 22:37:20 -04:00
parent af7618c7f9
commit 32eac97e0c
2 changed files with 9 additions and 4 deletions
+2 -3
View File
@@ -2,9 +2,8 @@
(:require [robotwar.brain :as brain]
[robotwar.register :as register]))
; TICK_DURATION is in seconds. MAX_ACCEL is in decimeters per second per second.
; MAX_ACCEL is in decimeters per second per second.
; TODO: should be passed in from some higher level module, or a config module.
(def TICK_DURATION 1)
(def MAX_ACCEL 40)
; yay classical mechanics
@@ -73,7 +72,7 @@
TODO: add support for collision with walls first (right now it just
stops when it gets there, and doesn't get damaged or bounce),
then support for collision with other robots."
[{robot-idx :idx :as robot} world]
[{robot-idx :idx :as robot} world tick-duration]
(if (>= (:damage robot) 100)
world
(let [new-world (brain/step-brain
+7 -1
View File
@@ -2,6 +2,12 @@
(:use [clojure.string :only [join]])
(:require [robotwar.robot :as robot]))
(def TICK_DURATION 1)
; TODO: pass in tick-duration to world from somewhere else.
;
(defn init-world
"initialize all the variables for a robot world."
[width height programs]
@@ -26,7 +32,7 @@
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)
(assoc (robot/step-robot (robots robot-idx) world TICK_DURATION)
:robot-idx
(mod (inc robot-idx) (count robots))))