diff --git a/marl_factory_grid/modules/doors/constants.py b/marl_factory_grid/modules/doors/constants.py index c14f6eb..cb26ce4 100644 --- a/marl_factory_grid/modules/doors/constants.py +++ b/marl_factory_grid/modules/doors/constants.py @@ -1,18 +1,18 @@ # Names / Identifiers -DOOR = 'Door' # Identifier of Single-Door Entities. -DOORS = 'Doors' # Identifier of Door-objects and groups (groups). +DOOR = 'Door' # Identifier of Single-Door Entities. +DOORS = 'Doors' # Identifier of Door-objects and groups (groups). # Symbols (in map) SYMBOL_DOOR = 'D' # Door _identifier for resolving the string based map files. # Values -VALUE_ACCESS_INDICATOR = 1 / 3 # Access-door-Cell value used in observation -VALUE_OPEN_DOOR = 2 / 3 # Open-door-Cell value used in observation -VALUE_CLOSED_DOOR = 3 / 3 # Closed-door-Cell value used in observation +VALUE_ACCESS_INDICATOR = 0.2222 # Access-door-Cell value used in observation +VALUE_OPEN_DOOR = 0.4444 # Open-door-Cell value used in observation +VALUE_CLOSED_DOOR = 0.6666 # Closed-door-Cell value used in observation # States STATE_CLOSED = 'closed' # Identifier to compare door-is-closed state STATE_OPEN = 'open' # Identifier to compare door-is-open state # Actions -ACTION_DOOR_USE = 'use_door' +ACTION_DOOR_USE = 'use_door' # Identifier for door-action diff --git a/marl_factory_grid/utils/observation_builder.py b/marl_factory_grid/utils/observation_builder.py index ed725cc..4a4d4b2 100644 --- a/marl_factory_grid/utils/observation_builder.py +++ b/marl_factory_grid/utils/observation_builder.py @@ -204,7 +204,7 @@ class RayCaster: rot_M = np.unique(np.round(rot_M @ north), axis=0) return rot_M.astype(int) - def ray_block_cache(self, cache_dict, key, callback, ents): + def ray_block_cache(self, cache_dict, key, callback): if key not in cache_dict: cache_dict[key] = callback() return cache_dict[key] @@ -221,24 +221,13 @@ class RayCaster: entities_hit = entities.pos_dict[(x, y)] hits = self.ray_block_cache(cache_blocking, (x, y), - lambda: any(e.var_is_blocking_light for e in entities_hit), - entities) + lambda: any(True for e in entities_hit if e.var_is_blocking_light)) - try: - d = next(x for x in entities_hit if 'Door' in x.name) - if d.pos in entities.pos_dict.keys(): - if d.is_closed and not entities.pos_dict[d.pos]: - print() - except StopIteration: - pass - - diag_hits = any([ + diag_hits = all([ self.ray_block_cache( cache_blocking, key, - # lambda: all(False for e in entities.pos_dict[key] if not e.var_is_blocking_light), - lambda: any(e.var_is_blocking_light for e in entities.pos_dict[key]), - entities) + lambda: all(False for e in entities.pos_dict[key] if not e.var_is_blocking_light)) for key in ((x, y-cy), (x-cx, y)) ]) if (cx != 0 and cy != 0) else False