Hey so I am trying to finish up a lab that I did not finish during a class this summer. The goal is to have the computer navigate an ASCII maze on its own. We use left/right hand rule to find our way through the maze. IE. you have your hands out to your side and if it is open we take a turn down that hallway. We leave breadcrumbs behind us to mark our taken path. In this version of the lab we are to have it recall its path between different trail runs, and use the best path to find the exit.
So far it successfully finds the finish point after some wrong turns and backtracking. There is a slight but difficult problem that needs solving to finish this first stage.
Here I will describe how I go about solving the maze and storing the path in memory.
I have a Linked List for X/Y coordinate pairs (contained inside a class called PathElement). At each turn (including turning down hallways that have already been tracked over once) I store that coordinate in to the list.
The slight but difficult problem to solve occurs in maze1. A few turns prior to finding the finish line, there is an intersection. Because it is an intersection it does not get stored in the path list. It is the quintessential "missing link". I have managed to separate the path elements in the list to different lists, one for paths that have been tracked over once, and the other for paths that have been tracked over more than once.
That part was sort of simple.
This "missing link" has been difficult to figure out how to store in the path list.
As I write this I'm thinking maybe if all adjacent array elements are "open" (ie. open or a breadcrumb) I could just store it in the list. That seems simplest.
But I will provide some illustrations just for good measure
The red being the path which has only been tracked over once. Every right angle in both of these pictures is a PathElement node because it gets stored when the computer makes a turn.
The worst path photo changes colors every time it begins backtracking. The blue square is where the first photo's path ends, and the worst path begings. The purple is the terminal path.
I just need an easier way to find that intersection just south of the F circled in black. It does not currently findable in my list because even though it is a turn, it only shows up once (after making the green turn headed west it does not make a turn coming back instead taking the purple path straight through it).