Maze solving with path drawing

7 vues (au cours des 30 derniers jours)
Shizuka
Shizuka le 2 Mar 2013
I've been using the maze_solution function from Image Analyst http://www.mathworks.com/matlabcentral/fileexchange/27175-mazesolution for a while without problems. There are a few limitations: the maze has to be perfect and without circular paths.
That being said, it generally works very well when I test it, let me provide you with two examples of outputs:
Now let me put some rules that are not obvious about my mazes:
  1. 1) There are no circular paths (there are some that are trapped in the walls, but no one that the the maze solver would run into).
  2. 2) They begin always at the top left, and then there are four exits in the same coordinates every time.
  3. 3) There is always only one exit.
So, what I would like to do is, let's consider the first screenshot. It works well and 'finds' the exit, is there any way to make mat lab pop up a messagebox (using msgbox(), for instance) and tell me "A", "B", "C" or "D"? I already thought about this for a long while, but found no solution. One of the solutions I thought about was, in pseudocode:
if CertainCoordinate = red pixel
return A
Whereas CertainCoordinate Could be the unchangeable coordinate of A, B,C and D (Then I would use 4 'ifs'), but I don't really know how to implement even that. Any ideas or... something to point me in the right direction?
Secondly, I was trying to solve the second ScreenShot's problem, it's not really a problem since it finds the exit, but it goes berserk afterwards, so I thought of coloring the two white bands (with the letters) as black bands, this way MatLab wouldn't be confused and think those are walls. Would this be a viable solution?
Thanks in advance!
  3 commentaires
Image Analyst
Image Analyst le 2 Mar 2013
message = sprintf('Hey User!\nI Actually found the answer,\nit's %f!', B);
uiwait(helpdlg(message));
Image Analyst
Image Analyst le 2 Mar 2013
You could have a list of what pixels are exits. Then label the path(s) and call regionprops. If a pixel coordinate on the labeled blob is on the "exit list" and "entrance list" then that path (blob) is a solution. You can get the coordinates from the 'PixelList' measurement of regionprops().

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 2 Mar 2013
You could have a list of what pixels are exits. Then label the path(s) and call regionprops. If a pixel coordinate on the labeled blob is on the "exit list" and "entrance list" then that path (blob) is a solution. You can get the coordinates from the 'PixelList' measurement of regionprops().
  3 commentaires
Image Analyst
Image Analyst le 3 Mar 2013
Not really. Of course it contains everything. Now you need to compare that against KNOWN exit locations. The paths don't know where the exits are, you have to tell it. A path just has a start and a stop but the endpoints don't know whether they're inside the maze or outside the maze unless you find out where the maze boundaries are and check for both endpoints being outside of that.
Image Analyst
Image Analyst le 4 Mar 2013
Sorry, I'm not going to be able to devote more time in solving this for you. I have very limited time for devoting to one discussion.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by