New Szenario "Two_Rooms_One_Door"

This commit is contained in:
Steffen Illium 2023-07-12 15:59:28 +02:00
parent 9135a69da6
commit 061934ed11
2 changed files with 10 additions and 21 deletions

View File

@ -1,18 +1,18 @@
# Names / Identifiers # Names / Identifiers
DOOR = 'Door' # Identifier of Single-Door Entities. DOOR = 'Door' # Identifier of Single-Door Entities.
DOORS = 'Doors' # Identifier of Door-objects and groups (groups). DOORS = 'Doors' # Identifier of Door-objects and groups (groups).
# Symbols (in map) # Symbols (in map)
SYMBOL_DOOR = 'D' # Door _identifier for resolving the string based map files. SYMBOL_DOOR = 'D' # Door _identifier for resolving the string based map files.
# Values # Values
VALUE_ACCESS_INDICATOR = 1 / 3 # Access-door-Cell value used in observation VALUE_ACCESS_INDICATOR = 0.2222 # Access-door-Cell value used in observation
VALUE_OPEN_DOOR = 2 / 3 # Open-door-Cell value used in observation VALUE_OPEN_DOOR = 0.4444 # Open-door-Cell value used in observation
VALUE_CLOSED_DOOR = 3 / 3 # Closed-door-Cell value used in observation VALUE_CLOSED_DOOR = 0.6666 # Closed-door-Cell value used in observation
# States # States
STATE_CLOSED = 'closed' # Identifier to compare door-is-closed state STATE_CLOSED = 'closed' # Identifier to compare door-is-closed state
STATE_OPEN = 'open' # Identifier to compare door-is-open state STATE_OPEN = 'open' # Identifier to compare door-is-open state
# Actions # Actions
ACTION_DOOR_USE = 'use_door' ACTION_DOOR_USE = 'use_door' # Identifier for door-action

View File

@ -204,7 +204,7 @@ class RayCaster:
rot_M = np.unique(np.round(rot_M @ north), axis=0) rot_M = np.unique(np.round(rot_M @ north), axis=0)
return rot_M.astype(int) 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: if key not in cache_dict:
cache_dict[key] = callback() cache_dict[key] = callback()
return cache_dict[key] return cache_dict[key]
@ -221,24 +221,13 @@ class RayCaster:
entities_hit = entities.pos_dict[(x, y)] entities_hit = entities.pos_dict[(x, y)]
hits = self.ray_block_cache(cache_blocking, hits = self.ray_block_cache(cache_blocking,
(x, y), (x, y),
lambda: any(e.var_is_blocking_light for e in entities_hit), lambda: any(True for e in entities_hit if e.var_is_blocking_light))
entities)
try: diag_hits = all([
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([
self.ray_block_cache( self.ray_block_cache(
cache_blocking, cache_blocking,
key, key,
# lambda: all(False for e in entities.pos_dict[key] if not e.var_is_blocking_light), 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)
for key in ((x, y-cy), (x-cx, y)) for key in ((x, y-cy), (x-cx, y))
]) if (cx != 0 and cy != 0) else False ]) if (cx != 0 and cy != 0) else False