@@ -35,12 +35,12 @@ def __init__(
3535 num_agents = 512 ,
3636 action_type = "discrete" ,
3737 dynamics_model = "classic" ,
38- max_controlled_agents = - 1 ,
3938 buf = None ,
4039 seed = 1 ,
4140 init_steps = 0 ,
4241 init_mode = "create_all_valid" ,
4342 control_mode = "control_vehicles" ,
43+ max_controlled_agents = 32 ,
4444 map_dir = "resources/drive/binaries/training" ,
4545 ):
4646 # env
@@ -63,6 +63,7 @@ def __init__(
6363 self .termination_mode = termination_mode
6464 self .resample_frequency = resample_frequency
6565 self .dynamics_model = dynamics_model
66+ self .max_controlled_agents = max_controlled_agents
6667
6768 # Observation space calculation
6869 self .ego_features = {"classic" : binding .EGO_FEATURES_CLASSIC , "jerk" : binding .EGO_FEATURES_JERK }.get (
@@ -96,9 +97,11 @@ def __init__(
9697 self .control_mode = 2
9798 elif self .control_mode_str == "control_sdc_only" :
9899 self .control_mode = 3
100+ elif self .control_mode_str == "control_mixed_play" :
101+ self .control_mode = 4
99102 else :
100103 raise ValueError (
101- f"control_mode must be one of 'control_vehicles', 'control_wosac', or 'control_agents '. Got: { self .control_mode_str } "
104+ f"control_mode must be one of 'control_vehicles', 'control_wosac', 'control_agents' or 'control_mixed_play '. Got: { self .control_mode_str } "
102105 )
103106 if self .init_mode_str == "create_all_valid" :
104107 self .init_mode = 0
@@ -140,7 +143,6 @@ def __init__(
140143 raise ValueError (
141144 f"num_maps ({ num_maps } ) exceeds available maps in directory ({ available_maps } ). Please reduce num_maps or add more maps to resources/drive/binaries."
142145 )
143- self .max_controlled_agents = int (max_controlled_agents )
144146
145147 # Iterate through all maps to count total agents that can be initialized for each map
146148 agent_offsets , map_ids , num_envs = binding .shared (
@@ -150,9 +152,9 @@ def __init__(
150152 init_mode = self .init_mode ,
151153 control_mode = self .control_mode ,
152154 init_steps = self .init_steps ,
153- max_controlled_agents = self .max_controlled_agents ,
154155 goal_behavior = self .goal_behavior ,
155156 goal_target_distance = self .goal_target_distance ,
157+ max_controlled_agents = self .max_controlled_agents ,
156158 )
157159
158160 self .num_agents = agent_offsets [- 1 ]
@@ -186,14 +188,14 @@ def __init__(
186188 dt = dt ,
187189 episode_length = (int (episode_length ) if episode_length is not None else None ),
188190 termination_mode = (int (self .termination_mode ) if self .termination_mode is not None else 0 ),
189- max_controlled_agents = self .max_controlled_agents ,
190191 map_id = map_ids [i ],
191192 max_agents = nxt - cur ,
192193 ini_file = "pufferlib/config/ocean/drive.ini" ,
193194 init_steps = init_steps ,
194195 init_mode = self .init_mode ,
195196 control_mode = self .control_mode ,
196197 map_dir = map_dir ,
198+ max_controlled_agents = self .max_controlled_agents ,
197199 )
198200 env_ids .append (env_id )
199201
@@ -218,11 +220,11 @@ def resample_maps(self):
218220 init_mode = self .init_mode ,
219221 control_mode = self .control_mode ,
220222 init_steps = self .init_steps ,
221- max_controlled_agents = self .max_controlled_agents ,
222223 goal_behavior = self .goal_behavior ,
223224 goal_target_distance = self .goal_target_distance ,
224225 goal_speed = self .goal_speed ,
225226 map_dir = self .map_dir ,
227+ max_controlled_agents = self .max_controlled_agents ,
226228 )
227229 self .agent_offsets = agent_offsets
228230 self .map_ids = map_ids
@@ -253,7 +255,6 @@ def resample_maps(self):
253255 offroad_behavior = self .offroad_behavior ,
254256 dt = self .dt ,
255257 episode_length = (int (self .episode_length ) if self .episode_length is not None else None ),
256- max_controlled_agents = self .max_controlled_agents ,
257258 map_id = map_ids [i ],
258259 max_agents = nxt - cur ,
259260 ini_file = "pufferlib/config/ocean/drive.ini" ,
@@ -262,6 +263,7 @@ def resample_maps(self):
262263 control_mode = self .control_mode ,
263264 map_dir = self .map_dir ,
264265 termination_mode = (int (self .termination_mode ) if self .termination_mode is not None else 0 ),
266+ max_controlled_agents = self .max_controlled_agents ,
265267 )
266268 env_ids .append (env_id )
267269 self .c_envs = binding .vectorize (* env_ids )
0 commit comments