@@ -333,69 +333,6 @@ def have_cake_and_eat_cake_too():
333
333
effect = 'Have(Cake)' )])
334
334
335
335
336
- def monkey_and_bananas ():
337
- """
338
- [Exercise 10.3] MONKEY AND BANANAS
339
-
340
- The monkey-and-bananas problem is faced by a monkey in a laboratory
341
- with some bananas hanging out of reach from the ceiling. A box is
342
- available that will enable the monkey to reach the bananas if he
343
- climbs on it. Initially, the monkey is at A, the bananas at B, and
344
- the box at C. The monkey and box have height Low, but if the monkey
345
- climbs onto the box he will have height High, the same as the
346
- bananas. The actions available to the monkey include Go from one
347
- place to another, Push an object from one place to another, ClimbUp
348
- onto or ClimbDown from an object, and Grasp or UnGrasp an object.
349
- The result of a Grasp is that the monkey holds the object if the
350
- monkey and object are in the same place at the same height.
351
-
352
- Example:
353
- >>> from planning import *
354
- >>> mb = monkey_and_bananas()
355
- >>> mb.goal_test()
356
- False
357
- >>> mb.act(expr('Go(A, C)'))
358
- >>> mb.act(expr('Push(Box, C, B)'))
359
- >>> mb.act(expr('ClimbUp(B, Box)'))
360
- >>> mb.act(expr('Grasp(Bananas, B, High)'))
361
- >>> mb.goal_test()
362
- True
363
- >>> mb.act(expr('UnGrasp(Bananas)'))
364
- >>> mb.act(expr('ClimbDown(Box)'))
365
- >>> mb.goal_test()
366
- False
367
- >>> mb.act(expr('ClimbUp(B, Box)'))
368
- >>> mb.act(expr('Grasp(Bananas, B, High)'))
369
- >>> mb.goal_test()
370
- True
371
- >>>
372
- """
373
-
374
- return PlanningProblem (
375
- init = 'At(Monkey, A) & At(Bananas, B) & At(Box, C) & Height(Monkey, Low) & Height(Box, Low) & Height(Bananas, '
376
- 'High) & Pushable(Box) & Climbable(Box) & Graspable(Bananas)' ,
377
- goals = 'Have(Monkey, Bananas)' ,
378
- actions = [Action ('Go(x, y)' ,
379
- precond = 'At(Monkey, x) & Height(Monkey, Low)' ,
380
- effect = 'At(Monkey, y) & ~At(Monkey, x)' ),
381
- Action ('Push(b, x, y)' ,
382
- precond = 'At(Monkey, x) & Height(Monkey, Low) & At(b, x) & Pushable(b) & Height(b, Low)' ,
383
- effect = 'At(b, y) & At(Monkey, y) & ~At(b, x) & ~At(Monkey, x)' ),
384
- Action ('ClimbUp(x, b)' ,
385
- precond = 'At(Monkey, x) & Height(Monkey, Low) & At(b, x) & Climbable(b) & Height(b, Low)' ,
386
- effect = 'On(Monkey, b) & Height(Monkey, High) & ~Height(Monkey, Low)' ),
387
- Action ('ClimbDown(b)' ,
388
- precond = 'On(Monkey, b)' ,
389
- effect = '~On(Monkey, b) & Height(Monkey, Low) & ~Height(Monkey, High)' ),
390
- Action ('Grasp(b, x, h)' ,
391
- precond = 'At(Monkey, x) & Height(Monkey, h) & Height(b, h) & At(b, x) & Graspable(b)' ,
392
- effect = 'Have(Monkey, b)' ),
393
- Action ('UnGrasp(b)' ,
394
- precond = 'Have(Monkey, b)' ,
395
- effect = '~Have(Monkey, b)' )
396
- ])
397
-
398
-
399
336
def shopping_problem ():
400
337
"""
401
338
SHOPPING-PROBLEM
@@ -1204,11 +1141,6 @@ def have_cake_and_eat_cake_too_graphPlan():
1204
1141
return [GraphPlan (have_cake_and_eat_cake_too ()).execute ()[1 ]]
1205
1142
1206
1143
1207
- def monkey_and_bananas_graphPlan ():
1208
- """Solves the monkey and bananas problem using GraphPlan"""
1209
- return GraphPlan (monkey_and_bananas ()).execute ()
1210
-
1211
-
1212
1144
def shopping_graphPlan ():
1213
1145
"""Solves the shopping problem using GraphPlan"""
1214
1146
return GraphPlan (shopping_problem ()).execute ()
0 commit comments