程序代写 CPS 721 Quiz 8

CPS 721 Quiz 8
2021 Practice Version
(not shared) Switch account
The wolf, the goat, and the cabbage

Copyright By PowCoder代写 加微信 powcoder

In this famous problem, a farmer must transport a wolf, a goat, and a cabbage across a river by boat. The farmer can only paddle one of them across at a time, and cannot leave the wolf alone with the goat, nor the goat alone with the cabbage.
Let the state for this problem be represented by a list of 4 elements, [Farmer, Cabbage, Goat, Wolf], where each element is either ‘near’ or ‘far’, representing which shore each entity is on.
The possible actions for this domain are listed below:
transportNothing – the farmer rows to the opposite shore of the river alone transportCabbage – the farmer rows to the opposite shore of the river with the cabbage transportGoat – the farmer rows to the opposite shore of the river with the goat transportWolf – the farmer rows to the opposite shore of the river with the wolf

Select *both* of the valid legal_move predicates which fully capture the rules for transporting the cabbage across the river. (Select exactly 2, correct answers will be adjacent)
legal_move([far, far, G, W], transportCabbage, [near, near, G, W]):- not G = W. legal_move([near, near, G, W], transportCabbage, [far, far, G, W]):- not G = W.
legal_move([F2, C2, G2, W2], transportCabbage, [F1, C1, G1, W1]):- not F1 = F2, not C1 = C2, G1 = G2, W1 = W2.
legal_move([F2, C2, G2, W2], transportCabbage, [F1, C1, G1, W1]):- F1 = F2, C1 = C2, not G1 = G2, not W1 = W2.
legal_move([F2, C2, G2, W2], transportCabbage, [F1, C1, G1, W1]):- F2 = C2, not G2 = W2.
legal_move([F2, C2, G2, W2], transportCabbage, [F1, C1, G1, W1]):- F1 = C1, not G1 = W1.
legal_move([F2, C2, far, near], transportCabbage, [F1, C1, far, near]):- F1 = C1, F2 = C2. legal_move([F2, C2, near, far], transportCabbage, [F1, C1, near, far]):- F1 = C1, F2 = C2.
Select *both* of the valid legal_move predicates which fully capture the rules for rowing across the river alone. (Select exactly 2, correct answers will be adjacent)
legal_move([F2, near, far, near], transportNothing, [F1, near, far, near]).
legal_move([F2, far, near, far], transportNothing, [F1, far, near, far]).
legal_move([F2, C, G, W], transportNothing, [F1, C, G, W]):- F2 = G.
legal_move([F2, C, G, W], transportNothing, [F1, C, G, W]):- F1 = G, not G = C, not G = W.
legal_move([far, C, G, W], transportNothing, [near, C, G, W]):- not G = C, not G = W.
legal_move([near, C, G, W], transportNothing, [far, C, G, W]):- not G = C, not G = W.
legal_move([F2, C2, G2, W2], transportNothing, [F1, C1, G1, W1]):- not F1 = F2, C1 = C2, G1 = G2, W1 = W2.
legal_move([F2, C2, G2, W2], transportNothing, [F1, C1, G1, W1]):- F1 = F2, not C1 = C2, not G1 = G2, not W1 = W2.

Which of the following best describes the actions in this domain (i.e. transportCabbage, transportGoat, etc.)
They are Prolog facts They are Prolog rules They are Prolog lists They are Prolog variables They are Prolog terms
How many different legal_move rules must be written to fully capture the desired behaviour for this domain?
4 7 8 9 10
Clear form
This form was created inside of . Report Abuse Forms

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