Skip to content

Commit

Permalink
Issue #158 is solved.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghaffari1992 committed Oct 26, 2022
1 parent 0f0874d commit b08ea65
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/test/scala/symsim/examples/concrete/breaking/CarSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,42 @@ class CarSpec

"A stopped car cannot move, however much you break" in check {
forAll (positions, actions) { (p, a) =>
val (s1, r) = Car.step (CarState (v = 0.0, p = p)) (a).head
s1.p == p
for (s1, r) <- Car.step (CarState (v = 0.0, p = p)) (a)
yield s1.p == p
}
}

"The car cannot move backwards by breaking" in check {
forAll (velocities, positions, actions) { (v, p, a) =>
for (s1, r) <- Car.step (CarState (v, p = p)) (a)
for (s1, r) <- Car.step (CarState (v, p = p)) (a)
yield (v != 0 ==> s1.p >= p)
}
}

"Position never becomes negative" in check {
forAll (velocities, positions, actions) { (v, p, a) =>
val (s1, r) = Car.step (CarState (v = v, p = p)) (a).head
s1.p >= 0.0
for (s1, r) <- Car.step (CarState (v = v, p = p)) (a)
yield s1.p >= 0.0
}
}


"Reward is valid 1" in check {
forAll (positions, positions, velocities, actions) { (p1, p2, v, a) =>
val r1 = Car.step (CarState (v = v, p = p1)) (a).head._2
val r2 = Car.step (CarState (v = v, p = p2)) (a).head._2
p1 <= p2 ==> r1 >= r2
for
(_, r1) <- Car.step (CarState (v = v, p = p1)) (a)
(_, r2) <- Car.step (CarState (v = v, p = p2)) (a)
yield p1 <= p2 ==> r1 >= r2
}
}


"Reward is valid 2" in check {
forAll (velocities, velocities, positions, actions) { (v1, v2, p, a) =>
val r1 = Car.step (CarState (v1, p)) (a).head._2
val r2 = Car.step (CarState (v2, p)) (a).head._2
v1 <= v2 ==> r1 >= r2
for
(_, r1) <- Car.step (CarState (v1, p)) (a)
(_, r2) <- Car.step (CarState (v2, p)) (a)
yield v1 <= v2 ==> r1 >= r2
}
}

Expand Down

0 comments on commit b08ea65

Please sign in to comment.