• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #728

21 Oct 2025 09:16AM UTC coverage: 76.144% (-2.2%) from 78.302%
#728

Pull #113

github

sceredi
feat: add rewards management to rl controller
Pull Request #113: feat: create reinforcement learning controller

139 of 233 new or added lines in 22 files covered. (59.66%)

6 existing lines in 3 files now uncovered.

1497 of 1966 relevant lines covered (76.14%)

8.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/main/scala/io/github/srs/model/BaseSimulationState.scala
1
package io.github.srs.model
2

3
import scala.concurrent.duration.{ FiniteDuration, MILLISECONDS }
4

5
import io.github.srs.config.SimulationConfig
6
import io.github.srs.model.environment.ValidEnvironment
7
import io.github.srs.utils.random.{ RNG, SimpleRNG }
8

9
/**
10
 * Simulation state case class that holds the current state of the simulation.
11
 * @param simulationTime
12
 *   the current simulation time, if applicable.
13
 * @param elapsedTime
14
 *   the elapsed time since the start of the simulation.
15
 * @param dt
16
 *   the time step for each simulation update.
17
 * @param simulationSpeed
18
 *   the speed at which the simulation is running.
19
 * @param simulationRNG
20
 *   the random number generator used in the simulation.
21
 * @param simulationStatus
22
 *   the current status of the simulation.
23
 * @param environment
24
 *   the current environment of the simulation.
25
 */
26
final case class BaseSimulationState(
27
    override val simulationTime: Option[FiniteDuration],
64✔
28
    override val elapsedTime: FiniteDuration = FiniteDuration(0, MILLISECONDS),
6✔
29
    override val dt: FiniteDuration = FiniteDuration(100, MILLISECONDS),
12✔
30
    override val simulationRNG: RNG,
12✔
31
    override val environment: ValidEnvironment,
6✔
32
) extends ModelModule.BaseState
6✔
33

34
/**
35
 * Companion methods for the [[ModelModule.State]] to provide pretty-printing functionality.
36
 */
37
object BaseSimulationState:
NEW
38

×
39
  /**
40
   * Creates the initial state of the simulation based on the provided configuration.
41
   *
42
   * @param cfg
43
   *   the simulation configuration to use for initializing the state
44
   * @return
45
   *   the initial state of the simulation
46
   */
47
  def from(cfg: SimulationConfig[ValidEnvironment]): BaseSimulationState =
48
    val rng = SimpleRNG(cfg.simulation.seed.getOrElse(42))
5✔
49
    from(cfg, rng)
11✔
50

5✔
51
  def from(cfg: SimulationConfig[ValidEnvironment], rng: RNG): BaseSimulationState =
52
    BaseSimulationState(
53
      simulationTime = cfg.simulation.duration.map(FiniteDuration(_, MILLISECONDS)),
9✔
54
      simulationRNG = rng,
7✔
55
      environment = cfg.environment,
1✔
56
    )
5✔
57
end BaseSimulationState
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc