The Soar 9 Tutotial 筆記

part 1 simple soar programs

2 building a simple soar agent using rules

2.4 hello world rule : soar

soar的規則寫法:

sp { hello-world
	# 條件
    (state <s> ^type state) 
-->
	# 動作
    (write | Hello world|)
    (halt)
  }

2.5 working memory

工作記憶中包含soar智能體的世界及其內部推理的動態信息。包含傳感器數據,中間計算,當前的operators和goals。在soar中,工作記憶被組織爲圖結構。例如下圖 1 :
在這裏插入圖片描述
和圖 2:
在這裏插入圖片描述
圖1 和圖2中的工作記憶由節點和連接構成。圖中的S1,B1,B2,A和blue都是節點,block,table,name,color和superstate是連接。節點分爲兩類:1.identifiers;2.constants。可以發出連接的節點爲identifiers,其它的(終止節點)節點叫作constants。
在soar中,所有的節點會被soar自動建立,它們是一個字母加數字的形式。在soar中,屬性的前面有這個:“^”.只有identifiers有屬性。
工作記憶其實是由identifiers、attribute(屬性)和值(value)構成,值就是由屬性引導的指向的節點,它可以是constants和identifiers。上面的圖由如何工作記憶的元素(elements)

S1 ^superstate nil
S1 ^io I1
S1 ^type state
I1 ^output-link I2
I1 ^input-link I3

這是工作記憶最小的內容。
享有相同的identifiers的工作記憶的元素構成了object。上圖的三個工作記憶的元素共同享有identifiers S1就構成了這個狀態的object。構成object 的工作記憶元素叫作augmentations。object常常表示爲使用括號括起來的augmentation的列表。如下面所示:

(S1 ^io I1 ^superstate nil ^type state)
(I1 ^input-link I3 ^output-link I2)

一個工作記憶的object常常表示現實世界中的something。例如牆,一片食物等。單個的augmentation表示性質(properties),如顏色,大小,重量。對於不同的soar的任務,工作記憶中的內容是不同的,例如下圖:
在這裏插入圖片描述
工作記憶常常包括object,它不表示實際存在的東西,只是概念上的things,例如S1.S1祖師其它的object,relation和properties。
soar不要求任何可能的屬性和constants的聲明,實際上,一些soar在執行過程中,產生新的attributes和constants。(soar編輯器,VisualSoar,要求聲明工作記憶元素來檢查我們的跪着(rules)中的錯誤)

2.6 hello-world rule:soar details

代碼:

sp { hello-world
    (state <s> ^type state)
-->
    (write |Hello world|)
    (halt)
  }

在soar中,當soar智能體被創建時,它就有(s1 ^type state)在工作記憶中,這表明智能體已經存在了。所以我們可以通過監測這個結構(s1 ^type state)來判斷是否智能體已經存在。S1知識一個任意的符號,可能不是智能體每次運行的identifiers。我們需要測試是否有identifiers,而不是測試特定的值。這就是變量要做的—it matches any symbol in working memory with the only constraint being that all occurrences of the same variable in a rule match the same symbol. A variable can match an identifier, an attribute, or a value, depending on its position in a condition – if it is first in a condition it will match the identifier, second the attribute, and third the value. 變量使用“<”“>”表示。“|”中間加入想要打印的字符串。

3 building simple agents using operators

operators做出動作,這個動作可以是in mind或者作用於world。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章