From 3a7b727ec6cdad7b2e0548c1b36ae9265be96533 Mon Sep 17 00:00:00 2001 From: Chanumask Date: Fri, 17 Nov 2023 12:09:25 +0100 Subject: [PATCH] maintainer test continued --- marl_factory_grid/environment/tests.py | 16 +++++++--------- marl_factory_grid/testing/test_config.yaml | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/marl_factory_grid/environment/tests.py b/marl_factory_grid/environment/tests.py index e180500..287e2e5 100644 --- a/marl_factory_grid/environment/tests.py +++ b/marl_factory_grid/environment/tests.py @@ -55,17 +55,16 @@ class MaintainerTest(Test): if maintainer._closed_door_in_path(state): self.assertEqual(maintainer.get_move_action(state).name, 'use_door') - if maintainer._path: + elif maintainer._path: # can move - print(maintainer.move(maintainer._path[1], state)) # 0 immer false ausser schritt 1, 1 meistens true nicht immer - # self.assertTrue(maintainer.move(maintainer._path[1], state)) + # print(maintainer.move(maintainer._path[1], state)) + self.assertTrue(maintainer.move(maintainer._path[1], state)) - else: - # finds valid targets oder hier? - route = maintainer.calculate_route(maintainer._last[-1], state.flootile_graph) + if not maintainer._path: + # finds valid targets when at target location + route = maintainer.calculate_route(maintainer._last[-1], state.floortile_graph) if entities_at_target_location := [entity for entity in state.entities.by_pos(route[-1])]: self.assertTrue(any(isinstance(e, Machine) for e in entities_at_target_location)) - return [] def tick_post_step(self, state) -> List[TickResult]: @@ -73,12 +72,11 @@ class MaintainerTest(Test): if maintainer._path: # if action was door use: was door opened successfully? if maintainer._closed_door_in_path(state): - # print(maintainer.get_move_action(state)) door = next( (entity for entity in state.entities.by_pos(maintainer._path[0]) if isinstance(entity, Door)), None) self.assertEqual(door.is_open, True) - + # when stepping off machine, did maintain action work? return [] diff --git a/marl_factory_grid/testing/test_config.yaml b/marl_factory_grid/testing/test_config.yaml index 1266e8a..1c3c0fa 100644 --- a/marl_factory_grid/testing/test_config.yaml +++ b/marl_factory_grid/testing/test_config.yaml @@ -2,7 +2,7 @@ Agents: Wolfgang: Actions: - Noop - - BtryCharge + - Charge - CleanUp - DestAction - DoorUse @@ -58,7 +58,7 @@ General: level_name: large pomdp_r: 3 verbose: false - tests: false + tests: true Rules: # Environment Dynamics