[不定更] 用 CLIPS 模拟生态

145 天前
 xuanwu

初入门 后,用 CLIPS 改写 生态模拟

步子很小,稍安勿躁。

(deftemplate 某种
  (slot 编号)
  (slot 出生时间))

(deftemplate 世界
  (slot 时间)
)

(defrule 开始
  =>
  (println "开天辟地")
  (assert (世界 (时间 0)))
  (assert (某种 (编号 0) (出生时间 0))))

; 当无优先级声明时,规则编写顺序决定了执行的优先级!

(defrule 时间流逝
  ?环境 <- (世界 (时间 ?时间))
  =>
  (modify ?环境 (时间 (+ ?时间 1)))
)

(defrule 繁衍
  (declare (salience 10))
  (世界 (时间 ?时间))
  (某种 (编号 ?编号) (出生时间 ?出生时间))
  (test (= 10000000 (- ?时间 ?出生时间)))
  =>
  (assert (某种 (编号 (+ 1 ?编号)) (出生时间 ?时间)))
)

待续。

1175 次点击
所在节点    分享创造
4 条回复
xuanwu
136 天前
xuanwu
134 天前
xuanwu
132 天前
xuanwu
124 天前
0.5:求最近;取属性、查事实等函数
https://zhuanlan.zhihu.com/p/1904371634070085633

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1126593

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX