V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
您的好友邀请您加入 Bybit!
Bybit交易所中国大陆注册及实名认证KYC,输入邀请码享全网最高返佣优惠。
Promoted by Muniu
xuanwu
V2EX  ›  分享创造

[不定更] 用 CLIPS 模拟生态

  •  
  •   xuanwu · 115 天前 · 1129 次点击
    这是一个创建于 115 天前的主题,其中的信息可能已经有所发展或是发生改变。

    初入门 后,用 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
       106 天前
    xuanwu
        2
    xuanwu  
    OP
       104 天前
    xuanwu
        3
    xuanwu  
    OP
       102 天前
    xuanwu
        4
    xuanwu  
    OP
       94 天前
    0.5:求最近;取属性、查事实等函数
    https://zhuanlan.zhihu.com/p/1904371634070085633
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5278 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:38 · PVG 16:38 · LAX 01:38 · JFK 04:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.