Note: I already have a method of randomly generating a maze, found here:
https://en.wikipedia.org/wiki/Loop-erased_random_walk
I'm looking for an algorithm to find the two farthest cells in the completed randomly generated maze. I don't mean the farthest, as in if you were to draw a straight line from one cell to another, the line would have the longest length. That would always result in one of two things:
The top-left cell and the bottom-right cell are chosen.
The top-right cell and the bottom-left cell are chosen.
I intend to find an algorithm to find the two cells that if you were to travel from the first cell to the second cell by one adjacent cell at a time (up, down, left, or right), while not passing through the walls of the maze, it would require you to travel through the most cells.
Example of Randomly Generated Maze Using the Algorithm Found in the Link Above
Thank you in advance.
A maze generated by the algorithm you're using is always a tree. The longest path in a tree is called its diameter, and if you google "diameter of a tree", you'll find algorithms that work.
The one I suggest for mazes is:
B-C is a diameter of your tree.