diff --git a/pufferlib/ocean/drive/binding.c b/pufferlib/ocean/drive/binding.c index 2011402d2..f289965e5 100644 --- a/pufferlib/ocean/drive/binding.c +++ b/pufferlib/ocean/drive/binding.c @@ -187,8 +187,26 @@ static int my_init(Env *env, PyObject *args, PyObject *kwargs) { env->human_agent_idx = unpack(kwargs, "human_agent_idx"); env->ini_file = unpack_str(kwargs, "ini_file"); env_init_config conf = {0}; + + // Check if INI file exists before parsing + FILE *ini_check = fopen(env->ini_file, "r"); + if (ini_check == NULL) { + char error_msg[1024]; + snprintf(error_msg, sizeof(error_msg), + "INI config file not found: '%s'. " + "Please ensure the file exists at this path.", + env->ini_file); + PyErr_SetString(PyExc_FileNotFoundError, error_msg); + return -1; + } + fclose(ini_check); + if (ini_parse(env->ini_file, handler, &conf) < 0) { - printf("Error while loading %s", env->ini_file); + char error_msg[1024]; + snprintf(error_msg, sizeof(error_msg), + "Failed to parse INI config file: '%s'", env->ini_file); + PyErr_SetString(PyExc_ValueError, error_msg); + return -1; } if (kwargs && PyDict_GetItemString(kwargs, "episode_length")) { conf.episode_length = (int)unpack(kwargs, "episode_length"); diff --git a/pufferlib/ocean/drive/drive.py b/pufferlib/ocean/drive/drive.py index 2b43a50f8..84dca7cf5 100644 --- a/pufferlib/ocean/drive/drive.py +++ b/pufferlib/ocean/drive/drive.py @@ -8,6 +8,8 @@ from multiprocessing import Pool, cpu_count from tqdm import tqdm +_PACKAGE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +_INI_FILE = os.path.join(_PACKAGE_DIR, "config", "ocean", "drive.ini") class Drive(pufferlib.PufferEnv): def __init__( @@ -83,7 +85,7 @@ def __init__( + self.max_partner_objects * self.partner_features + self.max_road_objects * self.road_features ) - self.single_observation_space = gymnasium.spaces.Box(low=-1, high=1, shape=(self.num_obs,), dtype=np.float32) + self.single_observation_space = gymnasium.spaces.Box(low=-1, high=2, shape=(self.num_obs,), dtype=np.float32) self.init_steps = init_steps self.init_mode_str = init_mode @@ -209,7 +211,7 @@ def __init__( max_controlled_agents=self.max_controlled_agents, map_path=self.map_files[map_ids[i]], max_agents=nxt - cur, - ini_file="pufferlib/config/ocean/drive.ini", + ini_file=_INI_FILE, init_steps=init_steps, init_mode=self.init_mode, control_mode=self.control_mode, @@ -281,7 +283,7 @@ def step(self, actions): max_controlled_agents=self.max_controlled_agents, map_path=self.map_files[map_ids[i]], max_agents=nxt - cur, - ini_file="pufferlib/config/ocean/drive.ini", + ini_file=_INI_FILE, init_steps=self.init_steps, init_mode=self.init_mode, control_mode=self.control_mode, diff --git a/setup.py b/setup.py index b834f94cf..4cba00049 100644 --- a/setup.py +++ b/setup.py @@ -307,10 +307,10 @@ def run(self): install_requires = [ "setuptools", - "numpy<2.0", + "numpy", "shimmy[gym-v21]", "gym==0.23", - "gymnasium==0.29.1", + "gymnasium==1.2.2", "pettingzoo==1.24.1", ]