### Program analogy.topspace.soar -- Top space of analogy.soar, ### with mapping rule ### Version 19.1.96 ### ### Started 5 Aug 93 ### Version 18 Nov 94, based on analogy.soar v. 1 Nov 94 -- original by rmy ### NB: nnpscm version -- conversion by John Rieman ### Version 5 Dec 94, some concessions to improving the trace ### in NNPSCM -- rmy ### Soar 7 ... ### Version 19 Jan 96, picked up Soar 7 demo from distribution, ### minor corrections -- rmy ### ### Program to do simple 'deliberate analogy' for figuring out how to launch ### a program on the Mac, given that one or two specific ones are known. ### ### This version developed specifically for the purposes of the one-day ### Soar tutorial given by Frank Ritter and Richard Young. A set of ### Macintosh files containing OHP slides together with exercises and ### other handouts (either describing just this program, else covering ### the whole one-day tutorial) can be obtained by contacting ### ritter@psychology.nottingham.ac.uk ### ### Note that I have used state-elaboration rules instead of operators in many ### places, probably to a far greater extent than is justified in terms of ### cognitive modelling, but it shortens the program and perhaps makes its ### behaviour easier to follow. ### ### Correspondingly, there are several highly specific monitoring rules ### present, which we would not normally expect to see in this kind of ### program. ### ====================================================================== ### DECLARATIONS, INITIALISATIONS, ETC. ### ====================================================================== ### This format is specifically for monitoring the Imagine-Task space # syntax won't work in nnpscm -jr #trace-format -object -add p perform "%id (perform%ifdef[ %v[type] %v[alias]])" ### All right, so for NNPSCM we do the following, which is intended ### for watch 0 format, might be a little weird in anything else: format-watch -stack -add s {%right[6,%dc]: %rsd[ ]==>S: %cs %rsd[ ]} sp {monitor*problem-space*nnpscm (state ^problem-space (

^name )) --> (write | P: |

|(| |)|)} sp {monitor*problem-space*imagine-task (state ^problem-space

) (

^type imaginary ^alias imagine-task) --> (write | type = imaginary alias = imagine-task|)} ### Ask what program to launch sp {preamble*ask-program-to-launch (state ^name perform) ( ^task ) ( ^feature ) ( ^fname arg1) --> (write (crlf) |What program to launch? [cg,word,draw,xl] |) ( ^fvalue (accept))} ### ====================================================================== ### PERFORM SPACE ### ====================================================================== ### -- Initialisation -- sp {perform*initialise*gps (state ^superstate nil) --> (

^name perform) ( ^name perform ^problem-space

)} sp {perform*initialise*state (state ^name perform) --> ( ^task ) ( ^feature + &, + &) ( ^fname effect ^fvalue launch) ( ^fname arg1)} ### -- Termination -- ### Kludgy-detect when a program has been successfully launched sp {perform*task*terminate (state ^problem-space.name perform) ( ^task ) ( ^feature ) ( ^fname effect ^fvalue launch) ( ^fname arg1 ^fvalue ) ( ^simulation ) ( ^status running ^object ) --> (write (crlf) |** Yeah, the program is running!|) (halt)} ### -- Performing actions -- ### If there's ever an Action attribute on the state, then perform the ### action. ### Issues about how to know when an action has been completed, ### what happens if there is more than one action proposed, and so on, ### are beyond the scope of this demonstation program (and hopefully will ### not arise). ### Propose a perform operator sp {perform*perform*propose (state ^problem-space.name perform) ( ^action ) --> ( ^name perform ^action ) ( ^operator )} ### Performing the double-click action sp {perform*perform*double-click*perform (state ^problem-space.name perform ^operator ) ( ^name perform ^action ) ( ^movement double-click ^object ) --> ( ^motor ) ( ^movement double-click ^object ) (write (crlf) |** User double-clicks on object | )} ### -- Kludgy simulation of Mac launching programs -- ### The following rule would be more elegant if it knew what objects ### were 'isa' program sp {perform*simulate*launch*program (state ^problem-space.name perform ^operator.name ) ( ^motor ) ( ^movement double-click ^object ^object << CG Word Draw XL >>) --> ( ^simulation ) ( ^status running ^object ) (write (crlf) |** Mac now has program | | running|)} ### -- Just for testing -- ### Just for testing, the following hand-written chunk proposes the action ### of double-clicking on a program to be launched. Commented out. sp {perform*task*action*double-click-to-launch (state ^problem-space.name perform) ( ^task ) ( ^feature ) ( ^fname effect ^fvalue launch) ( ^fname arg1 ^fvalue ) --> ( ^action ) ( ^movement double-click ^object )} ### Monitor ^task and ^action on the state sp {perform*monitor*state*task (state ^problem-space.name perform) ( ^task ) ( ^feature {<> }) ( ^fname effect ^fvalue ) ( ^fname arg1 ^fvalue ) --> (write (crlf) |State has ^task: effect=| | arg1=| )} sp {perform*monitor*state*action (state ^problem-space.name perform) ( ^action ) ( ^movement ^object ) --> (write (crlf) |State has ^action: | | | )} ### ====================================================================== ### EOF ### ======================================================================