Maze solving with path drawing

7 ビュー (過去 30 日間)
Shizuka
Shizuka 2013 年 3 月 2 日
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 件のコメント
Image Analyst
Image Analyst 2013 年 3 月 2 日
message = sprintf('Hey User!\nI Actually found the answer,\nit's %f!', B);
uiwait(helpdlg(message));
Image Analyst
Image Analyst 2013 年 3 月 2 日
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().

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2013 年 3 月 2 日
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 件のコメント
Image Analyst
Image Analyst 2013 年 3 月 3 日
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 2013 年 3 月 4 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabyrinth problems についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by