def traverse_all_path(graph): moves = [] # Memo this ### Create a queue/stack as appropriate stack = Stack() # put starting point in that stack.push(0) #player.current_room.id # Make a set to keep track of where weve been visited = set() #while there is stuff in the queue/stack while len(visited) < len(graph): # "pop" the first item # DO THE THINGS! temp = stack.head() visited.add(temp) current_room = graph[temp] neighbors = current_room[1] undiscovered = [] # For each edge in the item add that edge the queu/stack for direction, neighbor in neighbors.items(): # if not visitied if neighbor not in visited: undiscovered.append(neighbor) # if there is length keep pushing the next item #checking for the next available room to walk to if len(undiscovered) > 0: next_room = undiscovered[0] stack.push(next_room) else: stack.pop() next_room = stack.head() #create moves array to return all rooms and direction traveled. for direction, neighbor in neighbors.items(): if neighbor == next_room: moves.append(direction) return moves