步子很小,稍安勿躁。
(deftemplate 某种
(slot 编号)
(slot 出生时间))
(deftemplate 世界
(slot 时间)
)
(defrule 开始
=>
(println "开天辟地")
(assert (世界 (时间 0)))
(assert (某种 (编号 0) (出生时间 0))))
; 当无优先级声明时,规则编写顺序决定了执行的优先级!
(defrule 时间流逝
?环境 <- (世界 (时间 ?时间))
=>
(modify ?环境 (时间 (+ ?时间 1)))
)
(defrule 繁衍
(declare (salience 10))
(世界 (时间 ?时间))
(某种 (编号 ?编号) (出生时间 ?出生时间))
(test (= 10000000 (- ?时间 ?出生时间)))
=>
(assert (某种 (编号 (+ 1 ?编号)) (出生时间 ?时间)))
)
待续。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.