CS475 Project 2, Fall 1998 Due: Tuesday, November 10. PROBLEM STATEMENT ----------------- Students, your mission is to save a party of lost souls on an uncharted island. Each member of the party has a particular skill that may or may not actually be helpful in building a raft to get off the island. In addition, a variety of resources is available. Unfortunately, no one in the party has knowledge of artificial intelligence -- this is where you come in. Your task is to design a situation-calculus description of the problem and use it to determine how to achieve the goal. Prolog will be used to define the world and the agents, objects, etc. within it. There is a guaranteed solution to the problem; what you must infer is the plan of how to go about reaching it. To this end, many of the concepts covered so far in class will be used. Each agent has a single skill. An agent is able to make use of that skill only if it has the necessary tool(s) and material(s) at the right place and time. For example, a lumberjack cuts trees. For him to do that, he must be in the forest and possess an axe. To satisfy these preconditions, he must acquire an axe and then find his way to the forest (or be in the forest and have the axe brought to him). The axe is made by the blacksmith, who needs iron nuggets. The nuggets are acquired by the miner, who must find some, and so on. You might find it helpful to draw some kind of dependency graph showing how the agents interact (in fact, this is basically what you're implementing with the program). To make life more difficult, there is a thief among the agents, who does not contribute to the solution. Giving any item to him results in the item no longer being available for the solution. You may not encode a rule saying "don't give the thief anything" (assume that the agents do not know he is a thief). Your task is to design a Prolog program that saves these AI-illiterate people. Your output should show the plans (i.e., paths) that reach the goal. There could be a number of valid solutions, in which case you should show them all. SPECIFICATIONS -------------- Preconditions are requirements that must be met before an action can take place. Postconditions are the state of affairs after the action has occurred. The order of conditions shown here is not important. You can treat moving as a primitive action. That is, you do not need to represent directions or distances. Try placing agents at different starting positions (these can be hardcoded in the program, or randomized, if you can figure out how to do that). Agents also need to transfer possession of their objects to other agents (e.g., the miner gives the nuggets to the blacksmith). This could have the following structure: precondition: 1) agent 1 has the item 2) agent 1 is at position x 3) agent 2 is at position x postcondition: 1) agent 1 no longer has the item 2) agent 1 is still at position x 3) agent 2 is still at position x 4) agent 2 has the item you may want to prevent agent 2 from giving the item back to agent 1 on the next move, since the conditions above will still hold Agents ------ miner: preconditions: to acquire the nuggets for the blacksmith... 1) the agent is in the cave 2) there are nuggets in the cave postconditions: after picking up the nuggets... 1) the agent is still in cave 2) there is no nugget in the cave 3) the agent has the nugget blacksmith: preconditions: to make the axe for the carpenter... 1) the agent has the nugget postconditions: after making the axe... 1) the agent no longer has the nugget 2) the agent has the axe lumberjack: preconditions: to make lumber for the carpenter... 1) the agent is in the forest 2) the agent has the axe postconditions: after making lumber... 1) the agent is still in the forest 2) the agent still has the axe 3) the agent has lumber (don't worry about how he carries it all) engineer: preconditions: to make the plan to build the raft... none (meaning the agent can make the plan at any time. You may want to start with this state) postconditions: after making the plan... 1) the engineer has the plan for the raft carpenter preconditions: to build the raft... 1) the agent has the plan for the raft 2) the agent has the lumber 3) the agent has the axe postconditions: after building the raft... 1) the agent still has the plan for the raft 2) the agent has no more lumber 3) the agent still has the axe 4) the agent has the raft thief preconditions: to steal something... none, except for the requirements to transfer possession postconditions: 1) the agent keeps whatever he is given (you do not have to record what he has collected, since he will not use any of it or give it to anyone else) Items ----- axe - made from the nugget found in the cave nugget - found in the cave; needed for the axe plan - made by the engineer; used by the carpenter lumber - made by the lumberjack; needed by the carpenter raft - made by the carpenter from the lumber using the plan Locations --------- cave - contains the nugget (just lying around, so there is no need for tools to acquire them) forest - trees there which the lumberjack can cut down with the axe raft - everyone on-board before sailing home Goal State ---------- 1) the carpenter has the raft 2) everyone is on the raft (i.e., at the location of the carpenter. Do not worry about dragging it to the water, etc.) HAND IN: -------- Send your source code to Dan, and hand in a hardcopy of your prolog rules and a typescript showing interesting runs of your system. In addition, write a report about your solution, including a dictionary of your predicate and function symbols. **It is fine to add to the specification, as long as you explain your additions clearly in your documentation, and as long as you don't thereby make the problem too easy. **Also, start early, and feel free to bring up questions and issues in class. RUNNING PROLOG: --------------- Run Prolog with the sicstus command. It is available on the solaris and linux machines. You will see prompt: | ?- To load the file myfile.pl, enter the following at the probmt. [myfile]. Control D will exit you from the system.