66 GameConfig ,
77 WallConfig ,
88)
9- from mettagrid .config .vibes import VIBES
109from mettagrid .mettagrid_c import ActionConfig as CppActionConfig
1110from mettagrid .mettagrid_c import AgentConfig as CppAgentConfig
1211from mettagrid .mettagrid_c import AssemblerConfig as CppAssemblerConfig
@@ -36,15 +35,12 @@ def convert_to_cpp_game_config(mettagrid_config: dict | GameConfig):
3635 if "obs" in config_dict and "features" in config_dict ["obs" ]:
3736 config_dict ["obs" ] = config_dict ["obs" ].copy ()
3837 config_dict ["obs" ].pop ("features" , None )
39- # Keep vibe_names in sync with number_of_vibes ; favor the explicit count .
38+ # Keep vibe_names in sync with vibes ; favor the vibes list .
4039 config_dict .pop ("vibe_names" , None )
41- change_vibe_cfg = config_dict .setdefault ("actions" , {}).setdefault ("change_vibe" , {})
42- change_vibe_cfg ["number_of_vibes" ] = change_vibe_cfg .get ("number_of_vibes" ) or len (VIBES )
4340 game_config = GameConfig (** config_dict )
4441
4542 # Ensure runtime object has consistent vibes.
46- game_config .actions .change_vibe .number_of_vibes = game_config .actions .change_vibe .number_of_vibes or len (VIBES )
47- game_config .vibe_names = [vibe .name for vibe in VIBES [: game_config .actions .change_vibe .number_of_vibes ]]
43+ game_config .vibe_names = [vibe .name for vibe in game_config .actions .change_vibe .vibes ]
4844
4945 # Set up resource mappings
5046 resource_names = list (game_config .resource_names )
@@ -56,8 +52,7 @@ def convert_to_cpp_game_config(mettagrid_config: dict | GameConfig):
5652
5753 # Set up vibe mappings from the change_vibe action config.
5854 # The C++ bindings expect dense uint8 identifiers, so keep a name->id lookup.
59- num_vibes = game_config .actions .change_vibe .number_of_vibes
60- supported_vibes = VIBES [:num_vibes ]
55+ supported_vibes = game_config .actions .change_vibe .vibes
6156 vibe_name_to_id = {vibe .name : i for i , vibe in enumerate (supported_vibes )}
6257
6358 objects_cpp_params = {} # params for CppWallConfig
@@ -462,9 +457,8 @@ def process_action_config(action_name: str, action_config):
462457
463458 # Process change_vibe - always add to map
464459 action_params = process_action_config ("change_vibe" , actions_config .change_vibe )
465- action_params ["number_of_vibes" ] = (
466- actions_config .change_vibe .number_of_vibes if actions_config .change_vibe .enabled else 0
467- )
460+ num_vibes = len (actions_config .change_vibe .vibes ) if actions_config .change_vibe .enabled else 0
461+ action_params ["number_of_vibes" ] = num_vibes
468462 actions_cpp_params ["change_vibe" ] = CppChangeVibeActionConfig (** action_params )
469463
470464 game_cpp_params ["actions" ] = actions_cpp_params
0 commit comments