hey everyone,
got a small problem with prolog : I'm trying to create a basic graph searching algorythm (I want to reach A from B and I have the rule connection(X,Y))and I think the variables aren't getting instanced:
%direct link between the 2
i_aux(Loc1, Loc2, Visited, [Loc2|Visited]) :-
connection(Loc1, Loc2).
%non direct link between the 2
i_aux(Loc1, Loc2, Visited, Path) :-
connection(Loc1, Loc_Aux),
Loc_Aux \== Loc1,
Loc_Aux \== Loc2,
\+member(Loc_Aux, Visited),
i_aux(Loc_aux, Loc2, [Loc_aux | Visited], Path).
When I call the i_aux recursively in "i_aux(Loc_aux, Loc2, [Loc_aux | Visited], Path)." it seems to update the visited variable poorly. When I trace it the list becomes a sequence of repetetive variables: How do I get it to become instanced ?
got a small problem with prolog : I'm trying to create a basic graph searching algorythm (I want to reach A from B and I have the rule connection(X,Y))and I think the variables aren't getting instanced:
%direct link between the 2
i_aux(Loc1, Loc2, Visited, [Loc2|Visited]) :-
connection(Loc1, Loc2).
%non direct link between the 2
i_aux(Loc1, Loc2, Visited, Path) :-
connection(Loc1, Loc_Aux),
Loc_Aux \== Loc1,
Loc_Aux \== Loc2,
\+member(Loc_Aux, Visited),
i_aux(Loc_aux, Loc2, [Loc_aux | Visited], Path).
When I call the i_aux recursively in "i_aux(Loc_aux, Loc2, [Loc_aux | Visited], Path)." it seems to update the visited variable poorly. When I trace it the list becomes a sequence of repetetive variables: How do I get it to become instanced ?