public void FindPathInOneRoom() { Room[] rooms = LoadFromFile(); PrintWorld(rooms, Path<TileNode>.EMPTY); TileNode start = null, goal = null; foreach (Room r in rooms) { GameTypes.IntPoint localStart = r.WorldToLocalPoint(new GameTypes.IntPoint(-8, 1)); GameTypes.IntPoint localGoal = r.WorldToLocalPoint(new GameTypes.IntPoint(-1, 6)); if (r.GetTileType(localStart) == TileType.FLOOR) { start = r.GetTile(localStart); } if (r.GetTileType(localGoal) == TileType.FLOOR) { goal = r.GetTile(localGoal); } } Assert.NotNull(start); Assert.NotNull(goal); PathSolver<TileNode> solver = new PathSolver<TileNode>(); MultiRoomNetwork roomNetwork = new MultiRoomNetwork(rooms); var foundPath = solver.FindPath(start, goal, roomNetwork); Assert.AreEqual(PathStatus.FOUND_GOAL, foundPath.status); PrintWorld(rooms, foundPath); }
public void FindImpossiblePath() { Room[] rooms = LoadFromFile(); PrintWorld(rooms, Path<TileNode>.EMPTY); TileNode start = null, goal = null; foreach (Room r in rooms) { GameTypes.IntPoint localStart = r.WorldToLocalPoint(new GameTypes.IntPoint(-8, 1)); GameTypes.IntPoint localGoal = r.WorldToLocalPoint(new GameTypes.IntPoint(13, 4)); if (r.GetTileType(localStart) == TileType.FLOOR) { start = r.GetTile(localStart); } if (r.GetTileType(localGoal) == TileType.FLOOR) { goal = r.GetTile(localGoal); } } Assert.NotNull(start); Assert.NotNull(goal); PathSolver<TileNode> solver = new PathSolver<TileNode>(); MultiRoomNetwork roomNetwork = new MultiRoomNetwork(rooms); var foundPath = solver.FindPath(start, goal, roomNetwork, true); Assert.AreEqual(PathStatus.DESTINATION_UNREACHABLE, foundPath.status); PrintWorld(rooms, foundPath); }