Maze solving with path drawing
조회 수: 7 (최근 30일)
이전 댓글 표시
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) 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) They begin always at the top left, and then there are four exits in the same coordinates every time.
- 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
2013년 3월 2일
message = sprintf('Hey User!\nI Actually found the answer,\nit's %f!', B);
uiwait(helpdlg(message));
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
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
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
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 Exchange에서 Labyrinth problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!