CS代考 /* The following declaration is required because predicates are not consecu

/* The following declaration is required because predicates are not consecutive
in the program, and in addition they are distributed over several files. */

:- dynamic screwed/3,holds/2,inPlace/2,partOf/2,turnedOn/2,covers/3,attached/2.

Copyright By PowCoder代写 加微信 powcoder

solve_problem(N,L) :- C0 is cputime,
max_length(L,N),
reachable(S,L),
goal_state(S),
Cf is cputime, D is Cf – C0, nl,
write(‘Elapsed time (sec): ‘), write(D), nl.
max_length([],N) :- N >= 0.
max_length([_|L],N1) :- N1 > 0, N is N1 -1, max_length(L,N).
reachable(S,[]) :- initial_state(S).
/* This recursive rule is for the 1st question only: comment it out later when
you start working on the 2nd question and remove comments from the rule below. */
reachable(S2, [M|List]) :- reachable(S1,List),
legal_move(S2,M,S1).

/* Include the following rule when you use “useless(A,History)”: remove comments
and write your own rules to implement the predicate useless(M,List).
%reachable(S2, [M | ListOfActions]) :- reachable(S1,ListOfActions),
% legal_move(S2,M,S1),
% not useless(M,ListOfActions).

legal_move([A|S], A, S) :- poss(A,S).
initial_state([]).

/* Precondition Axioms */

/* Write here your rules implementing the predicate poss(A,S):
when an action A is possible in S. Write exactly 1 rule per action.
Recall that to avoid potential problems with negation in Prolog,
you should not start bodies of these rules with negated predicates.
Make sure that all variables in a predicate are instantiated by constants
before you apply negation to the predicate that mentions these variables.
Write brief comments explaining your rules.

/* Successor state axioms */

/* Write here your rules implementing what effects actions have on fluents.
Recall that the successor-state axioms characterize how the truth value
of all fluents change from the current situation $S$ to the next
situation [A | S]. You will need two types of rules for each fluent:
(a) rules that characterize when a fluent becomes true
in the next situation as a result of the last action, and
(b) rules that characterize when a fluent remains true
in the next situation, unless the most recent action
changes it to false.
When you write successor state axioms, you can start bodies of rules with
negation of a predicate. Write brief comments explaining your rules.

/* Initial theory */

:- [initFridge].

/* This is to compile also the file initFridge.pl before you
run a query. Do NOT insert this file here because your program
may be tested using different initial and goal states. */

/*—– Declarative heuristics —–*/

% Write below your rules that implement the predciate useles(Action,History).
% Read the assignment for explanations: Part 1, question 2.

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com