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

@ -6,13 +6,13 @@ DOORS = 'Doors' # Identifier of Door-objects and groups (grou
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

View File

@ -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