@@ -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