% Waterjug.pl 2.0    Jeroen Kruse  2 mei 1996

waterjug:-
	init(State1,State2),
	dfs([State1, State2], 10).
	
% HIER KOMT DE REST VAN HET PROGRAMMA


init(Stat1,Stat2):-
	Stat1 is 0,
        Stat2 is 0.

goal(Sta2):-
	Sta2 =:= 2.

list_new_states(Csta1,Csta2,List9):-
        leeg(List),!,
        ((Csta1 =\= 0,voegtoe(0,Csta2,List,List2));
	(List2=List)),!,
        ((Csta2=\=0,voegtoe(Csta1,0,List2,List3));
        (List3=List2)),!,
        ((Csta1=\=3,voegtoe(3,Csta2,List3,List4));
        (List4=List3)),!,
        ((Csta2=\=4,voegtoe(Csta1,4,List4,List5));
        (List5=List4)),!,
        ((Csta1=\=3,Csta1+Csta2=<3,Q is Csta1+Csta2,voegtoe(Q,0,List5,List6));
        (List6=List5)),!,
        ((Csta1=\=3,Csta1+Csta2>3,Q1 is Csta1+Csta2-3,voegtoe(3,Q1,List6,List7));
        (List7=List6)),!,
        ((Csta2=\=4,Csta1+Csta2=<4,Q3 is Csta1+Csta2,voegtoe(0,Q3,List7,List8));
        (List8=List7)),!,
        ((Csta2=\=4,Csta1+Csta2>4,Q2 is Csta1+Csta2-4,voegtoe(Q2,4,List8,List9));
        (List9=List8)).
        
voegtoe(A,B,[],[[A,B]]).
voegtoe(A,B,C,[[A,B]|C]).
leeg([]).


