backTrack ( stateList )
======================
state = first element of stateList
if state is a member of the rest of stateList, return 'FAILED-l
if deadEnd?(state) return 'FAILED-2
if goal(state), return NULL
if length(stateList) > depthBound, return 'FAILED-3
ruleSet = applicableRules(state)
if ruleSet == NULL, return 'FAILED-4
for each rule r in ruleSet,
newState = applyRule(r,state)
newStateList = addToFront(newState,stateList)
path = backTrack(newStateList)
if path != 'FAILED return append(path,r)
return 'FAILED-5
So this is the backTrack algorithm I am working with. I need some help modifying it. I want it, instead of returning a solution path when found, to just print that it found one and keep going searching for other solution paths, then returning the last one that it finds, or FAILED if that was the only one it could find.
Any ideas? I have tried a lot of different things but I am stuck. By the way, this is pseudo code, so I have not done any formal testing but I just need some ideas.