### Table of contents, ht.s7 ### ### i. Some simple things to help beginners ### I. Propose the top space ### II. Propose the main operators ### III. Implement the main operators ### IV. Noticing when full ### V. Operator Set-up ### VI. Better object traces ### ### Copyright 1994. F. E. Ritter & R. M. Young. ### ### Last substantially modified: 3-Nov-96 -FER ### With useful bug fixes from Kate Cook. ### ### 4-Jan-98 Richard Young - Some clean-up and internal consistency ### - Also added monitor rule for hungry/thirsty ### 3-Nov-96 Frank Ritter - moved to soar 7.0.4 ### 27/7/95 Gary Jones - Altered references to to be . ### For example, state is now state . ### Just to make it easier to understand. ### Also put in learn -off (because it should be). ### ### 5/7/95 Gary Jones - NNPSCM conversion. ### ### ### Saved as Text Only so that it can be loaded into Soar. ### ### A simple hungry-thirsty problem space and operators ### ### The code supplied has these characteristics: ### - The operators Eat & Drink are proposed iff they're ### applicable. that is, Eat if (^hungry yes), Drink if (^thirsty yes) ### - There is an explicit ^desired on the goal ### - which is tested by the goal attainment rule ### - There are hand-written control chunks giving Eat best ### ### Example command within Soar to get to this code and load it: ### ### Macintosh: cd "joe:EuroSoar7:tutorial" ### Unix: cd "/aigr/staff/ritter/res/soar/euro-soar93/tutorial/" ### ### Then: source "ht.s7" ### ### ### i. Some simple things to help beginners ### ## For safety, excise -all excise -all ## Resets the watch level to the base level in case you changed it: watch 1 echo "watch 1" learn -off echo "learn -off " ## Default is not to print chunks as learned! watch learning -print ## This makes chunk firings print watch -chunks -print ## What to do with sets of indifferent context elements: take the ## first one. indifferent-selection -first ## Upon reload, resetting the goal stack to be empty is usually ## required and is a good idea: init-soar echo "init-soar" ### ### I. Propose the top space ### ### The code in this section proposes a simple space to work in, and a ### simple state to start working in. sp {ht*propose-space*ht (state -^impasse ^superstate nil) --> ( ^name ht-state) ( ^problem-space

^desired ) (

^name hungry-thirsty) ( ^hungry no) ( ^thirsty yes ^hungry yes) } ## Initialise the top state ## simple way to set up the top-state with a separate production ##sp {ht*init-state*ht ## (state ^problem-space.name hungry-thirsty) ## --> ## ( ^name ht-state) ## ( ^thirsty yes ^hungry yes)} ## You can put the closing parenthesis on its own line (e.g., in the ## first production) to show that it is closed, but I generally don't ## to save space. ### ### II. Propose the main operators ### ### The code in this section proposes the two operators eat and drink. ### The third production creates a preference for choosing between ### them. ## Propose eat. sp {ht*propose-op*eat (state ^problem-space.name hungry-thirsty ) ( ^hungry yes) --> ( ^operator ) ( ^name eat)} ## Propose drink. sp {ht*propose-op*drink (state ^problem-space.name hungry-thirsty ) ( ^thirsty yes) --> ( ^operator ) ( ^name drink)} ## Eat is better if you are hungry and want not to be sp {ht*compare*eat*better*drink (state ^desired ^problem-space.name hungry-thirsty) ( ^hungry yes) ( ^hungry no) ( ^operator +) ( ^name eat) ( ^operator +) ( ^name drink) --> ( ^operator > )} ### ### III. Implement the main operators ### ## Implement the operators with productions that modify the state once ## the operators have been selected, and then terminate them after ## they have done ## what they need to do ## ## Note: We make the new value acceptable and reject the previous ## value. ## ## The reconsider preference effectively terminates the operator on ## the next decision cycle after it has done what its supposed to do. sp {ht*apply-op*eat (state ^operator ) ( ^name eat) ( ^hungry yes) --> (write (crlf) | chomp chomp... |) ( ^hungry yes - no +)} sp {ht*terminate*eat (state ^operator ) ( ^name eat) ( ^hungry no) --> ( ^operator @)} ## Implement drink sp {ht*apply-op*drink (state ^operator ) ( ^name drink) ( ^thirsty yes) --> (write (crlf) | glug glug... |) ( ^thirsty no + yes -)} sp {ht*terminate*drink (state ^operator ) ( ^name drink) ( ^thirsty no) --> ( ^operator @)} ### ### IV. Noticing when full ### ### This code terminates the problem solving when the goal is reached. ## How to tell if you can stop sp {ht*evaluate*state*success (state ^desired ) ( ^hungry ) ( ^hungry ) --> ( ^success )} ## One of the default rules is brought in to notice that we are ## finished. (Slightly modified to be more compact and less general.) sp {default*top-goal*halt*state*success :default (state ^desired ) ( ^success ) --> (write (crlf) | goal for | | achieved | ) (halt)} ### ### V. Better state traces ### ### To trace the hungriness & thirstiness, we use the following ### "monitoring" rules (they don't affect the processing, they ### just print out some information. sp {monitor*top-state*hungry (state ^superstate nil ^problem-space.name hungry-thirsty) ( ^hungry ) --> (write (crlf) |** Top-state has ^hungry | )} sp {monitor*top-state*thirsty (state ^superstate nil ^problem-space.name hungry-thirsty) ( ^thirsty ) --> (write (crlf) |** Top-state has ^thirsty | )} ## need to do this to get a new line in soar7 echo "" ###--------------------------------------------------------------- ### END OF FILE ###---------------------------------------------------------------