The following is due to Lou Duchez (http://atlas.csd.net/~cgadd/knowbase/MISC0146.HTM), but is, I believe, common knowledge - it was the one that sprang to my mind, anyway. As for traversing a maze: you are likely aware of the "right-hand rule" for walking a maze, by starting at the entrance, keeping your right hand on the wall at all times, and following your nose. Sooner or later, you will get to the exit. I will suggest how to implement the right-hand rule. First, you will always need to keep track of what direction you're walking. Now to simulate the right hand on the wall: check the grid location in the direction just clockwise to the direction you're walking. In other words, if you're walking to the right, check the downward direction. Is there a wall there? If not, go in that direction. But if there is a wall there, keep checking directions going counter-clockwise until you find a spot that isn't a wall. (Using the same example, if you couldn't go down, check right, then up, then left until you find a non-wall.) As soon as you find a non-wall, go in that direction. ------------------------------------------------------------------------ There are probably all sorts of ways to solve a maze, but here is the approach I use. First of all, you will need to associate another boolean variable with each maze location, indicating whether or not you've passed that spot already while trying to solve the maze. (Think of leaving a trail of bread crumbs and you have the right idea.) Set all your "bread crumbs" to false. Now start at the beginning of the maze, and walk the maze via the right-hand rule. Whenever you move to a new location, check to see if there's a bread crumb there already. If there is not, put one there, *and also in the location you were just at*. If there is already a bread crumb there, remove it, *and also remove the bread crumb from the location you were just at*. When you finally reach the exit, the only bread crumbs remaining, will comprise the solution. (All that bit about "the location you were just at", keeps bread crumbs from appearing improperly at corners and dead ends.)