mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
wrote SPEEDY acceleration tests to match the SPEEDX ones
This commit is contained in:
parent
1c079c1fe9
commit
96362ee41f
|
@ -49,3 +49,41 @@
|
|||
{:pos-x 68.5, :v-x -14.0, :desired-v-x -14.0}
|
||||
{:pos-x 54.5, :v-x -14.0, :desired-v-x -14.0}])))))
|
||||
|
||||
(deftest positive-acceleration-y-test
|
||||
(testing "application of SPEEDY register in
|
||||
positive direction has expected behavior"
|
||||
(let [zeroed-world (assoc-in world [:robots 0 :pos-y] 0.0)
|
||||
zeroed-registers (get-in world [:robots 0 :brain :registers])
|
||||
speedy-world (register/write-register (zeroed-registers "SPEEDY") zeroed-world 140)
|
||||
speedy-worlds (world/iterate-worlds speedy-world 1.0)]
|
||||
(is (= (take 6 (map (fn [world]
|
||||
{:pos-y (get-in world [:robots 0 :pos-y])
|
||||
:v-y (get-in world [:robots 0 :v-y])
|
||||
:desired-v-y (get-in world [:robots 0 :desired-v-y])})
|
||||
speedy-worlds))
|
||||
[{:pos-y 0.0, :v-y 0.0, :desired-v-y 14.0}
|
||||
{:pos-y 2.0, :v-y 4.0, :desired-v-y 14.0}
|
||||
{:pos-y 8.0, :v-y 8.0, :desired-v-y 14.0}
|
||||
{:pos-y 18.0, :v-y 12.0, :desired-v-y 14.0}
|
||||
{:pos-y 31.5, :v-y 14.0, :desired-v-y 14.0}
|
||||
{:pos-y 45.5, :v-y 14.0, :desired-v-y 14.0}])))))
|
||||
|
||||
(deftest negative-acceleration-y-test
|
||||
(testing "application of SPEEDY register in
|
||||
negative direction has expected behavior"
|
||||
(let [zeroed-world (assoc-in world [:robots 0 :pos-y] 100.0)
|
||||
zeroed-registers (get-in world [:robots 0 :brain :registers])
|
||||
speedy-world (register/write-register (zeroed-registers "SPEEDY") zeroed-world -140)
|
||||
speedy-worlds (world/iterate-worlds speedy-world 1.0)]
|
||||
(is (= (take 6 (map (fn [world]
|
||||
{:pos-y (get-in world [:robots 0 :pos-y])
|
||||
:v-y (get-in world [:robots 0 :v-y])
|
||||
:desired-v-y (get-in world [:robots 0 :desired-v-y])})
|
||||
speedy-worlds))
|
||||
[{:pos-y 100.0, :v-y 0.0, :desired-v-y -14.0}
|
||||
{:pos-y 98.0, :v-y -4.0, :desired-v-y -14.0}
|
||||
{:pos-y 92.0, :v-y -8.0, :desired-v-y -14.0}
|
||||
{:pos-y 82.0, :v-y -12.0, :desired-v-y -14.0}
|
||||
{:pos-y 68.5, :v-y -14.0, :desired-v-y -14.0}
|
||||
{:pos-y 54.5, :v-y -14.0, :desired-v-y -14.0}])))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user