### Program analogy.soar
### 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
### Converted to Soar 7 by unknown hand
### Some minor cleaning up, RMY 3 Mar 96
### Some minor cleaning up and move to 7.0.4, 2-Nov-96 -FER
### 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.
### Note that this program does NOT want the default rules loaded.
### 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@psyc.nott.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.
### ======================================================================
source soar-menu.tcl
## For safty, excise -all
excise -all
## this makes chunk firings print
watch -chunks -print
## default is not to print chunks as learned!
watch learning -print
## this will always take the first choice
indifferent-selection -first
### This format is specifically for monitoring the Imagine-Task space
### 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 |(| )
( ^type imaginary ^alias imagine-task)
-->
(write | type = imaginary alias = imagine-task|)}
### Ask what program to launch
## the non TK version
if {[info commands tk]==""} {
sp {preamble*ask-program-to-launch
(state ^name perform)
( )}
sp {perform*initialise*state
(state )
( ^name action-proposal)}
### -- Assumed knowledge --
### Here we hand-code the assumed knowledge about how to launch Word or Draw
### by double-clicking. When used, this will give rise to specific chunks
### back in the Perform space.
### If the task is to launch Word or Draw, then propose an action to
### double-click.
sp {action-proposal*read-big-hand
(state )
( ^name use-analogy)
( ^problem-space ^name perform)
( ^task ^name perform)
( ^task ^name perform)
( ^task ^superstate nil)
-->
( ^name perform ^problem-space ^name perform)
-->
( ^task ^problem-space.name perform)
( ^action )
-->
( ^operator ^problem-space.name perform ^operator ^motor ^problem-space ^motor ^simulation ^problem-space.name perform)
# ( ^task ^action )
# ( ^movement double-click ^object ^problem-space.name perform)
( ^task ^problem-space.name perform)
( ^action )
( ^movement ^superstate ^problem-space ^problem-space.name action-proposal ^superstate ^problem-space.name action-proposal)
-->
( ^operator ^superstate ^problem-space ^task-state ^problem-space.name use-analogy)
( ^task-state.task ^analogy-method analogy-1)}
### Attempt to recall other members of the same object class (= (2) & (3)).
### Note that this part is being handled very crudely. Since we don't have
### a justified representation of categorial knowledge, we're simply going
### to map directly from program -> Word and Draw.
### I ought properly to be doing this with operators (for recall, etc.),
### but since this part is all monotonic and elaborative, I'm using plain
### old elaborations.
### Get the class of the object (= step 2) (NB specialised for CG or XL)
### NB Notice how the first two clauses in this and subsequent rules are
### separated off, to give a standard beginning saying "Hey! We're
### applying the analogy-1 method".
sp {use-analogy*analogy-1*get-object-class*cg-xl
(state ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^task-state.task ^object-class program)}
### Recall other members of that class [program] (= step 3)
sp {use-analogy*analogy-1*recall-members*program
(state ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^object-class program)
-->
( ^class-member |1| + |1| =, |2| + |2| =, |3| + |3| =, |4| + |4| =, |5| + |5| =, |6| + |6| =, |7| + |7| =, |8| + |8| =, |9| + |9| =, |10| + |10| =, |11| + |11| =, |12| + |12| =)}
# Note that the items are made indifferent
### -- Imagining the task -- (= step 4)
### Now the fun starts. For a given ^class-member, we imagine the task
### which is the given task applied to the class-member. We do this via
### an operator, because it is going to be important to do the actual
### imagining in a subgoal which closely resembles the top context.
sp {use-analogy*analogy-1*imagine-task*propose
(state ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^object-class ^task-state.task ^operator ^problem-space.name use-analogy ^operator ^problem-space.name use-analogy ^operator ^analogy-method analogy-1)
;
( ^class-member ^class-member ^problem-space.name use-analogy ^operator ^analogy-method analogy-1)
;
( ^operator ^problem-space.name use-analogy ^operator ^analogy-method analogy-1)
;
( ^imagined-action )
( ^operator ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^imagined-action )
-->
( ^analogised-action ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^imagined-action ^analogised-action ^problem-space.name use-analogy)
( ^analogy-method analogy-1)
;
( ^imagined-action ^analogised-action ^task-state.task