question archive Consider the following well-known problem:   In his yard, a farmer has a fox, a hen, and a bushel of grain

Consider the following well-known problem:   In his yard, a farmer has a fox, a hen, and a bushel of grain

Subject:Computer SciencePrice:9.82 Bought3

Consider the following well-known problem:
 

In his yard, a farmer has a fox, a hen, and a bushel of grain. The farmer must transfer all these things to a stall at the market, using only a cart which can carry at most one of them (plus himself) at a time. The problem is that if the farmer leaves the fox unattended with the hen, it will eat the hen. Similarly, if the hen is left unattended with the grain, it will eat the grain.

Is there a way for the farmer (without helpers) to transfer all three items to market without any of them getting eaten?


Use Prolog to solve this as a planning problem using the plan predicate. A state can be represented by a list with four elements, [fox, hen, grain, cart], where each of these elements is a location: either yard or market. (Assume that the farmer is always with the cart.) A move is either go_alone(loc) or go_with(item, loc) where loc is a location and item is one of fox, hen, or grain. A move should not be legal if something will get eaten in the resulting state.


a. Define a predicate safe_state(s) that holds whenever s is a state where nothing will be eaten. So [yard,yard,market,yard] is considered to be a safe state, but [yard,market,market,yard] is not because the hen is with the grain unattended.

b. Define the predicate legal_move using the safe_state predicate.

c. Define initial_state and goal_state, and use the plan predicate to find a seven-step solution.

Option 1

Low Cost Option
Download this past answer in few clicks

9.82 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 3 times

Completion Status 100%

Related Questions