Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d37ae0

Browse files
committed
removed monkey & bananas planning problem
1 parent 24041e9 commit 9d37ae0

File tree

2 files changed

+0
-89
lines changed

2 files changed

+0
-89
lines changed

planning.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -333,69 +333,6 @@ def have_cake_and_eat_cake_too():
333333
effect='Have(Cake)')])
334334

335335

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-
399336
def shopping_problem():
400337
"""
401338
SHOPPING-PROBLEM
@@ -1204,11 +1141,6 @@ def have_cake_and_eat_cake_too_graphPlan():
12041141
return [GraphPlan(have_cake_and_eat_cake_too()).execute()[1]]
12051142

12061143

1207-
def monkey_and_bananas_graphPlan():
1208-
"""Solves the monkey and bananas problem using GraphPlan"""
1209-
return GraphPlan(monkey_and_bananas()).execute()
1210-
1211-
12121144
def shopping_graphPlan():
12131145
"""Solves the shopping problem using GraphPlan"""
12141146
return GraphPlan(shopping_problem()).execute()

tests/test_planning.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,6 @@ def test_have_cake_and_eat_cake_too():
104104
assert p.goal_test()
105105

106106

107-
def test_monkey_and_bananas():
108-
p = monkey_and_bananas()
109-
assert p.goal_test() is False
110-
solution = [expr("Go(A, C)"),
111-
expr("Push(Box, C, B)"),
112-
expr("ClimbUp(B, Box)"),
113-
expr("Grasp(Bananas, B, High)")]
114-
115-
for action in solution:
116-
p.act(action)
117-
118-
assert p.goal_test()
119-
120-
121107
def test_shopping_problem():
122108
p = shopping_problem()
123109
assert p.goal_test() is False
@@ -170,13 +156,6 @@ def test_graphPlan():
170156
assert expr('Move(B, Table, C)') in sussman_anomaly_solution
171157
assert expr('Move(A, Table, B)') in sussman_anomaly_solution
172158

173-
monkey_and_bananas_solution = monkey_and_bananas_graphPlan()
174-
monkey_and_bananas_solution = linearize(monkey_and_bananas_solution)
175-
assert expr('Go(A, C)') in monkey_and_bananas_solution
176-
assert expr('Push(Box, C, B)') in monkey_and_bananas_solution
177-
assert expr('ClimbUp(B, Box)') in monkey_and_bananas_solution
178-
assert expr('Grasp(Bananas, B, High)') in monkey_and_bananas_solution
179-
180159
shopping_problem_solution = shopping_graphPlan()
181160
shopping_problem_solution = linearize(shopping_problem_solution)
182161
assert expr('Go(Home, HW)') in shopping_problem_solution

0 commit comments

Comments
 (0)