mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
removed passing of tick-duration down into brain and robot
replaced with dynamic "constant" *GAME-SECONDS-PER-TICK*, so we can alter it during tests
This commit is contained in:
parent
b3814cb459
commit
cd1a9fabbd
|
@ -8,7 +8,7 @@
|
|||
|
||||
(def world
|
||||
(world/init-world 256.0 256.0 [(:multi-use test-programs/programs)]))
|
||||
(def worlds (world/iterate-worlds world 1.0))
|
||||
(def worlds (iterate world/tick-world world))
|
||||
|
||||
(def robots (:robots world))
|
||||
(def robot (robots 0))
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
; MAX_ACCEL is in decimeters per second per second.
|
||||
; TODO: should be passed in from some higher level module, or a config module.
|
||||
(def MAX_ACCEL 4.0)
|
||||
(def MAX-ACCEL 4.0)
|
||||
(def ^:dynamic *GAME-SECONDS-PER-TICK* 0.03)
|
||||
|
||||
; yay classical mechanics
|
||||
|
||||
|
@ -61,7 +62,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 tick-duration]
|
||||
[{robot-idx :idx :as robot} world]
|
||||
(if (<= (:damage robot) 0)
|
||||
world
|
||||
(let [new-world (brain/step-brain
|
||||
|
@ -71,12 +72,20 @@
|
|||
register/write-register)
|
||||
new-robot (get-in new-world [:robots robot-idx])
|
||||
{:keys [pos-x pos-y v-x v-y desired-v-x desired-v-y]} new-robot
|
||||
max-accel-x (if (pos? desired-v-x) MAX_ACCEL (- MAX_ACCEL))
|
||||
max-accel-y (if (pos? desired-v-y) MAX_ACCEL (- MAX_ACCEL))
|
||||
max-accel-x (if (pos? desired-v-x) MAX-ACCEL (- MAX-ACCEL))
|
||||
max-accel-y (if (pos? desired-v-y) MAX-ACCEL (- MAX-ACCEL))
|
||||
{new-pos-x :d new-v-x :v} (d-and-v-given-desired-v
|
||||
pos-x v-x desired-v-x max-accel-x tick-duration)
|
||||
pos-x
|
||||
v-x
|
||||
desired-v-x
|
||||
max-accel-x
|
||||
*GAME-SECONDS-PER-TICK*)
|
||||
{new-pos-y :d new-v-y :v} (d-and-v-given-desired-v
|
||||
pos-y v-y desired-v-y max-accel-y tick-duration)]
|
||||
pos-y
|
||||
v-y
|
||||
desired-v-y
|
||||
max-accel-y
|
||||
*GAME-SECONDS-PER-TICK*)]
|
||||
(assoc-in
|
||||
new-world
|
||||
[:robots robot-idx]
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
(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} tick-duration]
|
||||
(assoc (robot/step-robot (robots robot-idx) world tick-duration)
|
||||
[{:keys [robots robot-idx] :as world}]
|
||||
(assoc (robot/step-robot (robots robot-idx) world)
|
||||
:robot-idx
|
||||
(mod (inc robot-idx) (count robots))))
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
(def initial-world
|
||||
(world/init-world 256.0 256.0 [(:multi-use test-programs/programs)]))
|
||||
|
||||
(def worlds (world/iterate-worlds initial-world 1.0))
|
||||
(def worlds (iterate world/tick-world initial-world))
|
||||
|
||||
(deftest branching-test
|
||||
(testing "comparison statement should cause jump in instr-ptr"
|
||||
|
|
Loading…
Reference in New Issue
Block a user