Skip to content

Commit

Permalink
adding ability to override background agent module.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 694053569
Change-Id: Ia56a584f29367291006b18daaf1633cb3c29a4f6
  • Loading branch information
vezhnick authored and copybara-github committed Nov 7, 2024
1 parent 187cd09 commit 33fa99c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/modular/scenario/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,20 @@ def build_simulation(
support_agent_base_module: str = DEFAULT_IMPORT_SUPPORT_AGENT_MODULE,
env_base_module: str = DEFAULT_IMPORT_ENV_BASE_MODULE,
seed: int | None = None,
override_background_agent_module: types.ModuleType | None = None,
) -> RunnableSimulationWithMemories:
"""Builds a simulation from a scenario configuration."""
substrate_config = scenario_config.substrate_config
# Load the environment config with importlib
simulation = importlib.import_module(
f'{env_base_module}.{substrate_config.environment}'
)
background_agent_module = importlib.import_module(
f'{agent_base_module}.{scenario_config.background_agent_module}'
)
if override_background_agent_module is not None:
background_agent_module = override_background_agent_module
else:
background_agent_module = importlib.import_module(
f'{agent_base_module}.{scenario_config.background_agent_module}'
)
if scenario_config.focal_is_resident:
resident_agent_module = focal_agent_module
visitor_agent_module = background_agent_module
Expand Down

0 comments on commit 33fa99c

Please sign in to comment.