First of all id like to register my absolute disgust for this language, it's so frustrating.
Anyway. Basically I'm trying to use a recursive procedure and for some reason it never ends.
The task is on a 3x3 grid move from location X1,Y1 to X2,Y2, logging the steps taken in Path.
It executes ok but when it comes to the termination clause, X1==X2 it fails as expected, the recursive iteration fails, but then it calls a redo on something and carries on!
Any ideas?
Anyway. Basically I'm trying to use a recursive procedure and for some reason it never ends.
The task is on a 3x3 grid move from location X1,Y1 to X2,Y2, logging the steps taken in Path.
Code:
simple_move(at(X1,Y1), at(X2,Y2),Path) :-
map_size(Map), %size of map
X1\=X2, %check if found X value
XStep is (X1+1) mod Map, %step right one space
cost(at(X1,Y1),at(XStep,Y1),Cost), %determine cost of step
append(Path,[step(at(X1,Y1),at(XStep,Y1),Cost)],New_Path), %add step to list of previous steps
simple_move(at(XStep,Y1),at(X2,Y2),New_Path). %make next move
It executes ok but when it comes to the termination clause, X1==X2 it fails as expected, the recursive iteration fails, but then it calls a redo on something and carries on!
Any ideas?