matrx-software / matrx

Human-Agent Teaming Rapid Experimentation Software
https://www.matrx-software.com
MIT License
10 stars 3 forks source link

get_self(self) returns a list containing the agent_properties dict rather than the dict alone. #300

Closed Stephenkruk closed 3 years ago

Stephenkruk commented 3 years ago

Describe the bug get_self(self) in state.py returns a list containing the dict of the agent properties (v2.0.8) rather than the dict itself (v2.0.7 and before). This has consequences when using the __get_closest(self, objs) function in state.py when it tries to perform self.__me['location'] or self.get_self()['location'] (line 417 or 419)

To Reproduce use the get_closest_room_door(self, room_name) (line 351) function to trigger this bug

Expected behavior The _getself() function needs to return only the dict of the agent properties, since it makes use of the __get_closest function

Stacktrace

Traceback (most recent call last):
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\bw4t\BW4TBrain.py", line 77, in filter_observations
    res= self.filter_bw4t_observations(newstate)
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\agents1\PredictorAgent.py", line 71, in filter_bw4t_observations
    self.startup_actions(state)
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\agents1\PredictorAgent.py", line 325, in startup_actions
    self.init_room_info(state)
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\agents1\PredictorAgent.py", line 350, in init_room_info
    closest_room_doors = state.get_closest_room_door(name)
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\venv\lib\site-packages\matrx\agents\agent_utils\state.py", line 361, in get_closest_room_door
    closest_objects = self.__get_closest(objs)
  File "C:\Users\steph\Documents\CSE_Y3\CSE3000\experiment\venv\lib\site-packages\matrx\agents\agent_utils\state.py", line 417, in __get_closest
    my_loc = self.__me['location']
TypeError: list indices must be integers or slices, not str

Additional context Not familiar with the framework yet, therefore posting this as a bug rather than fixing it, since I don't know about other implications this might have.

Edit: Formatted stacktrace.

jwaa commented 3 years ago

@Stephenkruk Thank you for reporting! If you are willing to contribute to MATRX Software, feel free to contact us to find a way that suits you!

After a quick glance I believe you are indeed correct. As the standardized output of State is the list of all objects adhering to some query, the bug is that in the methods you refer to the agent's own object representation is treated as a dict while being a list.

I will take a look at it this evening and see if I can add it last-minute to the release tonight.