15.07.2013 Views

Soar Tutorial - the Cognitive Systems Group

Soar Tutorial - the Cognitive Systems Group

Soar Tutorial - the Cognitive Systems Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

14<br />

3.1 Hello World Operator: English Version<br />

To demonstrate a very simple operator, you will now write an operator instead of a single rule to print<br />

“Hello World”. Operators allow you to have an action considered in multiple situations (rules that propose<br />

<strong>the</strong> operator), allow multiple reasons for selecting an action (rules for selecting operators), and allow<br />

multiple ways for doing it (rules that apply <strong>the</strong> operator). For printing “Hello World”, an operator is not<br />

necessary because <strong>the</strong>re are no alternatives, but as soon as o<strong>the</strong>r actions are possible and choices must<br />

be made, operators become necessary.<br />

To use an operator, we need two rules: one to propose <strong>the</strong> operator and one to apply it:<br />

Propose*hello­world:<br />

If I exist, propose <strong>the</strong> hello­world operator.<br />

Apply*hello­world:<br />

If <strong>the</strong> hello­world operator is selected, write “Hello World” and halt.<br />

The first rule proposes <strong>the</strong> hello-world operator, and <strong>the</strong> second performs its actions after <strong>the</strong> operator<br />

has been selected. Notice that <strong>the</strong> first rule only proposes <strong>the</strong> hello-world operator. As described earlier,<br />

an operator is selected by <strong>Soar</strong>’s decision procedure, which collects toge<strong>the</strong>r proposed operators and<br />

selects one.<br />

To see this operator run, you can ei<strong>the</strong>r create a new agent and <strong>the</strong>n destroy your previous agent (this is<br />

done on <strong>the</strong> same pull down menu that was used to create an agent), or you can remove all of <strong>the</strong><br />

existing rules in your agent by using <strong>the</strong> “excise ­­all” command, which removes all of <strong>the</strong> rules<br />

from memory and initializes <strong>Soar</strong>. Next, load in <strong>the</strong> hello-world-operator file using source. To see <strong>the</strong><br />

individual productions fire, you can modify <strong>the</strong> “watch” level. There are many different watch levels: and<br />

watch level 3 (and higher) includes traces of production firings. Go ahead and set <strong>the</strong> highest level:<br />

watch 5. You can use <strong>the</strong> “Watch 5” button at <strong>the</strong> bottom of <strong>the</strong> interaction window or use <strong>the</strong> Debug<br />

Level entry in <strong>the</strong> menu bar at <strong>the</strong> top. Then click <strong>the</strong> run button.<br />

The interaction window allows you to trace <strong>the</strong> execution of <strong>Soar</strong> at many different levels (decisions,<br />

phases, production firings, working memory changes), but selectively view <strong>the</strong> trace by expanding and<br />

collapsing <strong>the</strong> trace (using <strong>the</strong> “+” and “-” items on <strong>the</strong> left of <strong>the</strong> trace) and setting filters. Make sure you<br />

have <strong>the</strong> “tree view,” which is set under <strong>the</strong> layout tab in <strong>the</strong> top tool bar. A standard practice is to do a full<br />

trace (Watch 5), but only view decisions by collapsing <strong>the</strong> trace. If an error arises, or you want to look at<br />

<strong>the</strong> behavior in more detail, you can expand <strong>the</strong> trace. The button at <strong>the</strong> lower right corner of <strong>the</strong><br />

interaction window allows you to toggle between “collapse” and “expand” easily. You can <strong>the</strong>n control <strong>the</strong><br />

level of <strong>the</strong> trace by using <strong>the</strong> “filters” button that is next to <strong>the</strong> collapse/expand button. This allows you to<br />

view <strong>the</strong> trace at a high level and only dive into <strong>the</strong> details when necessary.<br />

After typing run, expand <strong>the</strong> “run” and “1: O: O1 (hello-world)” lines by clicking on <strong>the</strong> “+” signs next to<br />

<strong>the</strong>m. The trace shows that propose*hello-world fires first to propose <strong>the</strong> operator. The operator helloworld<br />

(O1) is <strong>the</strong>n selected (by <strong>the</strong> decision procedure). After hello-world is selected, apply*hello-world<br />

fires and performs <strong>the</strong> actions of <strong>the</strong> operator by printing out “Hello World” and halting.<br />

<strong>Soar</strong> <strong>Tutorial</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!