CLIPS-焦点
来源:互联网 发布:跆拳道和武术知乎 编辑:程序博客网 时间:2024/05/16 17:57
一、完成从MAIN->NO1->NO2模块变化
CLIPS> (clear)
CLIPS> (defmodule MAIN
(export deftemplate initial-fact))
CLIPS> (defmodule NO1
(import MAIN deftemplate initial-fact))
CLIPS> (defrule MAIN::START
=>(focus NO1))
CLIPS> (defrule NO1::next
=>
(printout t "begin no1" crlf)
(focus NO2)
(return)
(printout t "end no1" crlf))
CLIPS> (defmodule NO2)
CLIPS> (get-current-module)
NO2
CLIPS> (defrule NO2:next2
=>
(printout t "begin no2 " crlf)
(pop-focus)
(printout t "end no2" crlf)
)
CLIPS> (watch rules)
CLIPS> (watch focus)
CLIPS> (reset)
<== Focus MAIN
==> Focus MAIN
CLIPS> (run)
FIRE 1 START:*
==> Focus NO1 from MAIN
FIRE 2 next:*
begin no1
==> Focus NO2 from NO1
<== Focus NO1
FIRE 3NO2:next2: *
begin no2
<== Focus NO2 to MAIN
end no2
<== Focus MAIN
CLIPS>
二、当前焦点是称为焦点栈的堆栈数据结构的顶点值,用focus改变当前焦点,实际上就是交新的焦点移到焦点栈的顶部,取代原焦点,随着规则的执行,当前焦点的议程为空时,当前焦点将从焦点栈中弹出,同时此时位于栈顶的另一模块成为当前焦点,该焦点的议程被执行。
1、(get-current-module)得到当前模块
2、(list-focus-stack)列出模块堆栈
3、(defmodule NO2)定义模块
4、(pop-focus)为从栈中弹出当前焦点模块,但允许规则的RHS操作继续执行,因为end no2被打印出。
5、(return)为从栈中弹出当前焦点模块并返回,所以规则的RHS操作不会继续执行,end no1没有打印出
- CLIPS-焦点
- CLIPS-自动焦点
- 人工智能clips
- clips程序
- CLIPS-模块
- CLIPS-绑定
- CLIPS-变量
- CLIPS-断点
- CLIPS-监视
- clips系列二-clips调用外部函数
- CLIPS程式技巧
- CLIPS-控制策略
- CLIPS-规则优先级
- CLIPS-自定义模板属性
- CLIPS-测试条件元素
- CLIPS-谓词字段约束
- CLIPS-返回字段约束
- CLIPS-读写关闭文件
- 计算心理学家的哲学假定
- 键盘字典
- 人工智能相关电子书下载
- Struts2和Struts1的不同
- 卓越25元图书和当当恶意订单事件的猜测
- CLIPS-焦点
- CLIPS-自动焦点
- 字节串存储
- ubuntu 9.04如何直接进入命令行
- 就是写注释版汇编
- CLIPS-模块
- erthy
- struct内存分配分析
- CLIPS-控制策略