-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function for fetching gridworld env object(s) by type or name #14
Comments
In grid_world.py change function get_env_object with the following: def get_env_object(self, requested_id=None, obj_type=None):
obj = None
if requested_id in self.__registered_agents.keys():
if obj_type is not None:
if isinstance(self.__registered_agents[requested_id], obj_type):
obj = self.__registered_agents[requested_id]
else:
obj = self.__registered_agents[requested_id]
if requested_id in self.__environment_objects.keys():
if obj_type is not None:
if isinstance(self.__environment_objects[requested_id], obj_type):
obj = self.__environment_objects[requested_id]
else:
obj = self.__environment_objects[requested_id]
if requested_id is None and obj_type is not None:
for obj_id, env_obj in self.__environment_objects.items():
if isinstance(env_obj, obj_type):
obj = env_obj
break
return obj |
When did it occur that you wished to fetch an object while you don't know the ID? @thaije; please do not use the MATRXS account to post issues, as it makes it more difficult to track the origin and progress of issues. |
@olafvisker; the edit you propose returns the very first object if finds with a certain type. Why only the first and not a list of all those object types? |
@jwaa Ah yeah sorry about that, I was signed in by default using the MATRXS account by accident. For how this function should preferrably work, also see issue #15. Script above was a quick fix for AIMS, in #15 a more permanent solution is proposed which returns a list as you suggest. As for the use case: the AIMS project makes use of a Score object, simply named 'score' by the user when creating the scenario. At various locations in the code, e.g. in an action, this Score object needs to be fetched or changed. However, how to fetch this object? The current |
ID's of all env objects are now created as: obj_name + random_integer.
However, this makes it impossible to fetch an object when you don't know the ID of an object. It would be desirable to fetch an object by type (class) or name.
The text was updated successfully, but these errors were encountered: