[SOLVED] prolog代写:THE GARDEN PHOTOGRAPH PROBLEM

30 $

File Name: prolog代写:THE_GARDEN_PHOTOGRAPH_PROBLEM.zip
File Size: 414.48 KB

SKU: 2555597290 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


THE GARDEN PHOTOGRAPH PROBLEM
A photographer wants to take a photograph of her garden. Initially she is in her car, her camera is in her house, and the camera is switched off. The photographer can do any of the following actions:
Take a picture of the garden (provided she is in the garden holding the camera, and the camera is switched on).
Turn on the camera (provided she is holding the camera and it is switched off).
Pick up the camera (provided she is in the same place as the camera).
Go from one place (the car, the house or the garden) to another.
Put down the camera (provided she is holding the camera).
Turn off the camera (provided she is holding the camera and it is switched on).
The Garden Photograph Problem is the problem of finding a sequence of actions that the photographer can perform to end up with a photograph of her garden. (For simplicity it is assumed that the camera never runs out of memory or battery life.)
A Prolog program (see attached below) has been partially written to solve this problem. In this program the state of the photographer’s environment is represented by a ‘state’ term in which the functor ‘state’ takes five arguments as follows:
state(
Photographer_location,       % house, garden or car
Camera_location,             % house, garden or car
Holding_camera_or_not,       % holding or notHolding
Camera_on_or_off,            % on or off
Photo_taken_or_not           % photoTaken or photoNotTaken
)
The possible actions of the photographer are represented with the following six terms:
takeGardenPhoto
turnOn
pickUp
go(From, To)
putDown
turnOff
The completed program will consist of definitions for the predicates ‘place/1’, ‘can_do/3’ and ‘can_photo_garden/3’. The definitions for ‘place/1’ and ‘can_photo_garden/3’ are already complete and are as follows:
place(garden).
place(house).
place(car).
can_photo_garden(state(W, X , Y, Z, photoTaken), [], States_so_far).
can_photo_garden(State, [Action|Plan_for_state_after], States_so_far):-
can_do(State, Action, State_after),
+ member(State_after, States_so_far),
can_photo_garden(State_after, Plan_for_state_after, [State_after|States_so_far]).
Complete the program by adding clauses for ‘can_do/3’ that describe the effects of each of the individual actions above. The first argument of ‘can_do/3’ represents the state before the action has been performed, the second argument is the action name, and the third argument represents the state after the action has been performed. A clause for the action ‘takeGardenPhoto’ has already been added:
can_do(state(garden, garden, holding, on, Photo_taken_or_not),
takeGardenPhoto,
state(garden, garden, holding, on, photoTaken)).
The completed program should be able to produce input/output similar to the following:
?- can_photo_garden(state(car, house, notHolding, off, photoNotTaken),
Plan, [state(car, house, notHolding, off, photoNotTaken)]).
Plan = [go(car, garden), go(garden, house), pickUp, turnOn,
go(house, garden), takeGardenPhoto] ;
…..
Optionally, but only once you have completed the main programming task above, you may add extra code that enhances the program in some other way(s), for example by allowing the user to input alternative starting states for the problem, or by causing plans to be output in a natural-language-style format. But do not include enhancements that involve altering the definitions of ‘place/1’, ‘can_do/3’ or ‘can_photo_garden/3’ in any way.
attachment:
THE GARDEN PHOTOGRAPH PROBLEM
A photographer wants to take a photograph of her garden. Initially she is in his car, her camera is
in her house, and the camera is switched off. The photographer can do any of the following actions:
(1) Take a picture of the garden (provided she is in the garden holding the camera, and the camera is switched on).
(2) Turn on the camera (provided she is holding the camera and it is switched off).
(3) Pick up the camera (provided she is in the same place as the camera).
(4) Go from one place (the car, the house or the garden) to another.
(5) Put down the camera (provided she is holding the camera).
(6) Turn off the camera (provided she is holding the camera and it is switched on).
What must the photographer do to have a photograph of her garden?
In this program, “state” takes 5 arguments with intended possible values as follows:
state(
Photographer_location       % house, garden, car
Camera_location             % house, garden, car
Holding_camera_or_not       % holding, notHolding
Camera_on_or_off            % on, off
Photo_taken_or_not          % photoTaken, photoNotTaken
)
The second argument of “can_do” is intended to be one of the following 6 actions:
takeGardenPhoto        % take a photograph
turnOn                 % turn on the camera
pickUp                 % pick up the camera
go(From, To)           % go from one place to another
putDown                % put down the camera
turnOff                % turn off the camera
EXAMPLE QUERY:
can_photo_garden(state(car, house, notHolding, off, photoNotTaken), Plan, [state(car, house, notHolding, off, photoNotTaken)]).
*/
place(garden).
place(house).
place(car).
can_do(state(garden, garden, holding, on, Photo_taken_or_not),
takeGardenPhoto,
state(garden, garden, holding, on, photoTaken)).
% MORE can_do CLAUSES NEED TO BE ADDED HERE
can_photo_garden(state(W, X , Y, Z, photoTaken), [], States_so_far).
can_photo_garden(State, [Action|Plan_for_state_after], States_so_far):-
can_do(State, Action, State_after),
+ member(State_after, States_so_far),
can_photo_garden(State_after, Plan_for_state_after, [State_after|States_so_far]).

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] prolog代写:THE GARDEN PHOTOGRAPH PROBLEM
30 $