Skip to content

Commit 62f2fc0

Browse files
Rahul Patelnorvig
authored andcommitted
Added implementation of Three Block Tower (aimacode#263)
In the precondition positive list, I am not sure whether b!=x is the best way to represent the condition. IsNot(b, x) can be used instead.
1 parent 5fd9c6a commit 62f2fc0

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

planning.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,38 @@ def goal_test(kb):
175175
leave_overnight = Action(expr("LeaveOvernight"), [precond_pos, precond_neg], [effect_add, effect_rem])
176176

177177
return PDLL(init, [remove, put_on, leave_overnight], goal_test)
178+
179+
def three_block_tower():
180+
init = [expr('On(A, Table)'),
181+
expr('On(B, Table)'),
182+
expr('On(C, A)'),
183+
expr('Block(A)'),
184+
expr('Block(B)'),
185+
expr('Block(C)'),
186+
expr('Clear(B)'),
187+
expr('Clear(C)')]
188+
189+
def goal_test(kb):
190+
required = [expr('On(A, B)'), expr('On(B, C)')]
191+
for q in required:
192+
if kb.ask(q) is False:
193+
return False
194+
return True
195+
196+
## Actions
197+
# 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')]
200+
precond_neg = []
201+
effect_add = [expr('On(b, y)'), expr('Clear(x)')]
202+
effect_rem = [expr('On(b, x)'), expr('Clear(y)')]
203+
move = Action(expr('Move(b, x, y)'), [precond_pos, precond_neg], [effect_add, effect_rem])
204+
205+
# MoveToTable
206+
precond_pos = [expr('On(b, x)'), expr('Clear(b)'), expr('Block(b)'), expr('b != x')]
207+
precond_neg = []
208+
effect_add = [expr('On(b, Table)'), expr('Clear(x)')]
209+
effect_rem = [expr('On(b, x)')]
210+
moveToTable = Action(expr('MoveToTable(b, x)'), [precond_pos, precond_neg], [effect_add, effect_rem])
211+
212+
return PDLL(init, [move, moveToTable], goal_test)

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