V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
xuanwu
V2EX  ›  分享创造

[不定更] 用 CLIPS 模拟生态

  •  
  •   xuanwu · 24 天前 · 942 次点击

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

    步子很小,稍安勿躁。

    (deftemplate 某种
      (slot 编号)
      (slot 出生时间))
    
    (deftemplate 世界
      (slot 时间)
    )
    
    (defrule 开始
      =>
      (println "开天辟地")
      (assert (世界 (时间 0)))
      (assert (某种 (编号 0) (出生时间 0))))
    
    ; 当无优先级声明时,规则编写顺序决定了执行的优先级!
    
    (defrule 时间流逝
      ?环境 <- (世界 (时间 ?时间))
      =>
      (modify ?环境 (时间 (+ ?时间 1)))
    )
    
    (defrule 繁衍
      (declare (salience 10))
      (世界 (时间 ?时间))
      (某种 (编号 ?编号) (出生时间 ?出生时间))
      (test (= 10000000 (- ?时间 ?出生时间)))
      =>
      (assert (某种 (编号 (+ 1 ?编号)) (出生时间 ?时间)))
    )
    

    待续。

    xuanwu
        1
    xuanwu  
    OP
       15 天前
    xuanwu
        2
    xuanwu  
    OP
       13 天前
    xuanwu
        3
    xuanwu  
    OP
       11 天前
    xuanwu
        4
    xuanwu  
    OP
       3 天前
    0.5:求最近;取属性、查事实等函数
    https://zhuanlan.zhihu.com/p/1904371634070085633
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5099 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 03:47 · PVG 11:47 · LAX 20:47 · JFK 23:47
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.