Skip to content

Commit 6e76e55

Browse files
committed
local seed
1 parent a8dd126 commit 6e76e55

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

vmas/simulator/environment/environment.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def local_seed(vmas_random_state):
4747

4848

4949
class Environment(TorchVectorizedObject):
50+
"""
51+
The VMAS environment
52+
"""
53+
5054
metadata = {
5155
"render.modes": ["human", "rgb_array"],
5256
"runtime.vectorized": True,
@@ -320,16 +324,15 @@ def _seed(self, seed=None):
320324
@local_seed(vmas_random_state)
321325
def step(self, actions: Union[List, Dict]):
322326
"""Performs a vectorized step on all sub environments using `actions`.
327+
323328
Args:
324-
actions: Is a list on len 'self.n_agents' of which each element is a torch.Tensor of shape
325-
'(self.num_envs, action_size_of_agent)'.
329+
actions: Is a list on len 'self.n_agents' of which each element is a torch.Tensor of shape '(self.num_envs, action_size_of_agent)'.
330+
326331
Returns:
327-
obs: List on len 'self.n_agents' of which each element is a torch.Tensor
328-
of shape '(self.num_envs, obs_size_of_agent)'
332+
obs: List on len 'self.n_agents' of which each element is a torch.Tensor of shape '(self.num_envs, obs_size_of_agent)'
329333
rewards: List on len 'self.n_agents' of which each element is a torch.Tensor of shape '(self.num_envs)'
330334
dones: Tensor of len 'self.num_envs' of which each element is a bool
331-
infos : List on len 'self.n_agents' of which each element is a dictionary for which each key is a metric
332-
and the value is a tensor of shape '(self.num_envs, metric_size_per_agent)'
335+
infos: List on len 'self.n_agents' of which each element is a dictionary for which each key is a metric and the value is a tensor of shape '(self.num_envs, metric_size_per_agent)'
333336
334337
Examples:
335338
>>> import vmas
@@ -345,6 +348,7 @@ def step(self, actions: Union[List, Dict]):
345348
>>> obs = env.reset()
346349
>>> for _ in range(10):
347350
... obs, rews, dones, info = env.step(env.get_random_actions())
351+
348352
"""
349353
if isinstance(actions, Dict):
350354
actions_dict = actions
@@ -578,7 +582,7 @@ def get_random_action(self, agent: Agent) -> torch.Tensor:
578582
return action
579583

580584
def get_random_actions(self) -> Sequence[torch.Tensor]:
581-
"""Returns random actions for all agents that you can feed to :class:`step`
585+
"""Returns random actions for all agents that you can feed to :meth:`step`
582586
583587
Returns:
584588
Sequence[torch.tensor]: the random actions for the agents
@@ -767,15 +771,15 @@ def render(
767771
Render function for environment using pyglet
768772
769773
On servers use mode="rgb_array" and set
774+
770775
```
771776
export DISPLAY=':99.0'
772777
Xvfb :99 -screen 0 1400x900x24 > /dev/null 2>&1 &
773778
```
774779
775780
:param mode: One of human or rgb_array
776781
:param env_index: Index of the environment to render
777-
:param agent_index_focus: If specified the camera will stay on the agent with this index.
778-
If None, the camera will stay in the center and zoom out to contain all agents
782+
:param agent_index_focus: If specified the camera will stay on the agent with this index. If None, the camera will stay in the center and zoom out to contain all agents
779783
:param visualize_when_rgb: Also run human visualization when mode=="rgb_array"
780784
:param plot_position_function: A function to plot under the rendering.
781785
The function takes a numpy array with shape (n_points, 2), which represents a set of x,y values to evaluate f over and plot it
@@ -789,6 +793,7 @@ def render(
789793
:param plot_position_function_cmap_range: The range of the cmap in case plot_position_function outputs a single value
790794
:param plot_position_function_cmap_alpha: The alpha of the cmap in case plot_position_function outputs a single value
791795
:return: Rgb array or None, depending on the mode
796+
792797
"""
793798
self._check_batch_index(env_index)
794799
assert (

0 commit comments

Comments
 (0)