For a project I have to create a text adventure type game. Using a graph to setup the rooms. One option that is needed, is to find a path to from a start node to a finish node. I've tried implementing a breadth first search, but I'm not seeing how I'm supposed to use it. Right now, the BFS works correctly, however, I am supposed to print out the the path (room to room). I am having difficulty trying to figure out how to keep track of the path taken. Obviously I have to use some structure (array, list, stack, queue), but I don't understand how I am supposed to know which rooms need to be stored for the path. Once the destination is reached, it's not always possible to back track (going west to one room doesn't mean going east leads you back). Any ideas on what I'm missing?
Here is the basic idea of my BFS:
Code:clear all room's visit status to false set start room visit to true enqueue start room while queue is not empty {dequeue a roomif north path existsif north room is not yet visitedset north room as visitedif north room is destination room, display and exitenqueue north room//do the same for south, east, west paths}