Attachment 'strips2.pl'

Download

   1 /* STRIPS programmé par Jean-Gabriel Ganascia */
   2 
   3 
   4 test(Plan):- etat_initial(I), etat_final(F), resoudre(I, [F], Plan).
   5 
   6 resoudre(_, [], []).
   7 resoudre(Etat, [L|Buts], Plan) :- is_list(L), subset(L, Etat), !, marquer(1, Etat, Buts, Plan), resoudre(Etat,Buts,Plan).
   8 resoudre(Etat, [L|Buts], Plan) :- is_list(L), !, subtract(L, Etat, LL), append(LL, [L|Buts], NButs), marquer(2, Etat, NButs, Plan), resoudre(Etat, NButs, Plan).
   9 resoudre(Etat, [operateur(Op)|Buts], [Op|Plan]) :- !, appliquer_operateur(Etat, Op, NEtat), marquer(3, NEtat, Buts, Plan), resoudre(NEtat, Buts, Plan).
  10 resoudre(Etat, [But|Buts], Plan) :- member(But, Etat), !,marquer(4, Etat, Buts, Plan), resoudre(Etat, Buts, Plan).
  11 resoudre(Etat, [But|Buts], Plan) :- trouver_operateur(Etat, But, Op, P), intersection(P, Buts, []), operateur(Op, Preconds, _,_), marquer(5, Etat, [Preconds,operateur(Op),But|Buts], Plan), resoudre(Etat, [Preconds,operateur(Op),But|Buts], Plan).
  12 
  13 marquer(N, E, B, P):- write('Appel prédicat résoudre '), write(N), nl, write('\tEtat: '), write(E), write('; Plan: '), write(P), nl, write('\tButs: '), write(B), nl.
  14 trouver_operateur(Etat, But, Op, []) :- clause(operateur(Op, Preconds, _, AListe),Q), member(But, AListe), soustraction(Preconds, Etat,[]), call(Q), term_variables(Op,[]).
  15 trouver_operateur(Etat, But, Op, [T|S]) :- clause(operateur(Op, Preconds, _, AListe),Q), member(But, AListe), soustraction(Preconds, Etat,[T|S]), call(Q), term_variables(Op,[]).
  16 
  17 appliquer_operateur(Etat, Op, NEtat) :- operateur(Op, _, Dliste, Aliste), subtract(Etat, Dliste, DEtat), union(DEtat, Aliste, NEtat), write('Application opérateur '), write(Op), write('\n\tNouvel état: '), write(NEtat), nl.
  18 
  19 soustraction([], _, []).
  20 soustraction([X|L], D, LL) :- member(X, D), soustraction(L, D, LL).
  21 soustraction([X|L], D, [X|LL]) :- soustraction(L, D, LL).
  22 
  23 /************* Monde des blocs****************/
  24 /*etat_initial([sur_table(a), sur_table(b), sur(c, a), libre(b), libre(c), poignet_vide, bloc(a), bloc(b), bloc(c)]).*/
  25 /*etat_initial([sur_table(a), sur_table(b), sur_table(c), libre(a), libre(b), libre(c), poignet_vide, bloc(a), bloc(b), bloc(c)]).*/
  26 etat_initial([sur_table(a), sur_table(b), sur(c, a), libre(b), libre(c), poignet_vide, bloc(a), bloc(b), bloc(c)]).
  27 /*etat_initial([sur_table(a), sur_table(b), sur(c, b), libre(c), libre(a), poignet_vide, bloc(a), bloc(b), bloc(c)]).*/
  28 
  29 
  30 /*etat_final([sur_table(a), sur(c,b), sur(b, a), libre(c), poignet_vide]).*/
  31 etat_final([sur_table(a), sur(b, a), sur(c ,b), libre(c), poignet_vide]).
  32 
  33 operateur(deposer(B), [poignet_prise(B)], [poignet_prise(B)], [poignet_vide, sur_table(B),libre(B)]).
  34 operateur(depiler(B, C), [poignet_vide, bloc(B), libre(B), sur(B, C)], [poignet_vide, libre(B), sur(B, C)], [poignet_prise(B), libre(C)]):- \+ B == C.
  35 operateur(prendre(B), [poignet_vide, bloc(B), libre(B), sur_table(B)], [poignet_vide, libre(B), sur_table(B)], [poignet_prise(B)]).
  36 operateur(empiler(B,C), [poignet_prise(B), bloc(B), bloc(C), libre(C)], [poignet_prise(B), libre(C)], [poignet_vide, sur(B, C),libre(B)]):- \+ B == C.

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.