def test_solver_collectables_unreachable_collectable(self): level = Level() level.upper_layer = np.array([[s, e, B, f], [c, e, w, c]], dtype=object) level.required_collectable_count = 2 start = Start() c0 = Collectable("c0") c1 = Collectable("c1") barrier = CollectableBarrier("B", collectables=[c0, c1]) end = End() start.add_child_s([c0, barrier]) barrier.add_child_s([c1, end]) positions_map = { start: np.array([0, 0]), c0: np.array([1, 0]), c1: np.array([1, 3]), barrier: np.array([0, 2]), end: np.array([0, 3]), } level.mission = start level.positions_map = positions_map does_level_follow_mission, solution = Solver.does_level_follow_mission( level) self.assertEqual(does_level_follow_mission, False)
def test_solver_collectables(self): level = Level() level.upper_layer = np.array([[s, e, B, f], [c, c, w, e]], dtype=object) level.required_collectable_count = 2 start = Start() c0 = Collectable("c0") c1 = Collectable("c1") barrier = CollectableBarrier("B", collectables=[c0, c1]) end = End() start.add_child_s([c0, c1, barrier]) barrier.add_child_s(end) positions_map = { start: np.array([0, 0]), c0: np.array([1, 0]), c1: np.array([1, 1]), barrier: np.array([0, 2]), end: np.array([0, 3]), } level.mission = start level.positions_map = positions_map does_level_follow_mission, solution = Solver.does_level_follow_mission( level) self.assertEqual(does_level_follow_mission, True) if solution.steps[1][0] == c1: expected_steps = [(start, []), (c1, dM + rM), (c0, lM), (barrier, rM + uM + rM), (end, rM)] else: expected_steps = [(start, []), (c0, dM), (c1, rM), (barrier, uM + rM), (end, rM)] self.assert_steps_equal(solution.steps, expected_steps)