% Prolog Challenge 2 Part 3 - Kaitlyn Jesmonth

% Connected Spots
spot([1,2]).
spot([2,3]).
spot([3,5]).
spot([5,6]).
spot([6,7]).
spot([7,4]).
spot([7,9]).
spot([9,12]).
spot([5,8]).
spot([8,11]).
spot([11,10]).
spot([10,13]).

% start / end
start([1,2]).
end([10,13]).

% move
move([CurrX, CurrY], [CurrY, NextY]) :- spot([CurrY, NextY]).

% A solution of the maze from our current location is [] if our current location is the end.
solve(CurrentLocation, _, Path) :- end(CurrentLocation), Path = [CurrentLocation].

% Convenience Rule
solve(Path) :- start(Start), solve(Start, [Start], Path).


solve(CurrentLocation, _, Path) :-  move(CurrentLocation, NewLocation), spot(NewLocation),
	solve(NewLocation, _, NewPath), Path = [CurrentLocation | NewPath].

/*
	For this part of the assigment, I attempted to change the way we represented the maze. Instead
	of representing the maze as X,Y coordinates based on position, I decided to attempt to represent
	the maze as a set of connected squares with numbers. As an example, the starting position would 
	be labeled as 1, and the block connected below that would be represented as 2. For each location 
	in the maze that was okay to pass through, a number was given. The numbers went all the way up to 13, 
	since there were 13 spaces that were valid to go through in the maze. The numbers were assigned to 
	blocks starting at the top of the maze, and going from left to right. All valid connected block sets
	were listed out in the knowledge base.
	
	I decided to try this method since this maze was relatively small and I thought that the implementation
	might be a little bit simpler than what we had before. The downfalls of this particular heuristic is that
	if you have a large maze, entering in all the block numbers that are connected might be a very tedious
	process. So, this heuristic is best used when there is a small maze, like in our class example. This
	heuristic was sucessful and as anticipated the implementation was quite simple. If I were to change
	something I might allow that the connected spots can go in the reverse direction to allow for the
	possibility of backtracking. Right now the way I have it, the paths in the maze are only possible
	in a certain one-way direction. Therefore, I think allowing for more freedom of movement might be a nice
	way to improve upon this heuristic. 
*/

