Skip to content

Commit 1f3b32f

Browse files
Added test for three_block_tower and fixed a bug in three_block_tower code
1 parent 3f6d72d commit 1f3b32f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

planning.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,14 @@ def goal_test(kb):
195195

196196
## Actions
197197
# Move
198-
precond_pos = [expr('On(b, x)'), expr('Clear(b)'), expr('Clear(y)'), expr('Block(b)'),
199-
expr('Block(y)'), expr('b != x'), expr('b != y'), expr('x != y')]
198+
precond_pos = [expr('On(b, x)'), expr('Clear(b)'), expr('Clear(y)'), expr('Block(b)'), expr('Block(y)')]
200199
precond_neg = []
201200
effect_add = [expr('On(b, y)'), expr('Clear(x)')]
202201
effect_rem = [expr('On(b, x)'), expr('Clear(y)')]
203202
move = Action(expr('Move(b, x, y)'), [precond_pos, precond_neg], [effect_add, effect_rem])
204203

205204
# MoveToTable
206-
precond_pos = [expr('On(b, x)'), expr('Clear(b)'), expr('Block(b)'), expr('b != x')]
205+
precond_pos = [expr('On(b, x)'), expr('Clear(b)'), expr('Block(b)')]
207206
precond_neg = []
208207
effect_add = [expr('On(b, Table)'), expr('Clear(x)')]
209208
effect_rem = [expr('On(b, x)')]

tests/test_planning.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ def test_spare_tire():
4747

4848
assert p.goal_test()
4949

50+
def test_three_block_tower():
51+
p = three_block_tower()
52+
assert p.goal_test() is False
53+
solution = [expr("MoveToTable(C, A)"),
54+
expr("Move(B, Table, C)"),
55+
expr("Move(A, Table, B)")]
56+
57+
for action in solution:
58+
p.act(action)
59+
60+
assert p.goal_test()
61+
5062
def test_have_cake_and_eat_cake_too():
5163
p = have_cake_and_eat_cake_too()
5264
assert p.goal_test() is False

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy