Multithreaded Operation

Debugging
Doors, when no Doors are present
Smaller Bugfixes
This commit is contained in:
Steffen Illium
2021-08-31 17:27:19 +02:00
parent 2bf9aaed15
commit 4fb32c98c6
11 changed files with 228 additions and 149 deletions
+21 -11
View File
@@ -50,19 +50,28 @@ class Constants(Enum):
return bool(self.value)
class ManhattanMoves(Enum):
class MovingAction(Enum):
NORTH = 'north'
EAST = 'east'
SOUTH = 'south'
WEST = 'west'
class DiagonalMoves(Enum):
NORTHEAST = 'north_east'
SOUTHEAST = 'south_east'
SOUTHWEST = 'south_west'
NORTHWEST = 'north_west'
@classmethod
def is_member(cls, other):
return any([other == direction for direction in cls])
@classmethod
def square(cls):
return [cls.NORTH, cls.EAST, cls.SOUTH, cls.WEST]
@classmethod
def diagonal(cls):
return [cls.NORTHEAST, cls.SOUTHEAST, cls.SOUTHWEST, cls.NORTHWEST]
class EnvActions(Enum):
NOOP = 'no_op'
@@ -71,14 +80,13 @@ class EnvActions(Enum):
ITEM_ACTION = 'item_action'
d = DiagonalMoves
m = ManhattanMoves
m = MovingAction
c = Constants
ACTIONMAP = defaultdict(lambda: (0, 0), {m.NORTH: (-1, 0), d.NORTHEAST: (-1, +1),
m.EAST: (0, 1), d.SOUTHEAST: (1, 1),
m.SOUTH: (1, 0), d.SOUTHWEST: (+1, -1),
m.WEST: (0, -1), d.NORTHWEST: (-1, -1)
ACTIONMAP = defaultdict(lambda: (0, 0), {m.NORTH: (-1, 0), m.NORTHEAST: (-1, +1),
m.EAST: (0, 1), m.SOUTHEAST: (1, 1),
m.SOUTH: (1, 0), m.SOUTHWEST: (+1, -1),
m.WEST: (0, -1), m.NORTHWEST: (-1, -1)
}
)
@@ -126,8 +134,10 @@ def asset_str(agent):
return 'agent_collision', 'blank'
elif not agent.temp_valid or c.LEVEL.name in col_names or c.AGENT.name in col_names:
return c.AGENT.value, 'invalid'
elif agent.temp_valid:
elif agent.temp_valid and not MovingAction.is_member(agent.temp_action):
return c.AGENT.value, 'valid'
elif agent.temp_valid and MovingAction.is_member(agent.temp_action):
return c.AGENT.value, 'move'
else:
return c.AGENT.value, 'idle'