home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Club Elmshorn Atari PD
/
CCE_PD.iso
/
pc
/
0600
/
CCE_0622.ZIP
/
CCE_0622.PD
/
CLIPS
/
BLOCKS.CLP
next >
Wrap
Text File
|
1993-09-01
|
2KB
|
58 lines
;;;======================================================
;;; Sample Blocks World Problem
;;;
;;; A real simple implementation of the blocks
;;; world. Rules merely unstack the blocks in
;;; the proper order.
;;;
;;; To execute, merely load, reset and run.
;;;======================================================
(deffacts known
(stack a b c)
(stack d e f)
(move-goal b on-top-of e)
(stack))
(defrule move-it ""
?goal <- (move-goal ?block-1 on-top-of ?block-2)
?stack-1 <- (stack ?block-1 $?rest-1)
?stack-2 <- (stack ?block-2 $?rest-2)
=>
(retract ?goal ?stack-1 ?stack-2)
(assert (stack $?rest-1))
(assert (stack ?block-1 ?block-2 $?rest-2))
(printout ?block-1 " moved on top of " ?block-2 "." crlf))
(defrule floor-move ""
?goal <- (move-goal ?block on-top-of floor)
?stack <- (stack ?block ?under $?rest)
=>
(retract ?goal ?stack)
(assert (stack ?block))
(assert (stack ?under $?rest))
(printout ?block " moved on top of floor." crlf))
(defrule move-to-move ""
(declare (salience -100))
?goal <- (move-goal ?block-1 on-top-of ?block-2)
?stack <- (stack ?top $? ?block $?)
(test (|| (eq ?block ?block-1) (eq ?block ?block-2)))
=>
(assert (move-goal ?top on-top-of floor)))
(defrule goal-satisfied-1 ""
(declare (salience 100))
?goal <- (move-goal ?block-1 on-top-of ?block-2)
(stack $? ?block-1 ?block-2 $?)
=>
(retract ?goal))
(defrule goal-satisfied-2 ""
(declare (salience 100))
?goal <- (move-goal ?block on-top-of floor)
(stack $? ?block)
=>
(retract ?goal))