⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4人过河问题.clp

📁 使用clips解决4人限定时间过河问题。附带clips源代码。
💻 CLP
字号:
(deftemplate state (slot flashlight) (slot Bono) (slot Edge) (slot Adam) (slot Larry) (slot time))

(deffacts startup (state (flashlight L) (Bono L) (Edge L) (Adam L) (Larry L) (time 0)))

; one person from left to right

(defrule BLR1 (state (flashlight L) (Bono L) (Edge ?a) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono R) (Edge ?a) (Adam ?b) (Larry ?c) (time (+ ?t 1)))))

(defrule BLR2 (state (flashlight L) (Bono ?d) (Edge L) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge R) (Adam ?b) (Larry ?c) (time (+ ?t 2)))))

(defrule BLR3 (state (flashlight L) (Bono ?d) (Edge ?a) (Adam L) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge ?a) (Adam R) (Larry ?c) (time (+ ?t 5)))))

(defrule BLR4 (state (flashlight L) (Bono ?d) (Edge ?a) (Adam ?b) (Larry L) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge ?a) (Adam ?b) (Larry R) (time (+ ?t 10)))))


;..........


; one person from right to left

(defrule BRL5 (state (flashlight R) (Bono R) (Edge ?a) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono L) (Edge ?a) (Adam ?b) (Larry ?c) (time (+ ?t 1)))))

(defrule BRL6 (state (flashlight R) (Bono ?d) (Edge R) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge L) (Adam ?b) (Larry ?c) (time (+ ?t 2)))))

(defrule BRL7 (state (flashlight R) (Bono ?d) (Edge ?a) (Adam R) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge ?a) (Adam L) (Larry ?c) (time (+ ?t 5)))))

(defrule BRL8 (state (flashlight R) (Bono ?d) (Edge ?a) (Adam ?b) (Larry R) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge ?a) (Adam ?b) (Larry L) (time (+ ?t 10)))))

;……

; two persons from left to right

(defrule BLR9 (state (flashlight L) (Bono L) (Edge L) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono R) (Edge R) (Adam ?b) (Larry ?c) (time (+ ?t 2)))))

(defrule BLR10 (state (flashlight L) (Bono L) (Edge ?a) (Adam L) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono R) (Edge ?a) (Adam R) (Larry ?c) (time (+ ?t 5)))))

(defrule BLR11 (state (flashlight L) (Bono L) (Edge ?a) (Adam ?b) (Larry L) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono R) (Edge ?a) (Adam ?b) (Larry R) (time (+ ?t 10)))))

(defrule BLR12 (state (flashlight L) (Bono ?d) (Edge L) (Adam L) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge R) (Adam R) (Larry ?c) (time (+ ?t 5)))))

(defrule BLR13 (state (flashlight L) (Bono ?d) (Edge L) (Adam ?b) (Larry L) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge R) (Adam ?b) (Larry R) (time (+ ?t 10)))))

(defrule BLR14 (state (flashlight L) (Bono ?d) (Edge ?a) (Adam L) (Larry L) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight R) (Bono ?d) (Edge ?a) (Adam R) (Larry R) (time (+ ?t 10)))))


;……



; two persons from right to left

(defrule BRL15 (state (flashlight R) (Bono R) (Edge R) (Adam ?b) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono L) (Edge L) (Adam ?b) (Larry ?c) (time (+ ?t 2)))))

(defrule BRL16 (state (flashlight R) (Bono R) (Edge ?a) (Adam R) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono L) (Edge ?a) (Adam L) (Larry ?c) (time (+ ?t 5)))))

(defrule BRL17 (state (flashlight R) (Bono R) (Edge ?a) (Adam ?b) (Larry R) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono L) (Edge ?a) (Adam ?b) (Larry L) (time (+ ?t 10)))))

(defrule BRL18 (state (flashlight R) (Bono ?d) (Edge R) (Adam R) (Larry ?c) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge L) (Adam L) (Larry ?c) (time (+ ?t 5)))))

(defrule BRL19 (state (flashlight R) (Bono ?d) (Edge R) (Adam ?b) (Larry R) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge L) (Adam ?b) (Larry L) (time (+ ?t 10)))))

(defrule BRL20 (state (flashlight R) (Bono ?d) (Edge ?a) (Adam R) (Larry R) (time ?t)) (test (< ?t 17))
           => 
(assert (state (flashlight L) (Bono ?d) (Edge ?a) (Adam L) (Larry L) (time (+ ?t 10)))))



;.............


(defrule Goal (state (flashlight R) (Bono R) (Edge R) (Adam R) (Larry R) (time ?t)) (test (<= ?t 17))
              =>
	(halt))



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -