Вы находитесь на странице: 1из 8

TRNG I HC BCH KHOA TP.

HCM Khoa Khoa hc & K thut My tnh


ARTIFICIAL INTELLIGENCE ASSIGNMENT 2 Planning - The Monkey and the locked cabinet
I. Introduction

In a room, there is a Monkey who wants to get some bananas from the cabinet. However, the cabinet is on high place and is locked. The key to open cabinet is hanged on another place. He is trying his best to get the key and open the cabinet (Figure 1). The Monkey is not tall enough to take the key or to open the cabinet from the floor, but there are some cubic boxes that he can use as the assistant. There are three kinds of cubic box with the edge length of 20, 40 or 80 cm. The Monkey can push any box around, but he can bring only one 20 cm or 40 cm boxes in his hand. He can also climb on a box, but the maximum height that he can climb (up or down) is just 20 cm. So he may place boxes near each other, so that he can create some kind of ladder. The Monkey can lay one box on another box with the condition that only the smaller box can be on the surface of the other. In addition, the bottom of the smaller box must be completely on the top of the bigger one (not any part of smaller boxs bottom is outside). When the Monkey is moving (go on floor, climb up or climb down), he may or may not bring one thing (box or key) in his hand. The Monkey can only holding one thing in his hand each time.

Figure 1: The monkey and the clocked cabinet 1

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


II.

Requirement

You are required to help that poor Monkey by implementing a planner of which solution will be used to guide the Monkey to get bananas. If you need nonlinear planning knowledge to solve the problem, you must use nonlinear planning by posting constrains to do this task. Actions that the Monkey can do: goto(X,Y) The Monkey moves to the location (X, Y) on the same height coordinate Z. goNear(B) The Monkey moves to the location near box (or key) B (the distance from the Monkey to one side of B is 0). He can do this action only if he and B on the same surface S (floor, box or boxes) or the box B is closed to the boundary of the surface S.

goNear(b1)

Figure 2a: The box and Monkey is on the same surface S

goNear(Bigbox)

Figure 2b: The box B is closed to the boundary of the surface S push(B,X,Y) The Monkey pushes the box B to the location (X, Y) on the same height Z. In this case, he must be at the location where is near the box B, and the top surface of B must be cleared. When the action is finished, the Monkey is still near B. pickup(B) The Monkey picks the box (or key) B up from the surface (floor, box or boxes) and holds it in hands. He can do this action only if he is at a location where is near B and if B is a box, its top surface must be cleared.

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


putdown(B,X,Y) The Monkey puts the box (or key) B, which he is holding, down on the location (X, Y) on the same surface S (floor, box or boxes). After finishing the action, the Monkey will be near B. And B will be at location (X, Y, Z) where Z is a distance from the surface S to floor. Figure 2a give detailed example when putting the box down on the floor. The Monkey is holding the box and his location is at (X1, Y1, 0) or simply on the floor. When the action putdown(B, X, Y) is finished, the box B is put at the location (X, Y, 0) and the Monkey is near B.

Putdown(B,X,Y)

X1,Y1

X,Y

Figure 2a: Example when putting down on floor Figure 2b gives detailed example when putting down the box on the top of one box. The Monkey is on the big box and he is holding a smaller box B. He can put the box B down on the top of the big box. When the action is finished, the box B is on the big box and its location is at (X, Y, Z). Besides, the Monkey is near the box B. Putdown(B,X,Y)

X1,Y1,Z

X,Y,Z

Figure 2b: Example when putting down on the top of one box 3

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


Figure 2c gives detailed example when putting the box down on the surface that is created by 2 boxes. This situation is same as Figure 2b except that the Monkey can put the box B, which he is holding, down on the surface create by 2 boxes. Putdown(B,X,Y)

X1,Y1,Z

X,Y,Z

Figure 2c: Example of putting down on two boxes stack(B,C) The Monkey puts the box B that he is holding on top of the box C. He can do this action only if B and C have same size and he is currently near C. Besides, the difference between his height coordinate and the top of C must be in the range of [0 20] cm. When this action is finished, the Monkey is still near the box C. See Figure 3 for some detailed examples. unstack(B,C) The Monkey picks the box B that is currently on box C and holds it on hands. He can do this action only if B and C have same size and he is currently near C. Besides, the difference between his height coordinate and the top of C must be in the range of [0 - 20] cm. climbup(B) The Monkey climbs up on top of the box B. He can do this action only if he is currently near B and the difference between his height coordinate and the top of B must be in the range of (0 - 20] cm. After this action is finished, the Monkey is on the box B. Figure 4 gives example of climbup action. At first time, he is on the small box b1 and near the big box b2. He can climb up on b2. When he is on b2, he can apply action goNear(b3) because he and the box b3 are on the same surface. After that, he climbs up on b3.

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


Figure 3: Example of stack action

<= 20cm

Figure 4: Example of climbup action climbdown(B) The Monkey climbs down on top of the box B. He can do this action only if his height coordinate Z is higher than the top of box B at most 20 cm. When this action is finished, the Monkey will be on the box B. climb2floor 5

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


The Monkey climbs down on the floor. He can do this action only if his height coordinate value Z is higher than the floor at most 20 cm. When this action is finished, the Monkey will be on the floor. getkey The Monkey gets the key. He can do this action only if his X and Y coordinate are same as X and Y coordinate of the key. The height of the Monkey is 40 cm, so he can get the key that has the height coordinate is greater than his current height coordinate a value of a < 40 cm. open The Monkey uses the key, which he is holding, to open the cabinet. The height of the Monkey is 40 cm, so he can get the key that has the height coordinate is greater than his current height coordinate a value of a < 40 cm. The state of cabinet becomes open. putdown2floor(B) The Monkey will find the clear space on the floor and put the box or key B there. When this action is finished, B will have state on floor. Notes on coordinate system: The unit value in coordinate system is in cm. If one box B or the Monkey is on the floor or on top of the box C, its height coordinate is equal to 0 or height coordinate of the box C plus the size of box C. At a time, the location of the Monkey can be on one box, near a box or at a specific location (X, Y, Z). The location of a box or a key B can be on one box, on Monkeys hands, on floor or a specific location (X, Y, Z). Notes on input data: The input file will be map.txt which contains the following information (see the included map.txt file for details). Example: object(Monkey) : the Monkey object(key): the key object(cabinet): the cabinet object(box(b1,20): the box named b1 and has edge length of 20cm. at(loc(200,200,200),b1) : the box named b1 is at the location (200,200,200). object(box(b2,40)): the box named b1 has edge length of 40cm. on(b2,floor): the box named b2 is on the floor. 6

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


Notes on the output data: You are required to print out the action chain that will lead the Monkey open the cabinet. Actions are separated by commas. No newline at the start and end of action chain. Example: go(30,30),pickup(b1),go(50,50),putdown(b1),climbup(b1),getkey,open

III.

Sample plan-space (Your are not required to follow this sample)

Predicates which are used to describe the plan space: on(A,B): A is completely on the top of B where: + A can be a Monkey, a key or a box. + B can be the floor or a box Example: on(Monkey,b1) or on(key,floor) or on(Monkey,floor) near(B): the Monkey is near B (the distance from the Monkey to one side of B is 0, where B is a key or a box. The Monkey is either not near anything or near only one thing each time. room(Width,Length,Height) : The rooms size in cm. Example: room(100,500,400): the room have 100cm in width, 500cm in length and 400cm in height. at(loc(X,Y,Z),T): T is at the location (X,Y,Z) in the coordinate system. T is the name of object in the room. object(M): M is the object in room (Monkey, key, cabinet or box). If M is a box, M have the format box(N,S) where N is the name of box and S is the edge size of box in cm. open: The cabinet is opened At a time, the location of the Monkey can be on a box, near a box or at a specific location (X, Y, Z). The location of a box or a key B can be on one box, on Monkeys hands, on floor or a specific location (X, Y, Z).

IV.

Submission
a. Report of plan space definition, action specification and detail algorithm (heuristics on nonlinear planning by posting constrains). The file must be report.doc.

TRNG I HC BCH KHOA TP.HCM Khoa Khoa hc & K thut My tnh


b. A Prolog program file named planning.pl which receives input as a room map and output to screen the action chains to help the Monkey. You can use any version of Prolog that you are familiar with. However, you must specify it in the report so that TA can run your program correctly. c. The Prolog program is run by go predicate (see lab 5 plan.pl for the detail)

V.

Grading
The room size will very large and the number of boxes will be enough for you to create ladders. + Inputs have all boxes that have edge length of 20cm. (60 testcases) + Inputs have boxes with edge length of 20, 40 or 80cm with the maximum height of key and cabinet less than or equal 160cm. (30 testcases). + Inputs have boxes with edge length of 20, 40 or 80cm and there is no limit on height of key and cabinet. (20 testcases)

VI.

Deadline and plagiarism


The deadline for submission is strictly at 10:00AM Wednesday June 27th, 2012. There will be no submission or fixing errors after the deadline. You MUST do the assignment by yourself. Otherwise, you will get the F mark for the subject.

Вам также может понравиться