Skip to content

Commit a99b7cd

Browse files
committed
randomise agent indices
1 parent 04bcea6 commit a99b7cd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vmas/scenarios/football.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def init_params(self, **kwargs):
9292
self.spawn_in_formation = kwargs.pop("spawn_in_formation", True)
9393
self.only_blue_formation = kwargs.pop("only_blue_formation", True)
9494
self.formation_agents_per_column = kwargs.pop("formation_agents_per_column", 2)
95+
self.randomise_formation_indices = kwargs.pop(
96+
"randomise_formation_indices", False
97+
)
9598
self.formation_noise = kwargs.pop("formation_noise", 0.2)
9699

97100
# Ai config
@@ -391,6 +394,9 @@ def reset_agents(self, env_index: int = None):
391394
)
392395

393396
def _spawn_formation(self, agents, blue, env_index):
397+
if self.randomise_formation_indices:
398+
order = torch.randperm(len(agents)).tolist()
399+
agents = [agents[i] for i in order]
394400
agent_index = 0
395401
endpoint = -(self.pitch_length / 2 + self.goal_depth) * (1 if blue else -1)
396402
for x in torch.linspace(

0 commit comments

Comments
 (0)