diff --git a/vmas/scenarios/football.py b/vmas/scenarios/football.py index 52f2ed3b..4e380f63 100644 --- a/vmas/scenarios/football.py +++ b/vmas/scenarios/football.py @@ -130,7 +130,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs): world = self.init_world(batch_dim, device) self.init_agents(world) self.init_ball(world) - self.init_background(world) + self.init_background() self.init_walls(world) self.init_goals(world) self.init_traj_pts(world) @@ -196,6 +196,7 @@ def init_world(self, batch_dim: int, device: torch.device): def init_agents(self, world): self.blue_color = (0.22, 0.49, 0.72) + self.red_color = (0.89, 0.10, 0.11) # Add agents self.red_controller = ( AgentPolicy( @@ -284,7 +285,7 @@ def init_agents(self, world): if not self.enable_shooting or self.ai_red_agents else HolonomicWithRotation(), action_size=2 if not self.enable_shooting or self.ai_red_agents else 4, - color=(0.89, 0.10, 0.11), + color=self.red_color, alpha=1, ) world.add_agent(agent) @@ -604,7 +605,7 @@ def get_closest_agent_to_ball(self, team, env_index): return min_dist - def init_background(self, world): + def init_background(self): # Add landmarks self.background = Landmark( name="Background", @@ -1065,6 +1066,7 @@ def process_action(self, agent: Agent): ..., 2 ] # Red agents have the action rotation flipped + # You can shoot the ball only if you hae that action, are the closest to the ball, and the ball is within range and angle if self.enable_shooting and agent.action_script is None: agents_exclude_ball = [a for a in self.world.agents if a is not self.ball] if self._agents_rel_pos_to_ball is None: @@ -1521,6 +1523,7 @@ def extra_render(self, env_index: int = 0) -> "List[Geom]": from vmas.simulator.rendering import Geom # Background + # You can disable background rendering in case you are plotting the a function on the field geoms: List[Geom] = ( self._get_background_geoms(self.background_entities) if self._render_field