From 0937e66efb548c4bdc92c305bbca7a512c79d933 Mon Sep 17 00:00:00 2001 From: Nabzzz Date: Sun, 21 Feb 2021 18:50:08 +0100 Subject: [PATCH] =?UTF-8?q?Affichage=20corrig=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TP1.pl | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/TP1.pl b/TP1.pl index c077636..94bb4ab 100644 --- a/TP1.pl +++ b/TP1.pl @@ -693,7 +693,7 @@ main :- insert([[H,H,0],S0],Pf0,Pf), % CORRECT insert([S0,[H,H,0],nil,nil],Pu0,Pu), % CORRECT % lancement de Aetoile - aetoile(Pf,Pu,Q). + aetoile(Pf,Pu,Q), !. %******************************************************************************* aetoile(Pf, Pu, _) :- @@ -707,10 +707,6 @@ aetoile(Pf, _, Qs) :- suppress([Fin,[F,H,G],Pere,Action],_Pu,_Pu_new), write("Solution trouvée !"), writeln(""), - write("Pere = "),print(Pere), - writeln(""), - write("Action = "),print(Action), - writeln(""), affiche_solution([Fin,[F,H,G],Pere,Action], Qs). aetoile(Pf, Pu, Qs) :- @@ -740,28 +736,28 @@ expand(U,G,L):- findall(U3,(rule(Action,1,U,U2),heuristique(U2,H), F is H+G+1, G -affiche_solution([_,_,nil,nil],_) :- write(1). +affiche_solution([Debut,_,nil,nil],_) :- + initial_state(Debut), + write("Etat initial : "). + +affiche_solution(State,Qs) :- + State = [U,[_,_,G],Pere,Action], + final_state(U), + suppress([Pere,Cout,Pere1,Action1],Qs, Qs_new), + affiche_solution([Pere,Cout,Pere1,Action1],Qs_new), + writeln(""), + write("Final state : "), + print(U). affiche_solution(State,Qs):- State = [U,[_,_,G],Pere,Action], - print(U), + suppress([Pere,Cout,Pere1,Action1],Qs, Qs_new), + affiche_solution([Pere,Cout,Pere1,Action1],Qs_new), + print(U), writeln(""), write("Cout = "), print(G), writeln(""), - write("Action = "), print(Action), - writeln(""), - write(1), - writeln(""), - suppress([Pere,Cout,Pere1,Action1],Qs, Qs_new), - write(2), - writeln(""), - write("Pere = "),print(Pere), - writeln(""), - write("Pere1 = "),print(Pere1), - writeln(""), - write("Action1 = "),print(Action1), - writeln(""), - affiche_solution([Pere,Cout,Pere1,Action1],Qs_new). + write("Action = "), print(Action).