Skip to content

Commit f0f2b01

Browse files
committed
docs
1 parent ebb451c commit f0f2b01

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

vmas/scenarios/football.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def make_world(self, batch_dim: int, device: torch.device, **kwargs):
130130
world = self.init_world(batch_dim, device)
131131
self.init_agents(world)
132132
self.init_ball(world)
133-
self.init_background(world)
133+
self.init_background()
134134
self.init_walls(world)
135135
self.init_goals(world)
136136
self.init_traj_pts(world)
@@ -196,6 +196,7 @@ def init_world(self, batch_dim: int, device: torch.device):
196196

197197
def init_agents(self, world):
198198
self.blue_color = (0.22, 0.49, 0.72)
199+
self.red_color = (0.89, 0.10, 0.11)
199200
# Add agents
200201
self.red_controller = (
201202
AgentPolicy(
@@ -284,7 +285,7 @@ def init_agents(self, world):
284285
if not self.enable_shooting or self.ai_red_agents
285286
else HolonomicWithRotation(),
286287
action_size=2 if not self.enable_shooting or self.ai_red_agents else 4,
287-
color=(0.89, 0.10, 0.11),
288+
color=self.red_color,
288289
alpha=1,
289290
)
290291
world.add_agent(agent)
@@ -604,7 +605,7 @@ def get_closest_agent_to_ball(self, team, env_index):
604605

605606
return min_dist
606607

607-
def init_background(self, world):
608+
def init_background(self):
608609
# Add landmarks
609610
self.background = Landmark(
610611
name="Background",
@@ -1065,6 +1066,7 @@ def process_action(self, agent: Agent):
10651066
..., 2
10661067
] # Red agents have the action rotation flipped
10671068

1069+
# 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
10681070
if self.enable_shooting and agent.action_script is None:
10691071
agents_exclude_ball = [a for a in self.world.agents if a is not self.ball]
10701072
if self._agents_rel_pos_to_ball is None:
@@ -1521,6 +1523,7 @@ def extra_render(self, env_index: int = 0) -> "List[Geom]":
15211523
from vmas.simulator.rendering import Geom
15221524

15231525
# Background
1526+
# You can disable background rendering in case you are plotting the a function on the field
15241527
geoms: List[Geom] = (
15251528
self._get_background_geoms(self.background_entities)
15261529
if self._render_field

0 commit comments

Comments
 (0)