3. Consider a more ambitious version of the monkey and bananas problem. In this version, the monkey...
Question:
3. Consider a more ambitious version of the monkey and bananas problem. In this version, the monkey cannot reach the bananas even if he is on the box. However, there is a big stick located in a corner of the room that can be used to knock the bananas down when the monkey has the stick and is on the box under the bananas. The monkey can pick up or drop the stick, and can climb on the box while holding the stick. But the stick is bulky, and he can only push the box if he is not carrying the stick.
In this variant, a state can be represented using a list [b,m,l,o,h,s,c], which has two more components than the list in section 9.2.4: s stands for the current location of the stick, and c is y or n according to whether or not the monkey is carrying the stick. The actions available are climb_on, climb_off, go(x), and push(x), as before, and three new actions involving the stick: pick_up_stick, drop_stick, and swing_stick. (The grab action is omitted, since it no longer accomplishes anything.)
Formulate this version of the problem in Prolog and use the plan predicate to find a seven-step sequence of actions the monkey can do to get the bananas.
You will need to write clauses for the initial state and goal state, as well as legal_move clauses for each of the actions. For the first four actions, you can adapt the solution presented in section 9.2.4, but note that you now have to worry about the state of the stick. For example, going to a location changes the location of the stick if the monkey happens to be carrying it.
Step by Step Answer: