Question: The predicate solve() should be written in Prolog and only use the basic built-in functions. This question entails a farmer, a wolf, a goat, and

 The predicate solve() should be written in Prolog and only use

The predicate solve() should be written in Prolog and only use the basic built-in functions.

This question entails a farmer, a wolf, a goat, and a cabbage. All four are near a river The farmer has a boat that can carry only one of the other three Each of the four might initially be on either the left or right bank of the river The farmer is tasked with moving all four of them from some initial configuration to a given final configuration For example, all four of them might initially be on the left bank, and the farmer needs to use the boat so that they end up in the configuration in which all four of them are on the right bank of the river However, if the wolf and the goat are on the same river bank without the farmer, the wolf will eat the goat. If the goat and the cabbage are on the same river bank without the farmer, the goat wl eat the cabbage Thus, the farmer should avoid such unsafe configurations For example, it is possible to move farmer, wolf, goat and cabbage from left bank to right bank by avoiding the above unsafe configurations It is NOT possible to start with the farmer and cabbage on the left bank and the wolf and goat on the right bank, and then end with farmer, wolf, goat and cabbage on the right bank. (The wolf will eat the goat when they are alone on the right bank without the farmer It is NOT possible to start with farmer, wolf, goat and cabbage on the left bank, and end up with the farmer and wolf on the right bank, and the goat and cabbage on the left bank. (The goat will eat the cabbage when they are alone on the left bank without the farmer The terms left and right denote the left and right banks of the river . Complete the definition of the predicate solve (F1, W1, G1, C1, F2, W2 ,G2 ,C2) in hw4-handout/puzzle/puzzle.pl, which is true if and only if there exists a way to go from the initial state of the farmer (F1), wolf (W1), goat (G1), and cabbage (C1) to their respective final state F2, W2, G2 and C2 For example, solve (left, left, left, left, right, right, right, right) re- turns true This question entails a farmer, a wolf, a goat, and a cabbage. All four are near a river The farmer has a boat that can carry only one of the other three Each of the four might initially be on either the left or right bank of the river The farmer is tasked with moving all four of them from some initial configuration to a given final configuration For example, all four of them might initially be on the left bank, and the farmer needs to use the boat so that they end up in the configuration in which all four of them are on the right bank of the river However, if the wolf and the goat are on the same river bank without the farmer, the wolf will eat the goat. If the goat and the cabbage are on the same river bank without the farmer, the goat wl eat the cabbage Thus, the farmer should avoid such unsafe configurations For example, it is possible to move farmer, wolf, goat and cabbage from left bank to right bank by avoiding the above unsafe configurations It is NOT possible to start with the farmer and cabbage on the left bank and the wolf and goat on the right bank, and then end with farmer, wolf, goat and cabbage on the right bank. (The wolf will eat the goat when they are alone on the right bank without the farmer It is NOT possible to start with farmer, wolf, goat and cabbage on the left bank, and end up with the farmer and wolf on the right bank, and the goat and cabbage on the left bank. (The goat will eat the cabbage when they are alone on the left bank without the farmer The terms left and right denote the left and right banks of the river . Complete the definition of the predicate solve (F1, W1, G1, C1, F2, W2 ,G2 ,C2) in hw4-handout/puzzle/puzzle.pl, which is true if and only if there exists a way to go from the initial state of the farmer (F1), wolf (W1), goat (G1), and cabbage (C1) to their respective final state F2, W2, G2 and C2 For example, solve (left, left, left, left, right, right, right, right) re- turns true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!