I am having a problem with a algorithm that is designed to solve mazes.
I used an algorithm from here.http://www.cs.bu.edu/teaching/alg/maze/
FIND-PATH(x, y)
- if (x,y outside maze) return false
- if (x,y is goal) return true
- if (x,y not open) return false
- mark x,y as part of solution path
- if (FIND-PATH(North of x,y) == true) return true
- if (FIND-PATH(East of x,y) == true) return true
- if (FIND-PATH(South of x,y) == true) return true
- if (FIND-PATH(West of x,y) == true) return true
- unmark x,y as part of solution path
- return false
It is a recursive solution , i modified it such that it will continue even after finding exit so that it can find other solutions as well. It seems to work , just that it seems to find half the total number of solutions that i know are possible.
- if (x,y is goal) return true is changed to return false.
Anyone know what might be the problem with such an algorithm resulting in half the number of total possible solutions? I also have a problem into finding the total number of dead end paths, any suggestions on that?