sciencegym.simulations.Simulation_InclinedPlane module¶
- class sciencegym.simulations.Simulation_InclinedPlane.InclinePlaneCoordinates(angle: float, l: float = 20)¶
Bases:
object
- abs_ball_distance_form_initial_positione(ball_coords)¶
- get_coordinates()¶
- is_ball_in_plane_bounds(coordinates)¶
- is_x_coordinate_inside_plane_bounds(x)¶
- is_y_coordinate_inside_plane_bounds(y)¶
- rel_ball_distance_form_initial_positione(ball_coords)¶
- class sciencegym.simulations.Simulation_InclinedPlane.Sim_InclinedPlane(*args: Any, **kwargs: Any)¶
Bases:
SimulationInterface
- close()¶
Close the pygame window and terminate the program.
- convert_observation_space(obs_space: gym.spaces.Dict, order: list[str] = []) gym.spaces.Box ¶
Convert an existing scale environment so that the observation space is a Box instead of a Dict.
- Parameters:
obs_space (gym.spaces.Dict) – the given observation space in the old format
order (list[str]) – give a list of the descriptions as an order for the new observation space
- Returns:
the new observation space as a Box
- Return type:
gym.spaces.Box
- createNewExperiment()¶
- getState()¶
Resets and returns the current values of the state
get current
- Returns:
the new state
- Return type:
np.ndarray
- get_action_space()¶
Return a gymnasium.spaces.Space
- get_current_state()¶
Returns an array representing the current status of the simulation.
- get_state_space()¶
Returns a gymnasium.spaces.Space containing the ranges of the state space.
- internal_step(action=None)¶
Simulates the program with the given action and returns the observations
- Parameters:
action (list[float]) – the action(s) the agent chooses as an array of each new positions for each box that should be moved
- Returns:
new state after step, the reward, done, info
- Return type:
tuple[np.ndarray, float, bool, dict]
- performAction(action)¶
- render(mode='human')¶
Render function, which runs the simulation and render it (if wished)
- Parameters:
mode (str) – “human” for rendering, “state_pixels” for returning the pixel array
- Returns:
nothing if mode is human, if mode is “state_pixels”, we return the array of the screen
- Return type:
np.array
- reset()¶
Resets the simulation to the initial conditions and returns the initial conditions of the new environment, alongside additional information.
- simulated_step(action)¶
Actual step function called by the agent when box2d simulation is used
- Parameters:
action (list[float]) – the action(s) the agent chooses as an array of each new positions for each box that should be moved
- Returns:
new state after step, the reward, done, info
- Return type:
tuple[np.ndarray, float, bool, dict]
- step(action)¶
- step_no_sim(action)¶
- sciencegym.simulations.Simulation_InclinedPlane.degreeToRad(angle)¶
- Parameters:
angle – the angle in degrees (0-360jjjA)
- Returns:
the same measurement in radians
- sciencegym.simulations.Simulation_InclinedPlane.normal_vector(p1, p2)¶
- sciencegym.simulations.Simulation_InclinedPlane.radToDegree(rad)¶
- Parameters:
rad – an angle measured in radians
- Returns:
the same measurement in degrees
- sciencegym.simulations.Simulation_InclinedPlane.rescale_movement(original_interval, value, to_interval=(-15, 15))¶
Helper function to do and to undo the normalization of the action and observation space :param original_interval: Original interval, in which we observe the value. :type original_interval: list[float, float] :param value: Number that should be rescaled. :type value: float :param to_interval: New interval, in which we want to rescale the value. :type to_interval: list[float, float] :return: Rescaled value :rtype: float