// pathing private List<Room> path(Room start, Room destination, Set<Room> travelable) { Queue<Room> frontier = new LinkedList<Room>(); frontier.add(start); Map<Room, Room> visited = new HashMap<Room, Room>(); visited.put(start, null); while (!frontier.isEmpty()) { Room current = frontier.poll(); System.out.println("\n---\n" + frontier + "\n\n" + travelable + "\n---\n"); if ((destination == null && current.visited == false) || current == destination) { List<Room> path = new ArrayList<Room>(); Room next = current; while (visited.get(next) != null) { path.add(0, next); next = visited.get(next); } System.out.println("Returning: " + path); return path; } for (Room next : current.adjacent) { if (!visited.containsKey(next) && travelable.contains(next)) { frontier.add(next); visited.put(next, current); } } } System.out.println("Returning: null"); return null; }