mirror of
https://github.com/richardharrington/robotwar.git
synced 2026-04-19 16:16:36 +00:00
changed TICK_DURATION from a constant to a parameter that we pass into robot
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user