?? blocks.clp
字號:
;;;======================================================
;;; Blocks World Program
;;;
;;; This program was introduced in Chapter 8.
;;;
;;; CLIPS Version 6.0 Example
;;;
;;; To execute, merely load, reset and run.
;;;======================================================
(deftemplate goal (slot move) (slot on-top-of))
(deffacts initial-state
(stack A B C)
(stack D E F)
(goal (move C) (on-top-of E))
(stack))
(defrule move-directly
?goal <- (goal (move ?block1) (on-top-of ?block2))
?stack-1 <- (stack ?block1 $?rest1)
?stack-2 <- (stack ?block2 $?rest2)
=>
(retract ?goal ?stack-1 ?stack-2)
(assert (stack $?rest1))
(assert (stack ?block1 ?block2 $?rest2))
(printout t ?block1 " moved on top of "
?block2 "." crlf))
(defrule move-to-floor
?goal <- (goal (move ?block1) (on-top-of floor))
?stack-1 <- (stack ?block1 $?rest)
=>
(retract ?goal ?stack-1)
(assert (stack ?block1))
(assert (stack $?rest))
(printout t ?block1 " moved on top of floor." crlf))
(defrule clear-upper-block
(goal (move ?block1))
(stack ?top $? ?block1 $?)
=>
(assert (goal (move ?top) (on-top-of floor))))
(defrule clear-lower-block
(goal (on-top-of ?block1))
(stack ?top $? ?block1 $?)
=>
(assert (goal (move ?top) (on-top-of floor))))
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -