diff --git a/Documentation/Soar8Manual.pdf b/Documentation/Soar8Manual.pdf new file mode 100644 index 0000000..288e829 Binary files /dev/null and b/Documentation/Soar8Manual.pdf differ diff --git a/Documentation/TutorialPart1.pdf b/Documentation/TutorialPart1.pdf new file mode 100644 index 0000000..8092303 Binary files /dev/null and b/Documentation/TutorialPart1.pdf differ diff --git a/Documentation/TutorialPart2.pdf b/Documentation/TutorialPart2.pdf new file mode 100644 index 0000000..98d0edf Binary files /dev/null and b/Documentation/TutorialPart2.pdf differ diff --git a/Documentation/TutorialPart3.pdf b/Documentation/TutorialPart3.pdf new file mode 100644 index 0000000..67269b2 Binary files /dev/null and b/Documentation/TutorialPart3.pdf differ diff --git a/Documentation/TutorialPart4.pdf b/Documentation/TutorialPart4.pdf new file mode 100644 index 0000000..22a28ab Binary files /dev/null and b/Documentation/TutorialPart4.pdf differ diff --git a/Documentation/TutorialPart5.pdf b/Documentation/TutorialPart5.pdf new file mode 100644 index 0000000..8167b69 Binary files /dev/null and b/Documentation/TutorialPart5.pdf differ diff --git a/Documentation/TutorialPart6.pdf b/Documentation/TutorialPart6.pdf new file mode 100644 index 0000000..7a2e807 Binary files /dev/null and b/Documentation/TutorialPart6.pdf differ diff --git a/Documentation/soar7-to-soar8.txt b/Documentation/soar7-to-soar8.txt new file mode 100644 index 0000000..5eda6b8 --- /dev/null +++ b/Documentation/soar7-to-soar8.txt @@ -0,0 +1,77 @@ + List of changes required in upgrading from Soar 7 to Soar 8. + John E. Laird + December 11, 1998 + +This document list the changes that have to be made to Soar 7 programs +so that they run under Soar 8. + +1. All preferences in attributes are eliminated. Soar 8 uses + preferences exclusively for the selection of operators. + A. Previous use of preferences such as best (>) and worst (<) for + values of attributes to create defaults must be eliminated. You + may need to add operators to select the values of these attributes + explicitly. + B. Parallel preferences (&) are no longer needed to allow + multi-valued attributes - attributes that have more than one value + in working memory. All attributes (except the operator attribute + of a state) can have multiple values. + C. There are no longer any attribute impasses. + +2. The order of input, decision, and output has changed. The new +ordering is: + + input -> operator propose -> decision -> operator apply -> output + ^ i-support o-support & | + | i-support | + -------------------------------------------------------------- + + A. Input is called only once per decision. + B. Output is called only once per decision. + C. Only rules that create i-supported structures fire during the + operator propose phase. Rules fire in parallel and to quiescence. + D. During the operator apply phase, all matched rules fire in + parallel and to quiescence. + These changes do not necessarily lead to any change in your software, + and may even allow you to simplify your software. + +3. Selected operators are removed (the ^operator working memory + element is removed) as soon as the operator either no longer has an + acceptable preference, or if it would not stay selected because of + changes in the preferences. A new operator is selected only during + decision (thus, there may be parts of the cycle in which no operator + is selected). + + This process replaces the reconsider preference for operators - Soar + 8 does not support reconsider. You will need to remove all of the + rules that create reconsider preferences (terminate*operator rules). + + You may need to ``tweak'' the conditions of your proposals so that an + operator is not removed too early or too late. You may also need to + split an operator that created or changed many internal data + structures in sequence into separate operators because the operator + will probably be retracted as soon as the first data structure is + modified (which will probably cause the operator proposal to + retract). + +4. Goals (substates) are automatically retracted if any of the + o-supported structure in them become ``inconsistent'' with higher + levels of the goal/state stack. A goal with o-supported structure is + removed if any of the working memory elements in higher level + goals/states that were tested along the path to creating the + o-supported structure are removed. + + The easiest thing to do in response to this change is move + o-supported structures up to the top-level state. + +5. Dot notation is legal in actions. + +Some other changes that aren't required, but might be nice to note: + +1. RHS dot notation +2. Ability to run til agent produces output +3. Some ONCs are "free" (detected immediately, without extra decision cycles) + +In the section on the new decision cycle, we should indicate that +the TSI includes a facility to allow users to stop after the decision +phase. We could also include the info needed to set up callbacks +after the decision phase. diff --git a/Soar Suite 8.5.2 Release Notes.txt b/Soar Suite 8.5.2 Release Notes.txt new file mode 100644 index 0000000..40e076c --- /dev/null +++ b/Soar Suite 8.5.2 Release Notes.txt @@ -0,0 +1,185 @@ + Summary of changes between SoarSuite 8.5.1 and SoarSuite 8.5.2 + July, 2004 + + +A summary of changes in SoarSuite 8.5.2 is listed immediately below. For more +details, including changes not mentioned in the summary and a list of known +issues see the Details section after the summary. + +====================== +New Windows Installer: +====================== + + The Windows installer is now built with a different technology which +is much easier for us and results in a much smaller package. + +========================= +Several kernel bug fixes: +========================= + + Almost all known bugs fixed, including all known crash bugs. See the +details section below for more information. + +================== +New TankSoar Bots: +================== + + TankSoar now comes with two new bots. Mapping-bot demonstrates how a +tank might build up an internal map of the level. Obscure-bot is a challenge bot +for people to test their own bots against. The code is provided in an obfuscated +binary. See obscure-bot.txt in the TankSoar agents directory for details. + +========================== +SoarDoc and DMGen updated: +========================== + + These changes were actually in the the 8.5.1 release, but we failed +to note them. +SoarDoc: + - Fixed special character handling when UseExistingComments is used. + - Added ShowProdSourceInline which shows production source code + inline in the production documentation + - Ability disable datamap node coloring + - Fixed case-sensitivity issues for production names and list sorting. +DMGen: + - Fixed handling of mixed-case production names. + +====================== +Documentation Updated: +====================== + + The tutorials have had some typo fixes and screenshot updates, and also +explain substates better. + +================== +Tcl Soar Debugger: +================== + + The TSDebugger has several bug fixes which may have affected some +users. + +=================== +VisualSoar Updated: +=================== + + VisualSoar has several small bug fixes. + +====================== +Critical SGIO bug fix: +====================== + + Our fix for bug 254 in the last release actually caused serious +problems. This has been fixed for real now. + +==================================================================== + Details +==================================================================== + +Below is a fairly complete list of enhancements, changes, bug fixes, and known +issues, with bug numbers for reference. For more information and up to date list +of what's been fixed please visit the Soar bugzilla server at: + + https://winter.eecs.umich.edu/soar-bugzilla/. + +New bug submissions and enhancement requests are welcome! + + +Soar-8.5.2 +========== + +Bug Fixes +--------- +353 stats command keeps recording between runs +389 missing error handling for set_watch_prod_group_setting + +Enhancements +------------ +358 change soar8 command error message + +Known Issues +------------ +312 agent structure isn't cleaned up properly +356 All matches get same support as last processed match + +TSDebugger 4.0.1 +================ + +Bug Fixes +--------- +365 rules that contain a capital letter break productions tab +376 stop button doesn't work with Eaters, TankSoar +396 error when closing group from task bar +398 extra 0 gets printed when soar connected to environments + +Known Issues +------------ +336 negated conditions don't print properly in the console window +397 grouping bar in production tab not always right + +SGIO 1.1.2 +========== + +Bug Fixes +--------- +254 Some special characters in StringWME's do not transfer to Soar + +Eaters 3.0.8 +============ + +Bug Fixes +--------- +391 garbage printed to debugger output when Stop After Decision Phase is on + +TankSoar 3.0.8 +============== + +Bug Fixes +--------- +map loading menu now defaults to maps directory +188 Selecting Map->Random Map causes error message when agent present on + current map +392 garbage printed to debugger output when Stop After Decision Phase is on +393 command 'run 1' generates 'invalid command step' error + +Enhancements +------------ +new challenge bot (obscure-bot) and mapping bot provided + +Known Issues +------------ +399 can't use reset tank command in tank control panel tanks menu + +Documentation +============= + +Bug Fixes +--------- +349 tutorial images need to be updated +375 typo in tutorial part 1: move-north +386 typos in tutorial part 1 (search control) + +Enhancements +------------ +Added information to tutorial about substates. + +Known Issues +------------ +380 typo in section 5.6.3 +381 o-support-mode command missing newest support modes + +VisualSoar 4.5.3 +================ + +Bug Fixes +--------- +361 adding a dir that doesn't exist to agent path on file->new project fails with no warning +362 initial rules in a project are not justified correctly +363 if project loaded then create new project, title bar does not change +364 file with same name as datamap have same window names +366 Initialize- Operator not in datamap +368 dragging node onto itself makes node disappear +372 fails to detect extra whitespace after : + +Known Issues +------------ +Too many to list. See bugzilla for details. \ No newline at end of file diff --git a/dmgen-1.0.0/doc/dmgen.pdf b/dmgen-1.0.0/doc/dmgen.pdf new file mode 100644 index 0000000..e1a4265 Binary files /dev/null and b/dmgen-1.0.0/doc/dmgen.pdf differ diff --git a/dmgen-1.0.0/license.txt b/dmgen-1.0.0/license.txt new file mode 100644 index 0000000..2927b54 --- /dev/null +++ b/dmgen-1.0.0/license.txt @@ -0,0 +1,34 @@ +Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. + +The views and conclusions contained in the software and documentation +are those of the authors and should not be interpreted as representing +official policies, either expressed or implied, of Soar Technology, Inc., +the University of Michigan, or the Soar consortium. + diff --git a/dmgen-1.0.0/readme.txt b/dmgen-1.0.0/readme.txt new file mode 100644 index 0000000..058a803 --- /dev/null +++ b/dmgen-1.0.0/readme.txt @@ -0,0 +1,5 @@ +dmgen - Soar datamap generation tool by Soar Technology, Inc. + +Please see doc/dmgen.doc for details on running dmgen. The +main dmgen program script is src/dmgen.tcl. + diff --git a/dmgen-1.0.0/src/bwutil.tcl b/dmgen-1.0.0/src/bwutil.tcl new file mode 100644 index 0000000..4bfc8d9 --- /dev/null +++ b/dmgen-1.0.0/src/bwutil.tcl @@ -0,0 +1,145 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# BWidget utilities +# +# A set of utilities for dealing with widgets, mostly BWidgets. +package require BWidget + +namespace eval BwUtil { + +# Expand all the nodes in a BWidget tree widget. +proc ExpandBWidgetTree { t } { + set ch [$t nodes root 0 end] + foreach n $ch { + $t opentree $n + } +} + +# Given a graph and a start vertex, fills in a BWidget tree with +# using the value of $field as the label of each node. +# The tag of each tree node is the same as its corresponding vertex in the +# graph. +# The -data property of each tree node is filled with a 'struct' with the +# following values: +# BackEdges - List of adjacencies to this vertex that could not +# be connected because they would have formed a cycle (not easy +# to display with a tree :) +# Here's an example of getting at this data: +# array set data [$tree itemcget $node -data] +# puts "Backedges = $data(Backedges)" +# +# @param treeName Tree widget +# @param graph The source graph +# @param vert The starting vertex in the graph (only child of root) +# @param field The name of the vertex field that should be used as node +# label. (e.g, name) +proc NewBWidgetTreeFromGraph { treeName graph vert field } { + set w [Tree $treeName] + foreach v [$graph GetVertices] { + set visited($v) 0 + } + set visited($vert) 1 + + set NV [Graph::NullVertex] + set L [list [list $vert $NV]] + + while { [llength $L] > 0 } { + set vl [lindex $L 0] ;# Get head of queue + set L [lrange $L 1 end] ;# pop head of queue + + set c [lindex $vl 0] ;#child + set p [lindex $vl 1] ;#parent + if { $p == $NV } { set p root } + + $w insert end $p $c -text [$graph Get $c $field] + set be {} ;# accumulate back edges + foreach v [$graph GetOutAdjacencies $c] { + if { !$visited($v) } { + set visited($v) 1 + lappend L [list $v $c] + } else { + puts "backedge!" + lappend be $v + } + } + $w itemconfigure $c -data [list BackEdges $be] + } + return $w +} + +# Returns the selected text of a combo box. +proc GetComboBoxText { cb } { + return [lindex [$cb cget -values] [$cb getvalue]] +} + +# Sets a combo box selection from a text value (rather than an index) +# +# @param cb Widget path +# @param v Text value that should be selected. +# @returns The index of the selection, or -1 if it wasn't there. +proc SetComboBoxValue { cb v } { + set i [lsearch -exact [$cb cget -values] $v] + if { $i != -1 } { + $cb setvalue @$i ;# who knows why you need the @. + } + return $i +} + +# Set the text of an entry box +proc SetEntryText { e s } { + set old [$e get] + $e delete 0 [expr [string length $old] + 1] + $e insert 0 $s + return $old +} + +# Get the text from a text widget. +proc GetTextBoxText { t } { + return [$t get 0.0 "end -1 chars"] +} + +# Set the text in a text widget. +proc SetTextBoxText { e s } { + set old [GetTextBoxText $e] + $e delete 0.0 "end + 1 chars" + $e delete 0.0 ;# Get rid of last extra new-line + $e insert 0.0 $s + return $old +} + +} ;# namespace eval BwUtil diff --git a/dmgen-1.0.0/src/config.tcl b/dmgen-1.0.0/src/config.tcl new file mode 100644 index 0000000..84ffbc9 --- /dev/null +++ b/dmgen-1.0.0/src/config.tcl @@ -0,0 +1,235 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# dmgen Config file module. + +namespace eval DmGenCfg { + + variable defaults { + __section__ 0 +"dmgen configuration file.\n\n\ +Various configuration parameters can be set with this file.\n\ +Parameters are set with this syntax:\n\ +\tSet ParameterName ParameterValue\n\ +Note that is Set with a CAPITAL S\n\ +If ParameterValue has white space, it must be enclosed in quotes.\n\ +Comments are started with the # symbol." + + __section__ 0 "Setup parameters." + + SoarLibraryPath "" +"Path to Soar library (i.e. /path/to/Soar-x.x/library).\n\ +If this is just an empty string, then the SOAR_LIBRARY environment\n\ +variable is used.\n\ +Example: Set SoarLibraryPath \"c:/soar-8.3/library\"" + + __section__ 0 "Datamap generation parameters." + + ProblemSpaceSpec "name" +"Problem-space path specifier. Space delimited list of attributes\n\ +that gives the path to the problem-space name.\n\ +For TacAirSoar-style systems (^problem-space.name), this would be:\n\ +\tSet ProblemSpaceSpec \"problem-space name\"\n\ +For Visual Soar-style systems (^name), this would be:\n\ +\tSet ProblemSpaceSpec \"name\"" + + FillTopPs 1 +"Put anything under a top-state into the top-ps problem space,\n\ +even if it doesn't explicitly reference top-ps problem space name." + + FillAnyPs 1 +"If a production does not test a problem space name, put the\n\ +attributes it tests into the any-ps problem space." + + CopyTopPs 1 +"If FillTopPs is on, copy top-state attributes to top-ps,\n\ +but leave them in the original problem-space as well." + + SaveSourceProds 1 +"Store source production info in the 'prods' attribute of\n\ +each node in the datamap. Since these lists can get really\n\ +long, turning this off can speed things up a bit." + + ExcludedProds {} +"List of productions that should be excluded from processing.\n\ +Removing large productions that simply load data structures, such as\n\ +maps, can speed up datamap generation process a lot.\n\ +Example: Set ExcludedProds { elaborate*foo propose*bar }" + + __section__ 0 "Output related parameters" + + InputFile source.soar +"Name of file, in current directory, that is sourced to load all\n\ +productions that should be processed." + + DatamapName Datamap +"Name given to generated datamap." + + OutputFormat xml +"Output format to write to. Valid values are:\n\ +\txml - Writes the datamap in XML, suitable for SoarDoc\n\ +\thtml - Writes a simple set of HTML pages\n\ +\tnone - No output\n\ +Example: Set OutputFormat xml" + + OutputDirectory xml +"Directory to which output is written, relative to current directory\n\ +at time of execution.\n\ +Example: Set OutputDirectory xml" + + LogFileName "dmgenlog.txt" +"Name of log file, written to the current directory.\n\ +If set to the empty string, then no log is written." + + LogAutoFlush 0 +"If 1, then the logis flushed everytime it is written to.\n\ +This can slow things down a lot, but may be useful for debugging." + + __section__ 0 "HTML output related parameters" + + HtmlHideState 1 +" Don't show the root of the 'tree' since it's redundant (state or operator)" + + HtmlShowComments 1 "Write comments" + + HtmlColorPatched 0 +" If a vertex has been patched by the user, highlight its name." + + HtmlShowSpecial 0 +"Show values of 'special' attributes. Only really useful for debugging." + + HtmlSuppressedAttributes {} +"List of attribute names that will not be written." + + HtmlMaxValuesPerLine 4 +"Maximum number of attribute values that will be written inline before +they are moved to the separate values window." + + HtmlMaxSoarListDepth 4 +"Maximum depth to which a detectable soarList is displayed." + + } + + # Table of parameter values, indexed by param name + variable params + if [array exists params] { unset params } + + ## + # Read a config file. + proc Read { fileName } { + source $fileName + } + + ## + # Write a config file to the given file. + # + # @param fileName Name of file to write to, or stdout if it is "" + proc Write { { fileName "" } } { + if { $fileName != "" } { + set fd [open $fileName w] + } else { + set fd stdout + } + variable defaults + variable params + foreach { name value comments } $defaults { + if { $name != "__section__" } { + puts $fd "##\n# - $name -" + set c [join [split $comments "\n"] "\n# "] + puts $fd "# $c" + set v $params($name) + puts $fd "Set $name [escapeValue $v]\n" + } else { + puts $fd "###############################################################################" + set c [join [split $comments "\n"] "\n# "] + puts $fd "# $c\n" + } + } + if { $fd != "stdout" } { + close $fd + } + } + + ## + # Set the value of a parameter. + # + # @param param Name of parameter + # @param value Value of parameter + proc Set { param value } { + variable params + set params($param) $value + + # Custom param setting code + # Todo, make this more data driven! + if { $param == "ProblemSpaceSpec" } { + Production::ProblemSpaceSpec $value + } elseif { $param == "LogFileName" } { + LogSetFileName $value + } elseif { $param == "LogAutoFlush" } { + LogSetAutoFlush $value + } + + } + + ## + # Get the value of a parameter + # + # @param Name of parameter + proc Get { param } { + variable params + return $params($param) + } + + proc escapeValue { v } { + set v [join [split $v "\\"] "\\\\"] + set v [join [split $v "\""] "\\\""] + if { $v == "" || [regexp "\[ \r\n\t\]" $v] } { + set v "\"$v\"" + } + return $v + } + + # + # Load the default values into the parameter value table. + # do this last so we know that Set proc is loaded and callable. + foreach { name val comments } $defaults { + if { $name != "__section__" } { + Set $name $val + } + } + +} ;# namespace eval DmGenCfg diff --git a/dmgen-1.0.0/src/datamap.tcl b/dmgen-1.0.0/src/datamap.tcl new file mode 100644 index 0000000..8204f7e --- /dev/null +++ b/dmgen-1.0.0/src/datamap.tcl @@ -0,0 +1,511 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Datamap management code. Manages a set of datamaps created by the user. +# Also has the Generate function for generating a datamap from a set of +# productions. Here's the typical usage: +# ... Load productions ... +# set dm [Datamap::Create "Name Of Datamap"] +# Datamap::Generate $dm +# # Now you can use the various accessor functions to get at the produced +# # datamap. +# +# Requires: +# util.tcl +# graph.tcl +# log.tcl +# production.tcl +# partition.tcl +# merge.tcl +# config.tcl +# soarutil.tcl + +namespace eval Datamap { + + # Returns a list of valid vertex field names + # + # name - Name of the "attribute" + # value - List of values of the attribute + # side - Which side of the production was the attribute on + # L = left + # R = right + # B = both + # type - Type of the attribute (int string identifier unknown) + # range - currently unused + # link - A link to another problemspace or operator. Is a list + # where the first element is O or S to indicate type followed + # by names of targets...e.g. + # { S top-ps any-ps attack-delivery } + # + # prods - List of production names that contributed to this node. + # + proc VertexFields {} { + return [list name \ + value \ + side \ + type \ + range \ + link \ + special \ + prods \ + comment \ + patched] + } + # Returns a 'struct' of default vertex field values + proc DefVertexFields {} { + return [list name unknown \ + value {} \ + side B \ + type identifier \ + range {} \ + link {} \ + special {} \ + prods {} \ + comment "" \ + patched {}] + } + + variable datamaps + set datamaps(0) 0 + + ## + # Creates a datamap (problem-spaces + operators) and returns a handle to it + # + # @param name User-specified name given to the datamap. + # @returns A handle to the datamap for use in later calls. + proc Create { { name "" }} { + variable datamaps + set dm [GetTag DM] + set datamaps($dm,name) $name + return $dm + } + + ## + # Clear the contents of a datamap. Good for resetting before another call + # to Generate. + # + # @param dm Datmap handle. + proc Clear { dm } { + variable datamaps + # Clean up graphs + foreach n [array names datamaps $dm,*,*,graph] { + Graph::Destroy $datamaps($n) + } + # Clean up entries + foreach n [array names datamaps $dm,*,*,*] { + unset datamaps($n) + } + } + ## + # Remove a datamap from memory. The handle will be useless afterward. + # + # @param dm handle of datamap to destroy. + proc Destroy { dm } { + variable datamaps + Clear $dm + unset datamaps($dm,name) + } + + ## + # Returns the user specified name of a datamap. + proc GetName { dm } { + variable datamaps + if ![info exist datamaps($dm,name)] { + return "" + } + return $datamaps($dm,name) + } + ## + # Create a datamap structure for a problem-space or operator + # + # @param dm Datamap handle + # @param type S (problem space) or O (operator) + # @param name Name of ps or op (no whitespace!) + # @returns Handle to ps or op + proc createPsOrOp { dm type name } { + set g [Graph::Create [VertexFields]] + set s [$g InsertVertex [DefVertexFields]] + + set names(S) "state" + set names(O) "operator" + + $g Set $s name $names($type) + + variable datamaps + set datamaps($dm,$type,$name,graph) $g + set datamaps($dm,$type,$name,start) $s + return "$dm,$type,$name" + } + ## + # Same as createPsOrOp, except that if the requested ps or op already + # exists, the existing one is returned rather than creating a new one. + # + # @param dm Datamap handle + # @param type S (problem space) or O (operator) + # @param name Name of ps or op (no whitespace!) + # @returns Handle to ps or op + proc findOrCreatePsOrOp { dm type name } { + set h [GetPsOrOp $dm $type $name] + if { $h != {} } { + return $h + } + return [createPsOrOp $dm $type $name] + } + ## + # Create a new problem-space and return a handle to it + # + # @param dm Datamap handle + # @param name Name of problem-space (no whitespace!) + # @returns a new problem-space handle + proc CreateProblemSpace { dm name } { + return [createPsOrOp $dm S $name] + } + proc FindOrCreateProblemSpace { dm name } { + return [findOrCreatePsOrOp $dm S $name] + } + ## + # Create a new operator and return a handle to it + # + # @param dm Datamap handle + # @param name Name of operator (no whitespace!) + # @returns a new operator handle + proc CreateOperator { dm } { + return [createPsOrOp $dm O $name] + } + proc FindOrCreateOperator { dm name } { + return [findOrCreatePsOrOp $dm O $name] + } + + ## + # Remove a problem space or operator from datamap + proc removePsOrOp { h } { + variable datamaps + foreach n [array names datamaps $h,*] { + unset datamaps($n) + } + } + proc RemoveProblemSpace { h } { removePsOrOp $h } + proc RemoveOperator { h } { removePsOrOp $h } + + ## + # Returns a list of ps or op handles in the datamap. + # + # @param dm Datamap handle + # @param type S or O + # @returns List of problem-space or operator handles + proc getPsOrOps { dm type } { + variable datamaps + set r {} + foreach d [array names datamaps $dm,$type,*,graph] { + lappend r [join [lrange [split $d ","] 0 2] ","] ;#Handle + } + return $r + } + + proc GetProblemSpaces { dm } { return [getPsOrOps $dm S] } + proc GetOperators { dm } { return [getPsOrOps $dm O] } + + ## + # Generate or append to the given datamap using the information in the given + # productions. If no productions are given, then all loaded Soar productions + # are used. + # + # @param dm Datamap handle returned by Create + # @param prods Optional list of names of productions to process + proc Generate { dm { prods {} } } { + + Log "" + Log [clock format [clock seconds]] + Log "Datamap generation initiated for datamap [GetName $dm]" + if { [llength $prods] == 0 } { + Log "No productions specified, using all loaded productions." + set prods [SoarUtil::GetSoarProductions] + } + set total 0 + set passedParse 0 + set failedParse 0 + set psOrOpFound 0 + set noPsOrOpFound 0 + foreach p $prods { + Log "Parsing production: $p" + incr total + set g [Production::Parse $p] + if { $g == {} } { + LogError "Error parsing production: $p" + incr failedParse + } else { + incr passedParse + set parts [Partition::PartitionProduction $g] + if { $parts != {} } { + incr psOrOpFound + Log "Processing production partitions" + ProcessProd $dm $p $g $parts + # If the user wants topstate stuff also copied to the ps that + # it's used in, we do it one more time with slightly different + # options. This is a bit of a hack, but... + if { [DmGenCfg::Get CopyTopPs] && [DmGenCfg::Get FillTopPs] } { + DmGenCfg::Set FillTopPs 0 + set parts [Partition::PartitionProduction $g] + if { $parts != {} } { + Log "Copying top-state to calling problem space" + ProcessProd $dm $p $g $parts + } + DmGenCfg::Set FillTopPs 1 + } + } else { + incr noPsOrOpFound + Log "No problem spaces or operators identified" + } + } + } + Log "Updating attribute types" + foreach ps [concat [GetProblemSpaces $dm] [GetOperators $dm]] { + updateAttrTypes $ps + } + + Log "Pruning extraneous problem-space and operator names" + foreach ps [concat [GetProblemSpaces $dm] [GetOperators $dm]] { + prunePsAndOpNames $ps + } + + # Sort attributes alphabetically by name + Log "Sorting attributes" + SortAttributes $dm [DefAttrSortPriority] + + Log [clock format [clock seconds]] + Log "Datamap Generation complete:" + Log " $total productions attempted" + Log " $failedParse productions failed to parse" + Log " $passedParse productions parsed successfully" + Log " $psOrOpFound productions had identifiable problem space or operator" + Log " $noPsOrOpFound productions had NO identifiable problem space or operator" + LogFlush + } + + ## + # Get handle to a PS or OP from its type and name + # @param dm datamap handle + # @param type S or O + # @param name Name of ps or op + proc GetPsOrOp { dm type name } { + variable datamaps + set h "$dm,$type,$name" + if [info exists datamaps($h,graph)] { + return $h + } + return {} + } + + ## + # Get handles to particular PS or op of a datamap. Returns {} if it + # doesn't exist. + proc GetProblemSpace { dm name } { return [GetPsOrOp $dm S $name] } + proc GetOperator { dm name } { return [GetPsOrOp $dm O $name] } + + # What datamap does this handle belong to? + proc GetDatamap { h } { + return [lindex [split $h ","] 0] + } + # What is the name of the PS or OP that this handle points to. + proc GetPsOrOpName { h } { + return [lindex [split $h ","] end] + } + ## + # What is the type of this handle + # Problem-space -> S + # Operator -> O + proc GetType { h } { + return [lindex [split $h ","] 1] + } + # Is this handle for a problem space? + proc IsProblemSpace { h } { + return [expr [string compare [GetType $h] "S"] == 0] + } + # Is this handle for an operator? + proc IsOperator { h } { + return [expr [string compare [GetType $h] "O"] == 0] + } + # Get the graph for this handle + proc GetGraph { h } { + variable datamaps + return $datamaps($h,graph) + } + # Get the start vertex for the graph of this handle + # i.e. The state or operator vertex. + proc GetStartVertex { h } { + variable datamaps + return $datamaps($h,start) + } + + ## + # Find a vertex given a vertex name path + # + # @param dmGraph Graph + # @param start Vertex to start search from + # @param path List of vertex names e.g. { state operator name } + # @returns The vertex tag, or Graph::NullVertex if not found + proc FindVertexFromPath { dmGraph start path } { + set NV [Graph::NullVertex] + + set v $start + + set n [lindex $path 0] + if { [string compare [$dmGraph Get $v name] $n] != 0 } { + return $NV + } + if { [llength $path] == 1 } { + return $v + } + set path [lrange $path 1 end] + + foreach s $path { + set v [$dmGraph FindVertex name $s [$dmGraph GetOutAdjacencies $v]] + if { $v == $NV } { + return $NV + } + } + return $v + } + + ## + # Default priority list for datamap attribute sorting. + proc DefAttrSortPriority { } { + return [list { \ + attribute \ + impasse \ + operator \ + problem-space \ + superstate \ + top-state \ + io \ + name \ + }] + } + + ## + # Sort the sub nodes of each node by name. + # Names are sorted alphabetically unless the appear in the priority list. If + # a name appears in the priority list, it will sort higher than any other + # name, unless the other name is also in the priority list and appears + # earlier. + # + # After this is called, a call to GetOutAdjacencies of any graph vertex will + # return the adjacencies in the sorted order. + # + # @param dm Datamap to sort + # @param pri Name priority list + proc SortAttributes { dm pri } { + set stype(float) -real + set stype(int) -integer + set stype(string) -ascii + + foreach ps [concat [GetProblemSpaces $dm] [GetOperators $dm]] { + set g [GetGraph $ps] + foreach v [$g GetVertices] { + $g SortOutAjacencies $v name "Datamap::byNameSortFunc $pri " + + # Sort the values of the attribute if the type is known. + set t [$g Get $v type] + if { $t != "unknown" && $t != "identifier" } { + set vals [$g Get $v value] + $g Set $v value [lsort $stype($t) $vals] + } + } + } + } + + ## + # Vertex comparison function for sorting nodes by name using a priority list. + # + # @param priority Priority list + # @param g The graph (passed by Graph::SortOutAjacencies) + # @param field The field (passed by Graph::SortOutAjacencies) + # @param v1 First vertex + # @param v2 Second vertex + # @returns -1,0, or 1 indicating result of comparing v1 to v2 + proc byNameSortFunc { priority g field v1 v2 } { + set n1 [$g Get $v1 name] + set n2 [$g Get $v2 name] + + set i1 [lsearch $priority $n1] + set i2 [lsearch $priority $n2] + + if { $i1 >= 0 && $i2 >= 0 } { ;# They're both in the priority list + return [expr $i1 - $i2] + } elseif { $i1 >= 0 } { ;# v1 is in the priority list + return -1 + } elseif { $i2 >= 0 } { ;# v2 is in the priority list + return 1 + } else { ;# neither is in the priority list, sort alphabetically, case-insensitive + return [string compare [string tolower $n1] [string tolower $n2]] + } + } + + ## + # Fix up the type of the attributes after generation + proc updateAttrTypes { psOrOp } { + set g [GetGraph $psOrOp] + foreach v [$g GetVertices] { + if { [$g Get $v link] != {} || [llength [$g GetOutAdjacencies $v]] > 0 } { + $g Set $v type identifier + } else { + $g Set $v type [SoarUtil::GuessSoarTypeFromList [$g Get $v value]] + } + } + } + + proc prunePsAndOpNames { psOrOp } { + if [IsProblemSpace $psOrOp] { + set spec "ProblemSpaceSpec" + } else { + set spec "OperatorSpec" + } + set g [GetGraph $psOrOp] + set name [GetPsOrOpName $psOrOp] + + foreach v [$g GetVertices] { + if { [$g Get $v special] == $spec } { + set vals [$g Get $v value] + if { [llength $vals] > 0 && \ + [lsearch -exact $vals $name] != -1 } { + $g Set $v value $name + } + } + } + } +} ;# namespace Datamap + diff --git a/dmgen-1.0.0/src/dijkstra.tcl b/dmgen-1.0.0/src/dijkstra.tcl new file mode 100644 index 0000000..517416f --- /dev/null +++ b/dmgen-1.0.0/src/dijkstra.tcl @@ -0,0 +1,151 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Implementation of Dijkstra's single-source shortest paths algorithm. +# +# requires: +# graph.tcl + +namespace eval Dijkstra { + + variable d + set d([Graph::NullVertex]) {} + variable pi + set pi([Graph::NullVertex]) {} + + proc Inf { } { return 99999999 } + + ## + # Algorithm initialization function. Called internally + proc initSingleSource { g s } { + variable d + variable pi + foreach v [$g GetVertices] { + set d($v) [Inf] + set pi($v) [Graph::NullVertex] + } + set d($s) 0 + } + + ## + # Vertex 'relaxation' used internally. + proc relax { u v w } { + variable d + variable pi + if { $d($v) > $d($u) } { + set d($v) [expr $d($u) + [$w $u $v]] + set pi($v) $u + } + } + + ## + # Calculate single source shortest paths on a graph using Dijkstra's + # algorithm. + # Returns an adjacency array. + # + # @param g Graph to process + # @param w Edge weight function. Takes two vertices and returns the weight + # of the edge between them. See UnitWeight below. + # @param s Source vertex + # @returns An adjacency array. See test code below. + proc ShortestPaths { g w s } { + variable d + variable pi + unset d + unset pi + + initSingleSource $g $s + set s {} + set q [$g GetVertices] + while { [llength $q] > 0 } { + set u [getQMin q] + set s [lunion $s $u] + foreach v [$g GetOutAdjacencies $u] { + relax $u $v $w + } + } + return [array get pi] + } + + proc getQMin { qref } { + upvar 1 $qref q + variable d + variable pi + + set mv [lindex $q 0] + if { [llength $q] == 1 } { + set q {} + return $mv + } + foreach v [lrange $q 1 end] { + if { $d($v) < $d($mv) } { + set mv $v + } + } + set q [ldelete $q $mv] + return $mv + } + + # A weight function that returns a unit weight for all edges. + proc UnitWeight { u v } { return 1 } + + proc test { } { ;# Some test code... + set g [Graph::Create { name }] ;# Create a graph where each vertex has a 'name' field + set n1 [$g InsertVertex { name 1 }] + set n2 [$g InsertVertex { name 2 }] + set n3 [$g InsertVertex { name 3 }] + set n4 [$g InsertVertex { name 4 }] + set n5 [$g InsertVertex { name 5 }] + + $g AddEdge $n1 $n2 + $g AddEdge $n2 $n3 + $g AddEdge $n2 $n4 + $g AddEdge $n4 $n5 + $g AddEdge $n5 $n3 + + array set pi [ShortestPaths $g UnitWeight $n1] + set v $pi($n5) + while { $v != [Graph::NullVertex] } { + puts "[$g Get $v name] -> " + set v $pi($v) + } + } +} + +IfStandAlone { ;# Some test code + Dijkstra::test +} diff --git a/dmgen-1.0.0/src/dmgen.tcl b/dmgen-1.0.0/src/dmgen.tcl new file mode 100644 index 0000000..8ad7206 --- /dev/null +++ b/dmgen-1.0.0/src/dmgen.tcl @@ -0,0 +1,343 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Main dmgen program + +set dmGenVersion "1.0" + +## +# Generate a datamap and bring up the datamap window +# This function is for use when dmgen has been manually loaded +# into a Tcl interpretter. +# +# @param name Name of the datamap +# @param prods List of productions to process or {} for all loaded. +# @param compiled Strictly for debugging. Ignore. +# @returns The generated datamap +proc GenerateDatamap { { name "" } { prods {} } { compiled 1 } } { + global tk_version DmGenCompiled + + set DmGenCompiled $compiled + + set dm [Datamap::Create $name] + Datamap::Generate $dm $prods + if [info exists tk_version] { + DmWin::Create $dm + } + return $dm +} + + +### +## Everything from here down is for running from the command line. +proc dmGenUsage {} { + puts stderr "Usage: tclsh path/to/dmgen.tcl \[options\]" + puts stderr " -g : Prints a default config file to stdout." + puts stderr " -f configFile : Specify a config file. Defaults to \"dmgenfile\"." + puts stderr " -h : Print this message and exit." + puts stderr " -C param value : Set configuration parameter, overriding config file." + puts stderr " -v : Print dmgen version." +} + +proc dmGenPrintVersion { } { + global dmGenVersion + puts "Version $dmGenVersion" +} + +if [info exists dmGenArgs] { + unset dmGenArgs +} + +set dmGenArgs(GenerateConfig) 0 +set dmGenArgs(ConfigParams) {} +set dmGenArgs(Args) {} + +proc dmGenParseArgs { } { + global dmGenArgs argc argv + + for { set i 0 } { $i < $argc } { incr i } { + set arg [lindex $argv $i] + if { [string index $arg 0] == "-" } { + set opt [string range $arg 1 end] + if { $opt == "C" } { + if { [expr $argc - $i] < 3 } { + puts stderr "Too few arguments to option -C" + return 0 + } + set param [lindex $argv [expr $i + 1]] + set val [lindex $argv [expr $i + 2]] + lappend dmGenArgs(ConfigParams) $param + lappend dmGenArgs(ConfigParams) $val + + # Skip the args + incr i 2 + } elseif { $opt == "f" } { + if { [expr $argc - $i] < 2 } { + puts stderr "Too few arguments to option -f" + return 0 + } + set cfgFile [lindex $argv [expr $i + 1]] + set dmGenArgs(ConfigFile) $cfgFile + + # Skip the arg + incr i + } elseif { $opt == "g" } { + set dmGenArgs(GenerateConfig) 1 + } elseif { $opt == "h" } { + return 0 + } elseif { $opt == "v" } { + dmGenPrintVersion + exit 0 + } else { + puts stderr "Unknown option $opt" + return 0 + } + } else { + lappend dmGenArgs(Args) $arg + } + } + return 1 +} + +proc dmGenGetProdList { } { + set excluded [DmGenCfg::Get ExcludedProds] + + if { $excluded == {} } { + return {} + } + set loaded [SoarUtil::GetSoarProductions] + set prods {} + foreach p $loaded { + if { [lsearch $excluded $p] == -1 } { + lappend prods $p + } + } + return $prods +} + +proc dmGenMain { } { + global dmGenArgs DmGenCompiled env tk_version auto_path errorInfo + + puts stderr "dmgen - A Soar static datamap generation tool by Soar Technology, Inc." + + # set up auto_path for dmgen + # the foreach is just a cheap way of expanding the tuple + # without having to use lindex and all that. + foreach { dirName scriptName } [dmGenGetPathToScript] { + if { $scriptName != "dmgen.tcl" } { + puts stderr "dmGenMain must be called from top-level" + exit 1 + } + if ![file exists $dirName] { + puts stderr "Could not determine location of dmgen.tcl" + exit 1 + } + # Don't really need this any more, see related comment in tclIndex. + #set DmGenCompiled [file exists [file join $dirName "compiled.txt"]] + + lappend auto_path $dirName + break + } + + # parse args + if ![dmGenParseArgs] { + dmGenUsage + exit 1 + } + + if { $dmGenArgs(GenerateConfig) } { + # Load command-line config overrides, if any + foreach { param value } $dmGenArgs(ConfigParams) { + DmGenCfg::Set $param $value + } + DmGenCfg::Write + exit 0 + } + + # Load config file, if any + if [info exists dmGenArgs(ConfigFile)] { + set configFile $dmGenArgs(ConfigFile) + } elseif [file exists dmgenfile] { + set configFile dmgenfile + } + if [info exists configFile] { + if { [catch { DmGenCfg::Read $configFile } ] } { + puts stderr "Error while loading config file \"$configFile\":\n$errorInfo" + exit 1 + } + } + + # Load command-line config overrides, if any + foreach { param value } $dmGenArgs(ConfigParams) { + DmGenCfg::Set $param $value + } + + # set up auto_path for Soar + set soarLibPath [DmGenCfg::Get SoarLibraryPath] + if { $soarLibPath != "" } { + # user is overriding SOAR_LIBRARY env. var. + set env(SOAR_LIBRARY) $soarLibPath + } elseif [info exists env(SOAR_LIBRARY)] { + set soarLibPath $env(SOAR_LIBRARY) + } else { + LogError "No Soar library path was specified." + exit 1 + } + if ![file exists $soarLibPath] { + LogError "Specified Soar library path \"$soarLibPath\" does not exist." + exit 1 + } + lappend auto_path $soarLibPath + package require Soar + + # load user-specified source.soar + set inputFile [DmGenCfg::Get InputFile] + if ![file exists $inputFile] { + LogError "Could not find input file: $inputFile" + exit 1 + } + + puts "Sourcing input file" + if { [catch { source $inputFile }] } { + LogError "Error while sourcing input file \"$inputFile\":\n$errorInfo" + exit 1 + } + puts "Done Sourcing input file" + + # run dmgen + set dm [Datamap::Create [DmGenCfg::Get DatamapName]] + Datamap::Generate $dm [dmGenGetProdList] + if [info exists tk_version] { + DmWin::Create $dm + } + # write out any desired output... + set outFmt [DmGenCfg::Get OutputFormat] + set outDir [DmGenCfg::Get OutputDirectory] + if { $outFmt == "xml" } { + file mkdir $outDir + DmGenXmlOut::WriteXmlDatamap $outDir $dm + } elseif { $outFmt == "html" } { + file mkdir $outDir + DmGenHtmlOut::WriteHtmlDatamap $outDir $dm + } elseif { $outFmt == "none" } { + # That was easy. + } else { + LogError "Unknown output format: $outFmt" + exit 1 + } +} + +## +# Same as the proc in util.tcl, but we need it here before +# util.tcl may be loaded :( +proc dmGenJoinPathList { pathList } { + set r "" + foreach p $pathList { + set r [file join $r $p] + } + return $r +} + +## +# Same as the proc in util.tcl, but we need it here before +# util.tcl may be loaded :( +proc dmGenGetPathToScript { } { + set relPath [info script] + set scriptName [file tail $relPath] + set dirName [file dirname $relPath] + + set pathType [file pathtype $dirName] + if { $pathType == "absolute" } { + return [list $dirName $scriptName] + } elseif { $pathType == "relative" } { + set cur [file split [pwd]] + set parts [file split $dirName] + set end [llength $cur] + for { set i 0 } { $i < [llength $parts] } { incr i } { + set p [lindex $parts $i] + if { $p == ".." } { + incr end -1 + } elseif { $p != "." } { + break + } + } + set full [concat [lrange $cur 0 [expr $end - 1]] \ + [lrange $parts $i end]] + return [list [dmGenJoinPathList $full] $scriptName] + } else { ;# volumerelative + return [list $dirName $scriptName] + } +} +if $tcl_interactive { + +} else { + dmGenMain +} + +## +# Don't really need this stuff anymore. If we do need it at some point, +# it goes at the top of the file. +# +#global DmGenAutoLoaded +## Only source dependencies if we're not auto loading... +#if { ($tcl_interactive && ![info exists DmGenAutoLoaded]) } { +# puts "Not auto-loaded, sourcing files" +# source "util.tcl" +# source "log.tcl" +# source "graph.tcl" +# source "dijkstra.tcl" +# +# source "soarutil.tcl" +# source "lexer.tcl" +# source "parser.tcl" +# source "production.tcl" +# source "partition.tcl" +# source "merge.tcl" +# source "datamap.tcl" +# +# source "htmlout.tcl" +# source "xmlout.tcl" +# +# source "dmpatch.tcl" +# source "config.tcl" +# +# if [info exists tk_version] { +# source "bwutil.tcl" +# source "dmwin.tcl" +# source "patchwin.tcl" +# } +#} diff --git a/dmgen-1.0.0/src/dmpatch.tcl b/dmgen-1.0.0/src/dmpatch.tcl new file mode 100644 index 0000000..5a66810 --- /dev/null +++ b/dmgen-1.0.0/src/dmpatch.tcl @@ -0,0 +1,161 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code to support "patching" of generated datamaps. +# A patch file is a tcl file with a series of patch commands that modify +# datamap attributes and mark them as patched. The code in this file +# implements support for reading and writing patch files. +# +# The following types of patches are currently supported: +# Modifying values of datamap vertex attributes. +# 'attributes' include name, type, value, link, prods, etc. +# +# The following types of patches would be nice, but are tougher: +# Add new vertex to datamap (pretty easy) +# Remove vertex from datamap (harder) +# Add new edge to datamap (not that hard) +# +# Requires: +# dijkstra.tcl +# datamap.tcl +# graph.tcl + +namespace eval DmPatch { + + ## + # Set the value of a vertex field and update the vertex patch + # set appropriately. + # + # @param h PS or OP handle + # @param path .-seperated path from start vertex to vertex to modify + # e.g. state.operator.name + # @param field Name of field to patch + # @param value New field value + # @return 1 on success, 0 on failure + proc PatchVertex { h path field value } { + set g [Datamap::GetGraph $h] + set s [Datamap::GetStartVertex $h] + set path [split $path "."] + set v [Datamap::FindVertexFromPath $g $s $path] + if { $v == [Graph::NullVertex] } { + LogError "Vertex $path could not be found in datamap graph!" + return 0 + } + + PatchVertexFast $g $v $field $value + return 1 + } + + proc PatchVertexFast { g v field value } { + $g Set $v $field $value + + set patched [$g Get $v patched] + set patched [lunion $patched $field] + $g Set $v patched $patched + } + + proc RemoveVertex { dmStruct v } { + + } + + ## + # Write a patch file for a datamap to a file. + # + # @param dm Datamap to write patch file for + # @param fn Name of file. + # @returns 1 on success, 0 on failure. + proc SavePatches { dm fn } { + set fd [open $fn w] + set pss [lsort [Datamap::GetProblemSpaces $dm]] + set ops [lsort [Datamap::GetOperators $dm]] + foreach h [concat $pss $ops] { + writePatch $fd $h + } + close $fd + } + ## + # Write patches for a particular operator or problem space + # + # @param fd File descriptor to write to. + # @param h Handle to PS or OP. + proc writePatch { fd h } { + set g [Datamap::GetGraph $h] + set start [Datamap::GetStartVertex $h] + set type [Datamap::GetType $h] + set name [Datamap::GetPsOrOpName $h] + array set pi [Dijkstra::ShortestPaths $g Dijkstra::UnitWeight $start] + foreach v [$g GetVertices] { + set patches [$g Get $v patched] + set path [join [GetVertexPath $g $start $v pi] "." ] + foreach field $patches { + set value [$g Get $v $field] + puts $fd "DmPatch::PatchVertex \"\$PDM,$type,$name\" $path $field \{$value\}" + } + } + } + + ## + # Load a patch file and apply it to a datamap. + # + # @param dm Datamap that patches will be applied to. + # @param fn Name of file. + proc ApplyPatchFile { dm fn } { + set PDM $dm ;# The patchfile is expecting this variable.. + source $fn + } + + ## + # Get the name path to a vertex. + # + # @param g Graph + # @param s Start vertex of path + # @param v Vertex we want the path to + # @param rpi Name of an array initialized from running Dijkstra + # ShortestPaths on $g $s. + # @returns A list of vertex names, e.g. { state operator name } + proc GetVertexPath { g s v rpi } { + upvar 1 $rpi pi + + set path [$g Get $v name] + set v $pi($v) + while { $v != [Graph::NullVertex] } { + set path [concat [$g Get $v name] $path] + set v $pi($v) + } + return $path + } +} ;# namespace DmPatch diff --git a/dmgen-1.0.0/src/dmwin.tcl b/dmgen-1.0.0/src/dmwin.tcl new file mode 100644 index 0000000..80b53b5 --- /dev/null +++ b/dmgen-1.0.0/src/dmwin.tcl @@ -0,0 +1,212 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Main datamap window. +# Just has menus for saving patches and HTML export and for displaying +# problem-space and operators +# +# Requires: +# bwutil.tcl +# htmlout.tcl +# datamap.tcl +# patchwin.tcl +# dmpatch.tcl + +package require BWidget + +namespace eval DmWin { + # Get the name of the window for the given datamap + proc Get { dm } { return .$dm } + + # Create a window for the given datamap unless one already exists, in + # which case the existing window is simply raised. + proc Create { dm } { + # If there's already a window for this handle, raise it and return + set w .$dm + if [winfo exists $w] { + raise $w + return $w + } + set w [toplevel $w] + + bind $w [list DmWin::onDestroy {%W} $w $dm] + + wm title $w "Datamap: [Datamap::GetName $dm]" + + # Create a menu bar + set mb [menu $w.mb] + $w config -menu $mb + foreach m { File ProblemSpaces Operators } { + set mnu$m [menu $mb.mnu$m] + $mb add cascade -label $m -menu $mb.mnu$m + } + + $mnuFile add command -label "Apply patch file" \ + -command "DmWin::onApplyPatch $w $dm" + $mnuFile add command -label "Save patch file" \ + -command "DmWin::onSavePatch $w $dm" + $mnuFile add command -label "Export to HTML" \ + -command "DmWin::onExportToHtml $w $dm" + $mnuFile add command -label "Export to XML" \ + -command "DmWin::onExportToXml $w $dm" + + $mnuProblemSpaces config -postcommand "DmWin::psMenuPost $w $dm" + $mnuOperators config -postcommand "DmWin::opMenuPost $w $dm" + + set f [LabelFrame $w.htmlFrame \ + -text "HTML Export Options" \ + -side top -relief ridge] + foreach { v l } { HtmlHideState "Hide State/Operator" \ + HtmlShowComments "Show Comments" \ + HtmlColorPatched "Highlight Patched Attributes" \ + HtmlShowSpecial "Show special tags" } { + + set cb [checkbutton $f.[string tolower $v] \ + -text $l \ + -variable DmGenCfg::params($v) \ + -anchor w] + pack $cb -side top + } + pack [label $f.suppressedAttrLbl -text "Suppressed Attributes:"] -side top + pack [entry $f.suppressedAttr \ + -textvariable DmGenCfg::params(SuppressedAttributes)] -side top + + pack $f -side left + + return $w + } + proc onDestroy { widget w dm } { + if { [string compare $widget $w] != 0 } { return } + + # Clean up all problem-space and operator windows we've + # spawned. + set all [concat [Datamap::GetProblemSpaces $dm] \ + [Datamap::GetOperators $dm]] + foreach h $all { + if [winfo exists [PatchWin::Get $h]] { + destroy [PatchWin::Get $h] + } + } + } + proc onApplyPatch { w dm } { + set tl { + { "Datamap Patch File" { ".dmp" } } + { "All Files" {*} } + } + set f [tk_getOpenFile -title "Apply Datamap Patch File..." \ + -parent $w \ + -filetypes $tl] + if { $f != "" } { ;# user pressed open + DmPatch::ApplyPatchFile $dm $f + } + + } + proc onSavePatch { w dm } { + set tl { + { "Datamap Patch File" { ".dmp" } } + { "All Files" {*} } + } + set f [tk_getSaveFile -title "Apply Datamap Patch File..." \ + -parent $w \ + -initialfile "[Datamap::GetName $dm].dmp" \ + -filetypes $tl] + if { $f != "" } { ;# user pressed open + DmPatch::SavePatches $dm $f + } + } + + proc onExportToHtml { w dm } { + set tl { + { "HTML Files" { ".html" } } + { "All Files" {*} } + } + # tk_chooseDirectory isn't available until Tk8.3 :( + set msg "You will now be asked to choose a directory for HTML export. + Tk8.0 doesn't have a choose directory command, so please choose a file and + the HTML export will output to a directory called html located in the same + directory as the file you choose." + tk_messageBox -message $msg + set f [tk_getSaveFile -title "Export Datamap To HTML..." \ + -parent $w \ + -initialfile "[Datamap::GetName $dm].html" \ + -filetypes $tl] + if { $f != "" } { ;# user pressed open + set dirName [file join [file dirname $f] html] + file mkdir $dirName + DmGenHtmlOut::WriteHtmlDatamap $dirName $dm + } + } + + proc onExportToXml { w dm } { + set tl { + { "XML Files" { ".xml" } } + { "All Files" {*} } + } + # tk_chooseDirectory isn't available until Tk8.3 :( + set msg "You will now be asked to choose a directory for XML export. + Tk8.0 doesn't have a choose directory command, so please choose a file and + the XML export will output to a directory called XML located in the same + directory as the file you choose." + tk_messageBox -message $msg + set f [tk_getSaveFile -title "Export Datamap To XML..." \ + -parent $w \ + -initialfile "[Datamap::GetName $dm].xml" \ + -filetypes $tl] + if { $f != "" } { ;# user pressed open + set dirName [file join [file dirname $f] xml] + file mkdir $dirName + DmGenXmlOut::WriteXmlDatamap $dirName $dm + } + } + + proc psMenuPost { w dm } { + set mnu $w.mb.mnuProblemSpaces + $mnu delete 0 end + foreach ps [lsort [Datamap::GetProblemSpaces $dm]] { + set n [Datamap::GetPsOrOpName $ps] + $mnu add command -label $n -command "PatchWin::Create $ps" + } + } + proc opMenuPost { w dm } { + set mnu $w.mb.mnuOperators + $mnu delete 0 end + foreach op [lsort [Datamap::GetOperators $dm]] { + set n [Datamap::GetPsOrOpName $op] + $mnu add command -label $n -command "PatchWin::Create $op" + } + } +} diff --git a/dmgen-1.0.0/src/graph.tcl b/dmgen-1.0.0/src/graph.tcl new file mode 100644 index 0000000..a37373e --- /dev/null +++ b/dmgen-1.0.0/src/graph.tcl @@ -0,0 +1,476 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# A graph data structure +# +# The graph is stored as a table (array) +# Each vertex is given a unique tag. +# +# graph(__vertices__) = List of tags of all vertices in graph. +# graph($tag) = list of tags of adjacencent vertices, if any +# graph(__fields__) = List of user-specified fields for each vertex +# These fields are automatically unset when a vertex is +# deleted. +# $graph($tag,field) = Value of vertex field if set +# +# Sample: See test-code at end of file +# +# Requires: +# util.tcl + +namespace eval Graph { + + ## + # Constant tag used to indicate an invalid vertex tag. + proc NullVertex {} { return -1 } + +## +# Create a new graph +# +# To create a graph: +# set T [Graph::Create [list name type value]] +# +# @param List of user field names used for each vertex +# @returns Name of graph access proc +proc Create { fields } { + set graphTag [GetTag Graph] + variable $graphTag + upvar 0 $graphTag graph + + # Initialize the basic graph structure + set graph(__tag__) $graphTag + set graph(__fields__) $fields + set graph(__vertices__) {} + + # Add a global procedure for accessing this graph + # Using eval forces the variable argument list to be expanded so we can pass + # it to the proc. + proc ::$graphTag { cmd args } "return \[eval Graph::\$cmd $graphTag \$args\]" + + return $graphTag +} + +## +# Destroy a graph returned by Create. +# +# Graph::Destroy $T +proc Destroy { graph } { + unset Graph::$graph ;# Remove the table + rename $graph {} ;# Remove the access procedure +} + + +## +# Make a copy of the graph and return it. +# +# @param graphName Tree to copy +# @param fields list of Fields of new graph +# @param copycmd Command to execute to copy fields +proc Copy { graphName { fields "" } { copycmd Graph::BasicVertexCopy } } { + if { $fields == "" } { + set fields [GetFields $graphName] + } + set new [Create $fields] + + upvar 0 $graphName graph + upvar 0 Graph::$new newGraph + + set graphTag $graph(__tag__) + foreach n $graph(__vertices__) { + lappend newGraph(__vertices__) $n + set newGraph($n) $graph($n) ;# Copy adjacencies + $copycmd $new $n $graphTag $n + } + return $new +} + +## +# Insert a new vertex in the graph. +# +# @param graphName Name of graph +# #param fields List of field/value pairs to initialize the vertex (optional) +# @returns Tag of new vertex +proc InsertVertex { graphName { fields { } } } { + upvar 0 Graph::$graphName graph + + set tag [GetTag GraphVertices 1] ;# Get new tag for vertex + set graph($tag) { } + lappend graph(__vertices__) $tag ;# Add to vertex list + + SetAll $graphName $tag $fields ;# Set fields of vertex + + return $tag +} +proc AddEdge { graphName start end } { + upvar 0 Graph::$graphName graph + + set i [lsearch -exact $graph($start) $end] + if { $i < 0 } { ;# If the edge doesn't already exist + lappend graph($start) $end + } +} +proc RemoveEdge { graphName start end } { + upvar 0 Graph::$graphName graph + + set graph($start) [ldelete $graph($start) $end] +} +# Set a single field of a vertex +proc Set { graphName vertex name value } { + upvar 0 Graph::$graphName graph + set graph($vertex,$name) $value +} +proc SetL { graphName vertex values } { + upvar 0 Graph::$graphName graph + foreach { n v } $values { + set graph($vertex,$n) $v + } +} +proc SetAll { graphName vertex values } { + upvar 0 Graph::$graphName graph + + array set avals $values + foreach { f } $graph(__fields__) { + if [info exists avals($f)] { ;# Only copy valid fields + set graph($vertex,$f) $avals($f) + } + } +} +proc Get { graphName vertex { name "" } } { + upvar 0 Graph::$graphName graph + if { $name != "" } { + return $graph($vertex,$name) + } + + set r {} + foreach f $graph(__fields__) { + if [info exists graph($vertex,$f)] { + lappend r $f $graph($vertex,$f) + } else { + lappend r $f {} + } + } + return $r +} + +## +# Delete a vertex from the graph. +# Removes vertex and all adjacencies +# +# @param graphName Name of graph +# @param tag Tag of vertex to remove +proc DeleteVertex { graphName tag } { + upvar 0 Graph::$graphName graph + + if ![info exists graph($tag)] { + return + } + + # Remove incoming adjacencies + foreach n [GetInAdjacencies $graphName $tag] { + RemoveEdge $graphName $n $tag + } + unset graph($tag) ;# remove outgoing adjacencies + + # Eliminate the vertex's user fields if set + foreach f $graph(__fields__) { + if [info exists graph($tag,$f)] { + unset graph($tag,$f) + } + } + # Remove vertex from vertex list + set graph(__vertices__) [ldelete $graph(__vertices__) $tag] + +} + + +# Returns list of user fields in graph +proc GetFields { graphName } { + upvar 0 Graph::$graphName graph + return $graph(__fields__) +} +# Returns list of vertex in graph +proc GetVertices { graphName } { + upvar 0 Graph::$graphName graph + return $graph(__vertices__) +} + +proc EdgeExists { graphName start end } { + upvar 0 Graph::$graphName graph + + return [expr \ + [lsearch -exact \ + [GetOutAdjacencies $graphName $start] $end] \ + >= 0] +} +# Returns adjacency list of vertex +proc GetOutAdjacencies { graphName tag } { + upvar 0 Graph::$graphName graph + + return $graph($tag) +} +proc GetInAdjacencies { graphName tag } { + upvar 0 Graph::$graphName graph + set r { } + foreach n $graph(__vertices__) { + if { [EdgeExists $graphName $n $tag] } { + lappend r $n + } + } + return $r +} + +## +# Visit vertices in order that they were inserted +# +# @param graphName Name of graph +# @param cmd Command to invoke at each vertex. graph and vertex tag will +# be appended to command each invokation +# @param rval If true, a list of return values is constructed +# @returns List of return values of command invokations +proc Map { graphName cmd { rval 1 } } { + if [IsEmpty $graphName] { + return + } + upvar 0 Graph::$graphName graph + if { $rval } { + set o {} + foreach { t } $graph(__vertices__) { + lappend o [$cmd $graph(__tag__) $t] + } + return $o + } + + foreach { t } $graph(__vertices__) { + $cmd $graph(__tag__) $t + } +} + +## +# Visit vertices from a start vertex in a depth first manner. +# +# @param graphName Name of graph +# @param cmd Command to invoke at each vertex. graphName and vertex tag +# will be append to command each invokation +# @param tag Start vertex. This vertex is not visited so you'll +# have to expclicity visit it yourself prior to invkoing this +# proc. +proc MapDepthFirst { graphName cmd { tag TOP } { lvl -1 } } { + upvar 0 Graph::$graphName graph + incr lvl + foreach n $graph(__vertices__) { + set visited($n) 0 + } + set visited($tag) 1 + foreach { t } $graph($tag) { + $cmd $graph(__tag__) $t $lvl + MapDepthFirst $graphName $cmd $t $lvl + } +} + +## +# Visit vertices from a start vertex in a breadth first manner. +# +# @param graphName Name of graph +# @param tag Start vertex. This vertex is not visited so you'll +# have to expclicity visit it yourself prior to invkoing this +# proc. +# @param cmd Command to invoke at each vertex. graphName and vertex tag +# will be append to command each invokation +proc MapBreadthFirst { graphName tag cmd} { + upvar 0 Graph::$graphName graph + + foreach n $graph(__vertices__) { + set visited($n) 0 + } + set visited($tag) 1 + + set L [list $tag] + + while { [llength $L] > 0 } { + set v [lindex $L 0] ;# Get head of queue + set L [lrange $L 1 end] ;# Pop head of queue + $cmd $graph(__tag__) $v + foreach n $graph($v) { + if { !$visited($n) } { ;# If vertex hasn't been visited + set visited($n) 1 + lappend L $n ;# add to end of queue + } + } + } +} + +## +# Visit outgoing adjacenies of a vertex (one level only) +# +# @param graphName Name of graph +# @param cmd Command to invoke at each vertex. graphName and vertex tag will +# be append to command each invokation +# @param tag Vertex whose children should be visited. +proc MapOutAdjacencies { graphName cmd tag } { + upvar 0 Graph::$graphName graph + foreach { t } $graph($tag) { + $cmd $graph(__tag__) $t $lvl + } +} +## +# Visit incoming adjacenies of a vertex (one level only) +# +# @param graphName Name of graph +# @param cmd Command to invoke at each vertex. graphName and vertex tag will +# be append to command each invokation +# @param tag Vertex whose children should be visited. +proc MapInAdjacencies { graphName cmd tag } { + upvar 0 Graph::$graphName graph + set verts [GetInAdjacencies $graphName $tag] + foreach { t } $verts { + $cmd $graph(__tag__) $t $lvl + } +} + +## +# Return whether or not the graph is empty +# +proc IsEmpty { graphName } { + return [expr [Size $graphName] == 0] +} +## +# Returns the number of vertices in the graph +# +proc Size { graphName } { + upvar 0 Graph::$graphName graph + return [llength $graph(__vertices__)] +} + +## +# Find a vertex with the specified value for the specified field. +# +# @param graphName Name of graph +# @param field Name of field to check +# @param value Value to to compare +# @param verts Set of verts to search, defaults to all verts in graph +# @returns Vertex tag or {} if none found +proc FindVertex { graphName field value { verts {} } } { + if { $verts == {} } { + set verts [$graphName GetVertices] + } + foreach v $verts { + if { $value == [$graphName Get $v $field] } { + return $v + } + } + return [NullVertex] +} + +## +# Field-by-field copy function that is the default field copy function for the +# Copy method. +proc BasicVertexCopy { destTree destVertex srcTree srcVertex } { + $destTree SetAll $destVertex [$srcTree Get $srcVertex] +} +## +# A simple function that can be passed to MapDepthFirst to +# print out a vertex and all of its fields +# +proc Print { graph vertex { lvl -1 } } { + # Print fields of vertex + puts "$vertex->[$graph GetOutAdjacencies $vertex]" + puts "$vertex<-[$graph GetInAdjacencies $vertex]" + foreach { f v } [$graph Get $vertex] { + PrintTabs $lvl + puts "$f = $v" + } +} + +proc compareVerts { g field v1 v2 } { + return [string compare [$g Get $v1 $field] [$g Get $v2 $field]] +} +proc SortVertListByField { g L field { comp compareVerts } } { +# proc compare { v1 v2 } \ +# "return [string compare [$g Get \$v1 $field] [$g Get \$v2 $field]]" + return [lsort -command "$comp $g $field " $L] +} + +proc SortOutAjacencies { graphName v field { comp compareVerts } } { + upvar 0 Graph::$graphName g + set g($v) [$graphName SortVertListByField \ + [$graphName GetOutAdjacencies $v] \ + $field \ + $comp] + return $g($v) +} + +} ;# End Graph namespace + +IfStandAlone { ;# Some test code + +set T [Graph::Create { name }] ;# Create a graph where each vertex has a 'name' field +set n1 [$T InsertVertex] +$T Set $n1 name HOWDY + +# Insert a vertex and initialize its name in one call +set n2 [$T InsertVertex { name DOODY }] +$T AddEdge $n1 $n2 + +# Insert an unitialized vertex +set n3 [$T InsertVertex] +# Set a field of a vertex +$T Set $n3 name JUDY +$T AddEdge $n2 $n3 + +set n4 [$T InsertVertex { name TEX } ] +$T AddEdge $n1 $n4 + +set n5 [$T InsertVertex { name MEX } ] +$T AddEdge $n1 $n5 + +set n6 [$T InsertVertex { name aaa } ] +$T AddEdge $n1 $n6 + +$T SortOutAjacencies $n1 name + +# Print the graph +$T MapBreadthFirst $n1 Graph::Print + +# Delete a vertex +$T DeleteVertex $n3 +puts "---------------------" + +$T Map Graph::Print + +puts "---------------------" + +} diff --git a/dmgen-1.0.0/src/htmlout.tcl b/dmgen-1.0.0/src/htmlout.tcl new file mode 100644 index 0000000..8056558 --- /dev/null +++ b/dmgen-1.0.0/src/htmlout.tcl @@ -0,0 +1,376 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code to write a datamap nicely formatted in HTML +# +# Requires: +# pushd, popd +# datamap.tcl +# util.tcl +# graph.tcl + +namespace eval DmGenHtmlOut { + +# a simple hack to write out a string in HTML with proper escapes +proc EscapeHtmlString { s } { + set s [join [split $s "<"] "<"] + set s [join [split $s ">"] ">"] + + return $s +} +proc startHtmlDoc { fd { title "" } } { + puts $fd "" + puts $fd " " + puts $fd " $title" + puts $fd " " + puts $fd " " +} +proc endHtmlDoc { fd } { + puts $fd " " + puts $fd "" +} +proc startFrameHtmlDoc { fd { title "" } } { + puts $fd "" + puts $fd " " + puts $fd " $title" + puts $fd " " +} +proc endFrameHtmlDoc { fd } { + puts $fd "" +} + +## +# Write an HTML datamap to directory fn +proc WriteHtmlDatamap { fn dm } { + pushd $fn + + writeHtmlIndex "Datamap: [Datamap::GetName $dm]" + writeHtmlToc $dm + + set pss [lsort [Datamap::GetProblemSpaces $dm]] + set ops [lsort [Datamap::GetOperators $dm]] + foreach h [concat $pss $ops] { + writeHtmlPsOrOp $h + } + + popd ;# pop back to original directory +} + +proc writeHtmlIndex { title } { + set fd [open "index.html" w] + + startFrameHtmlDoc $fd $title + puts $fd " \n \ + \n \ + \n \ + \n \ + \n \ + \n \ + \n \ + \n \ + \n \ + " + + endFrameHtmlDoc $fd + + close $fd +} +proc writeHtmlToc { dm } { + set fd [open "toc.html" w] + + startHtmlDoc $fd "Table of Contents" + + puts $fd "" + puts $fd "

Problem Spaces" + puts $fd "

Operators" + + set pss [lsort [Datamap::GetProblemSpaces $dm]] + puts $fd "" + puts $fd "

Problem Spaces

" + foreach h $pss { + writeHtmlTocEntry $fd $h + } + + puts $fd "" + set ops [lsort [Datamap::GetOperators $dm]] + puts $fd "

Operators

" + foreach h $ops { + writeHtmlTocEntry $fd $h + } + + endHtmlDoc $fd + close $fd +} +proc writeHtmlTocEntry { fd h } { + set name [Datamap::GetPsOrOpName $h] + set type [Datamap::GetType $h] + puts $fd "
$name
" +} + +proc writeHtmlPsOrOp { h } { + global HtmlVisited + if [info exists HtmlVisited] { + unset HtmlVisited + } + set graph [Datamap::GetGraph $h] + set name [Datamap::GetPsOrOpName $h] + if [Datamap::IsProblemSpace $h] { + set typeName "Problem Space" + set type S + } else { + set typeName "Operator" + set type O + } + + set fd [open "$type-$name.html" w] + startValsFile $h + startProdsFile $h + startHtmlDoc $fd "$typeName: $name" + + foreach v [$graph GetVertices] { + set HtmlVisited($v) 0 + } + puts $fd "

$typeName: $name

" + puts $fd "
    " + writeHtmlDatamap_r $fd $graph [Datamap::GetStartVertex $h] 1 + puts $fd "
" + + endHtmlDoc $fd + endValsFile + endProdsFile + + close $fd +} +proc startValsFile { h } { + global ValsPsOrOp + set ValsPsOrOp $h +} +proc reallyStartValsFile { } { + global ValsPsOrOp ValsFd ValsFileName + + set h $ValsPsOrOp + + set name [Datamap::GetPsOrOpName $h] + if [Datamap::IsProblemSpace $h] { + set typeName "Problem Space" + set type S + } else { + set typeName "Operator" + set type O + } + set ValsFileName "$type-$name-vals.html" + set ValsFd [open $ValsFileName w] + startHtmlDoc $ValsFd "$typeName $name - Values" + + puts $ValsFd "

Over-run values for $typeName $name

" +} + +proc appendToValsFile { attr vals } { + global ValsFd ValsFileName + if ![info exists ValsFd] { + reallyStartValsFile + } + set tag [GetTag valTag] + set fd $ValsFd + + + puts $fd "" + puts $fd "

Values for attribute '$attr'

" + puts $fd "

" + foreach v $vals { + puts $fd " [EscapeHtmlString $v]
" + } + puts $fd "

" + puts $fd "





" + + return "$ValsFileName#$tag" +} + +proc endValsFile { } { + global ValsFd ValsPsOrOp + if [info exists ValsFd] { + close $ValsFd + unset ValsFd + unset ValsPsOrOp + } +} + +proc startProdsFile { h } { + global ProdsPsOrOp ProdsFd ProdsFileName + set ProdsPsOrOp $h + + set name [Datamap::GetPsOrOpName $h] + if [Datamap::IsProblemSpace $h] { + set typeName "Problem Space" + set type S + } else { + set typeName "Operator" + set type O + } + set ProdsFileName "$type-$name-prods.html" + set ProdsFd [open $ProdsFileName w] + startHtmlDoc $ProdsFd "$typeName $name - Productions" + + puts $ProdsFd "

Source productions for $typeName $name

" +} + +proc appendToProdsFile { attr prods } { + global ProdsFd ProdsFileName + + set tag [GetTag prodTag] + set fd $ProdsFd + + puts $fd "
" + puts $fd "

Source productions for attribute '$attr'

" + puts $fd "

" + foreach p [lsort $prods] { + puts $fd " [EscapeHtmlString $p]
" + } + puts $fd "

" + puts $fd "





" + + return "$ProdsFileName#$tag" +} + +proc endProdsFile { } { + global ProdsFd ProdsPsOrOp + if [info exists ProdsFd] { + close $ProdsFd + unset ProdsFd + unset ProdsPsOrOp + } +} + +## +# Is this vertex the start of a soarList, and if so, how deep does it go? +# Returns depth of (next,item) pairs, or 0 if none. +proc getSoarListDepth { g v } { + set NV [Graph::NullVertex] + set out [$g GetOutAdjacencies $v] + if { [llength $out] < 2 } { return 0 } + set vitem [$g FindVertex name item $out] + if { $vitem == $NV } { return 0 } + set vnext [$g FindVertex name next $out] + if { $vnext == $NV } { return 0 } + + return [expr [getSoarListDepth $g $vnext] + 1] +} + +proc writeHtmlDatamap_r { fd graph vert { top 0 } } { + global HtmlVisited + set HtmlVisited($vert) 1 + + set maxValues [DmGenCfg::Get HtmlMaxValuesPerLine] + + set show [expr !$top || ($top && ![DmGenCfg::Get HtmlHideState])] + + set out [$graph GetOutAdjacencies $vert] + + if { $show } { + puts $fd "
  • " + array set props [$graph Get $vert] + if { [DmGenCfg::Get HtmlColorPatched] && \ + [llength $props(patched)] > 0 } { + puts $fd "" + puts $fd "[EscapeHtmlString $props(name)]," + puts $fd "" + } else { + puts $fd "[EscapeHtmlString $props(name)]," + } + puts $fd "Type: $props(type)" + set nVals [llength $props(value)] + if { $nVals > 0 && $nVals <= $maxValues } { + set valString [EscapeHtmlString [join $props(value) " , "]] + puts $fd ", Value(s): $valString" + } elseif { $nVals > $maxValues } { + set tag [appendToValsFile $props(name) $props(value)] + puts $fd ", \[Values\]" + } + + # write out which productions it came from... + set tag [appendToProdsFile $props(name) $props(prods)] + puts $fd ", \[Productions\]" + + if { [DmGenCfg::Get HtmlShowSpecial] } { + puts $fd "
    Special: $props(special)" + } + if { $props(link) != {} } { + puts $fd "
    Links: " + set link $props(link) + set type [lindex $link 0] + set names [lrange $link 1 end] + set txt {} + foreach n $names { + lappend txt "[EscapeHtmlString $n]" + } + puts $fd [join $txt ", "] + } + if { [DmGenCfg::Get HtmlShowComments] && [llength $props(comment)] > 0 } { + puts $fd "
    Comment: " + foreach l $props(comment) { + puts $fd "$l" + puts $fd "
    " + } + puts $fd "
    " + } + + puts $fd "
      " + } + + foreach v $out { + set name [$graph Get $v name] + if { !$HtmlVisited($v) } { ;# we haven't hit this vertex yet + if { [lsearch -exact [DmGenCfg::Get HtmlSuppressedAttributes] $name] == -1 } { + set depth 0 + if { $name == "next" } { + set depth [getSoarListDepth $graph $v] + } + if { $depth > [DmGenCfg::Get HtmlMaxSoarListDepth] } { + puts $fd " ... Suppressed soarList with depth = $depth ... " + } else { + writeHtmlDatamap_r $fd $graph $v + } + } + } else { + puts $fd "
      ...Backedge to attribute $name..." + } + } + if { $show } { + puts $fd "
    " + } +} +} ;# namespace DmgenHtmlOut diff --git a/dmgen-1.0.0/src/lexer.tcl b/dmgen-1.0.0/src/lexer.tcl new file mode 100644 index 0000000..9d5300e --- /dev/null +++ b/dmgen-1.0.0/src/lexer.tcl @@ -0,0 +1,575 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Soar lexer. +# +# Proc exports: +# get_lexeme +# +# Globals: +# lexeme_value +# lexeme_type + + +proc initialize_file_scan {fd} { + global lexeme_value lexeme_type current_char file_buffer + set lexeme_value {} + set lexeme_type {} + set current_char { } + # global file_buffer must be set by caller before any calls + # to this module! +} + +proc get_lexeme {} { + global lexeme_value lexeme_type current_char whitespace lexer_routine + global constituent_chars + set lexeme_value {} + set lexeme_type {} + while 1 { + if ![string compare $current_char {EOF}] break; + if [regexp \[$whitespace\] $current_char] { + get_next_char + continue + } + if ![string compare $current_char {;}] { + get_next_char + continue + } + if ![string compare $current_char {#}] { + while {[string compare $current_char "\n"] && \ + [string compare $current_char {EOF}]} { + get_next_char + } + if [string compare $current_char {EOF}] { + get_next_char + } + continue + } + ## no whitespace found + break + } + if ![string compare $current_char {EOF}] { + lex_eof + } elseif [info exists lexer_routine("$current_char")] { + eval $lexer_routine("$current_char") + } elseif [regexp {[0-9]} $current_char] { + lex_digit + } elseif [regexp \[$constituent_chars\] $current_char] { + lex_constituent_string + } else { + lex_unknown + } + if 0 { + if ![string compare $current_char {EOF}] { + lex_eof + } elseif [info exists lexer_routine("$current_char")] { + eval $lexer_routine("$current_char") + } elseif [regexp \[$constituent_chars\] $current_char] { + lex_constituent_string + } elseif [regexp {[0-9]} $current_char] { + lex_digit + } else { + lex_unknown + } + } +} + +proc get_next_char {} { + global current_char file_buffer + if {$file_buffer == ""} { + set current_char "EOF" + } else { + set current_char [string index $file_buffer 0] + set file_buffer [string range $file_buffer 1 end] + + global parsing_function parsed_function + if { $parsing_function > 0 } { + set parsed_function "$parsed_function$current_char" + } + } +} + +proc lex_eof {} { + global lexeme_type + store_and_advance + set lexeme_type "EOF" +} + +proc lex_at {} { + global lexeme_type + store_and_advance + set lexeme_type at +} + +proc lex_tilde {} { + global lexeme_type + store_and_advance + set lexeme_type tilde +} + +proc lex_up_arrow {} { + global lexeme_type + store_and_advance + set lexeme_type up_arrow +} + +proc lex_lbrace {} { + global lexeme_type + store_and_advance + set lexeme_type l_brace +} + +proc lex_rbrace {} { + global lexeme_type + store_and_advance + set lexeme_type r_brace +} + +proc lex_exclamation_point {} { + global lexeme_type + store_and_advance + set lexeme_type exclamation_point +} + +proc lex_comma {} { + global lexeme_type + store_and_advance + set lexeme_type comma +} + +proc lex_equal {} { + global lexeme_type lexeme_value + read_constituent_string + if {[string length $lexeme_value] == 1} { + set lexeme_type equal + return + } + determine_type_of_constituent_string +} + +proc lex_ampersand {} { + global lexeme_type lexeme_value + read_constituent_string + if {[string length $lexeme_value] == 1} { + set lexeme_type ampersand + return + } + determine_type_of_constituent_string +} + +proc lex_lparen {} { + global lexeme_type + store_and_advance + set lexeme_type l_paren +} + +proc lex_rparen {} { + global lexeme_type + store_and_advance + set lexeme_type r_paren +} + +proc lex_greater {} { + global lexeme_type lexeme_value + read_constituent_string + if {[string length $lexeme_value] == 1} { + set lexeme_type greater + return + } + if {$lexeme_value == ">>"} { + set lexeme_type greater_greater + return + } + if {$lexeme_value == ">="} { + set lexeme_type greater_equal + return + } + determine_type_of_constituent_string +} + +proc lex_less {} { + global lexeme_type lexeme_value + read_constituent_string + if {[string length $lexeme_value] == 1} { + set lexeme_type less + return + } + if {$lexeme_value == "<>"} { + set lexeme_type not_equal + return + } + if {$lexeme_value == "<="} { + set lexeme_type less_equal + return + } + if {$lexeme_value == "<<"} { + set lexeme_type less_less + return + } + if {$lexeme_value == "<=>"} { + set lexeme_type less_equal_greater + return + } + determine_type_of_constituent_string +} + +proc lex_period {} { + global lexeme_type lexeme_value current_char + store_and_advance + if [regexp {[0-9]} $current_char] { + read_rest_of_floating_point_number + } + if {[string length $lexeme_value] == 1} { + set lexeme_type period + return + } + determine_type_of_constituent_string +} + +proc lex_plus {} { + global current_char lexeme_value lexeme_type + read_constituent_string + if {$current_char == "."} { + set could_be_floating_point 1 + foreach i [split [string range $lexeme_value 1 end]] { + if ![regexp {[0-9]} $i] { + set could_be_floating_point 0 + } + } + if $could_be_floating_point { + read_rest_of_floating_point_number + } + } + if {[string length $lexeme_value] == 1} { + set lexeme_type plus + return + } + determine_type_of_constituent_string +} + +proc lex_minus {} { + global current_char lexeme_value lexeme_type + read_constituent_string + if {$current_char == "."} { + set could_be_floating_point 1 + foreach i [split [string range $lexeme_value 1 end]] { + if ![regexp {[0-9]} $i] { + set could_be_floating_point 0 + } + } + if $could_be_floating_point { + read_rest_of_floating_point_number + } + } + if {[string length $lexeme_value] == 1} { + set lexeme_type minus + return + } + if {$lexeme_value == "-->"} { + set lexeme_type right_arrow + return + } + determine_type_of_constituent_string +} + +proc lex_digit {} { + global current_char lexeme_value lexeme_type + read_constituent_string + if {$current_char == "."} { + set could_be_floating_point 1 + foreach i [split [string range $lexeme_value 1 end]] { + if ![regexp {[0-9]} $i] { + set could_be_floating_point 0 + } + } + if $could_be_floating_point { + read_rest_of_floating_point_number + } + } + determine_type_of_constituent_string +} + +proc lex_unknown {} { + global current_char + parseError "Unknown character encountered by lexer '$current_char'" + get_next_char + get_lexeme +} + +proc lex_constituent_string {} { + read_constituent_string + determine_type_of_constituent_string +} + +proc lex_vbar {} { + global lexeme_type lexeme_value current_char + set lexeme_type sym_constant + get_next_char + while 1 { + if {$current_char == "EOF"} { + parseError "Opening '|' without closing '|'" + set lexeme_type "EOF" + return + } + if {$current_char == "\\"} { + get_next_char + set lexeme_value [format "%s%s" $lexeme_value $current_char] + get_next_char + } elseif {$current_char == "|"} { + get_next_char + break + } else { + set lexeme_value [format "%s%s" $lexeme_value $current_char] + get_next_char + } + } +} + +proc lex_quote {} { + global lexeme_type lexeme_value current_char + set lexeme_type quoted_string + get_next_char + while 1 { + if {$current_char == "EOF"} { + parseError "Opening '\"' without closing '\"'" + set lexeme_type "EOF" + return + } + if {$current_char == "\\"} { + get_next_char + set lexeme_value [format "%s%s" $lexeme_value $current_char] + get_next_char + } elseif {$current_char == "\""} { + get_next_char + break + } else { + set lexeme_value [format "%s%s" $lexeme_value $current_char] + get_next_char + } + } +} + +proc lex_dollar {} { + global lexeme_type lexeme_value current_char + set lexeme_type dollar_string + set lexeme_value "$" + get_next_char + while {($current_char != "\n") && ($current_char != "EOF")} { + set lexeme_value [format "%s%s" $lexeme_value $current_char] + get_next_char + } +} + +proc read_rest_of_floating_point_number {} { + global current_char + store_and_advance + while {[regexp {[0-9]} $current_char]} { + store_and_advance + } + if {($current_char == "e") || ($current_char == "E")} { + store_and_advance + if {($current_char == "+") || ($current_char == "-")} { + store_and_advance + } + while {[regexp {[0-9]} $current_char]} { + store_and_advance + } + } +} + +proc read_constituent_string {} { + global constituent_chars current_char + while {($current_char != "EOF") && \ + [regexp \[$constituent_chars\] $current_char]} { + store_and_advance + } +} + +proc store_and_advance {} { + global lexeme_value current_char + set lexeme_value [format "%s%s" $lexeme_value [string tolower $current_char]] + get_next_char +} + +proc determine_type_of_constituent_string {} { + global lexeme_value lexeme_type + set s [determine_possible_symbol_types_for_string [split $lexeme_value ""]] + if {[lsearch $s possible_var] >= 0} { + set lexeme_type variable + return + } + if {[lsearch $s possible_ic] >= 0} { + set lexeme_type int_constant + return + } + if {[lsearch $s possible_fc] >= 0} { + set lexeme_type float_constant + return + } + # For now we will always have this as 0, because we are just interested + # in productions (which do not contain identifiers), but if we want + # to care about other commands someday, we can use this code + set allow_ids 0 + if {$allow_ids && ([lsearch $s possible_id] >= 0)} { + set lexeme_type identifier + return + } + if {[lsearch $s possible_sc] >= 0} { + set lexeme_type sym_constant + if {[string index $lexeme_value 0] == "<"} { + if {[string index $lexeme_value 1] == "<"} { + parseError "Warning: Possible disjunct intended but interpreted as symbolic constant" + } else { + parseError "Warning: Possible variable intended but interpreted as symbolic constant" + } + } else { + if {[string index $lexeme_value [expr [string length $lexeme_value] - 1]] == ">"} { + if {[string index $lexeme_value [expr [string length $lexeme_value] - 2]] == ">"} { + parseError "Warning: Possible disjunct intended but interpreted as symbolic constant" + } else { + parseError "Warning: Possible variable intended but interpreted as symbolic constant" + } + } + } + return + } + set lexeme_type quoted_string +} + +proc determine_possible_symbol_types_for_string {s} { + global number_starters constituent_chars + set retval "" + if [regexp \[$number_starters\] [lindex $s 0]] { + set i 0 + if {([lindex $s 0] == "+") || ([lindex $s 0] == "-")} { + incr i + } + while {[regexp {[0-9]} [lindex $s $i]]} { + incr i + } + if {([lindex $s $i] == "") && \ + [regexp {[0-9]} [lindex $s [expr $i - 1]]]} { + lappend retval possible_ic + } + if {[lindex $s $i] == "."} { + incr i + while {[regexp {[0-9]} [lindex $s $i]]} { + incr i + } + if {([lindex $s $i] == "e") || ([lindex $s $i] == "E")} { + incr i + if {([lindex $s $i] == "+") || ([lindex $s $i] == "-")} { + incr i + } + while {[regexp {[0-9]} [lindex $s $i]]} { + incr i + } + } + if {[lindex $s $i] == ""} { + lappend retval possible_fc + } + } + } + for {set i 0} {[lindex $s $i] != ""} {incr i} { + if ![regexp \[$constituent_chars\] [lindex $s $i]] { + return $retval + } + } + lappend retval possible_sc + if {([lindex $s 0] == "<") && \ + ([lindex $s [expr [llength $s] - 1]] == ">")} { + lappend retval possible_var + } + if [regexp {[A-Za-z]} [lindex $s 0]] { + set i 1 + while {[regexp {[0-9]} [lindex $s $i]]} { + incr i + } + if {([lindex $s $i] == "") && \ + [regexp {[0-9]} [lindex $s [expr $i - 1]]]} { + lappend retval possible_id + } + } + return $retval +} + +proc discard_line {} { + global file_buffer + set file_buffer "" +} + +############################# + +initialize_file_scan "" + +global constituent_chars whitespace number_starters +set constituent_chars "A-Za-z0-9$%&*+/:<=>?_-" +set whitespace " \f\n\r\t\v" +set number_starters "0-9+\-." + +global lexer_routine +set lexer_routine("@") lex_at +set lexer_routine("(") lex_lparen +set lexer_routine(")") lex_rparen +set lexer_routine("+") lex_plus +set lexer_routine("-") lex_minus +set lexer_routine("~") lex_tilde +set lexer_routine("^") lex_up_arrow +set lexer_routine("{") lex_lbrace +set lexer_routine("}") lex_rbrace +set lexer_routine("!") lex_exclamation_point +set lexer_routine(">") lex_greater +set lexer_routine("<") lex_less +set lexer_routine("=") lex_equal +set lexer_routine("&") lex_ampersand +set lexer_routine("|") lex_vbar +set lexer_routine(",") lex_comma +set lexer_routine(".") lex_period +set lexer_routine("\"") lex_quote +set lexer_routine("$") lex_dollar + +# just a function for debugging the lexer +proc testLex { s } { + global file_buffer current_char lexeme_type lexeme_value + set file_buffer $s + set current_char { } + set lexeme_type "" + while { $lexeme_type != "EOF" } { + get_lexeme + puts "Lexeme: $lexeme_type, $lexeme_value" + } +} diff --git a/dmgen-1.0.0/src/log.tcl b/dmgen-1.0.0/src/log.tcl new file mode 100644 index 0000000..5cbef37 --- /dev/null +++ b/dmgen-1.0.0/src/log.tcl @@ -0,0 +1,143 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# A simple set of logging functions. Sends output to stdout as well as a +# file in the current directory (created at the time of the +# first Log call) + +set LogAutoFlush 0 ;# if true, then every log write is flushed to disk +set LogFileName "" ;# name of file to write to + +proc LogSetFileName { fileName } { + global LogFileName + LogReset + set LogFileName $fileName +} + +proc doLog { prefix s log } { + global LogAutoFlush + set s "$prefix $s" + puts $s + if { $log != -1 } { + puts $log $s + if { $LogAutoFlush } { + flush $log + } + } +} + +## +# Log an error +proc LogError { s } { + doLog "*** ERROR: " $s [getLogFileId] +} + +## +# Log a warning +proc LogWarning { s } { + doLog "--- WARNING: " $s [getLogFileId] +} + +## +# Log info +proc LogInfo { s } { + doLog "--- INFO: " $s [getLogFileId] +} + +## +# Write an arbitrary string to the log +proc Log { s { newLine 1 } } { + set log [getLogFileId] + + if { $newLine } { + puts $s + if { $log != -1 } { + puts $log $s + } + } else { + puts -nonewline $s + if { $log != -1 } { + puts -nonewline $log $s + } + } + global LogAutoFlush + if { $log != -1 && $LogAutoFlush } { + flush $log + } +} +## +# Flush the log to disk +proc LogFlush { } { + global LogFileId + if [info exists LogFileId] { + flush $LogFileId + } +} + +## +# Reset the log file. +proc LogReset { } { + global LogFileId + + if [info exists LogFileId] { + close $LogFileId + unset LogFileId + } +} +## +# Set the value of the auto-flush parameter +proc LogSetAutoFlush { b } { + global LogAutoFlush + + set LogAutoFlush $b +} + +## +# internal function to open log file. +proc getLogFileId {} { + global LogFileId LogFileName + + if ![info exists LogFileId] { + if { $LogFileName == "" } { + return -1 + } + set LogFileId [open $LogFileName w] + puts $LogFileId "" + puts $LogFileId "#################### LOG OPENED ##########################" + } + return $LogFileId +} diff --git a/dmgen-1.0.0/src/merge.tcl b/dmgen-1.0.0/src/merge.tcl new file mode 100644 index 0000000..f035d0c --- /dev/null +++ b/dmgen-1.0.0/src/merge.tcl @@ -0,0 +1,224 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code for merging a production into a datamap... +# +# Requires: +# config.tcl +# datamap.tcl +# graph.tcl + +## +# Process a partitioned production, merging it into the appropriate +# problem spaces and operators of the passed datamap. +# +# @param dm Datamap to fill +# @param name Name of source production +# @param graph Production graph +# @param part Partition info returned by PartitionProduction +proc ProcessProd { dm name graph part } { + # $part is a list of 4-tupes... + foreach { type pss state p } $part { + if { $type == "S" } { ;# it's a problem space + foreach ps $pss { ;# for each destination problem space + set h [Datamap::FindOrCreateProblemSpace $dm $ps] + set hGraph [Datamap::GetGraph $h] + set hStart [Datamap::GetStartVertex $h] + + MergeProdIntoDatamap $name $graph $state $p \ + $hGraph \ + $hStart + } + } else { ;# it's an operator + foreach op $pss { ;# for each named operator + set h [Datamap::FindOrCreateOperator $dm $op] + set hGraph [Datamap::GetGraph $h] + set hStart [Datamap::GetStartVertex $h] + MergeProdIntoDatamap $name $graph $state $p \ + $hGraph \ + $hStart + } + } + } +} + +## +# Merge a partitioned production into a particular problem space or +# operator graph. +# This is just a setup function. The real work is done in the recursive +# mergeProdIntoDatamap function. +# +# @param pName Name of production +# @param pGraph Production graph +# @param pState 'state' or 'operator' vertex of production +# @param part Production partition info +# @param dmGraph Target ps or op graph +# @param dmState 'state' or 'operator' vertex of ps or op +proc MergeProdIntoDatamap { pName pGraph pState part dmGraph dmState } { + global gMergeMap gMergeParts + if [info exists gMergeMap] { unset gMergeMap } + if [info exists gMergeParts] { unset gMergeParts } + foreach { v ps } $part { + set gMergeMap($v) [Graph::NullVertex] + set gMergeParts($v) $ps ;# external PS links + } + mergeProdIntoDatamap $pName $pGraph $pState $dmGraph $dmState +} + +## +# Merge a partitioned production into a particular problem space or +# operator graph. Performs a simultaneous depth-first traversal of +# the production graph and the datamap graph, filling in the datamap +# graph as necessary. +# +# Uses two global variables (gMergeMap and gMergeParts) initialized +# by MergeProdIntoDatamap to keep track of where it's been (to avoid +# cycles) and to make links when the boundary of a partition is +# reached. gMergeMap is a map from production vertex to datamap vertex. +# +# @param pName Name of production +# @param pGraph Production graph +# @param pTag current production vertex +# @param dmGraph Target ps or op graph +# @param dmTag current ps or op vertex +proc mergeProdIntoDatamap { pName pGraph pTag dmGraph dmTag } { + global gMergeMap gMergeParts + + set NV [Graph::NullVertex] ;# cache NullVertex value + set dmOut [$dmGraph GetOutAdjacencies $dmTag] + foreach v [$pGraph GetOutAdjacencies $pTag] { + # Have we been here before? Let's avoid cycles... + # Is this the coorect thing to do? + if { [info exists gMergeMap($v)] } { + set dv $gMergeMap($v) + if { $dv != $NV } { + $dmGraph AddEdge $dmTag $dv ;# just add an edge + continue + } + } + set name [$pGraph Get $v name] +# puts "M $name" + set dv [$dmGraph FindVertex name $name $dmOut] + if { $dv != $NV } { ;# DM already has this node... + + set gMergeMap($v) $dv ;# update merge map + + set pt [$pGraph Get $v type] + set dmt [$dmGraph Get $dv type] + if { $pt != $dmt } { + if { $dmt == "unknown" } { + # here we know that $pt != "unknown" so it's a better choice + # for the type, set it. + $dmGraph Set $dv type $pt + } elseif { $pt == "unknown" } { + # here we know that $dt != "unknown" so it's a better choice + # for the type, keep it. + } else { + # neither type is unknown, but they're in conflict, + # we'll just log it for now since it's hard to know + # which is the better guess for the type. + LogWarning "Non-matching data types! $pt != $dmt, $name" + } + } + + $dmGraph Set $dv special [lunion [$dmGraph Get $dv special] \ + [$pGraph Get $v special]] + + $dmGraph Set $dv value [lunion [$dmGraph Get $dv value] \ + [$pGraph Get $v value]] + + $dmGraph Set $dv side [Production::MergeSideValues \ + [$dmGraph Get $dv side] \ + [$pGraph Get $v side]] + + if { [DmGenCfg::Get SaveSourceProds] } { + $dmGraph Set $dv prods [lunion [$dmGraph Get $dv prods] $pName] + } + + set l [$dmGraph Get $dv link] + # If there is a known link, add it. + if { [info exists gMergeParts($v)] } { + # WARN: This is a little dangerous...it relies on the fact that + # lunion preserves some order, i.e. that the link type (O or S) + # will still be the first element after the union is done. + # bad bad bad. + $dmGraph Set $dv link [lunion $l $gMergeParts($v)] + } + # Recursively merge this branch of the graph. + # This isn't an else because in some productions we may have been able + # to determine a link, but in others we may not have. Think of a + # production that puts attributes on the operator without testing the + # name of the operator. + mergeProdIntoDatamap $pName $pGraph $v $dmGraph $dv + + # Edge is missing from DM, or node doesn't exist + # Make sure that this vertex is in the current partition (don't + # follow links) + } elseif { [info exists gMergeMap($v)] } { + set dv $gMergeMap($v) + if { $dv != $NV } { ;# Backedge, we've already seen $v and $dv before. + $dmGraph AddEdge $dmTag $dv ;# just add a vertex + } else { + # Create a new vertex in the datamap + set special [$pGraph Get $v special] + set type [$pGraph Get $v type] + set value [$pGraph Get $v value] + set side [$pGraph Get $v side] + set dv [$dmGraph InsertVertex [Datamap::DefVertexFields]] + $dmGraph SetL $dv [list name $name \ + type $type \ + side $side \ + value $value \ + special $special \ + link $gMergeParts($v)] + + if { [DmGenCfg::Get SaveSourceProds] } { + $dmGraph Set $dv prods $pName + } + + $dmGraph AddEdge $dmTag $dv + set gMergeMap($v) $dv ;# update merge map + + # Are we at the boundary of a partition? If not, keep going + # by recursively following this graph branch. + if { $gMergeParts($v) == {} } { + mergeProdIntoDatamap $pName $pGraph $v $dmGraph $dv + } + } + } + } +} diff --git a/dmgen-1.0.0/src/parser.tcl b/dmgen-1.0.0/src/parser.tcl new file mode 100644 index 0000000..7dc4183 --- /dev/null +++ b/dmgen-1.0.0/src/parser.tcl @@ -0,0 +1,443 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Soar production "parser". +# +# Proc exports: +# parse_production + +proc parse_production { buf } { + global file_buffer + set file_buffer $buf + global current_char + set current_char " " + global productionName lexeme_type lexeme_value + get_lexeme + if {($lexeme_type != "sym_constant") || ($lexeme_value != "sp")} { + parseError "Production must start with sp" + return 0 + } + get_lexeme + if {$lexeme_type != "l_brace"} { + parseError "Production definition must begin with \{" + return 0 + } + get_lexeme + if {$lexeme_type != "sym_constant"} { + parseError "Expected symbol for production name" + return 0 + } + set productionName $lexeme_value + get_lexeme + if {$lexeme_type == "quoted_string"} { + get_lexeme + } + while 1 { + if {$lexeme_type != "sym_constant"} { + break + } + if {($lexeme_value == ":o-support") || \ + ($lexeme_value == ":i-support") || ($lexeme_value == ":chunk") || \ + ($lexeme_value == ":default") || ($lexeme_value == ":justification")} { + get_lexeme + continue + } + break + } + set lhs [parse_lhs] + if {$lhs == 0} { + puts "parse_lhs failed" + return 0 + } + if {$lexeme_type != "right_arrow"} { + parseError "Expected --> in production" + return 0 + } + get_lexeme + set rhs [parse_rhs] + if {$rhs == 0} { + puts "parse_lhs failed" + return 0 + } + if {$lexeme_type != "r_brace"} { + parseError "Expected \} to end production" + return 0 + } + get_lexeme + if {$lexeme_type != "EOF"} { + parseError "Found text after production end?" + return 0 + } + return [concat $lhs $rhs] +} + +proc parse_lhs {} { + return [parse_cond_plus] +} + +proc parse_cond_plus {} { + global lexeme_type + set c "" + for {set nc [parse_cond]} \ + {($lexeme_type == "minus") || ($lexeme_type == "l_paren")} \ + {set nc [parse_cond]} { + if {$nc == 0} { + return 0 + } + set c [concat $c $nc] + } + if {$nc == 0} { + return 0 + } + set c [concat $c $nc] + return $c +} + +proc parse_cond {} { + global lexeme_type + if {$lexeme_type == "minus"} { + get_lexeme + } + if {$lexeme_type == "l_brace"} { + get_lexeme + set c [parse_cond_plus] + if {$c == 0} { + return 0 + } + if {$lexeme_type != "r_brace"} { + parseError "Expected \} to end conjunctive condition" + return 0 + } + get_lexeme + } else { + set c [parse_single_cond] + if {$c == 0} { + return 0 + } + } + return $c +} + +proc parse_single_cond {} { + global lexeme_type lexeme_value + if {$lexeme_type != "l_paren"} { + parseError "Expected ( to begin condition" + return 0 + } + get_lexeme + set headElement "" + if {$lexeme_type == "sym_constant"} { + if {($lexeme_value == "state") || ($lexeme_value == "impasse")} { + set headElement $lexeme_value + get_lexeme + } + } + if {$lexeme_type != "variable"} { + parseError "Expected variable for condition id test" + return 0 + } + set id_test $lexeme_value + get_lexeme + if {$lexeme_type == "minus"} { + get_lexeme + } + if {$lexeme_type != "up_arrow"} { + parseError "Expected ^ to begin attribute test" + return 0 + } + + get_lexeme + + global relational_test_types + + set attr_test [parse_test] + if {$attr_test == {} } { + return 0 + } + set attr_test_rels $relational_test_types + set value_test [parse_test] + if {$value_test == {} } { + return 0 + } + set value_test_rels $relational_test_types + + parse_preference ;# Make sure we get LHS operator preference + ;# Added by Dave Ray 05/02/2002 + + if {$lexeme_type != "r_paren"} { + parseError "Expected ) to end condition" + return 0 + } + get_lexeme + set c "" + if {$headElement != ""} { + lappend c [list L "TOP" $headElement $id_test \ + $attr_test_rels $value_test_rels] + } + foreach i $attr_test { + foreach j $value_test { + lappend c [list L \ + $id_test \ + $i $j \ + $attr_test_rels $value_test_rels] + } + } + return $c +} + +proc parse_test {} { + global lexeme_type relational_test_types + set relational_test_types {} + if {$lexeme_type != "l_brace"} { + return [parse_simple_test] + } + get_lexeme + set c "" + for {set r [parse_simple_test]} {$lexeme_type != "r_brace"} \ + {set r [parse_simple_test]} { + if {$r == {} } { + return $r + } + set c [concat $c $r] + } + if {$r == {} } { + return $r + } + set c [concat $c $r] + get_lexeme + return $c +} + +proc parse_simple_test {} { + global lexeme_type + if {$lexeme_type == "less_less"} { + return [parse_disjunction_test] + } else { + return [parse_relational_test] + } +} + +proc parse_disjunction_test {} { + global lexeme_type lexeme_value + if {$lexeme_type != "less_less"} { + parseError "Expected << to begin disjunction test" + return {} + } + set c "" + for {get_lexeme} {$lexeme_type != "greater_greater"} {get_lexeme} { + if {($lexeme_type != "sym_constant") && \ + ($lexeme_type != "int_constant") && \ + ($lexeme_type != "float_constant")} { + parseError "Expected constant or >> while reading disjunction test" + return {} + } + lappend c $lexeme_value + } + get_lexeme + return $c +} + +proc parse_relational_test {} { + global lexeme_type lexeme_value relational_test_types + if {($lexeme_type == "equal") || ($lexeme_type == "not_equal") || \ + ($lexeme_type == "less") || ($lexeme_type == "greater") || \ + ($lexeme_type == "less_equal") || ($lexeme_type == "greater_equal") || \ + ($lexeme_type == "less_equal_greater")} { + lappend relational_test_types $lexeme_type + + get_lexeme + } + if {($lexeme_type == "sym_constant") || ($lexeme_type == "int_constant") || \ + ($lexeme_type == "float_constant") || ($lexeme_type == "variable")} { + set c $lexeme_value + get_lexeme + return $c + # This is a special weird case that occurs when a production tests an + # attribute for the empty string ||. In this case, print -internal prints + # the value, but since it's the empty string it doesn't appear as anything. + # Annoying... + } elseif { $lexeme_type == "r_paren" } { + return "____DMGEN_EMPTYSTRING____" ; + # Can't just return "" because that's the error return code :( + # Stupid tcl. + } else { + parseError "Expected variable or constant for test" + return {} + #return 0 + } +} + +proc parse_rhs {} { + global lexeme_type + set c "" + while {$lexeme_type != "r_brace"} { + set nc [parse_rhs_action] + if {$nc == 0} { + return 0 + } + set c [concat $c $nc] + } + return $c +} + +proc parse_rhs_action {} { + global lexeme_type lexeme_value + if {$lexeme_type != "l_paren"} { + parseError "Expected ( to begin RHS action" + return 0 + } + get_lexeme + if {$lexeme_type != "variable"} { + if {[parse_function_call_after_lparen] == {} } { + return 0 + } + return "" + } + set id_make $lexeme_value + get_lexeme + if {$lexeme_type != "up_arrow"} { + parseError "Expected ^ in RHS action attribute" + return 0 + } + get_lexeme + set attr_make [parse_rhs_value] + if {$attr_make == {} } { + return 0 + } + set value_make [parse_rhs_value] + set alt_value_make [parse_preference] + if {$lexeme_type != "r_paren"} { + parseError "Expected ) to end RHS action, got $lexeme_type" + return 0 + } + get_lexeme + if {$alt_value_make == ""} { + return [list [list R $id_make $attr_make $value_make]] + } else { + return [list [list R $id_make $attr_make $value_make] \ + [list R $id_make $attr_make $alt_value_make]] + } +} + +# these are here just so we can store the text of a function call +set parsing_function 0 ;# current parse_function... call depth +set parsed_function "" ;# buffer where function call text is stored + +proc parse_function_call_after_lparen {} { + global lexeme_type lexeme_value + + global parsing_function parsed_function + incr parsing_function ;# increment call depth + if { $parsing_function == 1 } { + # Initialize function buffer. The left paren and operator have + # already been parsed + set parsed_function "( $lexeme_value " + } + + get_lexeme + while {$lexeme_type != "r_paren"} { + if { [parse_rhs_value] == {} } { + set parsing_function 0 ;# clean up call depth + set parsed_function "" + #return 0 + return {} + } + } + incr parsing_function -1 ;# decrement call depth + get_lexeme + if { $parsing_function == 0 } { ;# done parsing function + return [list [list "FUNCTION" $parsed_function]] + } + return "FUNCTION_CALL?" +} + +proc parse_rhs_value {} { + global lexeme_type lexeme_value + if {$lexeme_type == "l_paren"} { + get_lexeme + return [parse_function_call_after_lparen] + } + if {($lexeme_type == "sym_constant") || ($lexeme_type == "int_constant") || \ + ($lexeme_type == "float_constant") || ($lexeme_type == "variable")} { + set c $lexeme_value + get_lexeme + return $c + } + parseError "Illegal value for RHS value" + #return 0 + return {} +} + +proc parse_preference {} { + global lexeme_type + set x [parse_preference_specifier_without_referent] + if {$x == "binary"} { + set c [parse_rhs_value] + if {$c == {} } { + return 0 + } + return $c + } + return "" +} + +proc parse_preference_specifier_without_referent {} { + global lexeme_type + if {($lexeme_type == "plus") || ($lexeme_type == "minus") || \ + ($lexeme_type == "exclamation_point") || ($lexeme_type == "tilde") || \ + ($lexeme_type == "at")} { + get_lexeme + return unary + } + if {($lexeme_type == "greater") || ($lexeme_type == "equal") || \ + ($lexeme_type == "less") || ($lexeme_type == "ampersand")} { + get_lexeme + if {$lexeme_type != "r_paren"} { + return binary + } + return unary + } + return special +} + +proc parseError {x} { + global file_buffer lexeme_type lexeme_value + LogError "Parse Error: $x, \ +lexeme_type = $lexeme_type, lexeme_value = $lexeme_value \ +### Remaining buffer:\n$file_buffer\n###" + +} diff --git a/dmgen-1.0.0/src/partition.tcl b/dmgen-1.0.0/src/partition.tcl new file mode 100644 index 0000000..0ffea97 --- /dev/null +++ b/dmgen-1.0.0/src/partition.tcl @@ -0,0 +1,240 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code for partitioning a production graph into problem-spaces and operators. +# +# Requires: +# util.tcl +# production.tcl +# config.tcl +# log.tcl + +namespace eval Partition { + +## +# Given a production graph and a state vertex, get a list of problem +# spaces that that state refers to. +# +# The reason that this can return a list is because a production may +# test more than one problem space name. +# +# @param graph Production graph +# @param state State vertex +# @returns A list of problem space names +proc GetPsNames { graph state } { + + if ![$graph Get $state isState] { + return {} + } + + set special [$graph Get $state special] + + # We route everything under a top-state attribute to the top-ps problem + # space + # CFG - topstate to top-ps? + if { [DmGenCfg::Get FillTopPs] && $special == "TopState" } { + return "top-ps" + } + + # Search for children that test ^problem-space.name + set spec [Production::ProblemSpaceSpec] + set node $state + foreach s $spec { + set node [$graph FindVertex name $s [$graph GetOutAdjacencies $node]] + if { $node == [Graph::NullVertex] } { + break + } + } + if { $node != [Graph::NullVertex] } { + set psNames [$graph Get $node value] ;# list of problem-space names + # If they are testing for NOT a problem-space name, we assign it to + # any-ps. This is a bit of a hack, but a general solution for + # interpretting all relational operators in all tests is out of reach at + # the moment. + # an example of this would be: + # (state ^problem-space.name { <> waiting } ) + if { [$graph Get $node valRelOps] == "not_equal" } { + set psNames "any-ps" + LogInfo "not_equal relation found on problem-space.name test, assigning to any-ps." + } + } elseif { [DmGenCfg::Get FillAnyPs] && $special != "SuperState" && $special != "TopState" } { + # A non-superstate that does not inspect problem-space.name goes to any-ps + # Since we have no idea what the superstate is, it would be stupid to stick + # that stuff on any-ps. + set psNames "any-ps" + } else { + set psNames {} + } + + return $psNames +} + +## +# Like GetPsNames, except for operators. Given an operator attribute, +# it finds all the names referenced by that operator. +proc GetOpNames { graph op } { + set special [$graph Get $op special] + if { $special != "Operator" } { + return {} + } + + # TODO This should use Production::OperatorSpec just like GetPsNames. + set node [$graph FindVertex name name [$graph GetOutAdjacencies $op]] + if { $node == [Graph::NullVertex] } { + return {} + } + set opNames [$graph Get $node value] ;# return list of operator names + + # If they are testing for NOT an operator name, we treat it as if there + # was no operator named which means that any structure on the operator + # attribute will be copied into the problem-space where it's encountered. + # This is a bit of a hack, but a general solution for + # interpretting all relational operators in all tests is out of reach at + # the moment. + # an example of this would be: + # (state ^operator.name { <> waiting } ) + if { [$graph Get $node valRelOps] == "not_equal" } { + LogInfo "not_equal relation found on operator.name test" + set opNames {} + } + + return $opNames ;# return list of operator names +} + +## +# Partition a production graph into constituent problem spaces and operators. +# +# This gives us a way to merge the various parts of the production into the +# correct problem spaces or operators in the datamap. If top-state is +# tested, then everthing under that goes to top-ps. If there are multiple +# states testing multiple problem space names, they will all go to the +# correct place. +# +# Returns a list of tuples: +# 1 = tag of state or operator vertex +# 2 = type of vertex (S = problem space, O = operator) +# 3 = list of problem-space or operator names +# 4 = list of vertices that are part of that state or operator +# +# @param p Production graph +# @returns The list of 4-tuples described above. +proc PartitionProduction { p } { + set Parts {} + # For all identified states and operators in the production... + foreach s [concat [Production::GetStates $p] [Production::GetOperators $p]] { + if { [$p Get $s isState] } { + set type S + set psNames [GetPsNames $p $s] + } else { ;# s is an operator + set type O + set psNames [GetOpNames $p $s] + } + # If there were no problem spaces or operators found, we just ignore it. + # This should only happen if FillAnyPs is turned off! + if { $psNames == {} } { continue } + + # Prepare for breadth first traversal... + foreach v [$p GetVertices] { + set visited($v) 0 + } + + set P {} ;# Current partition we're building + + set L [$p GetOutAdjacencies $s] ;# traversal queue + set visited($s) 1 + foreach v $L { set visited($v) 1 } + + while { [llength $L] > 0 } { + set v [lindex $L 0] ;# Get head of queue + set L [lrange $L 1 end] ;# Pop head of queue + + # If this is not a state with a problem space, or a named operator, + # we keep going, otherwise, we stop the partition here, it will + # become a link. + set vIsState [$p Get $v isState] + set vPsNames [GetPsNames $p $v] + set link {} + if { ![expr $vIsState && { $vPsNames != {} }] } { + + # Is this a named operator? + set vIsOp [expr [string compare [$p Get $v special] "Operator"] == 0] + set vOpNames [GetOpNames $p $v] + if { ![expr $vIsOp && { $vOpNames != {} }] } { + foreach a [$p GetOutAdjacencies $v] { + if { !$visited($a) } { + set visited($a) 1 + lappend L $a + } + } + } else { ;# it's a named operator + set link [concat O $vOpNames] + } + } else { ;#it's a named problem-space + set link [concat S $vPsNames] + } + lappend P $v $link ;# Add v to partition + } + lappend Parts $type $psNames $s $P ;# Add current partition to list of partitions + } + return $Parts +} + +proc test { } { + sp { test + (state ^problem-space.name MyPs) + ( ^x 1) + ( ^y 5) + ( ^z 6) + ( ^superstate ) + ( ^problem-space.name SsPs) + ( ^p 2 ^q 3 ^r 4) + ( ^operator ) + ( ^name bob ^param howdy) + --> + ( ^p 5) + } + + set g [Production::Parse test] + set p [PartitionProduction $g] +} + +} ;# namespace + +IfStandAlone { ;# Some test code + DmGenPartition::test +} + diff --git a/dmgen-1.0.0/src/patchwin.tcl b/dmgen-1.0.0/src/patchwin.tcl new file mode 100644 index 0000000..d865017 --- /dev/null +++ b/dmgen-1.0.0/src/patchwin.tcl @@ -0,0 +1,345 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Implementation of the patch window which displays a problem-space or +# operator and allow it to be edited by the user. This window is spawned +# when the user chooses a ps or op from the datamap window. +# +# Requires: +# bwutil.tcl +# datamap.tcl +# soarutil.tcl + +package require BWidget + +namespace eval PatchWin { + # Returns the widget path for a patch window given a ps or op handle. + # This will return a value, even if the window doesn't exist! + proc Get { h } { return .$h } + + # Create a patch window for the given ps or op handle, or raise it if + # one already exists. + # + # @param h Handle to PS or OP, returned from Datamap:: functions. + # @returns Widget path of window. + proc Create { h } { + set w [Get $h] + + # If there's already a window for this handle, raise it and return + if [winfo exists $w] { + raise $w + return $w + } + set dm [Datamap::GetDatamap $h] + set w [toplevel $w] ;# create toplevel window + #wm geometry $w 500x400 + + # set up a window close handler + bind $w [list PatchWin::onDestroy {%W} $w $h] + + # set the window title + set dmName [Datamap::GetName $dm] + if [Datamap::IsProblemSpace $h] { + wm title $w "Datamap: $dmName, Problem Space: [Datamap::GetPsOrOpName $h]" + } else { + wm title $w "Datamap: $dmName, Operator: [Datamap::GetPsOrOpName $h]" + } + + # Add a menubar + set mb [menu $w.mb] + $w config -menu $mb + $mb add command -label "Datamap" -command "raise [DmWin::Get $dm]" + foreach m { Edit ProblemSpaces Operators } { + set mnu$m [menu $mb.mnu$m] + $mb add cascade -label $m -menu $mb.mnu$m + } + + # Set up post callbacks for PS and OP menus + $mnuProblemSpaces config -postcommand "PatchWin::psMenuPost $w $h" + $mnuOperators config -postcommand "PatchWin::opMenuPost $w $h" + + # Create a tree on the left of the window + ScrolledWindow $w.sw + set g [Datamap::GetGraph $h] + set s [Datamap::GetStartVertex $h] + set tree [BwUtil::NewBWidgetTreeFromGraph $w.tree $g $s name] + $tree bindText "PatchWin::onTreeLeftClick $w $h" + $tree bindText "PatchWin::onTreeRightClick $w $h %X %Y" + $w.sw setwidget $tree + #ExpandBWidgetTree $tree + + # Create a popup menu for right-clicking tree nodes + set pu [menu $tree.popup -tearoff 0] + menu $pu.prods + + + # Create a frame on the right with widgets for editing the selected + # tree node. + set f [frame $w.f] + + + grid [label $f.nameLbl -text "Name:"] -column 0 -row 1 -sticky e + grid [entry $f.name] -column 1 -row 1 -sticky ew + + grid [label $f.valueLbl -text "Value(s):"] -column 0 -row 2 -sticky e + grid [entry $f.value] -column 1 -row 2 -stick ew + + grid [label $f.typeLbl -text "Type:"] -column 0 -row 3 -sticky e + set cb [ComboBox $f.type -values [Production::NodeTypes] \ + -editable false] + $cb setvalue @0 + grid $cb -column 1 -row 3 -sticky ew + + + grid [label $f.commentLbl -text "Comment:"] -column 0 -row 4 -sticky e + grid [text $f.comment] -column 1 -row 4 + + set cb [checkbutton $f.showUnknownTypes \ + -text "Mark (?) nodes with type unknown" \ + -command "PatchWin::onUpdateAllNodes $w $h" \ + -variable $f.showUnknownTypes] + grid $cb -column 1 -row 5 + set cb [checkbutton $f.showEmptyValues \ + -text "Mark (@) nodes with empty value" \ + -command "PatchWin::onUpdateAllNodes $w $h" \ + -variable $f.showEmptyValues] + grid $cb -column 1 -row 6 + + foreach v [$g GetVertices] { + updateNodeDisplay $w $h $g $v + } + + pack $w.sw $tree -expand yes -fill both -side left + + pack $f -side right -expand yes -fill both + + return $w + } + proc psMenuPost { w h } { + set mnu $w.mb.mnuProblemSpaces + $mnu delete 0 end + + # Fill the PS menu with all PSs, except for this one if it's a PS. + if [Datamap::IsProblemSpace $h] { + set name [Datamap::GetPsOrOpName $h] + } else { + set name "" ;# Just so it doesn't match below + } + set dm [Datamap::GetDatamap $h] + foreach ps [lsort [Datamap::GetProblemSpaces $dm]] { + set n [Datamap::GetPsOrOpName $ps] + if { [string compare $n $name] != 0 } { + $mnu add command -label $n \ + -command "PatchWin::Create $ps" + } + } + } + proc opMenuPost { w h } { + set mnu $w.mb.mnuOperators + $mnu delete 0 end + + # Fill the OP menu with all OPs, except for this one if it's a OP. + if [Datamap::IsOperator $h] { + set name [Datamap::GetPsOrOpName $h] + } else { + set name "" ;# Just so it won't match below + } + set dm [Datamap::GetDatamap $h] + foreach op [lsort [Datamap::GetOperators $dm]] { + set n [Datamap::GetPsOrOpName $op] + if { [string compare $n $name] != 0 } { + $mnu add command -label $n \ + -command "PatchWin::Create $op" + } + } + } + proc onDestroy { widget w h } { + if { [string compare $widget $w] != 0 } { + return + } + ;# nothing to do here yet... + } + + # If 'new' value of vertex field is different from the current one, + # patch the vertex with the new value. + proc patchOnChange { g v field new } { + set old [$g Get $v $field] + if { [string compare $new $old] != 0 } { + DmPatch::PatchVertexFast $g $v $field $new + return 1 + } + return 0 + } + proc updateNodeDisplay { w h graph node } { + set tree $w.tree + set name [$graph Get $node name] + array set data [$tree itemcget $node -data] + if { [llength [$graph Get $node link]] > 0 || \ + [llength $data(BackEdges)] > 0 } { + set name "$name -->" + } + # check for unknown type + set type [$graph Get $node type] + global $w.f.showUnknownTypes + if { [set $w.f.showUnknownTypes] && \ + [string compare $type "unknown"] == 0 } { + set name "? $name" + } + # check for empty value + global $w.f.showEmptyValues + if { [set $w.f.showEmptyValues] && \ + [string compare $type "identifier"] != 0 && \ + [llength [$graph Get $node value]] == 0 } { + set name "@ $name" + } + $tree itemconfigure $node -text $name + if { [llength [$graph Get $node patched]] > 0 } { + $tree itemconfigure $node -fill blue + } + } + proc onTreeLeftClick { w h node } { + set f $w.f + set g [Datamap::GetGraph $h] + + set sel [$w.tree selection get] + if { $sel != "" } { + set c [expr [patchOnChange $g $sel name [$f.name get]] || \ + [patchOnChange $g $sel value [$f.value get]] || \ + [patchOnChange $g $sel type [BwUtil::GetComboBoxText $f.type]] || \ + [patchOnChange $g $sel comment [split [BwUtil::GetTextBoxText $f.comment] "\n"]]] + if $c { + updateNodeDisplay $w $h $g $sel + } + } + + $w.tree selection set $node + + BwUtil::SetEntryText $f.name [$g Get $node name] + BwUtil::SetEntryText $f.value [$g Get $node value] + BwUtil::SetComboBoxValue $f.type [$g Get $node type] + BwUtil::SetTextBoxText $f.comment [join [$g Get $node comment] "\n"] + + foreach p { name value type comment } { + $f.[join [list $p Lbl] "" ] configure -foreground black + } + foreach p [$g Get $node patched] { + $f.[join [list $p Lbl] "" ] configure -foreground blue + } + } + proc onTreeRightClick { w h x y node } { + onTreeLeftClick $w $h $node + + set pu $w.tree.popup + $pu delete 0 end + + set g [Datamap::GetGraph $h] + + # If source productions are available, show a menu with a list of them + set prods [$g Get $node prods] + set hasProds 0 + if { [llength $prods] > 0 } { + set hasProds 1 + $pu add cascade -label "Productions" -menu $pu.prods + $pu.prods config \ + -postcommand "PatchWin::onSourceProdsPost $pu.prods $h $node" + } + + set link [$g Get $node link] + + # if there are any links, add menu items to follow them + set hasLinks 0 + if { [llength $link] > 0 } { + if { $hasProds } { + $pu add separator ;# separate this from source prods + } + set hasLinks 1 + set type [lindex $link 0] + #set names [lindex $link 1] + set names [lrange $link 1 end] + if { $type == "S" } { + set typeName "Problem Space" + } else { + set typeName "Operator" + } + set dm [Datamap::GetDatamap $h] + foreach n $names { + set nh [Datamap::GetPsOrOp $dm $type $n] + $pu add command -label "Go to $typeName: $n" \ + -command "PatchWin::Create $nh" + } + } + # If there are any backedges, we add menu items to go to those + # vertices from here. + array set data [$w.tree itemcget $node -data] + if { [llength $data(BackEdges)] > 0 } { + if { $hasLinks } { + $pu add seperator ;# separate this from the links + } + set hasLinks 1 + set s [Datamap::GetStartVertex $h] + array set pi [Dijkstra::ShortestPaths $g Dijkstra::UnitWeight $s] + foreach v $data(BackEdges) { + set path [join [DmPatch::GetVertexPath $g $s $v pi] "." ] + $pu add command -label "Backedge: $path" \ + -command "PatchWin::onTreeLeftClick $w $h $v" + } + } + + if { $hasProds || $hasLinks } { + tk_popup $w.tree.popup $x $y + } + } + # Command called when the source productions submenu of a right-click is + # posted. Just fills in the list of productions and adds a command that + # prints the production to the console. + proc onSourceProdsPost { mnu h node } { + $mnu delete 0 end + set g [Datamap::GetGraph $h] + foreach p [$g Get $node prods] { + set cmd "SoarUtil::GetSoarPrint $p" + $mnu add command -label $p \ + -command "puts \"\[$cmd\]\"" + } + } + + proc onUpdateAllNodes { w h } { + set g [Datamap::GetGraph $h] + foreach v [$g GetVertices] { + updateNodeDisplay $w $h $g $v + } + } +} diff --git a/dmgen-1.0.0/src/production.tcl b/dmgen-1.0.0/src/production.tcl new file mode 100644 index 0000000..e322223 --- /dev/null +++ b/dmgen-1.0.0/src/production.tcl @@ -0,0 +1,527 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code for representing productions as graphs +# +# A Production is represented as a graph. Each vertex has the following +# properties: +# name - Name of vertex (state, name, etc) +# type - Type of vertex (identifier, string, float, etc) +# value - Value of vertex (only meaningful for string, float, etc) +# special - +# isState - true if the structure under this vertex is a state +# isVariablized - true if this vertex represents a variablized attribute +# valRelOps - Relational ops that we're used in the test of the value +# e.g., not_equal, less, equal, etc. +# side - which side of the production it came from (L, R, or B). +# +# Requires: +# parser.tcl +# util.tcl +# graph.tcl +# soarutil.tcl + +namespace eval Production { + # Properties of each node + proc NodeProps {} { return { + name + type + value + special + isState + isVariablized + valRelOps + side + } } + # Property defaults values + proc NodePropDefaults {} { return { + name "unknown" + type unknown + value {} + special {} + isState 0 + isVariablized 0 + valRelOps {} + side B + } } + + # Possible values for 'type' node property + # DR - removed enum 7/25/02 + proc NodeTypes {} { return { unknown identifier string int float } } + + # Possible values for 'special' node property + # Should ProblemSpace be removed? I'm not sure if it's ever actually + # used. partition.tcl appears to just use ProblemSpaceSpec. + proc SpecialTypes {} { return { + ProblemSpace + ProblemSpaceSpec + Operator + OperatorSpec + TopState + SuperState + } } + + proc StateSpec {} { return state } + + variable psSpec ;# internal problem-space spec list + + # Use this for TAS-style (state.problem-space.name) + set psSpec { problem-space name } + # Use this for Visual Soar-style (state.name) + #set psSpec { name } + + ## + # PS spec 'constant'. Set the value by calling with a single + # argument. + proc ProblemSpaceSpec { { s {} } } { + variable psSpec + if { [llength $s] > 0 } { + set psSpec $s + } + return $psSpec + } + + proc OperatorSpec {} { return { operator name } } + proc TopStateSpec {} { return { top-state } } + proc SuperStateSpec {} { return { superstate } } + + ## + # Parse a production + # + # @param name Name of production to parse + # @returns The graph of the production + proc Parse { name } { + set graph [parse $name] + + return $graph + } + + ## + # Return all nodes with isState property set to true + # + # @param graph Production graph returned by Parse + # @returns List of node tags + proc GetStates { graph } { + set r {} + foreach v [$graph GetVertices] { + if [$graph Get $v isState] { + lappend r $v + } + } + return $r + } + + ## + # Return all nodes with 'special' attribute set to ProblemSpace + # + # @param graph Production graph + # @param state State node to start search at + # @returns List of node tags + proc GetProblemSpaces { graph state } { + set r {} + foreach v [$graph GetVertices] { + if { [$graph Get $v special] == "ProblemSpace" } { + lappend r $v + } + } + return $r + } + + ## + # Return all nodes with 'special' attribute set to Operator + # + # @param graph Production graph + # @returns List of node tags + proc GetOperators { graph } { + set r {} + foreach v [$graph GetVertices] { + if { [$graph Get $v special] == "Operator" } { + lappend r $v + } + } + return $r + } + + ## + # Parse a loaded Soar production and return its graph + proc parse { name } { + set buf [SoarUtil::GetSoarPrintInternal $name] + if { $buf == {} } { + puts "No loaded production: $name" + return {} + } + + # Parse the production into WMEs + set wmes [parse_production $buf] + if {$wmes == 0} { + puts "Could not parse production $name" + puts $buf + return {} + } + return [buildProduction $wmes] + } + + proc sidesAreCompatible { s0 s1 } { + if {$s0 == $s1 } { + return 1 + } elseif { $s0 == "B" || $s1 == "B" } { + return 1 + } + return 0 + } + + proc MergeSideValues { s0 s1 } { + if { $s0 != $s1 } { + return B + } else { + return $s0 + } + } + + ## + # Builds a production graph given the list returned b parse_production + # + # Rewritten for file version 1.9 to handle LHS/RHS asymmetry + # + # @param list of wmes { Side Id AttrName Value } + proc buildProduction { wmes } { + set wmes [lunique $wmes] ;# Remove repeats + +# foreach s $wmes { +# puts $s +# } + + set graph [Graph::Create [NodeProps]] + array set props [NodePropDefaults] + set props(name) TOP + set props(side) L + # Insert a fake TOP node to start from + set top [$graph InsertVertex [array get props]] + + set tids($top) TOP ;# maps nodes to id values (<*>) + set tIdToNodes(TOP) $top ;# maps ids to nodes (multi-map) + set tNodeReroutes($top) $top ;# lookup table rerouting node when they are + ;# replaced because they're a duplicate + + set states {} + foreach s $wmes { + set side [lindex $s 0] + set id [lindex $s 1] + set attr [lindex $s 2] + set val [lindex $s 3] + + set attrRelOps [lindex $s 4] + set valRelOps [lindex $s 5] + + unset props + array set props [NodePropDefaults] + set props(name) $attr + set props(side) $side + set props(valRelOps) $valRelOps + set props(isVariablized) [isVariable $attr] + if { [string compare $attr "state"] == 0 && [string compare $id "TOP"] == 0 } { + set props(isState) 1 + } + + set n [$graph InsertVertex [array get props]] + set tNodeReroutes($n) $n ;# Add identity mapping to reroute table for now + + # Accumulate list of state node for later... + if $props(isState) { + lappend states $n + } + + # Is this a terminal node? + if { [isVariable $val] } then { ;# non-terminal + set tids($n) $val + if ![info exists tIdToNodes($val)] { + set tIdToNodes($val) {} + } + set tIdToNodes($val) [lunion $tIdToNodes($val) $n] + } else { ;# terminal, just store the value + $graph Set $n value $val + } + set tparents($n) $id + } +# parray tparents +# parray tIdToNodes + # Now the graph has all of its vertices. Let's go through and set + # parents making sure we take which side of the production the + # node was found on. + foreach n [$graph GetVertices] { + if ![info exists tparents($n)] { ;# no parents + continue + } + # We don't need to merge states, just leave them... + if { [string compare $tparents($n) TOP] == 0 } { + $graph AddEdge $top $n + continue + } + set side [$graph Get $n side] + set name [$graph Get $n name] + + # Get all the nodes that match this parent id + if { ![info exists tIdToNodes($tparents($n))] } { + LogWarning "No node for parent $tparents($n), skipping" + continue + } + set potParents $tIdToNodes($tparents($n)) ;# potential parents +# puts "$name - $n" +# puts "pot = $potParents" + set mySideParents {} ;# parents on the same side as me + set otherSideParents {} ;# parents on the other side from me + foreach p $potParents { + if { $p != $n && $p < $n } { ;# prevent self-loops + # Which side is the potential parent on relative to me? + # Use the reroute table in case the parent has moved... + if [sidesAreCompatible $side [$graph Get $p side]] { + lappend mySideParents $tNodeReroutes($p) + } else { + lappend otherSideParents $tNodeReroutes($p) + } + } + } +# puts "my = $mySideParents" +# puts "other = $otherSideParents" + # We give priority to parents that are on the same side as + # the node. + set parentsFound 0 + set realParents {} + if { [llength $mySideParents] > 0 } { + set realParents $mySideParents + set parentsFound 1 + } elseif { [llength $otherSideParents] > 0 } { + set realParents $otherSideParents + set parentsFound 1 + } + if { $parentsFound } { + # now reparent node under each of its true parents + foreach p $realParents { +# puts "parenting under $p" + # Does this parent already have a child by the same name? + set sibs [$graph GetOutAdjacencies $p] + set fnode "" + foreach s $sibs { + if { [$graph Get $s name] == $name } { ;# Yes! + set fnode $s + } + } + # If there is a sibling with the same name, merge our properties + # in with those of the sibling and don't reparent ourself... + if { $fnode != "" } { + $graph Set $fnode value [lunion [$graph Get $fnode value] [$graph Get $n value]] + # Now when are children try to find their parent they'll find + # this replacement instead... + set tNodeReroutes($n) $fnode + # other stuff? + $graph Set $fnode side [MergeSideValues [$graph Get $fnode side] $side] + } else { + $graph AddEdge $p $n ;# just set the node's parent + } + } + } else { + puts "No parents found!" + } + } + # Find all of the nodes that were duplicates and prune them from the + # graph... + foreach n [$graph GetVertices] { + if { $n != $top && [llength [$graph GetInAdjacencies $n]] == 0 } { + $graph DeleteVertex $n + } + } + # Determine special field for all nodes... + foreach n [$graph GetVertices] { + set sfVisitTable($n) 0 + } + foreach s $states { + setSpecialFields $graph $top $s {} sfVisitTable + } + # Try to guess types of all vertices... + $graph Map Production::setTypeField + + return $graph + } + + ## + # Determine any special attributes of a node such as problem-space, state, + # operator, etc. + # + # @param g The graph + # @param parents List of parents of this node + # @param n The node + # @param path The node name path (list of names) + # @param visitTableName A hashtable to indicate when a node has already + # been visited. + proc setSpecialFields { g parents n path visitTableName } { + upvar $visitTableName visitedTable + set visitedTable($n) 1 ;# mark this node as visited + set name [$g Get $n name] + set parent [lindex $parents end] + set nParents [llength $parents] + set p [concat $path $name] + set notfound 1 + + # This mess is mostly to handle finding problem-spaces no matter how + # they're specified in the productions (e.g. ^problem-space.name for TAS, + # ^name for Visual Soar code, etc). The code below for OperatorSpec et al + # should also look like this, but ^operator.name is more consistent so + # we'll worry about that when the time comes... + + # Let's see if we've found a problems space specifier + # (e.g. ^problem-space.name) + set psSpec [ProblemSpaceSpec] ;# The spec + set psSpecLen [llength $psSpec] ;# length of spec + # Does the current path look like the spec? + if { [lcompare [ltail $p $psSpecLen] $psSpec] } { + # ok, is the parent of the top of the spec a state? + # i.e., we have to have state.problem-space.name or + # superstate.problem-space.name. This is crucial if the spec is just + # ^name as in the case of visual soar generated code. + set specParent [lindex $parents [expr $nParents - $psSpecLen]] + if [$g Get $specParent isState] { + $g Set $n special ProblemSpaceSpec + $g Set $parent special ProblemSpace + set notfound 0 + } + } + + if { $notfound && [lcompare [ltail $p [llength [OperatorSpec]]] [OperatorSpec]] } { + $g Set $n special OperatorSpec + $g Set $parent special Operator + } elseif { [lcompare [ltail $p [llength [TopStateSpec]]] [TopStateSpec]] } { + $g Set $n special TopState + $g Set $n isState 1 + } elseif { [lcompare [ltail $p [llength [SuperStateSpec]]] [SuperStateSpec]] } { + $g Set $n special SuperState + $g Set $n isState 1 + } + + # depth first left-to-right traversal + foreach c [$g GetOutAdjacencies $n] { + if { !$visitedTable($c) } { + setSpecialFields $g [concat $parents $n] $c $p visitedTable + } + } + } + + ## + # Is the string in 'val' a Soar variable, i.e. <*> + proc isVariable { val } { + return [string match <*> $val] + } + ## + # Get list of variables from 'list' + proc getVarList { list } { + set olist {} + foreach v $list { + if [isVariable $v] { + lappend olist $v + } + } + return $olist + } + ## + # Get list of non-variables from 'list' + proc getValueList { list } { + set olist {} + foreach v $list { + if ![isVariable $v] { + lappend olist $v + } + } + return $olist + } + + proc extractAttrName { s } { + set e [expr [string last "," $s] + 1] + return [string range $s $e end] + } + proc extractVarName { s } { + set e [expr [string first "," $s] - 1] + return [string range $s 0 $e] + } + ## + # Tries to guess the type of a node. + proc setTypeField { graph v } { + set name [$graph Get $v name] + + if [llength [$graph GetOutAdjacencies $v]] { + $graph Set $v type identifier + return + } + set val [$graph Get $v value] + set len [llength $val] + if { $len == 0 } { + $graph Set $v type unknown + } else { + $graph Set $v type [SoarUtil::GuessSoarTypeFromList $val] + } + } + +} ;# namespace Production + +IfStandAlone { ;# Some test code + lappend auto_path $env(SOAR_LIBRARY) + package require Soar + + sp {test0 + (state ^operator + ^problem-space.name jim + ^judy ) + ( ^name bob) + (state ^operator + ^problem-space.name jim2) + ( ^name bob2) + ( ^{ << var1 var2 var3 >> } ) + --> + (write (crlf) |Judy message from | ) + } + + set g [Production::Parse test0] + set t [$g FindVertex name TOP] + $g MapBreadthFirst $t Graph::Print + + set states [Production::GetStates $g] + puts "States = $states" + foreach s $states { + puts "state $s" + puts " ProblemSpaces = [Production::GetProblemSpaces $g $s]" + puts " Operators = [Production::GetOperators $g $s]" + } + +} ;# End test code diff --git a/dmgen-1.0.0/src/soarutil.tcl b/dmgen-1.0.0/src/soarutil.tcl new file mode 100644 index 0000000..05e8fa8 --- /dev/null +++ b/dmgen-1.0.0/src/soarutil.tcl @@ -0,0 +1,190 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Various utility functions for dealing with Soar. +# +# Requires: +# Soar +# production.tcl (Production::NodeTypes) + +namespace eval SoarUtil { + +## +# Strip the bars off a Soar string if they're both there. +# +# @param s The String to process +# @returns If s has bars, returns s with the bars removed. Otherwise, +# returns s +proc StripSoarBars { s } { + set n [string length $s] + if { $n > 1 && \ + [string range $s 0 0 ] == "|" && \ + [string range $s end end ] == "|" } { + return [string range $s 1 [expr $n - 2]] + } + return $s +} + +## +# Run a soar command and return its output. +# +# @param cmd Command to run +# @returns Result of command +proc RunSoarCommand { cmd } { + output-strings-destination -push -append-to-result + catch { + set buf [eval $cmd] + } + output-strings-destination -pop + return $buf +} + +## +# Get the result of "print -internal" for the specified production +# +# @param name Name of production +# @returns {} if an error occured, the results otherwise. +proc GetSoarPrintInternal { name } { + set buf [RunSoarCommand "print -internal $name"] + if { [string range $buf 0 1] != "sp" } { + return {} + } + return $buf +} + +## +# Get the result of "print" for the specified production +# +# @param name Name of production +# @returns {} if an error occured, the results otherwise. +proc GetSoarPrint { name } { + set buf [RunSoarCommand "print $name"] + if { [string range $buf 0 1] != "sp" } { + return {} + } + return $buf +} + +## +# Get a list of all loaded productions +proc GetSoarProductions { } { + set L {} + set b [split [RunSoarCommand "print -all"] " \n"] + foreach p $b { + if { [llength $p] > 0 } { + lappend L [StripSoarBars $p] + } + } + return $L +} + +## +# Get the name of the file from which a production was loaded. +# +# @param name Name of production +# @returns Name of file. +proc GetSoarProductionFile { name } { + return [RunSoarCommand "print -filename $name"] +} + +## +# Try to guess the type of a single value (int, float, or string) +# +proc GuessSoarType { s } { + set t {} + set s [string trim $s] + set int {^([+-])*[0-9]+$} + set float1 {^([+-])*[0-9]*\.?[0-9]+$} ;# normal float + set float2 {^([+-])*[0-9]+\.$} ;# no digits after '.' + if [regexp $int $s] { + set t int + } elseif [regexp $float1 $s] { + set t float + } elseif [regexp $float2 $s] { + set t float + } else { + set t string + } + return $t +} + +## +# Try to guess a Soar type given a list of values... +proc GuessSoarTypeFromList { s } { + set ls [llength $s] + if { $ls == 0 } { ;# no value, no guess (could be identifier?) + return unknown + } + if { $ls == 1 } { ;#single value, one guess + return [GuessSoarType $s] + } + + # initialize bitmap indexed by typename + foreach i [Production::NodeTypes] { set rlu($i) 0 } + + # accumulate individual guesses in a bitmap indexed by typename + set lr 0 ;# count of number of different guesses encountered + foreach v $s { + set t [GuessSoarType $v] + if { $rlu($t) == 0 } { incr lr } + set rlu($t) 1 + } + + if { $lr == 1 } { ;# single type guessed. yay. + if { $rlu(float) } { + set r float + } elseif { $rlu(int) } { + set r int + } else { + #set r enum + set r string + } + } elseif { $lr > 0 } { ;# multiple, conflicting guesses + # possibilities are string int float... + + # If only float and int have been guessed, go with float. + if { $lr == 2 && $rlu(float) && $rlu(int) } { + set r float + } else { ;# mix of strings, ints, and floats, go with enum + #set r enum + set r string + } + } + return $r +} + +} ;# end namespace SoarUtil diff --git a/dmgen-1.0.0/src/tclIndex b/dmgen-1.0.0/src/tclIndex new file mode 100644 index 0000000..2db94e1 --- /dev/null +++ b/dmgen-1.0.0/src/tclIndex @@ -0,0 +1,228 @@ +# Tcl autoload index file, version 2.0 + +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Only "public" functions from each module are included in the auto index. +# Public procs are easy to find because they start with a capital letter, +# with the exception of util.tcl, lexer.tcl and parser.tcl + +## +# Set a flag so we know where we're coming from... +global DmGenAutoLoaded +set DmGenAutoLoaded 1 + +## +# These are for an overly complicated and painful "compiled" +# version of dmgen. For now, we'll hard code the DmGenCompiled +# flag to 0 to avoid any weird behavior or bugs... DR 10/22/2003 +global DmGenCompiled +set DmGenCompiled 0 +global DmGenTbcVersion + +global tcl_version + +if { $DmGenCompiled } { + set ext tbc + array set verdirtab { 8.0 10 \ + 8.3 13 } + if { [info exists verdirtab($tcl_version)] } { + set DmGenTbcVersion $verdirtab($tcl_version) + set dir [file join $dir "tbc$DmGenTbcVersion"] + } else { + puts stderr "Unsupported Tcl version: $tcl_version" + exit 1 + } +} else { + set ext tcl + set verdir "" +} + + + +set auto_index(::DmGenCfg::Read) [list source [file join $dir config.$ext]] +set auto_index(::DmGenCfg::Write) [list source [file join $dir config.$ext]] +set auto_index(::DmGenCfg::Get) [list source [file join $dir config.$ext]] +set auto_index(::DmGenCfg::Set) [list source [file join $dir config.$ext]] + +set auto_index(::BwUtil::ExpandBWidgetTree) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::NewBWidgetTreeFromGraph) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::GetComboBoxText) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::SetComboBoxValue) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::SetEntryText) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::GetTextBoxText) [list source [file join $dir bwutil.$ext]] +set auto_index(::BwUtil::SetTextBoxText) [list source [file join $dir bwutil.$ext]] +set auto_index(::Datamap::VertexFields) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::DefVertexFields) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::Create) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::Clear) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::Destroy) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetName) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::CreateProblemSpace) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::FindOrCreateProblemSpace) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::CreateOperator) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::FindOrCreateOperator) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::RemoveProblemSpace) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::RemoveOperator) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetProblemSpaces) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetOperators) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::Generate) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetPsOrOp) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetProblemSpace) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetOperator) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetDatamap) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetPsOrOpName) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetType) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::IsProblemSpace) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::IsOperator) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetGraph) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::GetStartVertex) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::FindVertexFromPath) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::DefAttrSortPriority) [list source [file join $dir datamap.$ext]] +set auto_index(::Datamap::SortAttributes) [list source [file join $dir datamap.$ext]] +set auto_index(::Dijkstra::Inf) [list source [file join $dir dijkstra.$ext]] +set auto_index(::Dijkstra::ShortestPaths) [list source [file join $dir dijkstra.$ext]] +set auto_index(::Dijkstra::UnitWeight) [list source [file join $dir dijkstra.$ext]] +set auto_index(GenerateDatamap) [list source [file join $dir dmgen.$ext]] +set auto_index(::DmPatch::PatchVertex) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::PatchVertexFast) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::RemoveVertex) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::SavePatches) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::writePatch) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::ApplyPatchFile) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmPatch::GetVertexPath) [list source [file join $dir dmpatch.$ext]] +set auto_index(::DmWin::Get) [list source [file join $dir dmwin.$ext]] +set auto_index(::DmWin::Create) [list source [file join $dir dmwin.$ext]] +set auto_index(::Graph::NullVertex) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Create) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Destroy) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Copy) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::InsertVertex) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::AddEdge) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::RemoveEdge) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Set) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::SetL) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::SetAll) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Get) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::DeleteVertex) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::GetFields) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::GetVertices) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::EdgeExists) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::GetOutAdjacencies) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::GetInAdjacencies) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Map) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::MapDepthFirst) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::MapBreadthFirst) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::MapOutAdjacencies) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::MapInAdjacencies) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::IsEmpty) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Size) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::FindVertex) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::BasicVertexCopy) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::Print) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::SortVertListByField) [list source [file join $dir graph.$ext]] +set auto_index(::Graph::SortOutAjacencies) [list source [file join $dir graph.$ext]] +set auto_index(::DmGenHtmlOut::EscapeHtmlString) [list source [file join $dir htmlout.$ext]] +set auto_index(::DmGenHtmlOut::WriteHtmlDatamap) [list source [file join $dir htmlout.$ext]] +set auto_index(get_lexeme) [list source [file join $dir lexer.$ext]] + +set auto_index(LogError) [list source [file join $dir log.$ext]] +set auto_index(LogWarning) [list source [file join $dir log.$ext]] +set auto_index(LogInfo) [list source [file join $dir log.$ext]] +set auto_index(Log) [list source [file join $dir log.$ext]] +set auto_index(LogFlush) [list source [file join $dir log.$ext]] +set auto_index(LogReset) [list source [file join $dir log.$ext]] +set auto_index(LogSetAutoFlush) [list source [file join $dir log.$ext]] +set auto_index(LogSetFileName) [list source [file join $dir log.$ext]] + +set auto_index(ProcessProd) [list source [file join $dir merge.$ext]] +set auto_index(MergeProdIntoDatamap) [list source [file join $dir merge.$ext]] +set auto_index(mergeProdIntoDatamap) [list source [file join $dir merge.$ext]] +set auto_index(parse_production) [list source [file join $dir parser.$ext]] +set auto_index(::Partition::GetPsNames) [list source [file join $dir partition.$ext]] +set auto_index(::Partition::GetOpNames) [list source [file join $dir partition.$ext]] +set auto_index(::Partition::PartitionProduction) [list source [file join $dir partition.$ext]] +set auto_index(::PatchWin::Get) [list source [file join $dir patchwin.$ext]] +set auto_index(::PatchWin::Create) [list source [file join $dir patchwin.$ext]] +set auto_index(::Production::NodeProps) [list source [file join $dir production.$ext]] +set auto_index(::Production::NodePropDefaults) [list source [file join $dir production.$ext]] +set auto_index(::Production::NodeTypes) [list source [file join $dir production.$ext]] +set auto_index(::Production::SpecialTypes) [list source [file join $dir production.$ext]] +set auto_index(::Production::StateSpec) [list source [file join $dir production.$ext]] +set auto_index(::Production::ProblemSpaceSpec) [list source [file join $dir production.$ext]] +set auto_index(::Production::OperatorSpec) [list source [file join $dir production.$ext]] +set auto_index(::Production::TopStateSpec) [list source [file join $dir production.$ext]] +set auto_index(::Production::SuperStateSpec) [list source [file join $dir production.$ext]] +set auto_index(::Production::Parse) [list source [file join $dir production.$ext]] +set auto_index(::Production::GetStates) [list source [file join $dir production.$ext]] +set auto_index(::Production::GetProblemSpaces) [list source [file join $dir production.$ext]] +set auto_index(::Production::GetOperators) [list source [file join $dir production.$ext]] +set auto_index(::Production::sidesAreCompatible) [list source [file join $dir production.$ext]] +set auto_index(::Production::MergeSideValues) [list source [file join $dir production.$ext]] +set auto_index(::SoarUtil::RunSoarCommand) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GetSoarPrintInternal) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GetSoarPrint) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GetSoarProductions) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GetSoarProductionFile) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GuessSoarType) [list source [file join $dir soarutil.$ext]] +set auto_index(::SoarUtil::GuessSoarTypeFromList) [list source [file join $dir soarutil.$ext]] +set auto_index(Constant) [list source [file join $dir util.$ext]] +set auto_index(Static) [list source [file join $dir util.$ext]] +set auto_index(Assert) [list source [file join $dir util.$ext]] +set auto_index(IfStandAlone) [list source [file join $dir util.$ext]] +set auto_index(Max) [list source [file join $dir util.$ext]] +set auto_index(Min) [list source [file join $dir util.$ext]] +set auto_index(GetTag) [list source [file join $dir util.$ext]] +set auto_index(lempty) [list source [file join $dir util.$ext]] +set auto_index(ldelete) [list source [file join $dir util.$ext]] +set auto_index(lunique) [list source [file join $dir util.$ext]] +set auto_index(lcompare) [list source [file join $dir util.$ext]] +set auto_index(ltail) [list source [file join $dir util.$ext]] +set auto_index(lunion) [list source [file join $dir util.$ext]] +set auto_index(lintersect) [list source [file join $dir util.$ext]] +set auto_index(ldiff) [list source [file join $dir util.$ext]] +set auto_index(PrintTabs) [list source [file join $dir util.$ext]] +set auto_index(UnwindDirStack) [list source [file join $dir util.$ext]] +set auto_index(ReplaceChar) [list source [file join $dir util.$ext]] +set auto_index(::DmGenXmlOut::EscapeXmlString) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::OpenXmlTag) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::CloseXmlTag) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::XmlTabs) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::getPsOrOpHref) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::WriteXmlDatamap) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::WriteXmlPsOrOp) [list source [file join $dir xmlout.$ext]] +set auto_index(::DmGenXmlOut::writeXmlDatamap_r) [list source [file join $dir xmlout.$ext]] diff --git a/dmgen-1.0.0/src/util.tcl b/dmgen-1.0.0/src/util.tcl new file mode 100644 index 0000000..33ff4c2 --- /dev/null +++ b/dmgen-1.0.0/src/util.tcl @@ -0,0 +1,285 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Generic utility functions + +## +# Create a globally accessible constant, e.g. +# Constant Pi 3.1415926535 +# puts "Pi = [pi]" +# +# @param name Name of constant +# @param value Value of constant +proc Constant { name value } { + proc $name { } [list return $value] +} + +## +# Create a proc static variable +# @param List of names of static variables to create +proc Static { args } { + set procName [lindex [info level -1] 0] + foreach varName $args { + uplevel 1 "upvar #0 staticvars($procName:$varName) $varName" + } +} + +## +# Simple assertion. remove with 'proc Assert {x} { }' +proc Assert {condition} { + if {[catch {uplevel [list expr $condition]} n] || $n == "" || $n == 0} { + puts "Assertion failed (result $n), in:" + set prefix "" + for {set i [info level]} {$i} {incr i -1} { + append prefix " " + puts "$prefix'[info level $i]'" + } + # try to call a failure handler to collect more info + if {![catch ::AssertionFailureHandler msg] && $msg != ""} { + append condition " ($msg)" + } + #error "Assertion failed: $condition" + puts "Assertion failed: $condition" + exit + } +} + +## +# Add code that is run if the source file is run standalone. +# +# @param body Code to execute when script is run standalone. +proc IfStandAlone body { + global argv0 + # If the script file is the same as "this" file, run body. + if { [info exists argv0] && \ + ![string compare [file tail [info script]] [file tail $argv0]] } { + catch {console show} + uplevel $body + } + } + +proc Max {a args} {foreach i $args {if {$i>$a} {set a $i}};return $a} +proc Min {a args} {foreach i $args {if {$i<$a} {set a $i}};return $a} + + +## +# Generate a unique "tag" for a particular namespace. Subsequent calls with +# the same namespace will return new unique tags. +# +# @param nspace Name of tag +# @param int If true, then the tag is simply an integer, otherwise it is a +# string. +proc GetTag { nspace { int 0 } } { + set idx __nextNum$nspace ;# A global "static" variable with the next tag + global $idx + if ![info exists $idx] { ;# initialize on first call + set $idx 0 + } + incr $idx + if { $int } { + return [set $idx] + } + return "__tag$nspace[set $idx]" +} + +## +# Join a list of path elements with the system path separator. +# +# @param pathList List of path elements +proc JoinPathList { pathList } { + set r "" + foreach p $pathList { + set r [file join $r $p] + } + return $r +} + +## +# Get an absolute path to the currently running script. +# +# This function is only accurate if it's called from a top-level +# script that hasn't changed the current directory. +# +# @returns a tuple (path to script, name of script) +proc GetPathToScript { } { + set relPath [info script] + set scriptName [file tail $relPath] + set dirName [file dirname $relPath] + + set pathType [file pathtype $dirName] + if { $pathType == "absolute" } { + return [list $dirName $scriptName] + } elseif { $pathType == "relative" } { + set cur [file split [pwd]] + set parts [file split $dirName] + set end [llength $cur] + for { set i 0 } { $i < [llength $parts] } { incr i } { + set p [lindex $parts $i] + if { $p == ".." } { + incr end -1 + } elseif { $p != "." } { + break + } + } + set full [concat [lrange $cur 0 [expr $end - 1]] \ + [lrange $parts $i end]] + return [list [JoinPathList $full] $scriptName] + } else { ;# volumerelative + return [list $dirName $scriptName] + } +} + +## +# Returns true if a list is empty +proc lempty { list } { + return [expr [llength $list] == 0] +} + +## +# Returns a new list that is 'list' with the first instance of 'value' +# removed. +# +# @param list Input list +# @param value Value of item to remove from list +# @retursn New list +proc ldelete { list value } { + set ix [lsearch -exact $list $value] + if { $ix >= 0 } { + return [lreplace $list $ix $ix] + } else { + return $list + } +} + +## +# Remove duplicates from a list and return a new list +# +# @param list List to process +# @returns Copy of list with duplicates removed +proc lunique {list} { + # ulist is the uniq-ed list + set ulist {} + + # The main loop + foreach e $list { + if {![info exist vec($e)]} { + set vec($e) {} + lappend ulist $e + } + } + + return [lrange $ulist 0 end] +} + +proc lcompare {a b} { + set la [llength $a] + set lb [llength $b] + + if { $la != $lb } { return 0 } + for { set i 0 } { $i < $la } { incr i } { + if { [lindex $a $i] != [lindex $b $i] } { + return 0 + } + } + return 1 +} +proc ltail { L i } { + set l [llength $L] + if { $l < $i } { + return $L + } + return [lrange $L [expr $l - $i] end] +} + +## +# Create the union of two lists, i.e. all elements from both with no duplicates +# +# @param a First list +# @param b Second list +# @returns A new list that is the a U b. +proc lunion { a b } { + return [lunique [concat $a $b]] +} +## +# Calculate set intersection of lists a and b and return it. +proc lintersect { a b } { + set i {} + foreach v $a { + if { [lsearch -exact $b $v] >= 0 } { + lappend i $v + } + } + return $i +} +## +# Calculate the set difference a - b of lists a and b and return it +proc ldiff { a b } { + set d $a + foreach v $b { + set d [ldelete $d $v] + } + return $d +} + +## +# Repeatedly print a string to the console. +# +# @param lvl Number of repititions of string +# @param s String to repeat +proc PrintTabs { lvl { s " " } } { + for { set i 0 } { $i < $lvl } { incr i } { + puts -nonewline $s + } +} + +proc UnwindDirStack {} { + while { ![catch { popd }] } { } +} + +proc ReplaceChar { s ic oc } { + set l [string length $s] + set r "" + for { set i 0 } { $i != $l } { incr i } { + set c [string index $s $i] + if { [string compare $c $ic] == 0 } { + set c $oc + } + set r [concat $r $c] + } + return [join $r ""] +} + diff --git a/dmgen-1.0.0/src/xmlout.tcl b/dmgen-1.0.0/src/xmlout.tcl new file mode 100644 index 0000000..32b94b8 --- /dev/null +++ b/dmgen-1.0.0/src/xmlout.tcl @@ -0,0 +1,200 @@ +### +# Copyright 1995-2004 Soar Technology, Inc., University of Michigan. All +# rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SOAR +# CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# The views and conclusions contained in the software and documentation +# are those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of Soar Technology, Inc., +# the University of Michigan, or the Soar consortium. +### + +## +# Code to write a datamap in XML + +namespace eval DmGenXmlOut { + +# a simple hack to write out a string in XML with proper escapes +proc EscapeXmlString { s } { + set s [join [split $s "<"] "<"] + set s [join [split $s ">"] ">"] + + return $s +} + +proc OpenXmlTag { fd tag attrs } { + puts -nonewline $fd "<$tag " + foreach { a v } $attrs { + puts -nonewline $fd "$a=\"$v\" " + } + puts -nonewline $fd ">" +} +proc CloseXmlTag { fd tag } { + puts $fd "" +} + +proc XmlTabs { fd lvl { s " " } } { + for { set i 0 } { $i < $lvl } { incr i } { + puts -nonewline $fd $s + } +} + +proc getPsOrOpHref { type name } { + return "$type-$name.xml" +} + +proc writeXmlHeader { fd } { + global dmGenVersion + puts $fd "\n" + puts $fd "" +} + +proc WriteXmlDatamap { fn dm } { + pushd $fn + + set pss [lsort [Datamap::GetProblemSpaces $dm]] + set ops [lsort [Datamap::GetOperators $dm]] + + set dmfd [open index.xml w] + writeXmlHeader $dmfd + puts $dmfd "" + foreach h [concat $pss $ops] { + set name [Datamap::GetPsOrOpName $h] + if [Datamap::IsProblemSpace $h] { + set type S + } else { + set type O + } + set href [getPsOrOpHref $type $name] + XmlTabs $dmfd 1 + puts $dmfd "<$type name=\"$name\" href=\"$href\"/>" + set hfd [open $href w] + writeXmlHeader $hfd + WriteXmlPsOrOp $hfd $h 0 + close $hfd + } + puts $dmfd "" + + close $dmfd + + popd ;# pop back to original directory +} + +proc WriteXmlPsOrOp { fd h depth } { + global XmlVisited + if [info exists XmlVisited] { + unset XmlVisited + } + if [info exists XmlRefPaths] { + unset XmlRefPaths + } + set graph [Datamap::GetGraph $h] + set name [Datamap::GetPsOrOpName $h] + if [Datamap::IsProblemSpace $h] { + set typeName "Problem Space" + set type S + } else { + set typeName "Operator" + set type O + } + + foreach v [$graph GetVertices] { + set XmlVisited($v) 0 + } + XmlTabs $fd $depth + puts $fd "<$type name=\"[Datamap::GetPsOrOpName $h]\">" + writeXmlDatamap_r $fd $graph [Datamap::GetStartVertex $h] [expr $depth + 1] {} + XmlTabs $fd $depth + puts $fd "" +} + +proc writeXmlDatamap_r { fd graph vert depth path } { + global XmlVisited XmlRefPaths + set XmlVisited($vert) 1 + + set out [$graph GetOutAdjacencies $vert] + + array set props [$graph Get $vert] + + set path [concat $path $props(name)] + set XmlRefPaths($vert) $path + + XmlTabs $fd $depth +# puts $fd "" + puts $fd "" + set nextDepth [expr $depth + 1] + + XmlTabs $fd $nextDepth + puts $fd "[EscapeXmlString $props(name)]" + + XmlTabs $fd $nextDepth + puts $fd "" + set valDepth [expr $nextDepth + 1] + foreach val $props(value) { + XmlTabs $fd $valDepth + puts $fd "[EscapeXmlString $val]" + } + XmlTabs $fd $nextDepth + puts $fd "" + + if { $props(link) != {} } { + set link $props(link) + set type [lindex $link 0] + set names [lrange $link 1 end] + foreach n $names { + XmlTabs $fd $nextDepth + puts $fd "" + } + } + XmlTabs $fd $nextDepth + puts $fd "" + set prodDepth [expr $nextDepth + 1] + foreach p $props(prods) { + XmlTabs $fd $prodDepth + puts $fd "[EscapeXmlString $p]" + } + XmlTabs $fd $nextDepth + puts $fd "" + + foreach v $out { + set name [$graph Get $v name] + if { !$XmlVisited($v) } { ;# we haven't hit this vertex yet + writeXmlDatamap_r $fd $graph $v $nextDepth $path + } else { + XmlTabs $fd $nextDepth + set vpath [join $XmlRefPaths($v) "."] +# puts $fd "[EscapeXmlString $vpath]" + puts $fd "[EscapeXmlString $vpath]" + } + } + XmlTabs $fd $depth + puts $fd "" +} + +} ;# namespace eval DmgenXmlOut diff --git a/eaters-3.0.8/INSTALL.txt b/eaters-3.0.8/INSTALL.txt new file mode 100644 index 0000000..7dbc93b --- /dev/null +++ b/eaters-3.0.8/INSTALL.txt @@ -0,0 +1,37 @@ +$Id: INSTALL.txt,v 1.3 2004/07/10 04:46:31 toolshed Exp $ +_______________________ +Installing Eaters-3.0.8 +----------------------- + +Eaters 3.0.8 is part of the Soar-Suite package and is installed as a component of +that package. Installation instructions for Soar-Suite are located in the INSTALL +file in the soar-8.5.2 directory of the Soar-Suite package and on the Soar +website: + + http://sitemaker.umich.edu/soar/ + +________________________________ +Running Eaters-3.0.8 on Windows: +-------------------------------- + +Simply double-click the start-eaters.bat file. + +This .bat file will run init-eaters.tcl using the version of Tcl/Tk distributed +with Soar-Suite 8.5.2. + +_____________________________ +Running Eaters-3.0.8 on Unix: +----------------------------- + +On Unix, type this command to run Eaters: +./init-eaters.tcl + +You may need to make the same changes to the first line of the init-eaters.tcl +file that you made to the init-soar.tcl file to point to the location of the +wish binary on your machine. For example, if you needed to install ActiveTcl +when you installed Soar, you would change that first line to: +#!/usr/local/ActiveTcl/bin/wish + + +-- +Updated for the Eaters 3.0.8 release by Jonathan Voigt (voigtjr@gmail.com). diff --git a/eaters-3.0.8/LICENSE.txt b/eaters-3.0.8/LICENSE.txt new file mode 100644 index 0000000..6d648e4 --- /dev/null +++ b/eaters-3.0.8/LICENSE.txt @@ -0,0 +1,30 @@ +$Id: LICENSE.txt,v 1.1 2004/07/09 23:24:29 toolshed Exp $ + +Copyright 1995-2004 Carnegie Mellon University, University of Michigan, +University of Southern California/Information Sciences Institute. All rights +reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained +in the software and documentation are those of the authors and should not be +interpreted as representing official policies, either expressed or implied, of +Carnegie Mellon University, the University of Michigan, the University of +Southern California/Information Sciences Institute, or the Soar consortium. \ No newline at end of file diff --git a/eaters-3.0.8/README.txt b/eaters-3.0.8/README.txt new file mode 100644 index 0000000..fdc7103 --- /dev/null +++ b/eaters-3.0.8/README.txt @@ -0,0 +1,23 @@ +$Id: README.txt,v 1.3 2004/07/10 04:53:10 toolshed Exp $ + +Eaters 3.0.8 is an example environment for the Soar architecture and is used for +research and to help teach the basics of Soar in the Soar tutorial. Eaters +3.0.8 is installed as a component of the Soar-Suite package. For more +information, please see the website: + + http://sitemaker.umich.edu/soar/ + +____________________ +File/Directory list: +-------------------- +README.txt - This file. +INSTALL.txt - Installation and execution notes. +LICENSE.txt - The license that Eaters is distributed under. +start-eaters.bat - The Windows file used to start Eaters (see INSTALL file). +init-eaters.tcl - The Tcl/Tk initialization code for Eaters (see INSTALL file). +agents/ - Example and tutorial Soar agents. +simulator/ - The Eaters Tcl/Tk source code. + +-- + +Updated for the Eaters 3.0.8 release by Jonathan Voigt (voigtjr@gmail.com). diff --git a/eaters-3.0.8/agents/counter example/counter.soar b/eaters-3.0.8/agents/counter example/counter.soar new file mode 100644 index 0000000..53fa7f1 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter.soar @@ -0,0 +1,3 @@ +pushd counter +source counter_source.soar +popd diff --git a/eaters-3.0.8/agents/counter example/counter.vsa b/eaters-3.0.8/agents/counter example/counter.vsa new file mode 100644 index 0000000..86e5e9b --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter.vsa @@ -0,0 +1,10 @@ +Version 1 +\counter\counter.dm +0 ROOT counter counter +1 0 FILE _firstload _firstload.soar +2 0 FOLDER all all +3 0 FOLDER common common +4 0 OPERATOR count count.soar +5 0 FOLDER elaborations elaborations +6 5 FILE elaborations elaborations.soar +7 0 OPERATOR init-count init-count.soar diff --git a/eaters-3.0.8/agents/counter example/counter/_firstload.soar b/eaters-3.0.8/agents/counter example/counter/_firstload.soar new file mode 100644 index 0000000..e69de29 diff --git a/eaters-3.0.8/agents/counter example/counter/count.soar b/eaters-3.0.8/agents/counter example/counter/count.soar new file mode 100644 index 0000000..fbcf2a5 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/count.soar @@ -0,0 +1,15 @@ +sp {counter*propose*count + (state ^name counter) + --> + ( ^operator + =, <) + ( ^name count) +} + +sp {apply*count + (state ^operator + ^count ) + ( ^name count) + --> + ( ^count - + (+ 1)) +} diff --git a/eaters-3.0.8/agents/counter example/counter/counter.dm b/eaters-3.0.8/agents/counter example/counter/counter.dm new file mode 100644 index 0000000..def4865 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/counter.dm @@ -0,0 +1,22 @@ +10 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 counter +SOAR_ID 4 +ENUMERATION 5 1 init-count +INTEGER 6 +SOAR_ID 7 +ENUMERATION 8 1 count +INTEGER 9 +10 +0 count 6 +0 name 3 +0 operator 7 +0 operator 4 +0 superstate 2 +0 top-state 0 +0 type 1 +4 name 5 +7 count 9 +7 name 8 diff --git a/eaters-3.0.8/agents/counter example/counter/counter_source.soar b/eaters-3.0.8/agents/counter example/counter/counter_source.soar new file mode 100644 index 0000000..57041b5 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/counter_source.soar @@ -0,0 +1,6 @@ +source _firstload.soar +source count.soar +pushd elaborations +source elaborations_source.soar +popd +source init-count.soar diff --git a/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations.soar b/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations.soar new file mode 100644 index 0000000..54262b7 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations.soar @@ -0,0 +1,4 @@ +sp {elaborations*elaborate*state + (state ^superstate nil) + --> + ( ^name counter)} \ No newline at end of file diff --git a/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations_source.soar b/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations_source.soar new file mode 100644 index 0000000..50ab400 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/elaborations/elaborations_source.soar @@ -0,0 +1 @@ +source elaborations.soar diff --git a/eaters-3.0.8/agents/counter example/counter/init-count.soar b/eaters-3.0.8/agents/counter example/counter/init-count.soar new file mode 100644 index 0000000..9c0de60 --- /dev/null +++ b/eaters-3.0.8/agents/counter example/counter/init-count.soar @@ -0,0 +1,14 @@ +sp {counter*propose*init-count + (state ^name counter + -^count) + --> + ( ^operator + =) + ( ^name init-count) +} + +sp {apply*init-count + (state ^operator ) + ( ^name init-count) + --> + ( ^count 0) +} diff --git a/eaters-3.0.8/agents/eater-default.soar b/eaters-3.0.8/agents/eater-default.soar new file mode 100644 index 0000000..d800c2e --- /dev/null +++ b/eaters-3.0.8/agents/eater-default.soar @@ -0,0 +1,3 @@ +pushd eater-default +source eater-default_source.soar +popd diff --git a/eaters-3.0.8/agents/eater-default.vsa b/eaters-3.0.8/agents/eater-default.vsa new file mode 100644 index 0000000..2764b2d --- /dev/null +++ b/eaters-3.0.8/agents/eater-default.vsa @@ -0,0 +1,9 @@ +VERSION 4 +\eater-default\eater-default.dm +0 ROOT eater-default eater-default 1 +1 0 FOPERATOR _firstload _firstload.soar 3 +2 0 FOLDER all all 4 +3 0 FOLDER elaborations elaborations 2 +4 3 FOPERATOR _all _all.soar 5 +5 3 FOPERATOR top-state top-state.soar 6 +END diff --git a/eaters-3.0.8/agents/eater-default/_firstload.soar b/eaters-3.0.8/agents/eater-default/_firstload.soar new file mode 100644 index 0000000..e69de29 diff --git a/eaters-3.0.8/agents/eater-default/all/all_source.soar b/eaters-3.0.8/agents/eater-default/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/eaters-3.0.8/agents/eater-default/comment.dm b/eaters-3.0.8/agents/eater-default/comment.dm new file mode 100644 index 0000000..81dc845 --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/comment.dm @@ -0,0 +1,23 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/eaters-3.0.8/agents/eater-default/eater-default.dm b/eaters-3.0.8/agents/eater-default/eater-default.dm new file mode 100644 index 0000000..2dfd7a2 --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/eater-default.dm @@ -0,0 +1,43 @@ +18 +SOAR_ID 0 +SOAR_ID 1 +SOAR_ID 2 +SOAR_ID 3 +ENUMERATION 4 1 state +ENUMERATION 5 1 nil +ENUMERATION 6 1 eater-default +SOAR_ID 7 +ENUMERATION 8 1 complete +ENUMERATION 9 4 east north south west +SOAR_ID 10 +ENUMERATION 11 5 bonusfood eater empty normalfood wall +SOAR_ID 12 +ENUMERATION 13 4 east north south west +ENUMERATION 14 5 black blue purple red yellow +INTEGER_RANGE 15 -2147483648 2147483647 +INTEGER_RANGE 16 -2147483648 2147483647 +INTEGER_RANGE 17 -2147483648 2147483647 +23 +0 io 1 +0 name 6 +0 superstate 5 +0 top-state 0 +0 type 4 +1 input-link 2 +1 output-link 3 +2 eater 12 +2 my-location 10 +3 jump 7 +3 move 7 +7 direction 9 +7 status 8 +10 content 11 +10 east 10 +10 north 10 +10 south 10 +10 west 10 +12 direction 13 +12 name 14 +12 score 15 +12 x 16 +12 y 17 diff --git a/eaters-3.0.8/agents/eater-default/eater-default_source.soar b/eaters-3.0.8/agents/eater-default/eater-default_source.soar new file mode 100644 index 0000000..9947dbe --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/eater-default_source.soar @@ -0,0 +1,7 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd diff --git a/eaters-3.0.8/agents/eater-default/elaborations/_all.soar b/eaters-3.0.8/agents/eater-default/elaborations/_all.soar new file mode 100644 index 0000000..571b0d1 --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/elaborations/_all.soar @@ -0,0 +1,12 @@ +sp {elaborate*state*name + (state ^superstate.operator.name ) +--> + ( ^name ) +} + +sp {elaborate*state*top-state + (state ^superstate.top-state ) +--> + ( ^top-state ) +} + diff --git a/eaters-3.0.8/agents/eater-default/elaborations/elaborations_source.soar b/eaters-3.0.8/agents/eater-default/elaborations/elaborations_source.soar new file mode 100644 index 0000000..48f7de1 --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/elaborations/elaborations_source.soar @@ -0,0 +1,2 @@ +source _all.soar +source top-state.soar diff --git a/eaters-3.0.8/agents/eater-default/elaborations/top-state.soar b/eaters-3.0.8/agents/eater-default/elaborations/top-state.soar new file mode 100644 index 0000000..4127a9a --- /dev/null +++ b/eaters-3.0.8/agents/eater-default/elaborations/top-state.soar @@ -0,0 +1,12 @@ +sp {elaborate*top-state*name + (state ^superstate nil) +--> + ( ^name eater-default) +} + +sp {elaborate*top-state*top-state + (state ^name eater-default) +--> + ( ^top-state ) +} + diff --git a/eaters-3.0.8/agents/tutorial/advanced-move.soar b/eaters-3.0.8/agents/tutorial/advanced-move.soar new file mode 100644 index 0000000..52cfc24 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/advanced-move.soar @@ -0,0 +1,128 @@ +############################################################################ +# From Chapter 9 of Soar 8 Tutorial +# +# These are the final versions of the rules for the generalized advanced move +# operator. + +sp {initialize*state*directions + (state ^type state) + --> + ( ^directions ) + ( ^value north ^opposite south) + ( ^value east ^opposite west) + ( ^value south ^opposite north) + ( ^value west ^opposite east)} + +# Propose*move*no-backward: +# If there is normalfood, bonusfood, eater, or empty in an adjacent cell, +# and there is no last direction equal to the opposite direction for that # cell, +# propose move in the direction of that cell, with the cell's content, +# and indicate that this operator can be selected randomly. + +sp {propose*move*no-backward + (state ^io.input-link.my-location..content { <> wall } + ^directions + -^last-direction ) + ( ^value + ^opposite ) +--> + ( ^operator +, =) + ( ^name move + ^direction + ^content )} + +# Apply*move +# If the move operator for a direction is selected, +# generate an output command to move in that direction. + +sp {apply*move + (state ^io.output-link
      + ^operator ) + ( ^name move + ^direction ) +--> + (write | | ) + (
        ^move.direction )} + +# Apply*move*remove-move: +# If the move operator is selected, +# and there is a completed move command on the output link, +# then remove that command. + +sp {apply*move*remove-move + (state ^io.output-link
          + ^operator.name move) + (
            ^move ) + ( ^status complete) +--> + (
              ^move -)} + +# Apply*move*create*last-direction +# If the move operator for a direction is selected, +# create an augmentation called last-direction with that direction. + +sp {apply*move*create*last-direction + (state ^operator ) + ( ^name move + ^direction ) +--> + ( ^last-direction )} + +# Apply*move*remove*last-direction +# If the move operator for a direction is selected, +# and the last-direction is not equal to that direction, +# then remove the last-direction. + +sp {apply*move*remove*last-direction + (state ^operator + ^last-direction ) + ( ^direction <> + ^name move) +--> + ( ^last-direction -)} + +# Select*move*bonusfood-better-than-normalfood +# If there is a proposed operator to move to a cell with bonusfood and +# there is a second proposed operator to move to a cell that is empty or +# has normalfood +# prefer the first operator. + +sp {select*move*bonusfood-better-than-normalfood-empty + (state ^operator + + ^operator +) + ( ^name move + ^content bonusfood) + ( ^name move + ^content << normalfood empty >>) +--> + ( ^operator > )} + +# Select*move*avoid-empty-eater +# If there is a proposed operator to move to an empty cell or a cell with +# another eater, +# then avoid that operator. + +sp {select*move*avoid-empty-eater + (state ^operator +) + ( ^name move + ^content << empty eater >>) +--> + ( ^operator <)} + +# Select*move*reject*backward +# If there is a proposed operator to move in the direction +# opposite the last move, +# reject that operator. + + +sp {select*move*reject*backward + (state ^operator + + ^directions + ^last-direction ) + ( ^value + ^opposite ) + ( ^name move + ^direction ) +--> + (write | Reject | ) + ( ^operator -)} diff --git a/eaters-3.0.8/agents/tutorial/hello-world-operator.soar b/eaters-3.0.8/agents/tutorial/hello-world-operator.soar new file mode 100644 index 0000000..f9446ee --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/hello-world-operator.soar @@ -0,0 +1,19 @@ +########################################################################### +# From Chapter 3 of Soar 8 Tutorial +# +### This operator writes "Hello World" and halts. + +sp {propose*hello-world + (state ^type state) +--> + ( ^operator +) + ( ^name hello-world) +} + +sp {apply*hello-world + (state ^operator ) + ( ^name hello-world) +--> + (write |Hello World|) + (halt) +} diff --git a/eaters-3.0.8/agents/tutorial/hello-world-rule.soar b/eaters-3.0.8/agents/tutorial/hello-world-rule.soar new file mode 100644 index 0000000..abc2cb6 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/hello-world-rule.soar @@ -0,0 +1,10 @@ +########################################################################### +# From Chapter 2 of Soar 8 Tutorial +### This rule writes "Hello World" and halts. + +sp {hello-world + (state ^type state) +--> + (write |Hello World|) + (halt) +} diff --git a/eaters-3.0.8/agents/tutorial/jump-and-move.soar b/eaters-3.0.8/agents/tutorial/jump-and-move.soar new file mode 100644 index 0000000..68bbfbe --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/jump-and-move.soar @@ -0,0 +1,78 @@ +############################################################################ +# From Chapter 10 of Soar 8 Tutorial +# +# These are the final versions of the rules for the jump and move operator. + +sp {initialize*state*directions + (state ^type state) + --> + ( ^directions ) + ( ^value north ^opposite south) + ( ^value east ^opposite west) + ( ^value south ^opposite north) + ( ^value west ^opposite east)} + +sp {init*elaborate*name-content-value + (state ^type state) + --> + ( ^name-content-value + ) + ( ^name move ^content empty ^value 0) + ( ^name move ^content eater ^value 0) + ( ^name move ^content normalfood ^value 5) + ( ^name move ^content bonusfood ^value 10) + ( ^name jump ^content empty ^value -5) + ( ^name jump ^content eater ^value -5) + ( ^name jump ^content normalfood ^value 0) + ( ^name jump ^content bonusfood ^value 5)} + +sp {propose*move + (state ^io.input-link.my-location..content { <> wall }) +--> + ( ^operator +, =) + ( ^name move + ^content + ^actions.move.direction )} + +sp {propose*jump + (state ^io.input-link.my-location...content { <> wall }) +--> + ( ^operator +, =) + ( ^name jump + ^content + ^actions.jump.direction )} + +sp {elaborate*operator*value + (state ^operator + + ^name-content-value ) + ( ^name ^content ) + ( ^name ^content ^value ) + --> + ( ^value )} + +sp {select*compare*best*value + (state ^operator + + ^operator +) + ( ^value ) + ( ^value < ) +--> + ( ^operator > )} + + +## General operator application rules + +sp {apply*operator*create-action-command + (state ^operator + ^io.output-link
                ) + ( ^actions ) + ( ^ ) +--> + (
                  ^ )} + +sp {apply*operator*remove-command + (state ^operator.actions + ^io.output-link
                    ) + (
                      ^ ) + ( ^status complete) +--> + (
                        ^ -)} diff --git a/eaters-3.0.8/agents/tutorial/jump.soar b/eaters-3.0.8/agents/tutorial/jump.soar new file mode 100644 index 0000000..4bd0f05 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/jump.soar @@ -0,0 +1,56 @@ +############################################################################ +# From Chapter 10 of Soar 8 Tutorial +# +# These are the final versions of the rules for the jump operator. +# These can be loaded in with the advanced move operator + +sp {initialize*state*directions + (state ^type state) + --> + ( ^directions + ^directions + ^directions + ^directions ) + ( ^value north ^opposite south) + ( ^value east ^opposite west) + ( ^value south ^opposite north) + ( ^value west ^opposite east)} + +# Propose*jump: +# If the content of a cell two steps away in a direction is not a wall, +# propose jump in the direction of that cell, with the cell's content, +# and indicate that this operator can be selected randomly. + +sp {propose*jump + (state ^io.input-link.my-location...content + { <> wall }) +--> + ( ^operator +, =) + ( ^name jump + ^direction + ^content )} + +# Apply*move*jump +# If the move or jump operator for a direction is selected, +# generate an output name to move in that direction. + +sp {apply*move + (state ^io.output-link
                          + ^operator ) + ( ^name { << move jump >> } + ^direction ) +--> + (
                            ^.direction )} + +# Apply*move*jump*remove-name: +# If the move or jump operator is selected, +# and there is a completed name on the output link, +# then remove that name. + +sp {apply*move*remove-move + (state ^io.output-link
                              + ^operator.name ) + (
                                ^ ) + ( ^status complete) +--> + (
                                  ^ -)} diff --git a/eaters-3.0.8/agents/tutorial/move-north-2.soar b/eaters-3.0.8/agents/tutorial/move-north-2.soar new file mode 100644 index 0000000..0fa5703 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/move-north-2.soar @@ -0,0 +1,36 @@ +############################ Move-north operator ############################ +# From Chapter 5 of Soar 8 Tutorial +# Corrected from move-north.soar so that operator applies more than once. +# +# Propose*move-north: +# If I am at some location, then propose the move-north operator. + +sp {propose*move-north + (state ^io.input-link.eater ) + ( ^x ^y ) +--> + ( ^operator +) + ( ^name move-north) +} + +# Apply*move-north: +# If the move-north operator is selected, then generate an output command to +# move north. + +sp {apply*move-north + (state ^operator.name move-north + ^io.output-link
                                    ) +--> + (
                                      ^move.direction north)} + +# Apply*move-north*remove-move +# If the move-north successfully performs a move command, then remove +# the command from the output-link + +sp {apply*move-north*remove-move + (state ^operator.name move-north + ^io.output-link
                                        ) + (
                                          ^move ) + ( ^status complete) +--> + (
                                            ^move -)} diff --git a/eaters-3.0.8/agents/tutorial/move-north.soar b/eaters-3.0.8/agents/tutorial/move-north.soar new file mode 100644 index 0000000..ed12c50 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/move-north.soar @@ -0,0 +1,32 @@ +############################ Move-north operator ############################ +# From Chapter 4 of Soar 8 Tutorial +# +# Propose*move-north: +# If I exist, then propose the move-north operator. + +sp {propose*move-north + (state ^type state) +--> + ( ^operator +) + ( ^name move-north)} + +# Apply*move-north: +# If the move-north operator is selected, then generate an output command to +# move north. + +sp {apply*move-north + (state ^operator + ^io ) + ( ^output-link
                                              ) + ( ^name move-north) +--> + (
                                                ^move ) + ( ^direction north)} + + +## short cut version +#sp {move-north*apply +# (state ^operator.name move-north +# ^io.output-link
                                                  ) +#--> +# (
                                                    ^move.direction north)} diff --git a/eaters-3.0.8/agents/tutorial/move-to-food.soar b/eaters-3.0.8/agents/tutorial/move-to-food.soar new file mode 100644 index 0000000..c6c5078 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/move-to-food.soar @@ -0,0 +1,48 @@ +############################################################################ +# From Chapter 6 of Soar 8 Tutorial +# +# These are the final versions of the rules. +# +# This program proposes the move-to-food operator in any direction +# that contains normal or bonus food. If there is no food nearby, no +# instances of the operator will be proposed and the halt operator +# will be proposed. + +# Propose*move-to-food*normalfood +# If there is normalfood in an adjacent cell, +# propose move-to-food in the direction of that cell +# and indicate that this operator can be selected randomly. + +sp {propose*move-to-food + (state ^io.input-link.my-location..content + << normalfood bonusfood >>) +--> + ( ^operator + =) + ( ^name move-to-food + ^direction )} + +# Apply*move-to-food +# If the move-to-food operator for a direction is selected, +# generate an output command to move in that direction. + +sp {apply*move-to-food + (state ^io.output-link
                                                      + ^operator ) + ( ^name move-to-food + ^direction ) +--> + (
                                                        ^move.direction )} + +# Apply*move-to-food*remove-move: +# If the move-to-food operator is selected, +# and there is a completed move command on the output link, +# then remove that command. + +sp {apply*move-to-food*remove-move + (state ^io.output-link
                                                          + ^operator.name move-to-food) + (
                                                            ^move ) + ( ^status complete) +--> + (
                                                              ^move -)} + diff --git a/eaters-3.0.8/agents/tutorial/move.soar b/eaters-3.0.8/agents/tutorial/move.soar new file mode 100644 index 0000000..2e07622 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/move.soar @@ -0,0 +1,70 @@ +############################################################################ +# From Chapter 8 of Soar 8 Tutorial +# +# These are the final versions of the rules for the generalized move operator +# +# Propose*move: +# If there is normalfood, bonusfood, eater, or empty in an adjacent cell, +# propose move in the direction of that cell +# and indicate that this operator can be selected randomly. +sp {propose*move + (state ^io.input-link.my-location..content + { <> wall }) +--> + ( ^operator + =) + ( ^name move + ^direction + ^content )} + +# Apply*move +# If the move operator for a direction is selected, +# generate an output command to move in that direction. + +sp {apply*move + (state ^io.output-link
                                                                + ^operator ) + ( ^name move + ^direction ) +--> + (
                                                                  ^move.direction )} + +# Apply*move*remove-move: +# If the move operator is selected, +# and there is a completed move command on the output link, +# then remove that command. + +sp {apply*move*remove-move + (state ^io.output-link
                                                                    + ^operator.name move) + (
                                                                      ^move ) + ( ^status complete) +--> + (
                                                                        ^move -)} + +# Select*move*bonusfood-better-than-normalfood +# If there is a proposed operator to move to a cell with bonusfood and +# there is a second proposed operator to move to a cell that is empty or +# has normalfood +# prefer the first operator. + +sp {select*move*bonusfood-better-than-normalfood-empty + (state ^operator + + ^operator +) + ( ^name move + ^content bonusfood) + ( ^name move + ^content << normalfood empty >>) +--> + ( ^operator > )} + +# Select*move*avoid-empty-eater +# If there is a proposed operator to move to an empty cell or a cell with +# another eater, +# then avoid that operator. + +sp {select*move*avoid-empty-eater + (state ^operator +) + ( ^name move + ^content << empty eater >>) +--> + ( ^operator <)} diff --git a/eaters-3.0.8/agents/tutorial/semantic-errors.soar b/eaters-3.0.8/agents/tutorial/semantic-errors.soar new file mode 100644 index 0000000..9069245 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/semantic-errors.soar @@ -0,0 +1,31 @@ +############################################################################ +### This program proposes the move-to-food operator in any direction +### that contains normal or bonus food. If there is no food nearby, no +### instances of the operator will be proposed and the halt operator +### will be proposed. + +sp {propose*move-to-food + (state ^io.input-link.my-location..contant + << normalfood bonusfood >>) +--> + ( ^operator + =) + ( ^name move-to-food + ^direction )} + +sp {apply*move-to-food + (state ^io.output-link
                                                                          + ^operator ) + ( ^name move-to-food + ^direction ) +--> + (
                                                                            ^moves.direction )} + +sp {apply*move-to-food*remove-move + (state ^operator.name move-to-food + ^io.output-link
                                                                              ) + (
                                                                                ^move ) + ( ^status complete) +--> + (
                                                                                  ^move -)} + + diff --git a/eaters-3.0.8/agents/tutorial/syntax-error.soar b/eaters-3.0.8/agents/tutorial/syntax-error.soar new file mode 100644 index 0000000..3ed8c46 --- /dev/null +++ b/eaters-3.0.8/agents/tutorial/syntax-error.soar @@ -0,0 +1,60 @@ +############################################################################ + +### This program proposes the move-to-food operator in any direction + +### that contains normal or bonus food. If there is no food nearby, no + +### instances of the operator will be proposed and the halt operator + + will be proposed. + + + +sp propose*move-to-food + + (state ^io.input-link.my-location..content + + << normalfood bonusfood >> + +--> + + ( ^operator +, =) + + ( ^name move-to-food + + ^direction )} + + + +sp {apply*move-to-food + + (state ^io.output-link
                                                                                    + + ^operator ) + + ( ^name move-to-food) + + ^direction ) + +--> + + (
                                                                                      ^move.direction )} + + + +sp {apply*move-to-food*remove-move + + (state operator.name move-to-food + + ^io.output-link
                                                                                        ) + + (
                                                                                          ^move ) + +--> + + (
                                                                                            ^move -)} + + + + + diff --git a/eaters-3.0.8/eaters.ico b/eaters-3.0.8/eaters.ico new file mode 100644 index 0000000..c1a9fb3 Binary files /dev/null and b/eaters-3.0.8/eaters.ico differ diff --git a/eaters-3.0.8/init-eaters.tcl b/eaters-3.0.8/init-eaters.tcl new file mode 100755 index 0000000..072d251 --- /dev/null +++ b/eaters-3.0.8/init-eaters.tcl @@ -0,0 +1,62 @@ +#!/usr/bin/wish + +# If you are not on a Unix system, you can ignore this block of comments. +# +# The first line of this file invokes wish on unix systems. If you +# are running Soar on a Unix system, you must edit the above line to +# reflect the full pathname of your Wish executable if it is not in +# the default location /usr/bin. +# +# If you installed ActiveTcl to its default location, the first line +# of this file should change to: +#!/usr/local/ActiveTcl/bin/wish + +# $Id: init-eaters.tcl,v 1.5 2004/06/28 21:47:42 rmarinie Exp $ + +set tcl_pkgPath {} + +set soar_library [file join [file join [pwd] ..] [file join "soar-8.5.2" "library"]] +set tsi_library [file join [file join [pwd] ..] tsi-4.0.1] +set soar_doc_dir [file join $soar_library doc] +set doc_dir [file join $soar_library doc] + + +# We need to set the environment variables here because the +# Soar dll uses them + +set env(SOAR_LIBRARY) $soar_library +set env(TSI_LIBRARY) $tsi_library + +###set auto_path {} +lappend auto_path $tcl_library $tk_library $soar_library $tsi_library + + +# Start with controller hidden, then expose it when it has been altered +set ETCPConfig(AgentName) Eater +set ETCPConfig(AgentFolder) agents + +set mode off +if { [llength $argv] > 0 } { set mode [lindex $argv 0] } + + +if { ![string compare $mode client] } { + + tsi 1 -mode client + + wm deiconify . + +} else { + + source [file join simulator PDFileMenus.tcl] + source [file join simulator et-controlpanel.tcl] + source [file join simulator eaters-configure.tcl] + + tsi 1 -controlpanel makeETControlPanel + + source [file join simulator process.tcl] + source [file join simulator eaters-layout.tcl] + source [file join simulator interface.tcl] + + + wm deiconify . +} diff --git a/eaters-3.0.8/simulator/PDFileMenus.tcl b/eaters-3.0.8/simulator/PDFileMenus.tcl new file mode 100644 index 0000000..8d567ea --- /dev/null +++ b/eaters-3.0.8/simulator/PDFileMenus.tcl @@ -0,0 +1,264 @@ +proc __PDFMReplaceSpace { orig } { + + + regsub -all " " "$orig" PDFileMenuSPACESTRING modified + + return $modified + +} + +proc __PDFMUnreplaceSpace { mod } { + + regsub -all PDFileMenuSPACESTRING "$mod" " " original + + return $original +} + +proc __PDFMUnreplaceSpaceList {modList} { + + foreach element $modList { + regsub -all PDFileMenuSPACESTRING "$element" " " newElement + lappend origList "$newElement" + } + return $origList +} + +proc PDFileMenus { fileMenu fileVar args } { + + set emptyValue "**NO FILES**" + set filter "*.*" + set pathVar "" + set pathMenu "" + set path [__PDFMReplaceSpace [pwd]] + set initialPath [__PDFMReplaceSpace [pwd]] + set filenameDisplay standard + set pathnameDisplay relative + set maxDepth -1 + + foreach {key value} $args { + switch -exact -- $key { + + -pathMenu { set pathMenu $value } + -pathVar { set pathVar $value } + -filter { set filter $value } + -emptyValue { set emptyValue $value } + -path { set path $value } + -maxDepth { set maxDepth $value } + -filenameDisplay { set filenameDisplay $value } + -pathnameDisplay { set pathnameDisplay $value } + } + } + + + if [catch {cd "[__PDFMUnreplaceSpace $path]"} err] { + error "Could not find the directory [__PDFMUnreplaceSpace $path]: $err" + return + } + + set filesAndDirs [__PDFMGetFilesAndDirs [__PDFMReplaceSpace [pwd]] $filenameDisplay \ + $pathnameDisplay $filter $maxDepth] + + set files [lindex $filesAndDirs 0] + set dirs [lindex $filesAndDirs 1] + set fulldirs [lindex $filesAndDirs 2] + + if { ![winfo exists $fileMenu] } { + + if { $files == {} } { + tk_optionMenu $fileMenu $fileVar $emptyValue + $fileMenu configure -state disabled + } else { + eval tk_optionMenu $fileMenu $fileVar $files + } + + } else { + error "$fileMenu already exists." + if [catch {cd "[__PDFMUnreplaceSpace $initialPath]"} msg] { + error "Could not return to the original path '[__PDFMUnreplaceSpace $initialPath]': $msg" + } + return + } + + if { [string compare $pathMenu ""] != 0 && \ + [string compare $pathVar ""] != 0 } { + # create the path menu as well... + + if { ![winfo exists $pathMenu] } { + eval tk_optionMenu $pathMenu __PDFMInternalPath$fileMenu [__PDFMUnreplaceSpaceList $dirs] + uplevel #0 set $pathVar \"[__PDFMUnreplaceSpace [lindex $fulldirs 0]]\" + set dirLen [llength $dirs] + for {set i 0} {$i < $dirLen } {incr i} { + [$pathMenu cget -menu] entryconfigure $i -command \ + [list __PDFMLoadFiles [__PDFMReplaceSpace [pwd]] [lindex $fulldirs $i] \ + $fileMenu $fileVar $filenameDisplay $pathMenu \ + $pathVar $pathnameDisplay $filter $maxDepth \ + $emptyValue] + } + + + } else { + error "$pathMenu already exists." + } + } else { + # We want to keep track of the path anyway + + #uplevel #0 set __PDFMInternalPath$fileMenu [__PDFMUnreplaceSpace "$path"] + } + + if [catch {cd "[__PDFMUnreplaceSpace $initialPath]"} msg] { + error "Could not return to the original path '[__PDFMUnreplaceSpace $initialPath]': $msg" + } + + return +} + +proc __PDFMLoadFiles {topDir workingDir fileMenu fileVar filenameDisplay \ + pathMenu pathVar pathnameDisplay filter \ + maxDepth emptyValue } { + + set cPath [__PDFMReplaceSpace [pwd]] + cd "[__PDFMUnreplaceSpace $workingDir]" + + + set filesAndDirs [__PDFMGetFilesAndDirs $topDir $filenameDisplay \ + $pathnameDisplay $filter $maxDepth] + + [$pathMenu cget -menu] delete 0 end + [$fileMenu cget -menu] delete 0 end + + set files [lindex $filesAndDirs 0] + set dirs [lindex $filesAndDirs 1] + set fulldirs [lindex $filesAndDirs 2] + + set nDirs [llength $dirs] + + if { $files == {} } { + uplevel #0 [list set $fileVar "$emptyValue"] + $fileMenu configure -state disabled + } else { + foreach file $files { + [$fileMenu cget -menu] add command -label $file -command \ + [list set $fileVar $file] + } + uplevel #0 set $fileVar [lindex $files 0] + $fileMenu configure -state normal + } + + + for {set i 0} {$i < $nDirs} {incr i} { + [$pathMenu cget -menu] add command -label "[__PDFMUnreplaceSpace [lindex $dirs $i]]" \ + -command [list __PDFMLoadFiles $topDir [lindex $fulldirs $i] \ + $fileMenu $fileVar $filenameDisplay $pathMenu \ + $pathVar $pathnameDisplay $filter $maxDepth \ + $emptyValue ] + } + uplevel #0 set __PDFMInternalPath$fileMenu \"[__PDFMUnreplaceSpace [lindex $dirs 0]]\" + uplevel #0 set $pathVar \"[__PDFMUnreplaceSpace [lindex $fulldirs 0]]\" + + cd "[__PDFMUnreplaceSpace $cPath]" + +} + +proc __PDFMGetFilesAndDirs { topDir filenameDisplay \ + pathnameDisplay filter maxDepth} { + + + + set currDir [__PDFMReplaceSpace [pwd]] + if { $maxDepth < 0 } { + set cDepth 1 + } else { + set cDepth [expr $maxDepth - [llength [file split $currDir]] \ + + [llength [file split $topDir]]] + } + + + switch -exact $filenameDisplay { + + standard { + foreach i [glob -nocomplain $filter] { + lappend files [file tail $i] + } + } + root { + foreach i [glob -nocomplain $filter] { + lappend files [file rootname [file tail $i]] + } + } + default { + set files [glob -nocomplain $filter] + } + } + + switch -exact $pathnameDisplay { + base { + if { $topDir == $currDir } { + set dirs . + set fulldirs $topDir + } else { + set dirs [list . .. ] + set fulldirs [list $currDir [file join $currDir ..]] + } + if { $cDepth > 0 } { + foreach file [glob -nocomplain *] { + if [file isdirectory $file] { + lappend dirs [file join . [file tail $file]] + lappend fulldirs [file join $currDir $file] + } + } + } + } + relative { + if { $topDir == $currDir } { + set thisPath . + set dirs . + set fulldirs $topDir + } else { + set thisPath [eval file join . [lrange [file split $currDir] \ + [llength [file split $topDir]] \ + end]] + set dirs [list $thisPath [file join $thisPath ..]] + set fulldirs [list $currDir [file join $currDir ..]] + } + if { $cDepth > 0 } { + foreach file [glob -nocomplain *] { + if [file isdirectory $file] { + lappend dirs [file join $thisPath $file] + lappend fulldirs [file join $currDir $file] + } + } + } + + } + default { + if { $topDir == $currDir } { + set dirs $currDir + set fulldirs $currDir + } else { + set dirs [list $currDir [file join $currDir ..]] + set fulldirs [list $currDir [file join $currDir ..]] + } + if { $cDepth > 0 } { + foreach file [glob -nocomplain *] { + if [file isdirectory $file] { + lappend dirs $file + lappend fulldirs [file join $currDir $file] + } + } + } + } + } + + set topDir [__PDFMReplaceSpace [pwd]] + + + + if [info exists files] { + return [list [lsort -ascii $files] $dirs $fulldirs] + } else { + return [list {} $dirs $fulldirs] + } + +} + + diff --git a/eaters-3.0.8/simulator/agent-testbed-gui.tcl b/eaters-3.0.8/simulator/agent-testbed-gui.tcl new file mode 100644 index 0000000..d59d176 --- /dev/null +++ b/eaters-3.0.8/simulator/agent-testbed-gui.tcl @@ -0,0 +1,204 @@ +rename eaterStartLocation stdEaterStartLocation +proc eaterStartLocation {} { + global testbedStartIndex + + puts "RESET EATERS!!!" + switch $testbedStartIndex { + + 1 { + set placementArgs [list 1 1 0] + } + 2 { + set placementArgs [list 1 15 1] + } + 3 { + set placementArgs [list 4 11 0] + } + 4 { + set placementArgs [list 13 2 3] + } + 5 { + set placementArgs [list 2 7 4] + } + default { + set placementArgs [list -1 -1 -1] + } + } + +} + + + +rename makeBoard stdMakeBoard +proc makeBoard {} { + + global testbedStartIndex testbedMapIndex gridSize boardColor \ + boardX boardY eaterList + + + if { $testbedMapIndex < 6 } { + set boardX 15 + set boardY 15 + } + + if [winfo exists .wGlobal] { + destroy .wGlobal + ## making the board gets confused if it thinks there are eaters + ## around, so temporarily pretend there aren't any + if [info exists eaterList] { + set tempEaterList $eaterList + unset eaterList + } + } + toplevel .wGlobal + wm title .wGlobal "Eaters Playing Board" + wm geometry .wGlobal +0+0 + ### Try to make the board a nice size + set gridSize [expr [expr [winfo screenwidth .wGlobal] / 3] / \ + [expr 2 + $boardX]] + canvas .wGlobal.c -width [expr ($boardX+2) * $gridSize] \ + -height [expr ($boardY+2) * $gridSize] \ + -background $boardColor + pack .wGlobal.c -side top + ## First fill the world with food + for {set i 1} {$i <= $boardX} {incr i} { + for {set j 1} {$j <= $boardY} {incr j} { + createFood .wGlobal.c $i $j + } + } + ## Put down the border walls + for {set i 0} {$i <= ($boardX+1)} {incr i} { + createWall .wGlobal.c $i 0 + createWall .wGlobal.c $i [expr $boardY+1] + } + for {set j 1} {$j <= $boardY} {incr j} { + createWall .wGlobal.c 0 $j + createWall .wGlobal.c [expr $boardX+1] $j + } + + puts "MAP INDEX: $testbedMapIndex" + switch $testbedMapIndex { + + 1 { + # Empty + } + + 2 { + for {set x 3} {$x < 9} {incr x} { + createWall .wGlobal.c $x 4 + } + for {set x 2} {$x < 6} {incr x} { + createWall .wGlobal.c $x 7 + } + for {set x 3} {$x < 13} {incr x} { + createWall .wGlobal.c $x 12 + } + for {set y 5} {$y < 9} {incr y} { + createWall .wGlobal.c 11 $y + } + for {set y 6} {$y < 9} {incr y} { + createWall .wGlobal.c 13 $y + } + for {set y 9} {$y < 10} {incr y} { + createWall .wGlobal.c 3 $y + } + } + 3 { + for {set x 5} {$x < 9} {incr x} { + createWall .wGlobal.c $x 2 + } + for {set x 2} {$x < 10} {incr x} { + createWall .wGlobal.c $x 5 + } + for {set x 7} {$x < 13} {incr x} { + createWall .wGlobal.c $x 12 + } + for {set y 7} {$y < 11} {incr y} { + createWall .wGlobal.c 11 $y + } + for {set y 7} {$y < 12} {incr y} { + createWall .wGlobal.c 4 $y + } + for {set y 9} {$y < 13} {incr y} { + createWall .wGlobal.c 2 $y + } + createWall .wGlobal.c 11 3 + createWall .wGlobal.c 13 9 + + } + Random { + stdMakeBoard + return + } + + default {} + + + + } + ## Now put the eaters back + if [info exists tempEaterList] { + set eaterList $tempEaterList + } + resetEaters +} + + + + +global currentColor +set currentColor 0 + + +global xplacer yplacer +set xplacer 100 +set yplacer 100 + +### Change control panel name +wm title . "Eaters TestBed Control Panel" + +### Change around the File menu +### delete the original Exit entry, so it can stay at the bottom +.menu.file.m delete Exit +.menu.file.m add command -label "Reload Eater name menu" \ + -command {loadEaterNames .agents.create.e} +.menu.file.m add command -label Exit -command exit + + + +.agents.create.createAgentButton configure -text {Create Eater} \ + -command {startEater .wGlobal.c $tsiCurrentAgentSourceFile $currentColor } + + +pack forget .agents.create.createAgentButton +pack .agents.create.createAgentButton -side left + +## Get rid of the normal TSI focus behavior +bind . {} + + +frame .mapcontrol -borderwidth 2 +frame .mapcontrol.inner +global eaterList eaterTick eaterScore + +label .mapcontrol.inner.mapLbl -text {Map Index:} +tk_optionMenu .mapcontrol.inner.mapIndex testbedMapIndex 1 2 3 4 5 Random + +label .mapcontrol.inner.startPosLbl -text {Starting Position:} +tk_optionMenu .mapcontrol.inner.startPosIndex testbedStartIndex 1 2 3 4 5 Random + +button .mapcontrol.inner.setUpMap -text {Set Up Map} \ + -command makeBoard + +pack .mapcontrol.inner.mapLbl .mapcontrol.inner.mapIndex \ + .mapcontrol.inner.startPosLbl .mapcontrol.inner.startPosIndex \ + .mapcontrol.inner.setUpMap -side left +pack .mapcontrol.inner -side top +pack .mapcontrol -side top -fill x -padx 10 + + +### Now we can display the window +wm deiconify . + + +makeBoard \ No newline at end of file diff --git a/eaters-3.0.8/simulator/agent.tcl b/eaters-3.0.8/simulator/agent.tcl new file mode 100644 index 0000000..e235a28 --- /dev/null +++ b/eaters-3.0.8/simulator/agent.tcl @@ -0,0 +1,147 @@ +global interp_name +#puts "Loading interface code for $interp_name" + +### default setup +learn -off +indifferent-selection -random + +foreach i [io -list -input] { + io -delete -input $i +} +io -add -input manageInputLink + +foreach i [io -list -output] { + io -delete -output $i +} +io -add -output manageOutputLink output-link + +proc manageInputLink {mode} { + global ioID interp_name + +# puts "manageInputLink $mode (begin)" + switch $mode { + + + top-state-just-created { + output-strings-destination -push -append-to-result + set topStateID [lindex [wmes {(* ^superstate nil)}] 1] + set ioID [lindex [wmes "($topStateID ^io *)"] 3] + ## remove the trailing parenthesis + set ioID [string trimright $ioID ")"] + set inID [lindex [wmes "($ioID ^input-link *)"] 3] + set inID [string trimright $inID ")"] + + set outID [lindex [wmes "($ioID ^output-link *)"] 3] + set outID [string trimright $outID ")"] + output-strings-destination -pop + setUpInputLink $ioID $inID $outID + + } + normal-input-cycle { + + + updateInputLink + + + } + top-state-just-removed { + + removeInputLink + + + } + } +# puts "manageInputLink $mode (end)" +} + +proc manageOutputLink {mode outputs} { + global ioID outputLinkID + +# puts "manageOutputLink $mode (begin)" + + switch $mode { + added-output-command { + set outputLinkID [getOutputValue $outputs $ioID "output-link"] + set walkID [getOutputValue $outputs $outputLinkID "move"] + set jumpID [getOutputValue $outputs $outputLinkID "jump"] + + ## SB May 02 1997 + ## walkdir is actually used to walk the eater one step; movement is + ## for one step and then stops. + if {$walkID != ""} { + set walkdir [getOutputValue $outputs $walkID "direction"] + set isComplete [getOutputValue $outputs $walkID "status"] + + if {$walkdir == "" || $isComplete == "complete" } { + +# puts "CANNOT FIND WALK DIRECTION OR ALREADY APPLIED 1!!!" + } else { + setWalkDir $walkdir $walkID +# puts "WALK DIRECTION is $walkdir" + } + # send $controlName "set eaterDir($interp_name) $walkdir" + } else { + if {$jumpID != ""} { + set jumpdir [getOutputValue $outputs $jumpID "direction"] + set isComplete [getOutputValue $outputs $jumpID "status"] + + if { $jumpdir == "" || $isComplete == "complete" } { +# puts "CANNOT FIND JUMP DIRECTION OR ALREADY APPLIED 1!!!" + } else { + setJumpDir $jumpdir $jumpID + } + # send $controlName "set eaterDir($interp_name) $jumpdir" + } + + } + } + modified-output-command { + set walkID [getOutputValue $outputs $outputLinkID "move"] + set jumpID [getOutputValue $outputs $outputLinkID "jump"] + ## SB May 02 1997 + ## walkdir is actually used to move the eater; movement is + ## for one step and then stops. + if {$walkID != ""} { + set walkdir [getOutputValue $outputs $walkID "direction"] + set isComplete [getOutputValue $outputs $walkID "status"] + + if {$walkdir == "" || $isComplete == "complete"} { +# puts "CANNOT FIND WALK DIRECTION OR ALREADY APPLIED 2!!!" +# puts "WALK DIRECTION Is $walkdir" + } else { + setWalkDir $walkdir $walkID +# puts "WALK DIRECTION is $walkdir" + } + # send $controlName "set eaterDir($interp_name) $walkdir" + } else { +# puts "NO WALK DIR--------- Checking for JUMP" + if {$jumpID != ""} { + set jumpdir [getOutputValue $outputs $jumpID "direction"] + set isComplete [getOutputValue $outputs $jumpID "status"] + + if { $jumpdir == "" || $isComplete == "complete" } { +# puts "CANNOT FIND JUMP DIRECTION OR ALREADY APPLIED 2!!!" + } else { + setJumpDir $jumpdir $jumpID + } + # send $controlName "set eaterDir($interp_name) $jumpdir" + } + } + } + } + + + +# puts "manageOutputLink $mode (end)" +} + +proc getOutputValue {outputs id attr} { + foreach wme $outputs { + if {(($id == "") || [string match $id [lindex $wme 0]]) && \ + (($attr == "") || [string match $attr [lindex $wme 1]])} { + return [lindex $wme 2] + } + } + return "" +} + diff --git a/eaters-3.0.8/simulator/dbc.tcl b/eaters-3.0.8/simulator/dbc.tcl new file mode 100644 index 0000000..154ed0f --- /dev/null +++ b/eaters-3.0.8/simulator/dbc.tcl @@ -0,0 +1,102 @@ + +proc dbcsafe {inpt outpt {key *} } { + + if [file exists $outpt] { + puts "The output file '$outpt' already exists. Aborting." + return + } + set nBegins 0 + set nEnds 0 + + dbc $inpt $outpt $key + undbc $outpt dbcBuffer $key + + set original [open $inpt r] + set buffer [open dbcBuffer r] + + if { [string compare [read $original] [read $buffer]] } { + puts "Error" + } else { + puts "Files are OK." + } + + close $original + close $buffer + file delete dbcBuffer +} +proc dbc { inpt outpt {key *} } { + + if [file exists $outpt] { + puts "The output file '$outpt' already exists. Aborting." + return + } + set inFile [open $inpt r] + set outFile [open $outpt w] + set nBegins 0 + set nEnds 0 + foreach line [split [read $inFile] \n] { + + if [string match "*\#*DBC END*$key*" $line] { + incr nEnds + } + + if { $nBegins > $nEnds } { + # inside DBC + puts $outFile "\#$line" + } else { + puts $outFile $line + } + + if [string match "*\#*DBC BEGIN*$key*" $line ] { + incr nBegins + } + } + if { $nEnds != $nBegins } { + puts "DBC ERROR -- EOF before DBC END!" + } + close $inFile + close $outFile +} + +proc undbc { inpt outpt {key *}} { + + if [file exists $outpt] { + puts "The output file '$outpt' already exists. Aborting." + return + } + + set inFile [open $inpt r] + set outFile [open $outpt w] + set nBegins 0 + set nEnds 0 + + foreach line [split [read $inFile] \n] { + + if [string match "*\#*DBC END*$key*" $line] { + incr nEnds + } + + if { $nBegins > $nEnds } { + # inside DBC + puts $outFile [string trimleft $line \#] + } else { + puts $outFile $line + } + + if [string match "*\#*DBC BEGIN*$key*" $line ] { + incr nBegins + + } + } + + if { $nEnds != $nBegins } { + puts "DBC ERROR -- EOF before DBC END!" + } + + + close $inFile + close $outFile +} + + + diff --git a/eaters-3.0.8/simulator/eaters-configure.tcl b/eaters-3.0.8/simulator/eaters-configure.tcl new file mode 100644 index 0000000..96a1ae6 --- /dev/null +++ b/eaters-3.0.8/simulator/eaters-configure.tcl @@ -0,0 +1,116 @@ +### boardX and boardY define the dimensions of the *playable* eater area. +### This areas is entirely surrounded by a wall, so the actual playing map +### will be incremented by 2 in each direction. +global boardX boardY +set boardX 15 +set boardY 15 + + + + +### The maximum radius of grid squares that an eater can sense. +global maxSensorRange +set maxSensorRange 2 + +global sensorRange +set sensorRange 2 + +### The different possible colors that eaters can assume +global possibleEaterColors +set possibleEaterColors {red blue yellow green orange purple black} + + +### worldCount keeps track of the number of turns in the current game. +### worldCountLimit specifies when the game ends. +global worldCount worldCountLimit +set worldCount 0 +set worldCountLimit 2000 + + + +global sendMoveCount +set sendMoveCount 0 + + + +### tickDelay is the actual number of milliseconds to wait in between +### simulation cycles (in case things are going too fast). +global tickDelay +set tickDelay 0 + +### ticksPerMove is the number of simulation cycles to go through between +### each move of the eaters. This is designed to give the world a chance to +### update, and the eaters a chance to think between moves. The only +### thing that changes in the world during a "non-moving tick" is the +### eaters' mouths. As far as the agents are concerned, the world only +### changes on once every $ticksPerMove simulation cycles. +global ticksPerMove +set ticksPerMove 1 + +### soarTimePerTick and soarTimeUnit specify the number and units of +### reasoning cycles that each eater gets during a single simulation cycle. +### This is independent of simulation processing. For example, if +### soarTimePerTick is 2 and soarTimeUnit is d, then each eater gets two +### decision cycles for every "tick" of the simulation clock. +global soarTimePerTick soarTimeUnit +set soarTimePerTick 1 +set soarTimeUnit d + +### ticksPerEaterCycle is simply to set how fast the eaters open and close +### their mouths. This variable specifies how many ticks it takes for +### an eater to do a complete cycle of opening and closing. It has no +### effect on the state of the world as the eater agents see it. +global ticksPerEaterCycle +set ticksPerEaterCycle 10 + +### eaterOpenMouth just sets (in degrees) how far the eaters' mouths open. +global eaterOpenMouth +set eaterOpenMouth 60 + +### The size, in pixels, of each grid square in the eater map +global gridSize +set gridSize 25 + +### The size, in pixels, of each grid square in the sensor display +global sensorGridSize +set sensorGridSize 20 + +### These numbers are just to specify what a "bump" looks like visually +### on the map. It is basically an 8-pointed star and the two radius +### numbers specify the dimensions of the star points. +global bumpOuterRadius bumpInnerRadius +set bumpOuterRadius 25 +set bumpInnerRadius 8 + +### Various color parameters that can be tailored to your heart's content +global boardColor normalfoodColor bonusfoodColor foodEdgeColor \ + wallColor wallEdgeColor eaterEdgeColor bumpColor +set boardColor gray +set normalfoodColor blue +set bonusfoodColor red +set foodEdgeColor black +set wallColor black +set wallEdgeColor gray +set eaterEdgeColor black +set bumpColor red + +### Parameters specifying how big food and eaters are relative to the +### size of a map grid square +global foodSize eaterSize +set foodSize 0.3 +set eaterSize 0.75 + + +### The score values for different types of food in the game +global normalfoodScore bonusfoodScore +set normalfoodScore 5 +set bonusfoodScore 10 + +### jumpPenalty is the amount of score an eater must "pay" in order to +### "jump" instead of doing a normal move. +global jumpPenalty +set jumpPenalty 5 + +### boardWalls is the default number of walls to place on the map. +global boardWalls +set boardWalls 10 diff --git a/eaters-3.0.8/simulator/eaters-layout.tcl b/eaters-3.0.8/simulator/eaters-layout.tcl new file mode 100644 index 0000000..b6a7e7c --- /dev/null +++ b/eaters-3.0.8/simulator/eaters-layout.tcl @@ -0,0 +1,139 @@ +### $Id: eaters-layout.tcl,v 1.1.1.1 2003/06/16 13:48:36 swallace Exp $ +### $Log: eaters-layout.tcl,v $ +### Revision 1.1.1.1 2003/06/16 13:48:36 swallace +### eaters initial cvs version (3.0.5) +### +### Revision 1.4 1998/10/26 15:48:50 swallace +### Prior to Release for 494 +### +### Revision 1.3 1998/10/25 14:52:30 swallace +### Synced w/ Mazin +### +### Revision 1.2 1998/10/05 12:55:48 swallace +### Release 2.0a (w/ new tsi30alpha) and new control panel etc. +### +### Revision 1.1 1998/10/02 13:49:18 swallace +### Initial revision +### +### Revision 5.3 1998/08/21 12:10:46 swallace +### seems to work with remote agent proprioceptic feedback +### +### Revision 5.2 1998/08/19 13:03:54 swallace +### All Fixes :) except for propreoceptic feedback +### +### Revision 5.1 1998/06/02 16:51:22 swallace +### 2 side step & run +### +### Revision 4.1 1998/06/01 22:15:06 swallace +### works using step on both sides. +### +### Revision 3.1 1998/05/21 18:33:56 swallace +### Client/Server Interface allows info to be passed to client. +### +### Revision 1.2 1998/05/19 21:43:20 swallace +### slightly better, goes w/ version 2.2 of most other source +### + + +global currentColor +set currentColor 0 + +randomMap + +global xplacer yplacer +set xplacer 100 +set yplacer 100 + + +### Change around the File menu +### delete the original Exit entry, so it can stay at the bottom +#.menu.file.m delete Exit +#.menu.file.m add command -label "Reload Eater name menu" \ +# -command {loadEaterNames .agents.create.e} +#.menu.file.m add command -label Exit -command exit +# +#### Agent Creation Menu: +#global currentAgentSourceFile +#.agents.create.createAgentButton configure -text {Create Eater} \ +# -command {startEater .wGlobal.c $tsiCurrentAgentSourceFile $currentColor} +# +#pack forget .agents.create.createAgentButton +#pack .agents.create.createAgentButton -side left + + +## Get rid of the normal TSI focus behavior +#bind . {} + + +#frame .mapcontrol -borderwidth 2 + +#frame .mapcontrol.inner + +#global eaterList eaterTick eaterScore +#button .mapcontrol.inner.newmap -text {New Map} \ +# -command {makeBoard $boardX $boardY} +#button .mapcontrol.inner.reset -text {Restart This Map} \ +# -command restartMap +#pack .mapcontrol.inner.newmap .mapcontrol.inner.reset -side left +#pack .mapcontrol.inner -side top +#pack .mapcontrol -side top -fill x -padx 10 + + +global tsiConfig +if { [info exists tsiConfig(ControlPanel)] } { + if { [string compare $tsiConfig(ControlPanel) ETControlPanel] != 0 } { + error "The Eaters Simulator Requires the ETControlPanel." + exit 0 + } +} else { + error "The Eaters Simulator Requires the ETControlPanel." + exit 0 +} + +# Now we make the eater specific changes to the et-controlpanel. +# In particular, we need to change all the occurances of 'Agent' with 'Eater' + +.agentcreation.createAgent configure -command \ + {startEater -1 -1 -1 $tsiCurrentAgentSourceDir $tsiCurrentAgentSourceFile $currentAgentColor ; updateAvailableAgentColors } + +#.menu.agents configure -text {Eaters} +#.menu.agents.m entryconfigure {Destroy All Agents} -label {Destroy All Eaters} +#.menu.windowtoggle.m entryconfigure {Agent Info} -label {Eater Info} + +#[.destroyAgent cget -menu] delete 0 end + + +### Now we can display the window +wm deiconify . + + + + +proc updateAvailableAgentColors {} { + global currentAgentColor eaterList agentColorMenu possibleAgentColors + + ### Update the color choices, based on existing eater colors + foreach color $possibleAgentColors { + if {![info exists eaterList] || [lsearch $eaterList $color] < 0} { + $agentColorMenu entryconfigure $color -state normal + } else { + $agentColorMenu entryconfigure $color -state disabled + } + } + ### If the current color is disabled, find a new one. If a new one can't + ### be found, disable the create eater button + if {($currentAgentColor == {}) || \ + ([$agentColorMenu entrycget $currentAgentColor -state] == {disabled})} { + set currentAgemtColor {} + .agentcreation.createAgent configure -state disabled + foreach i $possibleAgentColors { + if {[$agentColorMenu entrycget $i -state] == "normal"} { + $agentColorMenu invoke $i + .agentcreation.createAgent configure -state normal + break + } + } + } +} + + diff --git a/eaters-3.0.8/simulator/et-controlpanel.tcl b/eaters-3.0.8/simulator/et-controlpanel.tcl new file mode 100644 index 0000000..78be1b3 --- /dev/null +++ b/eaters-3.0.8/simulator/et-controlpanel.tcl @@ -0,0 +1,585 @@ +### +### $Id: et-controlpanel.tcl,v 1.4 2004/07/12 15:25:56 rmarinie Exp $ +### +### $Log: et-controlpanel.tcl,v $ +### Revision 1.4 2004/07/12 15:25:56 rmarinie +### fixed bugzilla bug 391 +### +### Revision 1.3 2004/07/12 14:45:30 toolshed +### fixed erroneous stop after decision cycle monitor command +### +### Revision 1.2 2003/10/21 18:24:55 snason +### uncommented the restart map button +### +### Revision 1.1.1.1 2003/06/16 13:48:36 swallace +### eaters initial cvs version (3.0.5) +### +### Revision 1.6 1998/10/26 15:48:50 swallace +### Prior to Release for 494 +### +### Revision 1.5 1998/10/25 14:52:30 swallace +### Synced w/ Mazin +### +### Revision 1.4 1998/10/08 13:54:45 swallace +### Released to John +### +### +### +### +### +### + +set possibleAgentColors [list red blue green yellow purple orange black] + +set tsiSimulatorPath [pwd] + +source [file join $tsi_library tsiControlPanelCommon.tcl] + + +proc makeETControlPanel { {hide 0} {x -20} {y 1} } { + global agentColorMenu possibleAgentColors currentAgentColor tsiConfig \ + ETCPConfig soarTimeUnit + + + + + InstantiateETCPConfig + + if $hide { + wm withdraw . + } else { + wm deiconify . + } + . configure -relief ridge -borderwidth 5 + wm title . "$ETCPConfig(AgentName) Control Panel" + if {$x >= 0} { set x +$x } + if {$y >= 0} { set y +$y } + wm geometry . $x$y + + # ---------------------------------------------------------------------- + # Main Menu + # ---------------------------------------------------------------------- + + frame .menu -relief raised -bd 2 + pack .menu -side top -fill x + + menubutton .menu.file -text {File} -menu .menu.file.m + menu .menu.file.m + + + # .menu.file.m add command -label "Reload $ETCPConfig(PluralAgentName)" + .menu.file.m add command -label Exit -command quitSoar + + pack .menu.file -side left -padx 5 + + + # ---------------------------------------------------------------------- + # Buttons, etc + # ---------------------------------------------------------------------- + + + frame .socketio + pack .socketio -side bottom -fill x + + # menubutton .destroyAgent -relief raised -text {Destroy Agent} \ + \# -menu .destroyAgent.m + # menu .destroyAgent.m + + + #pack .destroyAgent -side bottom -padx 5 + # create a frame for the general buttons + + # BUG BUG --------- These need to be changed to agree w/ my stuff + # in tsi24beta tsiControlPanel + frame .run -relief sunken -borderwidth 2 + button .run.step -text Step -command environmentStep + button .run.run -text Run -command environmentRun + button .run.stop -text Stop -command environmentStop + button .run.quit -text Quit -command quitSoar + + # pack the frame, and its components + pack .run.step .run.run .run.stop .run.quit -side top -anchor n -fill both + pack .run -side right + + + + # create the agent frame and control for maing new agents. + frame .agentcreation -borderwidth 2 + + label .agentcreation.lPath -text {Path:} -width 6 + label .agentcreation.lFile -text {File:} -width 6 + + PDFileMenus .agentcreation.file tsiCurrentAgentSourceFile \ + -pathMenu .agentcreation.path -pathVar tsiCurrentAgentSourceDir \ + -maxDepth 3 -path $ETCPConfig(AgentFolder) \ + -filter {*.soar} -filenameDisplay root + + grid .agentcreation.lPath .agentcreation.path + grid .agentcreation.lFile .agentcreation.file + grid .agentcreation.lPath -sticky w + grid .agentcreation.path -sticky ew -padx 5 + grid .agentcreation.lFile -sticky w + grid .agentcreation.file -sticky ew -padx 5 + + label .agentcreation.lColor -text {Color:} -width 6 + set agentColorMenu [eval tk_optionMenu .agentcreation.color \ + currentAgentColor $possibleAgentColors] + + foreach i $possibleAgentColors { + $agentColorMenu entryconfigure $i -command \ + "[list set currentAgentColor $i]; updateAvailableAgentColors" + } + + grid .agentcreation.lColor .agentcreation.color + grid .agentcreation.lColor -sticky w + grid .agentcreation.color -sticky ew -padx 5 + + menubutton .agentcreation.destroyAgent -relief raised \ + -text "Destroy $ETCPConfig(AgentName)" -menu \ + .agentcreation.destroyAgent.m -activebackground red + menu .agentcreation.destroyAgent.m + + button .agentcreation.createAgent -text "Create $ETCPConfig(AgentName)" \ + -command createNewAgent -activebackground green + + #grid .agentcreation.destroyAgent .agentcreation.createAgent + grid .agentcreation.createAgent -column 1 -sticky ew -padx 5 + grid .agentcreation.destroyAgent -column 1 -sticky ew -padx 5 + + + + # Force the column with the pull down mennus to be at least 100 pixels wide + grid columnconfigure .agentcreation 1 -minsize 100 + + + pack .agentcreation -side left + + # ---------------------------------------------------------------------- + # Specialized Menus + # ---------------------------------------------------------------------- + + + menubutton .menu.agents -text $ETCPConfig(PluralAgentName) \ + -menu .menu.agents.m + menu .menu.agents.m + .menu.agents.m add command -label \ + "Destroy All $ETCPConfig(PluralAgentName)" -command \ + {destroyAllAgents} + + + + .menu.agents.m add checkbutton -label {Stop After Decision Phase} \ + -variable ETCPConfig(afterDecision) \ + -command "if \$ETCPConfig(afterDecision) { \ + stopAfterDecision ; \ + set ETCPConfig(runTilOutputGen) 0; \ + set soarTimeUnit d; \ + } else { \ + dontStopAfterDecision \ + };" + + .menu.agents.m add checkbutton -label {Run til Output Generated} \ + -variable ETCPConfig(runTilOutputGen) \ + -command "if \$ETCPConfig(runTilOutputGen) { \ + set ETCPConfig(afterDecision) 0 ; \ + dontStopAfterDecision ; \ + set soarTimeUnit out ; \ + } else { \ + set soarTimeUnit d \ + };" + + pack .menu.agents -side left -padx 5 + + menubutton .menu.map -text {Map} -menu .menu.map.m + + menu .menu.map.m + .menu.map.m add command -label {Load Map} -command {mapLoader} + .menu.map.m add command -label {Restart Map} -command {restartMap} + .menu.map.m add command -label {Random Map} -command {randomMap} + + pack .menu.map -side left -padx 5 + + + + menubutton .menu.windowtoggle -text {Windows} -menu .menu.windowtoggle.m + + menu .menu.windowtoggle.m + .menu.windowtoggle.m add command -label "Hide/Show All Windows" \ + -command {toggleAllWindows} + .menu.windowtoggle.m add command -label {Save Window Prefs} -command \ + {saveWindowPreferences} + .menu.windowtoggle.m add command -label {Load Window Prefs} -command \ + {loadWindowPreferences} + .menu.windowtoggle.m add command -label {Hide/Show World Map} -command \ + {toggleWindow .wGlobal} + .menu.windowtoggle.m add command -label "Hide/Show $ETCPConfig(AgentName) Info" \ + -command {toggleWindow .wAgentInfo} + + + pack .menu.windowtoggle -side left -padx 5 + + return .socketio + + +} + +proc stopAfterDecision {} { +# sendAllAgents {monitor -add after-decision-phase-cycle "stop-soar -self {}" dp1} +# changed to fix bugzilla bug 391 + sendAllAgents {monitor -add after-decision-phase-cycle "stop-soar -self" dp1} +} +proc dontStopAfterDecision {} { + sendAllAgents {monitor -delete after-decision-phase-cycle dp1} +} + + +proc registerAgent {name} { + global showAgent ETCPConfig tsiAgentInfo + + .menu.agents.m add cascade -label $name -menu .menu.agents.m.$name + menu .menu.agents.m.$name + + .menu.agents.m.$name add checkbutton -label \ + "Show $ETCPConfig(AgentName) Window" -variable showAgent($name) \ + -command "agentToggleCommand $name \$showAgent($name) \ + {wm deiconify .tsw} {wm withdraw .tsw}" + set showAgent($name) 1 + .menu.agents.m.$name add command -label \ + "Raise $ETCPConfig(AgentName) Window" \ + -command "tsiSendAgent $name {raise .tsw}" + .menu.agents.m.$name add command -label {Reload Productions} \ + -command "tsiLoadAgentSource $name" + .menu.agents.m.$name add command -label "Reset $ETCPConfig(AgentName)" \ + -command "tsiSendAgent $name {tsiDisplayAndSendCommand {excise -all}}; tsiLoadAgentSource $name" + .menu.agents.m.$name add command -label {Excise All} \ + -command "tsiSendAgent $name {tsiDisplayAndSendCommand {excise -all}}" + .menu.agents.m.$name add command -label {Excise Chunks} \ + -command "tsiSendAgent $name {tsiDisplayAndSendCommand {excise -chunks}}" + + .agentcreation.destroyAgent.m add command -label $name \ + -command [list destroyAgent $name] + + set tsiAgentInfo($name,addFN) localAgentAddWME + set tsiAgentInfo($name,rmFN) localAgentRemoveWME + +} + + +proc destroyAllAgents {} { +global tankList + + foreach name [tsiListAgents] { + destroyAgent $name + } + # Only defined in tankSoar + if {[info exists tankList] && ($tankList != {})} { + foreach name $tankList { + destroyAgent $name + } + } +} + +proc destroyAgent {name} { + global localAgents + + if {[info proc envDestroyAgent] == ""} { + error "Note that you should create a 'envDestroyAgent' function to clean up stuff in your environment." + } else { + envDestroyAgent $name + } + + if {[lsearch [tsiListAgents] $name] >= 0} { + if [catch "destroy-interpreter $name"] { + if [catch "interp delete $name"] { + error "Cannot delete agent '$name'!" + return + } + } + } + if { ![catch ".menu.agents.m index $name"] } { + .menu.agents.m delete $name + destroy .menu.agents.m.$name + } + + .agentcreation.destroyAgent.m delete $name + + set localAgents [ldelete $localAgents $name] + +} + + + +proc destroyRemoteAgent {name} { } + + + +proc registerRemoteAgent {name socket} { + global showAgent sio_agentStatus sio_socketToAgent sio_agentToSocket \ + tsiAgentInfo tsiConfig ETCPConfig + + + if { $tsiConfig(sioDebug) > 3 } { + puts "registerRemoteAgent: et-controlpanel (begin) -- name: $name socket: $socket" + } + + + + + .menu.agents.m add cascade -label $name -menu .menu.agents.m.$name + menu .menu.agents.m.$name + + .menu.agents.m.$name add checkbutton -label \ + "Show $ETCPConfig(AgentName) Window" -variable showAgent($name) \ + -command "agentToggleCommand $name \$showAgent($name) \ + {wm deiconify .tsw} {wm withdraw .tsw}" + set showAgent($name) 1 + .menu.agents.m.$name add command -label \ + "Raise $ETCPConfig(AgentName) Window" \ + -command "tsiSendAgent $name {raise .tsw}" + .menu.agents.m.$name add checkbutton -label {Online} \ + -variable sio_agentStatus($name,online) + .menu.agents.m.$name add command -label {Excise All} \ + -command "tsiSendAgent $name {tsiDisplayAndSendCommand {excise -all}}" + .menu.agents.m.$name add command -label {Excise Chunks} \ + -command "tsiSendAgent $name {tsiDisplayAndSendCommand {excise -chunks}}" + .agentcreation.destroyAgent.m add command -label $name \ + -command [list destroyRemoteAgent $name] + + set tsiAgentInfo($name,addFN) localAgentAddWME + set tsiAgentInfo($name,rmFN) localAgentRemoveWME + + if { [info exists sio_agentToSocket($name)] } { + error "In registerRemoteAgent: the agent $name already exists." + } + + if { [info exists sio_socketToAgent($socket)] } { + error "In registerRemoteAgent: the socket has already been assigned." + } + set sio_agentToSocket($name) $socket + set sio_socketToAgent($socket) $name + set tsiAgentInfo($name) remote + set tsiAgentInfo($name,addFN) remoteAgentAddWME + set tsiAgentInfo($name,rmFN) remoteAgentRemoveWME + + if { $tsiConfig(sioDebug) > 3 } { + puts "registerRemoteAgent (end) -- name: $name socket: $socket" + } +} + + + + +proc InstantiateETCPConfig {} { + global ETCPConfig tsiSimulatorPath + + + # since this control panel will be used with at least two simulators + # these configuration parameter are defined (ETCPConfig) so that all + # occurances of 'Agent' can be replaced with something more specific + # such as 'Eater' ... so far this is the only config parameter, if enough + # become necessary, a file could be used. + + + if { ![info exists ETCPConfig(AgentName)] } { + set ETCPConfig(AgentName) Agent + } + if { ![info exists ETCPConfig(PluralAgentName)] } { + set ETCPConfig(PluralAgentName) [format "%ss" $ETCPConfig(AgentName)] + } + if { ![info exists ETCPConfig(AgentFolder)] } { + set ETCPConfig(AgentFolder) $tsiSimulatorPath + } + if { ![info exists ETCPConfig(MapFolder)] } { + set ETCPConfig(MapFolder) $tsiSimulatorPath + } + if { ![info exists ETCPConfig(afterDecision)] } { + set ETCPConfig(afterDecision) 0 + } + if { ![info exists ETCPConfig(runTilOutputGen)] } { + set ETCPConfig(runTilOutputGen) 1 + } +} + + +proc tsiLoadSubDirectories { menuName fileMenuName } { + global tsiSimulatorPath tsiCurrentAgentSourceDir + + + if { $tsiSimulatorPath == [pwd] } { + set dirs [list .] + foreach file [glob -nocomplain *] { + if { [file isdirectory $file] } { + lappend dirs [file join . [file tail $file]] + } + } + + } else { + set currDir [file join . [file tail [pwd]]] + set dirs [list $currDir [file join $currDir ..]] + } + + if [winfo exists $menuName] { + [$menuName cget -menu] delete 0 end + foreach i $dirs { + [$menuName cget -menu] add command -label $i \ + -command [list tsiChangeAgentSourceDir $i $menuName $fileMenuName] + } + + set tsiCurrentAgentSourceDir [lindex $dirs 0] + + } else { + eval tk_optionMenu $menuName tsiCurrentAgentSourceDir $dirs + foreach dir $dirs { + [$menuName cget -menu] entryconfigure $dir -command \ + [list tsiChangeAgentSourceDir $dir $menuName $fileMenuName] + } + } + +} + + +proc tsiChangeAgentSourceDir { newDir dirMenuName fileMenuName } { + global tsiSimulatorPath + + set oldDir [pwd] + cd [file join $tsiSimulatorPath $newDir] + + if { $oldDir == [pwd] } { return } + + tsiLoadAgentNames $fileMenuName + tsiLoadSubDirectories $dirMenuName $fileMenuName + + +} + + + +proc tsiLoadAgentNames { menuName } { + global tsiCurrentAgentSourceFile + + set allNames [glob -nocomplain {*.soar}] + set names "" + + foreach i $allNames { + lappend names [file rootname [file tail $i]] + } + + set names [lsort -ascii $names] + + if { $names == {} } { + + if [winfo exists $menuName] { + [$menuName cget -menu] delete 0 end + set tsiCurrentAgentSourceFile {*NO AGENTS*} + } else { + tk_optionMenu $menuName tsiCurrentAgentSourceFile {*NO AGENTS*} + } + $menuName configure -state disabled + } else { + if [winfo exists $menuName] { + [$menuName cget -menu] delete 0 end + foreach i $names { + [$menuName cget -menu] add command -label $i \ + -command [list set tsiCurrentAgentSourceFile $i] + } + set tsiCurrentAgentSourceFile [lindex $names 0] + $menuName configure -state normal + } else { + eval tk_optionMenu $menuName tsiCurrentAgentSourceFile $names + } + } +} + +proc mapLoader {} { + global ETCPConfig ETCP_MapFile ETCP_MapPath + + if [winfo exists .wMapLoader] { + wm deiconify .wMapLoader + return + } + + # if [info exists ETCP_MapFile] { unset ETCP_MapFile } + # if [info exists ETCP_MapPath] { puts "$ETCP_MapPath" ; unset ETCP_MapPath } + + toplevel .wMapLoader + wm title .wMapLoader "Load Map" + + frame .wMapLoader.topFrame + + pack .wMapLoader.topFrame -side top + + + label .wMapLoader.topFrame.lFile -text "File :" + label .wMapLoader.topFrame.lPath -text "Path :" + + + PDFileMenus .wMapLoader.topFrame.file ETCP_MapFile \ + -pathMenu .wMapLoader.topFrame.path -pathVar ETCP_MapPath \ + -maxDepth 3 -path $ETCPConfig(MapFolder) \ + -filter {*.map} -filenameDisplay root + + pack .wMapLoader.topFrame.lPath .wMapLoader.topFrame.path \ + .wMapLoader.topFrame.lFile .wMapLoader.topFrame.file \ + -side left + + frame .wMapLoader.botFrame + pack .wMapLoader.botFrame -side bottom + + button .wMapLoader.botFrame.bLoadMap -text "Load Map" \ + -command {MapLoader_LoadMap} + button .wMapLoader.botFrame.bReturn -text "Back To Simulation" -command \ + {wm withdraw .wMapLoader} + + pack .wMapLoader.botFrame.bLoadMap .wMapLoader.botFrame.bReturn \ + -side left + +} + +proc MapLoader_LoadMap {} { + global ETCP_MapFile ETCP_MapPath + + set initialPath [pwd] + + #if [info proc envLoadMap] { + puts "files: $ETCP_MapPath $ETCP_MapFile" + envLoadMap $ETCP_MapPath $ETCP_MapFile + #} + + cd $initialPath + +} + +proc toggleWindow {whichWindow} { + + if [winfo exists $whichWindow] { + set displayed [winfo ismapped $whichWindow] + + if {$displayed == 1} { + wm iconify $whichWindow + raise $whichWindow + } else { + wm deiconify $whichWindow + } + } +} + + +proc toggleAllWindows {} { + + set windowList [winfo children .] + foreach w $windowList { + if {[winfo toplevel "$w"] == "$w"} { + if {[winfo ismapped $w]} { + wm iconify $w + } else { + wm deiconify $w + } + } + } + set slaveList [interp slaves] + foreach s $slaveList { + if {[$s eval [list info proc toggleAgentWindows]] != ""} { + $s eval [list toggleAgentWindows] + } + } +} diff --git a/eaters-3.0.8/simulator/interface.tcl b/eaters-3.0.8/simulator/interface.tcl new file mode 100644 index 0000000..b96fb88 --- /dev/null +++ b/eaters-3.0.8/simulator/interface.tcl @@ -0,0 +1,652 @@ +# +# +# $Id: interface.tcl,v 1.2 2003/10/21 18:26:42 snason Exp $ +# $Log: interface.tcl,v $ +# Revision 1.2 2003/10/21 18:26:42 snason +# hopefully eliminated error message after init-soar +# +# Revision 1.1.1.1 2003/06/16 13:48:36 swallace +# eaters initial cvs version (3.0.5) +# +# Revision 8.7 1998/10/25 14:52:30 swallace +# Synced w/ Mazin +# +# Revision 8.6 1998/10/08 13:54:45 swallace +# Released to John +# +# Revision 8.5 1998/10/07 14:24:12 swallace +# Updates an enemy eater's sensor entry properly +# +# Revision 8.4 1998/10/07 13:12:12 swallace +# 8.1 Safe +# +# Revision 8.3 1998/10/05 12:55:48 swallace +# Release 2.0a (w/ new tsi30alpha) and new control panel etc. +# +# Revision 8.2 1998/10/02 13:49:18 swallace +# *** empty log message *** +# +# Revision 8.1 1998/09/18 16:44:35 swallace +# Works fine, but code is dirty. About to clean up. +# +# Revision 6.4 1998/08/19 15:44:12 swallace +# proprioceptic feedback added - movecount remains +# +# Revision 6.3 1998/08/19 13:03:54 swallace +# All Fixes :) except for propreoceptic feedback +# +# Revision 6.2 1998/07/22 13:47:15 swallace +# removed an overlooked $addFN and replaced w/ tsiAgentInfo(agent,addFN) +# +# Revision 6.1 1998/06/02 19:02:32 swallace +# allows concurrent remote/local agents. +# +# Revision 5.1 1998/06/02 16:51:09 swallace +# 2 side step & run +# +# Revision 4.1 1998/06/01 22:14:54 swallace +# works using step on both sides. +# +# Revision 1.2 1998/05/28 20:20:52 swallace +# ready to work on WME wrappers +# +# + +proc getSimulatorInfo {} { + + set info(name) Eaters + set info(version) 1.0 + set info(autoAddOutputLnk) t + set info(outputCycle) elaboration + + return info +} + +proc setUpInputLink {agent ioID inID outID} { + global inputLinkWME inputLinkID tsiConfig tsiAgentInfo + + + + if { $tsiConfig(sioDebug) > 3 } { + puts "setUpInputLink -- (begin) agent: $agent" + } + + + if { $tsiConfig(sioDebug) > 4 } { + puts "AddWME Function is: $tsiAgentInfo($agent,addFN)" + } + + set inputLinkID($agent) $inID + + + updateInputLink $agent + + + + if { $tsiConfig(sioDebug) > 3 } { + puts "setUpInputLink -- (end) agent: $agent" + } + +} + + +proc updateInputLink {agent} { + global inputSensorRange sensorRange eaterSelfWME eaterObject deleteList \ + currentBumpList entityList eaterX eaterY eaterDir eaterScore \ + agentMoved numberOfMoves inputLinkID tsiAgentInfo \ + actionID tsiConfig + + + if { $tsiConfig(sioDebug) > 3 } { + puts "updateInputLink -- (begin) agent: $agent" + } + + ### See if there are any objects we need to delete WME's for + if [info exists deleteList($agent)] { + foreach obj $deleteList($agent) { + ### Currently we don't see other eaters, so this won't happen + if {[lsearch [.wGlobal.c itemcget $obj -tags] eater] >= 0} { +# puts "************ REMOVE EATER WME 1 ***************" + removeEaterWMEs $obj $agent + } else { + removeSimpleObjectWMEs $obj $agent + } + } + set deleteList($agent) "" + } + + ### If any bumps popped up, add them to the input link + if [info exists currentBumpList] { + foreach i $currentBumpList { + set obj [lindex $i 0] + if ![info exists entityList($obj,$agent)] { + addBumpWMEs $obj [lindex $i 1] $agent + } + } + } + + ### Set up the my-location WME if not already there + ### For now, we only create an eater WME for ourselves + if ![info exists eaterSelfWME($eaterObject($agent),$agent)] { +# puts "****************** ADD EATER WME 2 ********************" + addEaterWME $eaterObject($agent) $agent $agent + } + + ### Now update my eater's information + changeEaterXWME $eaterObject($agent) $agent \ + [convertToLogical $eaterX($agent)] + + + changeEaterYWME $eaterObject($agent) $agent \ + [convertToLogical $eaterY($agent)] + + changeEaterDirWME $eaterObject($agent) $agent $eaterDir($agent) + changeEaterScoreWME $eaterObject($agent) $agent $eaterScore($agent) + + ### Check whether we have built the sensor grid on the input link ye + if ![info exists inputSensorRange($agent)] { + set inputSensorRange($agent) -1 + } + ### Now check whether the sensor range has changed and build or + ### delete the necessary layers + ### This will work because a side-effect of addSensorLayer and + ### deleteSensorLayer is to update the value of inputSensorRange + while {$inputSensorRange($agent) < $sensorRange} { + addSensorLayer $agent + } + while {$inputSensorRange($agent) > $sensorRange} { + deleteSensorLayer $agent + } + + + + ### Finally, scan the sensors and update WME's appropriately + updateSensorWMEs $agent + + + + if {[info exists agentMoved($agent)] && $agentMoved($agent)} { + + unset agentMoved($agent) + if { ![info exists actionID($agent)] } { + if { $numberOfMoves($agent) != 0 } { + error "No Corresponding ActionID for agent $agent" + } + } else { + + $tsiAgentInfo($agent,addFN) $agent $actionID($agent) \ + "^status" "complete" + unset actionID($agent) + } + + + } + +} + +proc removeInputLink {agent} { + global inputLinkWME inputLinkID deleteList currentBumpList entityList \ + eaterSelfWME eaterNameWME eaterSelfID \ + eaterXWME eaterXVal eaterYWME eaterYVal eaterDirWME eaterNWME \ + eaterDirVal eaterNVal eaterScoreWME eaterScoreVal \ + sensorRange sensorID northWME southWME westWME eastWME \ + typeOfObj natureWME otherEaterColorWME otherEaterScoreWME \ + sensorEater agentMoved inputSensorRange \ + eaterObject tsiConfig moveDir jumpDir + + if { $tsiConfig(sioDebug) > 3 } { + puts "removeInputLink -- (begin) agent: $agent" + } + catch "unset inputLinkWME($agent)" + catch "unset inputLinkID($agent)" + catch "unset deleteList($agent)" + set agentMoved($agent) 0 + catch "unset inputSensorRange($agent)" + if [info exists moveDir($agent)] { + catch "unset moveDir($agent)" + } + if [info exists jumpDir($agent)] { + catch "unset jumpDir($agent)" + } + if [info exists currentBumpList] { + foreach i $currentBumpList { + set obj [lindex $i 0] + catch "unset entityList($obj,$agent)" + } + } + ### For now we are the only eater on the input link + set obj $eaterObject($agent) + catch "unset eaterSelfWME($obj,$agent)" + catch "unset eaterNameWME($obj,$agent)" + catch "unset eaterSelfID($obj,$agent)" + catch "unset eaterXWME($obj,$agent)" + catch "unset eaterXVal($obj,$agent)" + catch "unset eaterYWME($obj,$agent)" + catch "unset eaterYVal($obj,$agent)" + catch "unset eaterNWME($obj,$agent)" + catch "unset eaterNVal($obj,$agent)" + catch "unset eaterDirWME($obj,$agent)" + catch "unset eaterDirVal($obj,$agent)" + catch "unset eaterScoreWME($obj,$agent)" + catch "unset eaterScoreVal($obj,$agent)" + + ### Now do all the possible stuff in sensor locations + for {set i -$sensorRange} {$i<= $sensorRange} {incr i} { + for {set j -$sensorRange} {$j<= $sensorRange} {incr j} { + catch "unset sensorID($i,$j,$agent)" + catch "unset northWME($i,$j,$agent)" + catch "unset southWME($i,$j,$agent)" + catch "unset westWME($i,$j,$agent)" + catch "unset eastWME($i,$j,$agent)" + catch "unset typeOfObj($i,$j,$agent)" + catch "unset natureWME($i,$j,$agent)" + catch "unset otherEaterColorWME($i,$j,$agent)" + catch "unset otherEaterScoreWME($i,$j,$agent)" + catch "unset sensorEater($i,$j,$agent)" + } + } +} + +proc addBumpWMEs {obj names agent } { + global inputLinkID entityList tsiAgentInfo + + + set wme [$tsiAgentInfo($agent,addFN) $agent $inputLinkID($agent) ^bump *] + scan $wme "%d" temp + set entityList($obj,$agent) $temp + set id [lindex $wme 3] + foreach name $names { + $tsiAgentInfo($agent,addFN) $agent $id ^eater $name + } +} + +proc removeSimpleObjectWMEs {obj agent } { + global entityList tsiAgentInfo + + + if [info exists entityList($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $entityList($obj,$agent) + unset entityList($obj,$agent) + } +} + +proc addEaterWME {obj name agent } { + global eaterSelfWME eaterSelfID inputLinkID tsiAgentInfo + + set wme [$tsiAgentInfo($agent,addFN) $agent $inputLinkID($agent) ^eater *] + scan $wme "%d" eaterSelfWME($obj,$agent) + set eaterSelfID($obj,$agent) [lindex $wme 3] + $tsiAgentInfo($agent,addFN) $agent $eaterSelfID($obj,$agent) ^name $name +} + +proc removeEaterWMEs {obj name agent } { + global eaterSelfWME eaterSelfID eaterNameWME eaterXWME eaterYWME \ + eaterDirWME eaterScoreWME tsiAgentInfo + + if [info exists eaterSelfWME($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $eaterSelfWME($obj,$agent) + unset eaterSelfWME($obj,$agent) + catch "unset eaterSelfID($obj,$agent)" + } + catch "unset eaterNameWME($obj,$agent)" + catch "unset eaterXWME($obj,$agent)" + catch "unset eaterYWME($obj,$agent)" + catch "unset eaterDirWME($obj,$agent)" + catch "unset eaterScoreWME($obj,$agent)" +} + +proc changeEaterXWME {obj agent {val ""}} { + global eaterXWME eaterSelfID eaterXVal tsiAgentInfo + + if {[info exists eaterXVal($obj,$agent)] && \ + ($eaterXVal($obj,$agent) == $val)} { + return + } + if [info exists eaterXWME($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $eaterXWME($obj,$agent) + unset eaterXWME($obj,$agent) + catch "unset eaterXVal($obj,$agent)" + } + if {($val != "") && ([info exists eaterSelfID($obj,$agent)])} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $eaterSelfID($obj,$agent) ^x $val] + scan $wme "%d" eaterXWME($obj,$agent) + set eaterXVal($obj,$agent) $val + } +} + +proc changeEaterYWME {obj agent {val ""}} { + global eaterYWME eaterSelfID eaterYVal tsiAgentInfo + + if {[info exists eaterYVal($obj,$agent)] && \ + ($eaterYVal($obj,$agent) == $val)} { + return + } + if [info exists eaterYWME($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $eaterYWME($obj,$agent) + unset eaterYWME($obj,$agent) + catch "unset eaterYVal($obj,$agent)" + } + if {($val != "") && ([info exists eaterSelfID($obj,$agent)])} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $eaterSelfID($obj,$agent) ^y $val] + scan $wme "%d" eaterYWME($obj,$agent) + set eaterYVal($obj,$agent) $val + } +} + +proc changeEaterDirWME {obj agent {val ""}} { + global eaterDirWME eaterSelfID eaterDirVal tsiAgentInfo + + if {[info exists eaterDirVal($obj,$agent)] && \ + ($eaterDirVal($obj,$agent) == $val)} { + return + } + if [info exists eaterDirWME($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $eaterDirWME($obj,$agent) + unset eaterDirWME($obj,$agent) + catch "unset eaterDirVal($obj,$agent)" + } + if {($val != "") && ([info exists eaterSelfID($obj,$agent)])} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $eaterSelfID($obj,$agent) ^direction $val] + scan $wme "%d" eaterDirWME($obj,$agent) + set eaterDirVal($obj,$agent) $val + } +} + +proc changeEaterScoreWME {obj agent {val ""}} { + global eaterScoreWME eaterSelfID eaterScoreVal tsiAgentInfo eaterScore + + if {[info exists eaterScoreVal($obj,$agent)] && \ + ($eaterScoreVal($obj,$agent) == $val)} { + return + } + if [info exists eaterScoreWME($obj,$agent)] { + $tsiAgentInfo($agent,rmFN) $agent $eaterScoreWME($obj,$agent) + unset eaterScoreWME($obj,$agent) + catch "unset eaterScoreVal($obj,$agent)" + } + if {($val != "") && ([info exists eaterSelfID($obj,$agent)])} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $eaterSelfID($obj,$agent) ^score $val] + scan $wme "%d" eaterScoreWME($obj,$agent) + set eaterScoreVal($obj,$agent) $val + set eaterScore($agent) $val } +} + +proc addSensorLayer {agent} { + global inputSensorRange inputLinkID myLocationID sensorID \ + northWME southWME westWME eastWME tsiAgentInfo + + incr inputSensorRange($agent) + if !$inputSensorRange($agent) { + if ![info exists sensorID(0,0,$agent)] { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $inputLinkID($agent) ^my-location *] + scan $wme "%d" myLocationWME($agent) + set sensorID(0,0,$agent) [lindex $wme 3] + } + } elseif {$inputSensorRange($agent) > 0} { + ### Add top edge + set j -$inputSensorRange($agent) + for {set i [expr 1-$inputSensorRange($agent)]} \ + {$i <= [expr $inputSensorRange($agent)-1]} \ + {incr i} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,[expr $j+1],$agent) ^north *] + scan $wme "%d" northWME($i,[expr $j+1],$agent) + set sensorID($i,$j,$agent) [lindex $wme 3] + ### Don't need to save these, because they should get garbage + ### collected when we delete by layers. + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^south \ + $sensorID($i,[expr $j+1],$agent) + ### Link to previous neighbor on this layer + if {$i > [expr 1-$inputSensorRange($agent)]} { + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^west \ + $sensorID([expr $i-1],$j,$agent) + $tsiAgentInfo($agent,addFN) $agent \ + $sensorID([expr $i-1],$j,$agent) ^east $sensorID($i,$j,$agent) + } + } + ### Add bottom edge + set j $inputSensorRange($agent) + for {set i [expr 1-$inputSensorRange($agent)]} \ + {$i <= [expr $inputSensorRange($agent)-1]} \ + {incr i} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,[expr $j-1],$agent) ^south *] + scan $wme "%d" southWME($i,[expr $j-1],$agent) + set sensorID($i,$j,$agent) [lindex $wme 3] + ### Don't need to save these, because they should get garbage + ### collected when we delete by layers. + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^north \ + $sensorID($i,[expr $j-1],$agent) + ### Link to previous neighbor on this layer + if {$i > [expr 1-$inputSensorRange($agent)]} { + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^west \ + $sensorID([expr $i-1],$j,$agent) + $tsiAgentInfo($agent,addFN) $agent \ + $sensorID([expr $i-1],$j,$agent) ^east $sensorID($i,$j,$agent) + } + } + ### Add left edge + set i -$inputSensorRange($agent) + ### Don't need to decrement by 1 because now the top and bottom exist + for {set j -$inputSensorRange($agent)} \ + {$j <= $inputSensorRange($agent)} \ + {incr j} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID([expr $i+1],$j,$agent) ^west *] + if {($j > -$inputSensorRange($agent)) && \ + ($j < $inputSensorRange($agent))} { + scan $wme "%d" westWME([expr $i+1],$j,$agent) + } + set sensorID($i,$j,$agent) [lindex $wme 3] + ### Don't need to save these, because they should get garbage + ### collected when we delete by layers. + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^east \ + $sensorID([expr $i+1],$j,$agent) + ### Link to previous neighbor on this layer + if {$j > -$inputSensorRange($agent)} { + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^north \ + $sensorID($i,[expr $j-1],$agent) + $tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,[expr $j-1],$agent) ^south $sensorID($i,$j,$agent) + } + } + ### Add right edge + set i $inputSensorRange($agent) + ### Don't need to decrement by 1 because now the top and bottom exist + for {set j -$inputSensorRange($agent)} \ + {$j <= $inputSensorRange($agent)} \ + {incr j} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID([expr $i-1],$j,$agent) ^east *] + if {($j > -$inputSensorRange($agent)) && \ + ($j < $inputSensorRange($agent))} { + scan $wme "%d" eastWME([expr $i-1],$j,$agent) + } + set sensorID($i,$j,$agent) [lindex $wme 3] + ### Don't need to save these, because they should get garbage + ### collected when we delete by layers. + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^west \ + $sensorID([expr $i-1],$j,$agent) + ### Link to previous neighbor on this layer + if {$j > -$inputSensorRange($agent)} { + $tsiAgentInfo($agent,addFN) $agent $sensorID($i,$j,$agent) ^north \ + $sensorID($i,[expr $j-1],$agent) + $tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,[expr $j-1],$agent) ^south $sensorID($i,$j,$agent) + } + } + } +} + +proc deleteSensorLayer {agent} { + global inputSensorRange myLocationWME sensorID \ + northWME southWME westWME eastWME tsiAgentInfo + + incr inputSensorRange($agent) -1 + if {$inputSensorRange($agent) == -1} { + $tsiAgentInfo($agent,rmFN) $agent $myLocationWME($agent) + unset myLocationWME($agent) + unset sensorID(0,0,$agent) + } elseif {$inputSensorRange($agent) >= 0} { + ### Delete top and bottom edges + for {set i -$inputSensorRange($agent)} \ + {$i <= $inputSensorRange($agent)} \ + {incr i} { + $tsiAgentInfo($agent,rmFN) $agent \ + $northWME($i,-$inputSensorRange($agent),$agent) + $tsiAgentInfo($agent,rmFN) $agent \ + $southWME($i,$inputSensorRange($agent),$agent) + unset northWME($i,-$inputSensorRange($agent),$agent) + unset southWME($i,$inputSensorRange($agent),$agent) + unset sensorID($i,[expr -$inputSensorRange($agent)-1],$agent) + unset sensorID($i,[expr $inputSensorRange($agent)+1],$agent) + } + ### Delete left and right edges + for {set j -$inputSensorRange($agent)} \ + {$j <= $inputSensorRange($agent)} \ + {incr j} { + $tsiAgentInfo($agent,rmFN) $agent \ + $westWME(-$inputSensorRange($agent),$j,$agent) + $tsiAgentInfo($agent,rmFN) $agent \ + $eastWME($inputSensorRange($agent),$j,$agent) + unset westWME(-$inputSensorRange($agent),$j,$agent) + unset eastWME($inputSensorRange($agent),$j,$agent) + catch "unset sensorID([expr -$inputSensorRange($agent)-1],$j,$agent)" + catch "unset sensorID([expr $inputSensorRange($agent)+1],$j,$agent)" + } + ### ...and garbage collection should do the rest! + } +} + +proc updateSensorWMEs {agent} { + global sensorRange eaterX eaterY gridSize typeOfObj natureWME \ + otherEaterColorWME otherEaterScoreWME otherEaterScore sensorEater \ + sensorID eaterColor eaterScore boardX boardY tsiAgentInfo \ + eaterObjectName agentMoved + + for {set i -$sensorRange} {$i<= $sensorRange} {incr i} { + for {set j -$sensorRange} {$j<= $sensorRange} {incr j} { + ### Just in case something goes wrong... + if ![info exists sensorID($i,$j,$agent)] { + break + } + set x [expr $i + [convertToLogical $eaterX($agent)]] + set y [expr $j + [convertToLogical $eaterY($agent)]] + ### Everything beyond the boundaries is assumed to be a wall. + if {($x < 0) || ($x > [expr $boardX+1]) || \ + ($y < 0) || ($y > [expr $boardY+1])} { + set nature wall + } else { + set contents [.wGlobal.c find enclosed \ + [expr $x*$gridSize-1] [expr $y*$gridSize-1] \ + [expr ($x+1)*$gridSize] [expr ($y+1)*$gridSize]] + ### We are going to assume that there can only be one of these + ### things on a square at a time. + set nature empty + foreach c $contents { + if {[lsearch [.wGlobal.c itemcget $c -tags] eater] >= 0} { + set nature eater + set eaterObj $c + set eaterName $eaterObjectName($eaterObj) + } + if {[lsearch [.wGlobal.c itemcget $c -tags] normalfood] >= 0} { + set nature normalfood + } + if {[lsearch [.wGlobal.c itemcget $c -tags] bonusfood] >= 0} { + set nature bonusfood + } + if {[lsearch [.wGlobal.c itemcget $c -tags] wall] >= 0} { + set nature wall + } + } + } + ### If the nature of the object has changed, remove the WME's + ### describing the old object + if {[info exists typeOfObj($i,$j,$agent)] && \ + ($typeOfObj($i,$j,$agent) != $nature)} { + $tsiAgentInfo($agent,rmFN) $agent $natureWME($i,$j,$agent) + unset natureWME($i,$j,$agent) + if {$typeOfObj($i,$j,$agent) == {eater}} { + $tsiAgentInfo($agent,rmFN) $agent \ + $otherEaterColorWME($i,$j,$agent) + $tsiAgentInfo($agent,rmFN) $agent \ + $otherEaterScoreWME($i,$j,$agent) + unset otherEaterColorWME($i,$j,$agent) + unset otherEaterScoreWME($i,$j,$agent) + unset otherEaterScore($i,$j,$agent) + unset sensorEater($i,$j,$agent) + } + unset typeOfObj($i,$j,$agent) + } elseif { [info exists typeOfObj($i,$j,$agent)] && \ + [info exists agentMoved($agent)] && \ + $agentMoved($agent) } { + # If the agent moved, or turned, then we want new timetags + # on the contents of each square...that is, the eater should + # be able to distinguish between the piece of food that was + # on its left and the new piece of food that is currently + # on its left. + + # this might not be what we want for the special case + # of eaters moving alongside each other... + $tsiAgentInfo($agent,rmFN) $agent $natureWME($i,$j,$agent) + unset natureWME($i,$j,$agent) + unset typeOfObj($i,$j,$agent) + } + + ### If this is a new object, add a WME describing it + if ![info exists typeOfObj($i,$j,$agent)] { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,$j,$agent) ^content $nature] + scan $wme "%d" natureWME($i,$j,$agent) + set typeOfObj($i,$j,$agent) $nature + } + ### Remove old eater WMES, because these guys are dynamic -- + ### that is, their score changes... + if {($nature == {eater}) && \ + [info exists sensorEater($i,$j,$agent)] } { + + if { $sensorEater($i,$j,$agent) == $eaterObj } { + if {$eaterScore($eaterName) != $otherEaterScore($i,$j,$agent)} { + $tsiAgentInfo($agent,rmFN) $agent \ + $otherEaterScoreWME($i,$j,$agent) + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,$j,$agent) ^eater-score \ + $eaterScore($eaterName)] + scan $wme "%d" otherEaterScoreWME($i,$j,$agent) + set otherEaterScore($i,$j,$agent) $eaterScore($eaterName) + } + } else { + $tsiAgentInfo($agent,rmFN) $agent \ + $otherEaterColorWME($i,$j,$agent) + $tsiAgentInfo($agent,rmFN) $agent \ + $otherEaterScoreWME($i,$j,$agent) + unset sensorEater($i,$j,$agent) + unset otherEaterColorWME($i,$j,$agent) + unset otherEaterScoreWME($i,$j,$agent) + unset otherEaterScore($i,$j,$agent) + } + } + ### If the content is a new eater, add special eater WME's + if {($nature == {eater}) && \ + ![info exists sensorEater($i,$j,$agent)]} { + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,$j,$agent) ^eater-color \ + $eaterColor($eaterName)] + scan $wme "%d" otherEaterColorWME($i,$j,$agent) + set wme [$tsiAgentInfo($agent,addFN) $agent \ + $sensorID($i,$j,$agent) ^eater-score \ + $eaterScore($eaterName)] + scan $wme "%d" otherEaterScoreWME($i,$j,$agent) + set otherEaterScore($i,$j,$agent) $eaterScore($eaterName) + set sensorEater($i,$j,$agent) $eaterObj + } + } + } + + updateSensorDisplay $agent +} diff --git a/eaters-3.0.8/simulator/process.tcl b/eaters-3.0.8/simulator/process.tcl new file mode 100644 index 0000000..b87f0fc --- /dev/null +++ b/eaters-3.0.8/simulator/process.tcl @@ -0,0 +1,1794 @@ +# +# $Id: process.tcl,v 1.3 2004/07/12 15:25:56 rmarinie Exp $ +# $Log: process.tcl,v $ +# Revision 1.3 2004/07/12 15:25:56 rmarinie +# fixed bugzilla bug 391 +# +# Revision 1.2 2003/10/21 18:26:42 snason +# hopefully eliminated error message after init-soar +# +# Revision 1.1.1.1 2003/06/16 13:48:35 swallace +# eaters initial cvs version (3.0.5) +# +# Revision 8.7 1998/10/26 15:48:50 swallace +# Prior to Release for 494 +# +# Revision 8.6 1998/10/25 14:52:30 swallace +# Synced w/ Mazin +# +# Revision 8.5 1998/10/08 13:54:45 swallace +# Released to John +# +# Revision 8.4 1998/10/07 13:12:12 swallace +# 8.1 Safe +# +# Revision 8.3 1998/10/05 12:55:48 swallace +# Release 2.0a (w/ new tsi30alpha) and new control panel etc. +# +# Revision 8.2 1998/10/02 13:49:18 swallace +# *** empty log message *** +# +# Revision 8.1 1998/09/18 16:44:35 swallace +# Works fine, but code is dirty. About to clean up. +# +# Revision 7.4 1998/08/21 12:10:46 swallace +# seems to work with remote agent proprioceptic feedback +# +# Revision 7.3 1998/08/19 15:44:12 swallace +# proprioceptic feedback added - movecount remains +# +# Revision 7.2 1998/08/19 13:03:54 swallace +# All Fixes :) except for propreoceptic feedback +# +# Revision 7.1 1998/06/23 13:45:21 swallace +# Works w/ eaters in Run Mode & Step Mode +# Works with CLIPS & soar. +# +# Revision 6.1 1998/06/02 19:02:53 swallace +# allows concurrent remote/local agents. +# +# Revision 5.1 1998/06/02 16:51:59 swallace +# 2 side step & run +# +# Revision 4.1 1998/06/01 22:15:42 swallace +# works using step on both sides. +# +# Revision 3.2 1998/05/28 20:21:29 swallace +# ready to work on WME wrappers +# +# Revision 3.1 1998/05/21 18:34:11 swallace +# Client/Server Interface allows info to be passed to client. +# +# Revision 2.1 1998/05/19 17:22:53 swallace +# *** empty log message *** +# +# Revision 1.2 1998/05/19 05:05:01 swallace +# works but soar is not completely seperated. +# +# +# + + +global heading +set heading(north) 90 +set heading(east) 0 +set heading(south) 270 +set heading(west) 180 + +global oppositeDir +set oppositeDir(north) south +set oppositeDir(east) west +set oppositeDir(south) north +set oppositeDir(west) east + + +global deltax deltay +set deltax(north) 0 +set deltay(north) -1 +set deltax(east) 1 +set deltay(east) 0 +set deltax(south) 0 +set deltay(south) 1 +set deltax(west) -1 +set deltay(west) 0 + +### cbc: counter for number of turns passed so far +global turn +set turn 0 + + +if {[info exists tsiConfig(sioDebug)] && $tsiConfig(sioDebug) > 2} { set boardWalls 0 } + +proc goalIsAccomplished {} { + global eaterList eaterX eaterY gridSize numberOfMoves + + # The goal is Never Accomplished! + return 0 + +} + + +proc envDestroyAgent { name } { + +# Nothing needed at this point + +} + +proc envLoadMap {path file} { + + cd $path + source $file +} + + + +proc initMap {} { + global gridSize boardColor boardWalls boardX boardY eaterList + + if [winfo exists .wGlobal] { + destroy .wGlobal + ## making the board gets confused if it thinks there are eaters + ## around, so temporarily pretend there aren't any + if [info exists eaterList] { + set tempEaterList $eaterList + unset eaterList + } + } + toplevel .wGlobal + wm title .wGlobal "Eaters Playing Board" + wm geometry .wGlobal +0+0 + ### Try to make the board a nice size + set gridSize [expr [expr [winfo screenwidth .wGlobal] / 3] / \ + [expr 2 + $boardX]] + canvas .wGlobal.c -width [expr ($boardX+2) * $gridSize] \ + -height [expr ($boardY+2) * $gridSize] \ + -background $boardColor + pack .wGlobal.c -side top + frame .wGlobal.fScore + + + pack .wGlobal.fScore -side left + ## First fill the world with food + for {set i 1} {$i <= $boardX} {incr i} { + for {set j 1} {$j <= $boardY} {incr j} { + createFood .wGlobal.c $i $j + } + } + ## Put down the border walls + for {set i 0} {$i <= ($boardX+1)} {incr i} { + createWall .wGlobal.c $i 0 + createWall .wGlobal.c $i [expr $boardY+1] + } + for {set j 1} {$j <= $boardY} {incr j} { + createWall .wGlobal.c 0 $j + createWall .wGlobal.c [expr $boardX+1] $j + } + + .wGlobal.c bind eater {selectEater %W %x %y} + bind .wGlobal.c {setKeyInits %x %y} + bind .wGlobal.c { + eval "startEater [getLocationVector %x %y] $tsiCurrentAgentSourceDir $tsiCurrentAgentSourceFile $currentAgentColor" + updateAvailableAgentColors + } + + if [info exists tempEaterList] { + return $tempEaterList + } + return 0 + +} + +proc setKeyInits {x y} { + global key_initialx key_initialy + set key_initialx $x + set key_initialy $y +} + +proc getLocationVector {x y} { + global key_initialx key_initialy gridSize + + # Determine dominant motion axis + if {[expr abs($key_initialy - $y)] > [expr abs($key_initialx - $x)]} { + set key_initialx -1 + } else { + set key_initialy -1 + } + + # Set initial direction + if {$key_initialy != -1} { + if {$y < $key_initialy} { + # North + set dir 0 + } else { + # South + set dir 2 + } + } + if {$key_initialx != -1} { + if {$x < $key_initialx} { + # West + set dir 3 + + } else { + # East + set dir 1 + } + } + + set x [.wGlobal.c canvasx $x] + set y [.wGlobal.c canvasy $y] + + set x [expr floor($x/$gridSize)] + set y [expr floor($y/$gridSize)] + + + return [list $x $y $dir] +} + + +proc loadMap {} { + source [file join simulator board1.map] +} +proc randomMap {} { + global eaterList + + set eaters [initMap] + + ## And add some random walls (these will delete any food they land on) + randomWalls .wGlobal.c + + if { $eaters != 0 } { + set eaterList $eaters + } + + resetEaters +} + +proc selectEater {w x y} { + global currentEater eaterObjectName + + + set x [$w canvasx $x] + set y [$w canvasy $y] + + set whichOne [$w find closest $x $y] + if { [lsearch [$w gettags $whichOne] eater] < 0 } { + return + } else { + + if [info exists currentEater] { + pack forget .wAgentInfo.$currentEater + } + set currentEater $eaterObjectName($whichOne) + pack .wAgentInfo.$currentEater -side left -padx 3 -pady 3 + } + + return $whichOne + +} + +proc resetEaters {} { + global eaterList eaterTick eaterScore worldCount agentMoved \ + numberOfMoves localAgents + + if [info exists eaterList] { + foreach eater $eaterList { + set eaterTick($eater) 0 + set eaterScore($eater) 0 + set numberOfMoves($eater) 0 + eval placeEater $eater [eaterStartLocation] + + } + } + if [info exists localAgents] { + foreach eater $localAgents { + $eater eval tsiDisplayAndSendCommand init-soar + } + } + set worldCount 0 +} + +proc eaterStartLocation {} { + return [list -1 -1 -1] +} + +proc restartMap {} { + global boardX boardY + ## Refill the empty spaces in the world with food + for {set i 1} {$i <= $boardX} {incr i} { + for {set j 1} {$j <= $boardY} {incr j} { + if {![wallExists .wGlobal.c $i $j] && ![foodExists .wGlobal.c $i $j]} { + createFood .wGlobal.c $i $j + } + } + } + ## Put the eaters back down + resetEaters +} + +proc createWall {w x y} { + global gridSize wallEdgeColor wallColor + ## destroy anything that might be where we are about to put the wall + set contents [$w find enclosed [expr $x*$gridSize-1] [expr $y*$gridSize-1] \ + [expr ($x+1)*$gridSize] [expr ($y+1)*$gridSize]] + deleteObjects $w $contents + $w create rectangle [expr $x*$gridSize] [expr $y*$gridSize] \ + [expr ($x+1)*$gridSize-1] [expr ($y+1)*$gridSize-1] \ + -outline $wallEdgeColor -fill $wallColor -tags wall +} + +proc deleteObjects {w objs} { + ### We don't need to maintain a deleteList for the input link any more + ### since input is sensor-based now + eval $w delete $objs +} + + +proc createFood {w x y} { + global gridSize foodSize foodEdgeColor normalfoodColor bonusfoodColor \ + tsiConfig + ## squares whose x-coordinate is a multiple of 3, contain + ## bonus food, while the rest of the squares contain normal food + if {[expr $x%3] != 0} { + $w create oval [expr ($x+0.5-($foodSize/2)) * $gridSize] \ + [expr ($y+0.5-($foodSize/2)) * $gridSize] \ + [expr ($x+0.5+($foodSize/2)) * $gridSize] \ + [expr ($y+0.5+($foodSize/2)) * $gridSize] \ + -outline $foodEdgeColor -fill $normalfoodColor \ + -tags normalfood + } else { + $w create rectangle [expr ($x+0.5-($foodSize/2)) * $gridSize] \ + [expr ($y+.5-($foodSize/2)) * $gridSize] \ + [expr ($x+.5+($foodSize/2)) * $gridSize] \ + [expr ($y+.5+($foodSize/2)) * $gridSize] \ + -outline $foodEdgeColor -fill $bonusfoodColor \ + -tags bonusfood + #$w create text [expr ($x+.5)*$gridSize] [expr ($y+.5)*$gridSize] \ + # -text {*} -font 8x13bold -fill $bonusfoodColor -tags bonusfood + + + } +} + +proc wallExists {w x y} { + global gridSize + set contents [$w find enclosed [expr $x*$gridSize-1] [expr $y*$gridSize-1] \ + [expr ($x+1)*$gridSize] [expr ($y+1)*$gridSize]] + foreach c $contents { + if {[lsearch [$w itemcget $c -tags] wall] >= 0} { + return 1 + } + } + return 0 +} + +proc foodExists {w x y} { + global gridSize + set contents [$w find enclosed [expr $x*$gridSize-1] [expr $y*$gridSize-1] \ + [expr ($x+1)*$gridSize] [expr ($y+1)*$gridSize]] + foreach c $contents { + if {([lsearch [$w itemcget $c -tags] normalfood] >= 0) || \ + ([lsearch [$w itemcget $c -tags] bonusfood] >= 0)} { + return 1 + } + } + return 0 +} + +proc randomWalls {w} { + global gridSize boardX boardY boardWalls + + + for {set i 1} {$i <= $boardWalls} {incr i} { + set x [expr [rand [expr $boardX-2]]+2] + set y [expr [rand [expr $boardY-2]]+2] + set length [expr [rand [expr ($boardX+$boardY)/4]] + 1] + set dx 0 + set dy 0 + switch [rand 4] { + 0 {set dy -1; + set length [expr [rand [expr $boardY-2]]+2]} + 1 {set dx 1; + set length [expr [rand [expr $boardX-2]]+2]} + 2 {set dy 1; + set length [expr [rand [expr $boardY-2]]+2]} + 3 {set dx -1; + set length [expr [rand [expr $boardX-2]]+2]} + } + ## Don't let any walls touch any other walls, so we can make sure that + ## all points on the board are reachable. + ## Before actually drawing the wall, me find out which squares are + ## ineligible + set noWall "" + set tx $x + set ty $y + for {set j 1} {$j <= $length} {incr j} { + set stopLoop 0 + if {($tx < 1) || ($tx > $boardX) || ($ty < 1) || ($ty > $boardY)} { + lappend noWall $j + set stopLoop 1 + } + if !$stopLoop { + for {set k [expr $tx-1]} {$k <= ($tx+1)} {incr k} { + for {set l [expr $ty-1]} {$l <= ($ty+1)} {incr l} { + if [wallExists $w $k $l] { + lappend noWall $j + set stopLoop 1 + break + } + } + if $stopLoop {break} + } + } + incr tx $dx + incr ty $dy + } + ## Now let's actually draw the sucker + for {set j 1} {$j <= $length} {incr j} { + if {[lsearch $noWall $j] < 0} { + createWall $w $x $y + } + incr x $dx + incr y $dy + } + } +} + +proc drawEater {w name} { + global ticksPerEaterCycle eaterOpenMouth heading \ + eaterEdgeColor eaterSize gridSize \ + eaterX eaterY eaterColor eaterTick eaterDir eaterScore \ + eaterObjectName eaterObject openSize + + if {$eaterTick($name) < ($ticksPerEaterCycle*.5)} { + + set openSize [expr ($eaterTick($name)/($ticksPerEaterCycle*.5)) * \ + $eaterOpenMouth] + } else { + + set openSize [expr (($ticksPerEaterCycle-$eaterTick($name)) / \ + ($ticksPerEaterCycle*.5))*$eaterOpenMouth] + } + + set eater [$w find withtag $name] + + if {$eater != ""} { + $w coords $eater [expr $eaterX($name)+$gridSize*.5*(1-$eaterSize)] \ + [expr $eaterY($name)+$gridSize*.5*(1-$eaterSize)] \ + [expr $eaterX($name)+$gridSize*.5*(1+$eaterSize)] \ + [expr $eaterY($name)+$gridSize*.5*(1+$eaterSize)] + $w itemconfigure $eater \ + -start [expr $heading($eaterDir($name))+($openSize/2)] \ + -extent [expr 359-$openSize] + } else { + set eater [$w create arc \ + [expr $eaterX($name)+0.5*$gridSize*(1-$eaterSize)] \ + [expr $eaterY($name)+0.5*$gridSize*(1-$eaterSize)] \ + [expr $eaterX($name)+0.5*$gridSize*(1+$eaterSize)] \ + [expr $eaterY($name)+0.5*$gridSize*(1+$eaterSize)] \ + -start [expr $heading($eaterDir($name))+($openSize/2)] \ + -extent [expr 359-$openSize] \ + -outline $eaterEdgeColor -fill $eaterColor($name) \ + -tags "eater $name"] + set eaterObjectName($eater) $name + set eaterObject($name) $eater + } +} + +proc tickSimulation {w} { + global globalTick ticksPerMove gridSize ticksPerEaterCycle deltax deltay \ + eaterList eaterDir eaterColor eaterTick eaterScore \ + eaterX eaterY eaterOldX eaterOldY eaterObjectName \ + normalfoodScore bonusfoodScore currentBumpList deleteList \ + moveDir jumpDir initialdir oldtx oldty jumpPenalty agentMoved \ + tsiConfig numberOfMoves + + if { $tsiConfig(sioDebug) > 3 } { puts "tickSimulation -- (begin)" } + + if [info exists globalTick] { + set globalTick [expr ($globalTick + 1) % $ticksPerMove] + } else { + set globalTick 1 + } + + if [info exists eaterList] { + foreach eaterName $eaterList { + set eater [$w find withtag $eaterName] + if {$eater == ""} { + tk_dialog .error Warning \ + "$eaterName eater canvas object not found" warning 0 Ok + continue + } + if [info exists eaterTick($eaterName)] { + set eaterTick($eaterName) \ + [expr ($eaterTick($eaterName)+1)%$ticksPerEaterCycle] + } else { + set eaterTick($eaterName) 0 + } + ## If we have completed a global tick cycle, move the eaters, + ## otherwise just redraw them with a new mouth + if !$globalTick { + + #SB May 02 1997 + ## The direction should cause just a step-move instead of keep + ## the agent moving forever + + ## oldtx and oldty are the eater's current location + ## tx and ty correspond to the potential new location + ## The eater can't move to the new location if there's a wall + ## there, and all four numbers need to be saved in order to + ## check whether any eaters bumped into each other + set oldtx($eaterName) $eaterX($eaterName) + set oldty($eaterName) $eaterY($eaterName) + + if { $tsiConfig(sioDebug) > 5 } { puts " !Global Tick... " } + if [info exists moveDir($eaterName)] { + + set tx($eaterName) \ + [expr $eaterX($eaterName) + \ + $gridSize*$deltax($moveDir($eaterName))] + set ty($eaterName) \ + [expr $eaterY($eaterName) + \ + $gridSize*$deltay($moveDir($eaterName))] + set oldtx($eaterName) $tx($eaterName) + set oldty($eaterName) $ty($eaterName) + set eaterDir($eaterName) $moveDir($eaterName) + if { $tsiConfig(sioDebug) > 4 } { + puts " ! $eaterName Moved $moveDir($eaterName)" + } + unset moveDir($eaterName) + set agentMoved($eaterName) 1 + + incr numberOfMoves($eaterName) + } elseif [info exists jumpDir($eaterName)] { + set tx($eaterName) \ + [expr $eaterX($eaterName) + \ + $gridSize*2*$deltax($jumpDir($eaterName))] + set ty($eaterName) \ + [expr $eaterY($eaterName) + \ + $gridSize*2*$deltay($jumpDir($eaterName))] + set oldtx($eaterName) $tx($eaterName) + set oldty($eaterName) $ty($eaterName) + incr eaterScore($eaterName) -$jumpPenalty + set eaterDir($eaterName) $jumpDir($eaterName) + unset jumpDir($eaterName) + set agentMoved($eaterName) 1 + incr numberOfMoves($eaterName) + } elseif [info exists initialdir($eaterName)] { + set eaterDir $initialdir($eaterName) + unset initialdir($eaterName) + } elseif [info exists oldtx($eaterName)] { + set tx($eaterName) $oldtx($eaterName) + set ty($eaterName) $oldty($eaterName) + } + + ## cx and cy are the center coordinates of the tx,ty grid square + set cx($eaterName) [expr $tx($eaterName) + 0.5*$gridSize] + set cy($eaterName) [expr $ty($eaterName) + 0.5*$gridSize] + ## find out if anything is in the destination square + set contents \ + [$w find overlapping $cx($eaterName) $cy($eaterName) \ + $cx($eaterName) $cy($eaterName)] + ## if there is not a wall there, we can move there (for the time + ## being)...if there is a wall there, we can't move, but record + ## where we are in case we get bumped. + set eaterOldX($eaterName) $eaterX($eaterName) + set eaterOldY($eaterName) $eaterY($eaterName) + set noWall 1 + ### This assumes nothing is ever in a square along with a wall + if {[lsearch [$w itemcget $contents -tags] wall] < 0} { + set eaterX($eaterName) $tx($eaterName) + set eaterY($eaterName) $ty($eaterName) + } + } + drawEater $w $eaterName + } + ## If the eaters have just moved, check whether any have bumped into each + ## other...if so, put them back where they were. + if !$globalTick { + ## Erase any old bumps that are drawn on the board + foreach bump [$w find withtag bump] { + $w delete $bump + foreach agent $eaterList { + if [info exists deleteList($agent)] { + lappend deleteList($agent) $bump + } else { + set deleteList($agent) $bump + } + } + if [info exists currentBumpList] { + unset currentBumpList + } + } + ## Now check whether any eaters just tried to pass through each + ## other. If so, they bumped, so move them back. + for {set i 0} {$i < [expr [llength $eaterList] - 1]} {incr i} { + set e1 [lindex $eaterList $i] + for {set j [expr $i + 1]} {$j < [llength $eaterList]} {incr j} { + set e2 [lindex $eaterList $j] + if {($eaterX($e1)==$eaterOldX($e2)) && \ + ($eaterY($e1)==$eaterOldY($e2)) && \ + ($eaterX($e2)==$eaterOldX($e1)) && \ + ($eaterY($e2)==$eaterOldY($e1))} { + set obj [drawBump $w [expr 0.5*($eaterX($e1)+$eaterX($e2))] \ + [expr 0.5*($eaterY($e1)+$eaterY($e2))]] + if [info exists currentBumpList] { + lappend currentBumpList [list $obj [list $e1 $e2]] + } else { + set currentBumpList [list [list $obj [list $e1 $e2]]] + } + bumpEaters $w $e1 $e2 + } + } + } + ## Now see if any eaters are on the same square as each other, and + ## bump them back. + set bumpList "" + foreach e $eaterList { + ## This check is to prevent reflexive bumps (i.e., if a bumps + ## into b, we don't also want b to bump into a) + if {[lsearch $bumpList $e] < 0} { + set contents [eval $w find overlapping [$w coords $e]] + set bumpers "" + foreach c $contents { + if {[lsearch [$w itemcget $c -tags] eater] >= 0} { + lappend bumpers $eaterObjectName($c) + lappend bumpList $eaterObjectName($c) + } + if {[llength $bumpers] >= 2} { + set obj [drawBump $w $eaterX($e) $eaterY($e)] + if [info exists currentBumpList] { + lappend currentBumpList [list $obj $bumpers] + } else { + set currentBumpList [list [list $obj $bumpers]] + } + eval bumpEaters $w $bumpers + } + } + } + } + ## Finally, see if we are sitting on any food, and eat it. + foreach e $eaterList { + eatFood $w $e + } + } + } +} + +proc eatFood {w name} { + global eaterScore normalfoodScore bonusfoodScore + + + set contents [eval $w find overlapping [$w coords $name]] + + foreach c $contents { + + set lin [lsearch [$w itemcget $c -tags] normalfood] + set lib [lsearch [$w itemcget $c -tags] bonusfood] + + if {[lsearch [$w itemcget $c -tags] normalfood] >= 0} { + incr eaterScore($name) $normalfoodScore + $w delete $c + } + + if {[lsearch [$w itemcget $c -tags] bonusfood] >= 0} { + incr eaterScore($name) $bonusfoodScore + $w delete $c + } + } +} + +proc bumpEaters {w args} { + global eaterScore +# puts "BUMP! $args" + set totalScore 0 + foreach e $args { + incr totalScore $eaterScore($e) + eval placeEater $e + } + set averageScore [expr $totalScore/[llength $args]] + foreach e $args { + set eaterScore($e) $averageScore + } +} + + +### Assume x,y describes the upper left corner of the grid square +proc drawBump {w x y} { + global gridSize bumpOuterRadius bumpInnerRadius bumpColor + set cx [expr $x+0.5*$gridSize] + set cy [expr $y+0.5*$gridSize] + set ox1 $cx + set oy1 [expr $cy-$bumpOuterRadius] + set ox2 [expr $cx+0.7*$bumpOuterRadius] + set oy2 [expr $cy-0.7*$bumpOuterRadius] + set ox3 [expr $cx+$bumpOuterRadius] + set oy3 $cy + set ox4 [expr $cx+0.7*$bumpOuterRadius] + set oy4 [expr $cy+0.7*$bumpOuterRadius] + set ox5 $cx + set oy5 [expr $cy+$bumpOuterRadius] + set ox6 [expr $cx-0.7*$bumpOuterRadius] + set oy6 [expr $cy+0.7*$bumpOuterRadius] + set ox7 [expr $cx-$bumpOuterRadius] + set oy7 $cy + set ox8 [expr $cx-0.7*$bumpOuterRadius] + set oy8 [expr $cy-0.7*$bumpOuterRadius] + set ix1 $cx + set iy1 [expr $cy-$bumpInnerRadius] + set ix2 [expr $cx+0.7*$bumpInnerRadius] + set iy2 [expr $cy-0.7*$bumpInnerRadius] + set ix3 [expr $cx+$bumpInnerRadius] + set iy3 $cy + set ix4 [expr $cx+0.7*$bumpInnerRadius] + set iy4 [expr $cy+0.7*$bumpInnerRadius] + set ix5 $cx + set iy5 [expr $cy+$bumpInnerRadius] + set ix6 [expr $cx-0.7*$bumpInnerRadius] + set iy6 [expr $cy+0.7*$bumpInnerRadius] + set ix7 [expr $cx-$bumpInnerRadius] + set iy7 $cy + set ix8 [expr $cx-0.7*$bumpInnerRadius] + set iy8 [expr $cy-0.7*$bumpInnerRadius] + return [$w create polygon $ox1 $oy1 $ix1 $iy1 $ox2 $oy2 $ix2 $iy2 \ + $ox3 $oy3 $ix3 $iy3 $ox4 $oy4 $ix4 $iy4 \ + $ox5 $oy5 $ix5 $iy5 $ox6 $oy6 $ix6 $iy6 \ + $ox7 $oy7 $ix7 $iy7 $ox8 $oy8 $ix8 $iy8 \ + -fill $bumpColor -tags bump] +} + +#### simple pseudo-random number generator +global lastvalue +set lastvalue [expr [clock clicks]%65536] +proc rawrand {} { + global lastvalue +# per Knuth 3.6: +# 65277 mod 8 = 5 (since 65536 is a power of 2) +# c/m = .5-(1/6)\sqrt{3} +# c = 0.21132*m = 13849, and should be odd. + set lastvalue [expr (65277*$lastvalue+13849)%65536] + set lastvalue [expr ($lastvalue+65536)%65536] + return $lastvalue +} +proc rand {base} { + set rr [rawrand] + return [expr ($rr*$base)/65536] +} + + +proc newRange value { + global eaterList sensorRange + set sensorRange $value + if [info exists eaterList] { + foreach name $eaterList { + drawSensorGrid $name + } + } +} + +proc ldelete {eaterList name} { + set ix [lsearch -exact $eaterList $name] + if {$ix >= 0} { + return [lreplace $eaterList $ix $ix] + } else { + return $eaterList + } +} + + +rename destroyAgent ETCPDestroyAgent + +proc destroyAgent {newname} { + global eaterList eaterNameList eaterColor eaterColorByName + + ETCPDestroyAgent $newname + + set name [reverseEaterName $newname] + set color [reverseEaterColor $newname] + + ### Clean up all the input-link stuff for this name, in case a new + ### one comes along. Have to do this before deleting the canvas + ### object. + removeInputLink $newname + set obj [.wGlobal.c find withtag $newname] + .wGlobal.c delete $obj + destroy .wAgentInfo.$newname + set eaterList [ldelete $eaterList $newname] + if {$eaterList == {}} { + destroy .wAgentInfo + } + set eaterNameList [ldelete $eaterNameList $name] + #unset eaterColorByName($name) + unset eaterColor($newname) + + updateAvailableAgentColors + +} + + +proc eaterName {name color} { + # return $name$color + return $color +} + +proc reverseEaterName {newname} { + global eaterNameByNewname + return $eaterNameByNewname($newname) +} + +proc reverseEaterColor {newname} { + global eaterColor + return $eaterColor($newname) +} + +proc addRemoteAgentToEnvironment {socket} { + global possibleEaterColors eaterColor eaterTick eaterNameList agentMoved \ + eaterNameByNewname eaterColorByName soarTimeUnit moveCount \ + eaterScore eaterList tsiConfig numberOfMoves + + if { $tsiConfig(sioDebug) > 3 } { + puts "addRemoteAgentToEnvironment (begin)" + } + # First, grab an unused color. + foreach color $possibleEaterColors { + set newColor $color + foreach {key usedColor} [array get eaterColor] { + if {[string compare $color $usedColor] == 0} { + set newColor {nil} + break + } + } + if [string compare $newColor "nil"] { break } + } + + if { $tsiConfig(sioDebug) } { + puts " -The Agent from socket: $socket is Colored: $newColor" + } + if { [string compare $newColor "nil"] == 0} { + return "error" + } + set newname [eaterName $socket $newColor] +# puts "CREATING REMOTE AGENT..." + createNewRemoteAgent $newname $socket +# puts "CREATED... REGISTERING" + registerRemoteAgent $newname $socket +# puts "REGISTERED" + + # This needs to be looked at, now it relys on the fact that + # the eaters name corresponds to its socket id + $newname alias sendInput sendInput $newname + + + $newname alias setUpInputLink setUpInputLink $newname + $newname alias updateInputLink updateInputLink $newname + $newname alias removeInputLink removeInputLink $newname + $newname alias setWalkDir setWalkDir $newname + $newname alias setJumpDir setJumpDir $newname + + $newname alias run environmentRun + $newname alias step environmentStep + $newname alias stop environmentStop + # $newname alias stop-soar stop + + if {[info exists eaterColorByName($socket)]} { + lappend eaterColorByName($socket) $color + lappend eaterColor($newname) $color + } else { +# set eaterColorByName($socket) $color + set eaterColor($newname) $color + } + + set eaterNameByNewname($newname) $socket + if [info exists eaterList] { + lappend eaterList $newname + } else { + set eaterList $newname + } + if [info exists eaterNameList] { + lappend eaterNameList $socket + } else { + set eaterNameList $socket + } + set eaterTick($newname) 0 + set eaterScore($newname) 0 + set agentMoved($newname) 0 + set numberOfMoves($newname) 0 + eval placeEater $newname [eaterStartLocation] + + setupEaterSensor $newname $color + + updateAvailableAgentColors + + if { $tsiConfig(sioDebug) > 3 } { + puts "addRemoteAgentToEnvironment (end)" + } + return "ok $newname" + +} + + + + +proc initEaterOutputFile {filename color eaterName} { + + global eaterOutputFile + + + set fileID [open $filename-$color.log w 0660] + puts "Opened EaterOutputFile for $eaterName" + set eaterOutputFile($eaterName) $fileID +} + +proc simulatorQuit {} { + + global eaterOutputFile + + + if [info exists eaterOutputFile ] { + foreach {agent file} [array get eaterOutputFile] { + puts "Closing $file" + close $file + } + } +} + +proc startEater {x y dir path name color} { + global eaterList eaterColor eaterTick eaterScore eaterNameList agentMoved \ + eaterNameByNewname eaterColorByName \ + soarTimeUnit moveCount possibleEaterColors currentColor \ + tsiCurrentAgentSourceDir tsiSimulatorPath numberOfMoves \ + ETCPConfig + + #set initialDir [pwd] + #if [catch {cd $path} msg] { +# error "Could Not Change to Directory '$path' to Load Eater : $msg" +# + #return + #} + + if { $color == {} } { + # we are out of colors. + tk_dialog .error Error \ + "The Maximum Number of Eaters has Already Been Created. (Out of Colors)" error 0 Ok + error "Out of Colors" + } else { + incr currentColor + } + + set newname [eaterName $name $color] + if {[info exists eaterList] && [lsearch $eaterList $newname] >= 0} { + tk_dialog .error Error \ + "An eater with color $newname already exists...not creating a new one\nYou must choose a different color." \ + error 0 Ok + error "Tried to create duplicate eaters" + } + + + # initEaterOutputFile $name $color $newname + + # the new version of this routine should source this code automatically! + createNewAgent $newname $tsiCurrentAgentSourceDir "$name.soar" + + if {![interp exists $newname]} { + return + } + + if {$soarTimeUnit == {e}} { + $newname eval input-period 0 + } else { + $newname eval input-period 1 + } + $newname alias setUpInputLink setUpInputLink $newname + $newname alias updateInputLink updateInputLink $newname + $newname alias removeInputLink removeInputLink $newname + $newname alias setWalkDir setWalkDir $newname + $newname alias setJumpDir setJumpDir $newname + $newname eval rename run run-soar + $newname alias run environmentRun + $newname alias step environmentStep + $newname alias stop environmentStop +# $newname alias stop-soar stop +# $newname eval {.tsw.frame.step configure \ +# -command {tsiDisplayAndSendCommand step}} + if $ETCPConfig(afterDecision) { +# $newname eval monitor -add after-decision-phase-cycle \"stop-soar -self \{\}\" dp1 +# changed to fix bugzilla bug 391 + $newname eval monitor -add after-decision-phase-cycle \"stop-soar -self" dp1 + } + + if [catch {$newname eval \ + [list uplevel #0 source [file join simulator agent.tcl]]} msg] { + tk_dialog .error Warning \ + "Couldn't load interface code: $msg" warning 0 Ok + } + + if {[info exists eaterColorByName($name)]} { + lappend eaterColorByName($name) $color + lappend eaterColor($newname) $color + } else { +# set eaterColorByName($name) $color + set eaterColor($newname) $color + } + set eaterNameByNewname($newname) $name + if [info exists eaterList] { + lappend eaterList $newname + } else { + set eaterList $newname + } + if [info exists eaterNameList] { + lappend eaterNameList $name + } else { + set eaterNameList $name + } + set eaterTick($newname) 0 + set eaterScore($newname) 0 + set agentMoved($newname) 0 + set numberOfMoves($newname) 0 + eval placeEater $newname $x $y $dir + + setupEaterSensor $newname $color + $newname eval addTSIProductionMenu .tsw + +} + +proc setupEaterSensor {name color} { + global sensorGridSize sensorRange currentEater + + + ### Create the eater sensor display if it doesn't already exist. + if ![winfo exists .wAgentInfo] { + toplevel .wAgentInfo + ## Try to put the display in a convenient place + set bx [winfo width .wGlobal] + set my [winfo height .] + set x [expr 15 + $bx] + set y [expr 35 + $my] + wm geometry .wAgentInfo +$x+$y + wm title .wAgentInfo {Eaters Info} + frame .wAgentInfo.general + label .wAgentInfo.general.movelabel -text {World Count =} + label .wAgentInfo.general.worldcount -textvariable worldCount + pack .wAgentInfo.general.movelabel .wAgentInfo.general.worldcount \ + -side left + frame .wAgentInfo.general.space -width 15 + pack .wAgentInfo.general.space -side left + # label .wAgentInfo.general.info -text {X = Reload agent code} + # pack .wAgentInfo.general.info -side right + pack .wAgentInfo.general -side top -padx 3 -pady 3 + } + + ### And then add in the sensor display for this eater. + frame .wAgentInfo.$name + frame .wAgentInfo.$name.info + # button .wAgentInfo.$name.info.load -text "X" \ + \# -command "loadController $name $color" + frame .wAgentInfo.$name.info.numbers + frame .wAgentInfo.$name.info.numbers.score + label .wAgentInfo.$name.info.numbers.score.label -text "Score:" + label .wAgentInfo.$name.info.numbers.score.value \ + -textvariable eaterScore($name) + pack .wAgentInfo.$name.info.numbers.score.label \ + .wAgentInfo.$name.info.numbers.score.value -side left + frame .wAgentInfo.$name.info.numbers.count + label .wAgentInfo.$name.info.numbers.count.label -text "Moves:" + label .wAgentInfo.$name.info.numbers.count.value \ + -textvariable numberOfMoves($name) + pack .wAgentInfo.$name.info.numbers.count.label \ + .wAgentInfo.$name.info.numbers.count.value -side left + + pack .wAgentInfo.$name.info.numbers.score \ + .wAgentInfo.$name.info.numbers.count -side top + # pack .wAgentInfo.$name.info.load -padx 5 -pady 5 \ + \# -side left + pack .wAgentInfo.$name.info.numbers -side left + canvas .wAgentInfo.$name.sensors \ + -width [expr $sensorGridSize*(2*$sensorRange+1)] \ + -height [expr $sensorGridSize*(2*$sensorRange+1)] \ + -relief raised + + pack .wAgentInfo.$name.info .wAgentInfo.$name.sensors -side top + + + + if [info exists currentEater ] { + + pack forget .wAgentInfo.$currentEater + } + set currentEater $name + pack .wAgentInfo.$name -side left -padx 3 -pady 3 + + + drawSensorGrid $name + +} + +proc drawSensorGrid {namecolor} { + global drawnSensorRange sensorRange sensorGridSize + if {![info exists drawnSensorRange($namecolor)] || \ + ($drawnSensorRange($namecolor) != $sensorRange)} { + .wAgentInfo.$namecolor.sensors delete sensorGrid + .wAgentInfo.$namecolor.sensors configure \ + -width [expr $sensorGridSize*(2*$sensorRange+1)] \ + -height [expr $sensorGridSize*(2*$sensorRange+1)] + } + for {set i -$sensorRange} {$i <= $sensorRange} {incr i} { + for {set j -$sensorRange} {$j <= $sensorRange} {incr j} { + .wAgentInfo.$namecolor.sensors create rectangle \ + [expr ($sensorRange+$i)*$sensorGridSize+2] \ + [expr ($sensorRange+$j)*$sensorGridSize+2] \ + [expr ($sensorRange+$i+1)*$sensorGridSize+1] \ + [expr ($sensorRange+$j+1)*$sensorGridSize+1] \ + -tags sensorGrid + } + } + set drawnSensorRange($namecolor) $sensorRange +} + +proc updateSensorDisplay {name} { + global typeOfObj foodSize foodEdgeColor wallEdgeColor eaterEdgeColor \ + normalfoodColor bonusfoodColor wallColor \ + heading eaterDir openSize sensorRange sensorGridSize eaterList \ + eaterColor sensorEater eaterSize eaterObjectName + .wAgentInfo.$name.sensors delete sensorInfo + for {set i -$sensorRange} {$i <= $sensorRange} {incr i} { + for {set j -$sensorRange} {$j <= $sensorRange} {incr j} { + if [info exists typeOfObj($i,$j,$name)] { + switch $typeOfObj($i,$j,$name) { + bonusfood { + ## typeOfObj appears to use "normal" coordinates, but + ## that's not what the canvas uses. + + #puts "Found Bonus food: $i, $j" + #.wAgentInfo.$name.sensors create text \ + # [expr ($i+$sensorRange+.6)*$sensorGridSize] \ + # [expr ($j+$sensorRange+.6)*$sensorGridSize] \ + # -text {*} -font 8x13bold -fill $bonusfoodColor \ + # -tags sensorInfo + + .wAgentInfo.$name.sensors create rectangle \ + [expr ($i+$sensorRange+.5-($foodSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5-($foodSize/2))*$sensorGridSize+2] \ + [expr ($i+$sensorRange+.5+($foodSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5+($foodSize/2))*$sensorGridSize+2] \ + -outline $foodEdgeColor -fill $bonusfoodColor \ + -tags sensorInfo + } + normalfood { + .wAgentInfo.$name.sensors create oval \ + [expr ($i+$sensorRange+.5-($foodSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5-($foodSize/2))*$sensorGridSize+2] \ + [expr ($i+$sensorRange+.5+($foodSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5+($foodSize/2))*$sensorGridSize+2] \ + -outline $foodEdgeColor -fill $normalfoodColor \ + -tags sensorInfo + } + wall { + .wAgentInfo.$name.sensors create rectangle \ + [expr ($i+$sensorRange)*$sensorGridSize+2] \ + [expr ($j+$sensorRange)*$sensorGridSize+2] \ + [expr ($i+$sensorRange+1)*$sensorGridSize+1] \ + [expr ($j+$sensorRange+1)*$sensorGridSize+1] \ + -outline $wallEdgeColor -fill $wallColor \ + -tags sensorInfo + } + eater { + .wAgentInfo.$name.sensors create arc \ + [expr ($i+$sensorRange+.5-($eaterSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5-($eaterSize/2))*$sensorGridSize+2] \ + [expr ($i+$sensorRange+.5+($eaterSize/2))*$sensorGridSize+2] \ + [expr ($j+$sensorRange+.5+($eaterSize/2))*$sensorGridSize+2] \ + -start [expr \ + $heading($eaterDir($eaterObjectName($sensorEater($i,$j,$name)))) \ + + ($openSize/2)] \ + -extent [expr 359-$openSize] \ + -outline $eaterEdgeColor \ + -fill $eaterColor($eaterObjectName($sensorEater($i,$j,$name)))\ + -tags sensorInfo + } + } + } + } + } +} + + +proc placeEater {name {xloc -1} {yloc -1} {orient -1}} { + global boardX boardY gridSize eaterX eaterY eaterDir xplacer yplacer \ + tsiConfig + + set badlocation 1 + + if { $tsiConfig(sioDebug) > 3 } { puts "placeEater -- (begin)" } + + + + if { $tsiConfig(sioDebug) > 2 } { + puts "sioDebug -- placing 1st eater in NW corner" + set x $gridSize + set y $gridSize + } else { + if { $xloc > 0 && $xloc <= $boardX } { + set x [expr $xloc*$gridSize] + } else { + set x [expr ([rand $boardX]+1)*$gridSize] + } + if { $yloc > 0 && $yloc <= $boardY } { + set y [expr $yloc*$gridSize] + } else { + set y [expr ([rand $boardY]+1)*$gridSize] + } + } + while {$badlocation} { + + set contents [.wGlobal.c find enclosed [expr $x-1] [expr $y-1] \ + [expr $x+$gridSize] [expr $y+$gridSize]] + set gridOkay 1 + foreach c $contents { + if {([lsearch [.wGlobal.c itemcget $c -tags] wall] >= 0) || \ + ([lsearch [.wGlobal.c itemcget $c -tags] eater] >= 0)} { + set gridOkay 0 + break + } + } + if $gridOkay { + set eaterX($name) $x + set eaterY($name) $y + set badlocation 0 + } + set x [expr ([rand $boardX]+1)*$gridSize] + set y [expr ([rand $boardY]+1)*$gridSize] + + + } + + if { $orient < 0 || $orient > 3 } { + ## pick a random direction to start, if one wasn't supplied + set orient [rand 4] + } + if { $tsiConfig(sioDebug) > 2 } { + puts "sioDegub -- setting eater direction 'East'" + set orient 1 + } + switch $orient { + 0 { + set eaterDir($name) north + } + 1 { + set eaterDir($name) east + } + 2 { + set eaterDir($name) south + } + 3 { + set eaterDir($name) west + } + } + set initialdir($name) $eaterDir($name) + drawEater .wGlobal.c $name + eatFood .wGlobal.c $name + + if { $tsiConfig(sioDebug) > 3 } { puts "placeEater -- (end)" } +} + + + + +proc environmentRun {args} { + global runningSimulation + + tsiOnEnvironmentRun + + ### We'll try to be sneaky here, and assume that if someone gave run + ### an argument (like in the TSI buttons and menus), they meant to + ### step + if {$args!=""} { + set n 1 + scan $args %d n + + for {set i 1} {$i <= $n} {incr i} { + environmentStep + } + return + } + set runningSimulation 1 + runSimulation .wGlobal.c +} + +proc environmentStep {} { + global runningSimulation + + tsiOnEnvironmentStep + set runningSimulation 0 + runSimulation .wGlobal.c +} + +proc environmentStop {} { + global runningSimulation + + # This can be called in one of three ways : + # 1. By Pressing the STOP Button + # 2. As a response to a client's stop-simulation request + # 3. Via the RunSimulation Method as a result of runningSimulation == 0 + + # in the first two cases, the simulation is still going, so all we must + # do is signal its halt by setting runningSimulation to 0 + # This will result in this method being called again at the proper halting + # point, at which time tsiOnEnvironmentStop will be called. + + if { $runningSimulation } { + set runningSimulation 0 +# puts "Stop Button Hit? Waiting for Cycle's end...." + return + } + + + tsiOnEnvironmentStop + +} + +proc runSimulation {w} { + global runningSimulation tickDelay soarTimePerTick soarTimeUnit \ + worldCount worldCountLimit tsiConfig + set agents [interp slaves] + + set agent0 [lindex $agents 0] + # puts "runSimulation -- 0 :: agent0 = $agent0" + if {$agents == ""} { + tk_dialog .error Warning "There are currently no eaters to run." \ + warning 0 Ok + set runningSimulation 0 + return + } + if {([.wGlobal.c find withtag normalfood] == {}) && \ + ([.wGlobal.c find withtag bonusfood] == {})} { + set runningSimulation 0 + tk_dialog .info {Game Over} {Game over: All the food is gone.} info 0 Ok + return + } + if {$worldCount >= $worldCountLimit} { + set runningSimulation 0 + environmentStop + tk_dialog .info {Game Over} \ + {Game over: Move count limit reached.} info 0 Ok + return + } + if [goalIsAccomplished] { + + set runningSimulation 0 + environmentStop + tk_dialog .info {Goal Accomplished} \ + {The goal has been accomplished. Game Over.} info 0 Ok + return + } + incr worldCount + tickSimulation $w + update + tickIO $agents + +# [lindex $agents 0] eval [list run-soar $soarTimePerTick $soarTimeUnit] + if {[info exists runningSimulation] && $runningSimulation} { + after $tickDelay runSimulation $w + + } else { + #puts "Environment Stopping..." + environmentStop + } +} + + +proc tickIO { agents } { + global soarTimePerTick soarTimeUnit localAgents remoteAgents \ + sio_agentStatus tsiConfig agentUpdate + + if [info exists localAgents] { + if { $tsiConfig(sioDebug) > 4 } { puts "++ Soar Tick I/O..." } + [lindex $localAgents 0] eval \ + [list run-soar $soarTimePerTick $soarTimeUnit] + if { $tsiConfig(sioDebug) > 4 } { puts "++ End Soar Tick I/O" } + } + if [info exists remoteAgents] { + + # This should be done in another way... + if { [llength [array get remoteAgents]] > 0 } { + if { $tsiConfig(sioDebug) > 5 || $tsiConfig(sioWatch) > 1 } { + puts "+Remote Agent I/O Cycle Sending Output ..." + } + # This needs to be changed, now it relys on the fact that the remote + # eaters' names correspond to their socket ids. + foreach {name socket} [array get remoteAgents] { + if { $sio_agentStatus($name,online) } { + + + set sio_agentStatus($name,receivedOutput) 0 + SIO_SendSocketCommand $socket "tuples-begin" + if { ![string compare $sio_agentStatus($name,inputMode) \ + initialize] } { + setUpInputLink $name na + set sio_agentStatus($name,inputMode) update + } else { + updateInputLink $name + } + SIO_SendSocketCommand $socket "tuples-end" + + + } else { + puts "AGENT $name is not online..." + } + } + + + if { $tsiConfig(sioDebug) > 5 || $tsiConfig(sioWatch) > 1 } { + puts "+Remote Agent I/O Cycle Waiting For Input ..." + } + set agentUpdate waiting + if { $tsiConfig(sioDebug) > 4 } { + puts "--timeout in $tsiConfig(sioTimeOut) milliseconds" + } + + # When an agent times out, it should be taken offline. + # That is, it should be sent an offline control command to + # notify it of its new state, it should then be able to rejoin + # by sending an online status. + + if { $tsiConfig(sioTimeOut) == -1 } { + set afterID [after 180000 displayReceivedOutputStatus] + } else { + set afterID [after $tsiConfig(sioTimeOut) \ + [list set agentUpdate timeout]] + } + + vwait agentUpdate + + if { $tsiConfig(sioDebug) > 5 || $tsiConfig(sioWatch) > 1 } { + puts "+Remote agent IO Cycle Complete: AgentUpdate = $agentUpdate" + } + + if { [string compare $agentUpdate timeout] != 0 } { + after cancel $afterID + } else { + + + foreach {name socket} [array get remoteAgents] { + if { $sio_agentStatus($name,online) && \ + !$sio_agentStatus($name,receivedOutput) } { + + puts "***AGENT $name TIMED OUT!" + bell + bell + set sio_agentStatus($name,online) 0 + + # TODO: need to send an offline message to client. + } + } + } + } + } +} + + +proc displayReceivedOutputStatus {} { + global remoteAgents sio_agentStatus + + set n_waiting 0 + + foreach {name socket} [array get remoteAgents] { + if { $sio_agentStatus($name,online) } { + if { $sio_agentStatus($name,receivedOutput) } { +# puts " - Received Output From Agent '$name'" + } else { +# puts " - Waiting for Output From Agent '$name'" + incr n_waiting + } + } + } +# puts " - WAITING FOR OUTPUT FROM $n_waiting AGENT(S)." +} + +proc receiveRemoteAgentOutput { socket } { + global tsiConfig sio_socketToAgent sio_agentStatus agentUpdate \ + remoteAgents remoteAgentOutputLinks + + + if { $tsiConfig(sioDebug) > 3 || $tsiConfig(sioWatch) > 1 } { + puts "receiveRemoteAgentOutput agent: $sio_socketToAgent($socket) (begin)" + } + fileevent $socket readable {} + + set done 0 + while { $done == 0 } { + + gets $socket line + + if { [string compare $line "0"] != 0 } { + tk_messageBox -type ok -message "Expected control command but got garbage ($line)" -icon error + return + } + + gets $socket line + + if { [string compare $line "tuples-begin"] == 0 } { + set done 1 + } else { + # todo: implement this! + #puts "** SIO_ReceiveAllChangedInput :: Got message: $line" + tk_messageBox -type ok -message "Cannot handle $line\nNot impl yet!" -icon error + SIO_HandleSocketCommand $line + } + } + + + while {1} { + + # grab everything from the socket + + gets $socket idNumber + + if {$idNumber == 0} { + gets $socket line + if { [string compare $line "tuples-end"] == 0} { + break + } else { + tk_messageBox -type ok -message "Unexpected control command in tuple stream" -icon error + return + } + } + + gets $socket attribute + gets $socket valueType + gets $socket value + gets $socket action + + lappend tuples [list $idNumber $attribute $valueType $value $action] + + + } + + + # Now we remove this each decision cycle, this prevents the eaters from + # continually moving, if only single 'move' attribute is asserted + # to the output-link. + if { [info exists remoteAgentOutputLinks($sio_socketToAgent($socket))] } { + unset remoteAgentOutputLinks($sio_socketToAgent($socket)) + } + + if [info exists tuples] { + $tsiConfig(manageRemoteAgentOutputFN) $sio_socketToAgent($socket) $tuples + } else { + + # if no tuples were sent, we just need to work with the old ones. + $tsiConfig(actOnRemoteAgentOutputFN) $sio_socketToAgent($socket) + } + + + + fileevent $socket readable [list SIO_GetSocketInput $socket] + + # puts "Setting agentStatus (receivedOutput) for $sio_socketToAgent($socket) to 1" + set sio_agentStatus($sio_socketToAgent($socket),receivedOutput) 1 + + # Check to see if all remote agents have receive output. + set allReceivedOutput 1 + foreach {agent socket} [array get remoteAgents] { + if { $sio_agentStatus($agent,online) && \ + !$sio_agentStatus($agent,receivedOutput) } { + + # puts " -- Agent $agent has not sent output yet." + set allReceivedOutput 0 + break + } + } + + if { $allReceivedOutput } { + set agentUpdate complete + # puts " -- All agents have sent their output." + } + + if { $tsiConfig(sioDebug) > 3 || $tsiConfig(sioWatch) > 1 } { + puts "receiveRemoteAgentOutput agent: $sio_socketToAgent($socket) (end)" + } + +} + +# I've modified this significantly. Now, +# remoteAgentOutputLinks($agent) is deleted each decision cycle +# which means that a single (unchanged) structure on the ontput-link +# results in only a single action within the environment. +proc manageRemoteAgentOutput { agent tuples } { + global tsiConfig remoteAgentOutputLinks + + if { $tsiConfig(sioDebug) > 3 } { puts "manageRemoteAgentOutput -- (begin)"} + + + +# +# if { [info exists remoteAgentOutputLinks($agent)] } { +# +# foreach tuple $tuples { +# +# if { $tsiConfig(sioWatch) > 5 } { +# puts " $agent Received: $tuple" +# } +# switch -exact [lindex $tuple 4] { +# 1 { +# lappend remoteAgentOutputLinks($agent) [lrange $tuple 0 3] +# } +# 2 { +# set remoteAgentOutputLinks($agent) \ +# [ldelete $remoteAgentOutputLinks($agent) [lrange $tuple 0 3]] +# } +# 3 { +# error "Change not impl!" +# } +# } +# } +# } else { + + # We'll clean this up later so that the outputLink is already created. + foreach tuple $tuples { + if { $tsiConfig(sioWatch) > 5 } { + puts " $agent Received: $tuple" + } + + switch -exact [lindex $tuple 4] { + 1 { + lappend remoteAgentOutputLinks($agent) [lrange $tuple 0 3] + } + 3 { + error "Don't know what to do with a change $tuple...nothing to change." + } + } + } + #} +# Removed from switch: +# 2 { +# error "Can't evaluate the Remove ($tuple)...nothing to remove" +# } + + + $tsiConfig(actOnRemoteAgentOutputFN) $agent +} + + + +proc actOnRemoteAgentOutput { agent } { + global remoteAgentOutputLinks tsiConfig + + # This needs to be cleaned up so that this is guarenteed to exist + # at all times after agent creation.... + + if { [info exists remoteAgentOutputLinks($agent)] } { + + if { $tsiConfig(sioWatch) > 2 } { + puts "AGENT $agent has the OUTPUTLINK:" + } + foreach tuple $remoteAgentOutputLinks($agent) { + + if { $tsiConfig(sioWatch) > 2 } { + puts " $tuple" + } + switch -exact [lindex $tuple 1] { + move { + set actionTuple $tuple + set action move + #setWalkDir $agent [lindex $tuple 3] + } + jump { + set actionTuple $tuple + set action jump + #setJumpDir $agent [lindex $tuple 3] + } + } + } + if [info exists actionTuple] { + + foreach tuple $remoteAgentOutputLinks($agent) { + + if { [lindex $tuple 0] == [lindex $actionTuple 3] && \ + [lindex $tuple 1] == "direction" } { + # puts "DIRECTION IS: [lindex $tuple 3]" + + if { $action == "move" } { + setWalkDir $agent [lindex $tuple 3] [lindex $tuple 0] + } else { + setJumpDir $agent [lindex $tuple 3] [lindex $tuple 0] + } + } + } + } + + + if { $tsiConfig(sioWatch) > 2 } { + puts "END OF OUTPUTLINK" + } + } elseif { $tsiConfig(sioWatch) > 2 } { + + puts "REMOTE AGENT OUTPUT LINK NOT CREATED YET.." + } +} + + +proc loadController {agent color} { + [eaterName $agent $color] eval {tsiDisplayAndSendCommand {excise -all}} + if [catch "[eaterName $agent $color] eval \ + [list tsiLoadAgentSource $agent]" msg] { + tk_dialog .error Warning \ + "Couldn't load control code for $agent: $msg" error 0 Ok + } +} + +proc logicalX {w obj} { + global gridSize + return [expr int([lindex [$w coords $obj] 0] / $gridSize)] +} + +proc logicalY {w obj} { + global gridSize + return [expr int([lindex [$w coords $obj] 1] / $gridSize)] +} + +proc convertToLogical {n} { + global gridSize + return [expr int($n/$gridSize)] +} + +proc setWalkDir {agent dir id} { + global moveDir eaterOutputFile actionID + set moveDir($agent) $dir + set actionID($agent) $id + + + if [info exists eaterOutputFile($agent)] { + puts " --LOG FILE EXISTS" + puts $eaterOutputFile($agent) "move: $dir" + } + +} + +proc setJumpDir {agent dir id} { + global jumpDir eaterOutputFile actionID + set jumpDir($agent) $dir + set actionID($agent) $id + + if [info exists eaterOutputFile($agent)] { + puts $eaterOutputFile($agent) "jump: $dir" + } +} + + +proc loadEaterNames {button} { + global currentName + + set allNames [glob -nocomplain {*.soar}] + set names "" + foreach i $allNames { + lappend names [file rootname [file tail $i]] + } + + if {$names == {}} { + tk_dialog .error Error "There is no agent code in this directory" \ + error 0 Ok + if [winfo exists $button] { + [$button cget -menu] delete 0 end + [$button cget -menu] add command -label {*NONE*} -command {} + } else { + tk_optionMenu $button {*NONE*} + [$button cget -menu] entryconfigure {*NONE*} -command {} + } + $button configure -state disabled + set currentName {} + } else { + if [winfo exists $button] { + [$button cget -menu] delete 0 end + foreach i $names { + [$button cget -menu] add command -label $i \ + -command [list set currentName $i] + } + if {![info exists currentName] || + ([lsearch $names $currentName] < 0)} { + set currentName [lindex $names 0] + } + } else { + eval tk_optionMenu .agents.create.e currentName $names + } + } +} diff --git a/eaters-3.0.8/start-eaters.bat b/eaters-3.0.8/start-eaters.bat new file mode 100644 index 0000000..058df79 --- /dev/null +++ b/eaters-3.0.8/start-eaters.bat @@ -0,0 +1,2 @@ +@echo off +start ..\tcl-8.4.6\bin\wish84.exe init-eaters.tcl \ No newline at end of file diff --git a/eaters-3.0.8/tsi-defaults.tcl b/eaters-3.0.8/tsi-defaults.tcl new file mode 100644 index 0000000..317251a --- /dev/null +++ b/eaters-3.0.8/tsi-defaults.tcl @@ -0,0 +1,15 @@ +## set tsiConfig(debug) to 1 when debugging, 0 when not +set tsiConfig(debug) 0 + +## if expertise is 1, it is the full interface, +## if 0, it is for very very first time users +set tsiConfig(expertise) 1 + + +set tsiConfig(simulationName) {Eaters} +set tsiConfig(hasEnvironment) 1 + +set tsiConfig(ControlPanel) ETControlPanel +set tsiConfig(ControlPanelVersion) 3.2.0 + +set tsiSuppressMenus(demos) 1 diff --git a/soar-8.5.2/CHANGES.txt b/soar-8.5.2/CHANGES.txt new file mode 100644 index 0000000..40e076c --- /dev/null +++ b/soar-8.5.2/CHANGES.txt @@ -0,0 +1,185 @@ + Summary of changes between SoarSuite 8.5.1 and SoarSuite 8.5.2 + July, 2004 + + +A summary of changes in SoarSuite 8.5.2 is listed immediately below. For more +details, including changes not mentioned in the summary and a list of known +issues see the Details section after the summary. + +====================== +New Windows Installer: +====================== + + The Windows installer is now built with a different technology which +is much easier for us and results in a much smaller package. + +========================= +Several kernel bug fixes: +========================= + + Almost all known bugs fixed, including all known crash bugs. See the +details section below for more information. + +================== +New TankSoar Bots: +================== + + TankSoar now comes with two new bots. Mapping-bot demonstrates how a +tank might build up an internal map of the level. Obscure-bot is a challenge bot +for people to test their own bots against. The code is provided in an obfuscated +binary. See obscure-bot.txt in the TankSoar agents directory for details. + +========================== +SoarDoc and DMGen updated: +========================== + + These changes were actually in the the 8.5.1 release, but we failed +to note them. +SoarDoc: + - Fixed special character handling when UseExistingComments is used. + - Added ShowProdSourceInline which shows production source code + inline in the production documentation + - Ability disable datamap node coloring + - Fixed case-sensitivity issues for production names and list sorting. +DMGen: + - Fixed handling of mixed-case production names. + +====================== +Documentation Updated: +====================== + + The tutorials have had some typo fixes and screenshot updates, and also +explain substates better. + +================== +Tcl Soar Debugger: +================== + + The TSDebugger has several bug fixes which may have affected some +users. + +=================== +VisualSoar Updated: +=================== + + VisualSoar has several small bug fixes. + +====================== +Critical SGIO bug fix: +====================== + + Our fix for bug 254 in the last release actually caused serious +problems. This has been fixed for real now. + +==================================================================== + Details +==================================================================== + +Below is a fairly complete list of enhancements, changes, bug fixes, and known +issues, with bug numbers for reference. For more information and up to date list +of what's been fixed please visit the Soar bugzilla server at: + + https://winter.eecs.umich.edu/soar-bugzilla/. + +New bug submissions and enhancement requests are welcome! + + +Soar-8.5.2 +========== + +Bug Fixes +--------- +353 stats command keeps recording between runs +389 missing error handling for set_watch_prod_group_setting + +Enhancements +------------ +358 change soar8 command error message + +Known Issues +------------ +312 agent structure isn't cleaned up properly +356 All matches get same support as last processed match + +TSDebugger 4.0.1 +================ + +Bug Fixes +--------- +365 rules that contain a capital letter break productions tab +376 stop button doesn't work with Eaters, TankSoar +396 error when closing group from task bar +398 extra 0 gets printed when soar connected to environments + +Known Issues +------------ +336 negated conditions don't print properly in the console window +397 grouping bar in production tab not always right + +SGIO 1.1.2 +========== + +Bug Fixes +--------- +254 Some special characters in StringWME's do not transfer to Soar + +Eaters 3.0.8 +============ + +Bug Fixes +--------- +391 garbage printed to debugger output when Stop After Decision Phase is on + +TankSoar 3.0.8 +============== + +Bug Fixes +--------- +map loading menu now defaults to maps directory +188 Selecting Map->Random Map causes error message when agent present on + current map +392 garbage printed to debugger output when Stop After Decision Phase is on +393 command 'run 1' generates 'invalid command step' error + +Enhancements +------------ +new challenge bot (obscure-bot) and mapping bot provided + +Known Issues +------------ +399 can't use reset tank command in tank control panel tanks menu + +Documentation +============= + +Bug Fixes +--------- +349 tutorial images need to be updated +375 typo in tutorial part 1: move-north +386 typos in tutorial part 1 (search control) + +Enhancements +------------ +Added information to tutorial about substates. + +Known Issues +------------ +380 typo in section 5.6.3 +381 o-support-mode command missing newest support modes + +VisualSoar 4.5.3 +================ + +Bug Fixes +--------- +361 adding a dir that doesn't exist to agent path on file->new project fails with no warning +362 initial rules in a project are not justified correctly +363 if project loaded then create new project, title bar does not change +364 file with same name as datamap have same window names +366 Initialize- Operator not in datamap +368 dragging node onto itself makes node disappear +372 fails to detect extra whitespace after : + +Known Issues +------------ +Too many to list. See bugzilla for details. \ No newline at end of file diff --git a/soar-8.5.2/INSTALL.txt b/soar-8.5.2/INSTALL.txt new file mode 100644 index 0000000..c9a1124 --- /dev/null +++ b/soar-8.5.2/INSTALL.txt @@ -0,0 +1,136 @@ +$Id: INSTALL.txt,v 1.2 2004/07/10 05:10:32 toolshed Exp $ + +This file contains the installation and (optional) build instructions for +Soar 8.5.2 for the following platforms: + +1. Installing and running Soar on Windows 9x/Me/NT/2000/XP +2. OPTIONAL: Building Soar on Windows 9x/Me/NT/2000/XP +3. Installing, running, and building Soar on GNU/Linux and Unix + +__________________________________________________________ +1. Installing and running Soar on Windows 9x/Me/NT/2000/XP +---------------------------------------------------------- + +Requirements for running Soar 8.5.2 on Windows: +1.1 The Soar Suite 8.5.2 distribution installer from: + http://sitemaker.umich.edu/soar/soar_software_downloads + +1.2 To run VisualSoar (an optional component), you will need to download and + install version 1.3 or newer of the Java runtime environment: + http://java.sun.com/j2se/1.4.2/download.html + +Installation: +1.3 Double click the Setup-Soar-Suite-8.5.2.exe installer and follow the + prompts. By default, it will install Soar and its components and + documentation into your Program Files folder. If you are an advanced + user, you may choose to select what components you would like included + in the install. + +Running Soar: +1.4 Start Soar by launching the Start Soar icon listed in your start menu + under the folder "Soar". After a few moments, the Agent Control Panel + will pop up, and shortly after that, an agent window will pop up with the + name "soar1". The agent window has pulldown menus for issuing many Soar + commands, for viewing help, and to load and run Soar demos. + +1.5 You can start the other components distributed with Soar by launching + their icons in the "Soar" start menu folder. + +______________________________________________________ +2. OPTIONAL: Building Soar on Windows 9x/Me/NT/2000/XP +------------------------------------------------------ + +If you were not able to get through these steps, please send email to +soar-group@lists.sourceforge.net describing the results of each step above. +We'll try to respond within a few hours. + +Requirements for building Soar 8.5.2 Windows (optional): +2.1 Microsoft Visual C++, version 6.0. Although we do not use versions + greater than 6.0 for developing Soar, newer versions may work without + too much trouble. Other compilers may also work but have not been tested. + +Building Soar (optional): +2.2 Go to the kernel subfolder (inside the soar-8.5.2 folder) and open the + Kernel.dsw project file. + +2.3 Build soarkernel.lib. + +2.4 Open the SoarInterface.dsw project file in the Interface folder. + +2.5 Build libsoar8.5.2.dll. This must be built *after* the kernel since there + is static linking going on. If you rebuild the kernel, you must rebuild + the interface. + +2.6 Confirm that the new libsoar8.5.2.dll file exists in the soar-8.5.2/library + folder. It should be automatically moved here after compilation. + +_______________________________________________________________ +3. Installing, running, and building Soar on GNU/Linux and Unix +--------------------------------------------------------------- + +Requirements for running Soar 8.5.2 on GNU/Linux: +3.1 The X window system. Installation instructions for X are beyond the scope + of this document. + +3.2 Tcl/Tk version 8.4.6 and BWidgets 1.7 (a Tcl extension). Newer versions + should work. We recommend downloading and installing ActiveTcl + (instructions follow) if you don't know what version you have. + Installing ActiveTcl will not harm any version of Tcl currently installed + on your system (it is installed in its own /usr/local/ActiveTcl directory). + + Installing ActiveTcl: + 3.2.1 Get ActiveTcl 8.4.6 or better from here: + http://www.activestate.com/Products/Download/Download.plex?id=ActiveTcl + + 3.2.2 Extract the package in your home directory with this command: + tar xfvz ActiveTcl8.4.6.1-linux-.tar.gz + + 3.2.3 AS ROOT: run install.sh in the directory you just extracted: + su root + cd ActiveTcl8.4.6.1-linux-ix86 + ./install.sh + + 3.2.4 Accept all defaults during the install process (installing ActiveTcl + into its own directory in /usr/local). You do not have to mess with the + path and manpath environment variables (but go ahead and do that if you know + exactly what you are doing). + + 3.2.5 You no longer need to be (and shouldn't be) root to continue. + + 3.2.6 You will need to change the first line of init-soar.tcl in step 3.5 + below to point to the ActiveTcl wish binary. + +3.3 The Soar-Suite 8.5.2 distribution installer from: + http://sitemaker.umich.edu/soar/soar_software_downloads + +Installation: +3.4 Extract the soar-suite-8.5.2-linux.tar.gz file. It will extract into a + directory named "soar". The command when using GNU's tar utility is: + tar xvfz soar-suite-8.5.2-linux.tar.gz + + 2.5.1 If the above command fails, you may need to unzip the files in a separate + step, like this: + gunzip soar-suite-8.5.2-linux.tar.gz; tar xvf soar-suite-8.5.2-linux.tar + +Running Soar: +3.5 Change into the soar-8.5.2 subdir of the newly extracted directory and type this + command to run Soar: + ./init-soar.tcl + + You may need to change the first line of the init-soar.tcl file to point + to the location of the wish binary on your machine. For example, if you + installed ActiveTcl (above), you probably have to change that line to: + #!/usr/local/ActiveTcl/bin/wish + + If you have other errors, you may need to rebuild the Soar binaries + (instructions follow). + +Requirements for building Soar 8.5.2 GNU/Linux (optional): +3.6 A recent version of GCC and its utilites such as make. We're not sure + what versions other than 3.2.3 and 3.3.3 will work. 2.95.2 should work + with no problems. + +Building Soar (optional): +3.7 In the Soar directory, execute these commands to build Soar: + ./make-clean (ignore error messages if any) + ./make-soar diff --git a/soar-8.5.2/LICENSE.txt b/soar-8.5.2/LICENSE.txt new file mode 100644 index 0000000..f8a9e7d --- /dev/null +++ b/soar-8.5.2/LICENSE.txt @@ -0,0 +1,31 @@ +$Id: LICENSE.txt,v 1.1 2004/07/09 23:16:36 toolshed Exp $ + +Copyright 1995-2004 Carnegie Mellon University, University of Michigan, +University of Southern California/Information Sciences Institute. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +The views and conclusions contained in the software and documentation are +those of the authors and should not be interpreted as representing official +policies, either expressed or implied, of Carnegie Mellon University, the +University of Michigan, the University of Southern California/Information +Sciences Institute, or the Soar consortium. \ No newline at end of file diff --git a/soar-8.5.2/README.txt b/soar-8.5.2/README.txt new file mode 100644 index 0000000..f4542e6 --- /dev/null +++ b/soar-8.5.2/README.txt @@ -0,0 +1,41 @@ +$Id: README.txt,v 1.2 2004/07/10 05:10:32 toolshed Exp $ + +Soar is a general cognitive architecture for developing systems that exhibit +intelligent behavior. Researchers all over the world, both from the fields of +artificial intelligence and cognitive science, are using Soar for a variety of +tasks. It has been in use since 1983, evolving through many different versions +to where it is now Soar, Version 8.5.2. + +Please see the Soar website for more information about Soar: + + http://sitemaker.umich.edu/soar/ + +Soar now uses Bugzilla for feature requests and bug tracking. Please report +any bugs to the Soar Bugzilla: + + https://winter.eecs.umich.edu/soar-bugzilla/ + +_______________________ +File/Directory Listing: +----------------------- + +README.txt - This file. +INSTALL.txt - Installation and execution instructions for various platforms. +CHANGES.txt - Changes since the last major release of Soar. +LICENSE.txt - License agreement. +TROUBLESHOOTING.txt - Troubleshooting help, frequent problems. +start-soar.bat - The Windows file used to start Soar (see INSTALL file). +init-soar.tcl - The Tcl/Tk initialization code for Soar (see INSTALL file). +make-soar - A unix script used to build the Soar kernel and Tcl interface. +make-clean - A unix script to clean object files created during build. +cmdline-interface/ - The home of the command line interface source code. +demos/ - Example Soar agents. +demos_soar7/ - Example Soar version 7 agents. +doc/ - Soar documentation, excluding the Soar manual and tutorial. +kernel/ - The home of the Soar kernel source code. +library/ - Files and libraries needed by the Soar kernel and Tcl interface. +tcl-interface/ - The home of the Tcl interface source code. + +-- + +Updated for Soar release 8.5.2 by Jonathan Voigt (voigtjr@gmail.com). diff --git a/soar-8.5.2/TROUBLESHOOTING.txt b/soar-8.5.2/TROUBLESHOOTING.txt new file mode 100644 index 0000000..b515018 --- /dev/null +++ b/soar-8.5.2/TROUBLESHOOTING.txt @@ -0,0 +1,147 @@ +This file contains some troubleshooting information for Soar 8.5.2. + +If this file does not resolve your problem, please send email to: + soar-group@lists.sourceforge.net + + + +________________________________________________________________ +Contents: +1. I've installed Soar but none of the start menu links work! + +2. "Cannot find package Soar" when trying to create an agent. + +3. "Tcl84.dll not found" or "Tk84.dll not found" + +4. When I double-click on the VisualSoar jar file, it pops up an error box that +says it can't find the main class and is exiting? What gives? + +5. When I create an agent, Tcl complains about not being able to find the +BWidget 1.7 library. I'm pretty sure Tcl is installed. What's up? +---------------------------------------------------------------- + + + + +________________________________________________________________ +1. I've installed Soar but none of the start menu links work! +---------------------------------------------------------------- + +Unfortunately, the Windows installer silently fails to install if you do not +have administrator privileges. If you can't get administrator privileges, +uninstall and re-install changing the installation directory to something like: + +C:\Documents and Settings\Your Username\Soar\Soar Suite 8.5.2 + +...where "Your Username" is your login name. + +________________________________________________________________ +2. "Cannot find package Soar" when trying to create an agent. +---------------------------------------------------------------- + +Possibility 1: Wrong version of Tcl. + +The most common cause of this problem is that the wrong version of Tcl is +installed. This version of Soar requires Tcl 8.4.6 (it may also work with later +versions). + +The Windows distribution actually includes the correct version of Tcl, so as +long as you use the batch files that are included to start Soar, it will use the +version of Tcl we included. If you are trying to run the Tcl files directly, +then it will use whatever version of Tcl is registered with the OS (the version +included with Soar is NOT registered with the OS). + +On other platforms (i.e. *nix, Mac), make sure that you have installed Tcl +8.4.6. Some unusual versions of Unix may have to get the source and compile it +themselves. + +If you can't tell what version of Tcl is installed on your machine, there are +instructions in INSTALL.txt on how to install ActiveTcl. + +Possibility 2: Soar is not compiled. + +If you only installed the source code or have removed any of the binaries at +some point, you may get this message. Reinstall or follow the instructions in +the INSTALL file to build the binaries. + +Possibility 3: Wrong location of Soar is specified. + +If you are trying to run an application like Eaters or TankSoar, it is possible +that the application is looking in the wrong place for Soar. The applications +we distributed with Soar are set up to look in the right place, but if you have +moved Soar or the applications, you may need to edit these files: + +Eaters: The file init-eaters.tcl specifies the location of Soar on the line +beginning with "set soar_library". It is specified as a relative path, although +you can replace this with a full path. + +TankSoar: The file init-tanksoar.tcl specifies the location of Soar on the line +beginning with "set soar_library". It is specified as a relative path, although +you can replace this with a full path. + +________________________________________________________________ +3. "Tcl84.dll not found" or "Tk84.dll not found" +---------------------------------------------------------------- + +Possibility 1: Tcl not properly installed. + +Wish, the program which starts Tcl (and is used to run Soar, Eaters and +TankSoar), expects these dlls to be in the same directory as it is. If they are +not (i.e. Tcl is not properly installed), then there will be problems. Try +reinstalling Tcl. + +If you can't tell what version of Tcl is installed on your machine, there are +instructions in INSTALL.txt on how to install ActiveTcl. + +Possibility 2: The dlls are not in the search path. + +If you are trying to run an application which has Tcl compiled directly into it +(i.e. soarside, which is part of SGIO), then these dlls need to be in the PATH +environment variable. The Soar installer for Windows should have done this for +you. If you installed ActiveTcl, then the installer should have done this for +you. If you are manually installing Tcl, then you may have to do this step +yourself. + +__________________________________________________________________________ +4. When I double-click on the VisualSoar jar file, it pops up an error box +that says it can't find the main class and is exiting? What gives? +-------------------------------------------------------------------------- + +A: For some reason, certain Java installations are configured incorrectly to +launch Java applications in jar files. We are not exactly sure why this +happens. To fix the problem, you'll need to edit your registry. If you don't +feel comfortable editing the registry, you could also just create a text file +whose contents are: + +javaw.exe -jar VisualSoar.jar + +and save it in the same directory as "start-visualSoar.bat" + +Otherwise, open up Regedit and find the following key: + +HKEY_CLASSES_ROOT\Applications\javaw.exe\shell\open\command + +Its current value will probably be something like this: + +"C:\j2sdk1.4.2_01\bin\javaw.exe" "%1" + +Add a "-jar" between the 2 quoted items and a "%*" to the end. In the above +example, you would change it to: + +"C:\j2sdk1.4.2_01\bin\javaw.exe" -jar "%1\" %* + +That should allow you to launch VisualSoar by double-clicking the jar file. + +__________________________________________________________________________ +5. When I create an agent, Tcl complains about not being able to find the +BWidget 1.7 library. I'm pretty sure Tcl is installed. What's up? +-------------------------------------------------------------------------- + +If you got to this error, Tcl is probably installed correctly, however, some +packages of Tcl do not include the optional BWidget library needed for the new +Tcl-Soar debugger. If you run Linux, look for a bwidget package on whatever +distribution you use and install it. On Windows, try (re)installing ActiveTcl. + +If you're still perplexed and can't find a BWidget package for your Linux +distribution, follow the instructions for installing ActiveTcl in the +INSTALL.txt file. diff --git a/soar-8.5.2/cmdline-interface/.cvsignore b/soar-8.5.2/cmdline-interface/.cvsignore new file mode 100644 index 0000000..29e35d8 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/.cvsignore @@ -0,0 +1,6 @@ +shell.ncb +shell.plg +Debug +Release +shell.opt +soar_app diff --git a/soar-8.5.2/cmdline-interface/Makefile b/soar-8.5.2/cmdline-interface/Makefile new file mode 100644 index 0000000..77a6c99 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/Makefile @@ -0,0 +1,69 @@ + + +LIB_RUNTIME_DIR = /usr/lib +TCL_LD_SEARCH_FLAGS = + +CC = gcc +RANLIB = ranlib + +# Directories for installation +SRC_DIR = . +TOP_DIR = ./.. + +# The location of the Soar kernel library, libsoarkernel.a + +KERNEL_DIR = ../kernel +KERNEL_LIB_SPEC = -L$(KERNEL_DIR) -lsoarkernel +KERNEL_INCLUDE_DIR = ../kernel + + + +# Set these to be whatever flags you want to pass to your compiler. +# If the flags define ANSI C behavior, be sure to set them. +# + +ANSI_FLAGS = -fpcc-struct-return +SHLIB_CFLAGS = -fPIC +DEFS = -DSOAR_LIBRARY=\"$(SOAR_LIBRARY)\" -DSTDC_HEADERS=1 -DHAVE_UNISTD_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_GETHOSTNAME=1 -DHAVE_GETTIMEOFDAY=1 -DHAVE_GETWD=1 +INCLUDE_FLAGS = -I$(KERNEL_INCLUDE_DIR) +CFLAGS = -O -g -Wall $(ANSI_FLAGS) $(SHLIB_CFLAGS) $(DEFS) \ + $(INCLUDE_FLAGS) + +# The symbols below provide support for dynamic loading and shared +# libraries. See configure.in for a description of what the +# symbols mean. The values of the symbols are normally set by the +# configure script. You shouldn't normally need to modify any of +# these definitions by hand. +MATH_LIBS = -lieee -lm +LIBS = $(KERNEL_LIB_SPEC) -ldl \ + $(MATH_LIBS) -lc + + + + +# The objects +OBJS = parsing.o\ + soarInterfaceCommands.o\ + ask.o \ + demo_adder.o \ + demo_toh.o + +all: soar_app + +lib: libsoarnui.a + +soar_app: $(OBJS) main.o + $(CC) $(CFLAGS) -o soar_app $(OBJS) main.o $(LIBS) + +tests: nit1.o $(OBJS) + $(CC) $(CFLAGS) -o test1 nit1.o $(OBJS) $(LIBS) + +libsoarnui.a: $(OBJS) + $(AR) $(ARFLAGS) libsoarnui.a $(OBJS) + $(RANLIB) libsoarnui.a + +clean: + rm -f *.o core *~ soar-app libsoarnui.a + + + diff --git a/soar-8.5.2/cmdline-interface/README.txt b/soar-8.5.2/cmdline-interface/README.txt new file mode 100644 index 0000000..aa9d7cf --- /dev/null +++ b/soar-8.5.2/cmdline-interface/README.txt @@ -0,0 +1,42 @@ +The files in this directory constitue a simple example of how to use +the Soar API. The application built here is a simple shell interface +to Soar which lacks the standard Tk GUI. Although the complete +Command Set (as defined by the API) is not implemented in this +example, the shell does allow most of Soar's critical functionality to +be accessed. Moreover, it supports a mechanism for registering +commands which make it easy for anyone interested to extend the +current functionality. + + +Also included in this application is an example of how to send and +receive environmental information to and from Soar. This is +illustrated by running the "adder.soar" agent and watching it count +from 0 to infinity by passing a number from output-link to a +c-function and then back to the input-link. The c-functions required +for this behavior are defined in the file "io_example.c" + + +The majority of source code for this application has been extensively +documented to help the learning process. The only exception to this +occurs in the file "parsing.c" which contains a basic parser, and is +of no real education purpose. Nonetheless, some documentation does +exist within this file in case you wish to use it as a basis for your +own application. + +We suggest that you look over the example code in the following order: + + main.c - The interface event loop + io_example.c - IO functions used w/ adder agent + soarInterfaceCommands.c - Interface command registry + parsing.c - parsing utilities + + + + + + +documented: + main.c + io_example.c + parsing.c + soarInterfaceCommands.c \ No newline at end of file diff --git a/soar-8.5.2/cmdline-interface/agents/adder.soar b/soar-8.5.2/cmdline-interface/agents/adder.soar new file mode 100644 index 0000000..5e03978 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/agents/adder.soar @@ -0,0 +1,39 @@ +multi-attributes cheese 4 + +sp { propose*start-counting + (state ^superstate nil ^io.input-link ) + --> + ( ^operator + < ) + ( ^name start-counting + ^first-number 0 ) } + +sp { apply*start-counting + (state ^operator ^io.output-link
                                                                                              ) + ( ^name start-counting + ^first-number ) + --> + (
                                                                                                ^number + )} + +sp { propose*count + (state ^io.input-link.number ) +--> + ( ^operator + > ) + ( ^name count ^number ) } + +sp { propse*count-new-number + (state ^operator ^io.output-link
                                                                                                  ) + ( ^name count ^number ) + --> + (
                                                                                                    ^number + ) } + +sp { propse*count-remove-old-number + (state ^operator ^io.output-link
                                                                                                      ) + ( ^name count ^number ) + (
                                                                                                        ^number { <> } ) + --> + (
                                                                                                          ^number -)} + + + + + diff --git a/soar-8.5.2/cmdline-interface/agents/mac2.rete b/soar-8.5.2/cmdline-interface/agents/mac2.rete new file mode 100644 index 0000000..76acf43 Binary files /dev/null and b/soar-8.5.2/cmdline-interface/agents/mac2.rete differ diff --git a/soar-8.5.2/cmdline-interface/agents/toh.soar b/soar-8.5.2/cmdline-interface/agents/toh.soar new file mode 100644 index 0000000..36d55b2 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/agents/toh.soar @@ -0,0 +1,127 @@ +sp {e*top-state*top-state + (state ^superstate nil) + --> + ( ^top-state )} + +sp {e*top-state*sub-state + (state ^superstate.top-state ) +--> + ( ^top-state )} + +sp {e*biggest-disk + (state ^io.input-link ) + ( ^disk.size -^disk.size > ) +--> + ( ^biggest-disk )} + +sp {e*clear + (state ^io.input-link ) + ( ^disk.size -^disk.above ) + --> + ( ^clear )} + +sp {e*upper-disk*some-disk + (state ^io.input-link ) + ( ^disk -^disk.above ) + ( ^size ^on

                                                                                                          ) + --> + ( ^upper-disk ) + ( ^peg

                                                                                                          ^size )} + +sp {e*upper-disk*no-disk + (state ^io.input-link ^biggest-disk ) + ( ^peg

                                                                                                          -^disk.on

                                                                                                          ) + --> + ( ^upper-disk ) + ( ^peg

                                                                                                          ^size (+ 10))} + + + +sp { p*clear*biggest-not-on-goal + (state ^io.input-link ) + ( ^goal-peg

                                                                                                          ^disk ) + ( ^size ^on <>

                                                                                                          ) + -{( ^disk ) + ( ^size > ^on <>

                                                                                                          )} + --> + ( ^operator + <) + ( ^name clear-disk ^disk ^to-move-to

                                                                                                          )} + + +## If we want to clear a disk, and can do it primitively, +## clear the disk that is above it first. + +sp { p*clear*disk-above-disk-being-cleared + (state ^top-state.io.input-link ^superstate.operator ) + ( ^name clear-disk ^disk ^to-move-to ) + ( ^disk ^disk ^peg {

                                                                                                          <> <> }) + ( ^size ^on ) + ( ^size ^on ^above ) + --> + ( ^operator + ) + ( ^name clear-disk ^disk ^to-move-to

                                                                                                          )} + + +sp { p*move-disk*clear + (state ^superstate.operator ^top-state ) + ( ^name clear-disk ^disk ^to-move-to

                                                                                                          ) + ( ^clear ^upper-disk ) + ( ^peg

                                                                                                          ^size > ) + --> + ( ^operator + ) + ( ^name move-disk ^command ) + ( ^move-disk ) + ( ^size ^to

                                                                                                          )} + +sp { p*clear-disk*clear-target-peg + (state ^superstate.operator ^top-state ) + ( ^name clear-disk ^disk ^to-move-to

                                                                                                          ) + ( ^io.input-link ) + ( ^disk ^disk ^peg ) + ( ^size ^on { <> } ) + ( ^on {

                                                                                                          <> } ^size { < }) + -{( ^disk ) + ( ^on

                                                                                                          ^size {> < })} + --> + ( ^operator + ) + ( ^name clear-disk ^disk ^to-move-to )} + + +sp {a*copy-command*body + (state ^top-state.io.output-link

                                                                                                            ^operator ) + ( ^command ) + ( ^ ) + --> + (
                                                                                                              ^ )} + +sp {a*copy-command*args + (state ^top-state.io.output-link
                                                                                                                ^operator ) + (
                                                                                                                  ^ ) + ( -^status complete) + ( ^command ) + ( ^ ) + ( ^ ) + --> + ( ^ )} + + +sp {a*remove*complete + (state ^operator ^io.output-link
                                                                                                                    ) + ( ^name ) + (
                                                                                                                      ^ ) + ( ^status complete) + --> + (
                                                                                                                        ^ - )} + + +sp {e*goal-acheived + (state ^io.input-link ) + ( ^goal-peg

                                                                                                                        -^disk.on <>

                                                                                                                        ) +--> + (write (crlf) |Success!| (crlf)) + (halt)} + +sp {a*maintain + (state ^operator ) + --> + ( ^operator >)} diff --git a/soar-8.5.2/cmdline-interface/agents/toh5.soar b/soar-8.5.2/cmdline-interface/agents/toh5.soar new file mode 100644 index 0000000..33236b9 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/agents/toh5.soar @@ -0,0 +1,299 @@ + +### the constraints that (1) only one disk may be moved at a time, and + +multi-attributes holds 11 +#multi-attributes upper-disk +multi-attributes clear 3 + +learn -off + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^superstate nil) + --> + ( + ^peg a + + ^peg b + + ^peg c + + ^holds

                                                                                                                        + + ^holds

                                                                                                                        + + ^holds

                                                                                                                        + + ^holds

                                                                                                                        + + ^holds

                                                                                                                        + + ^last-disk1-peg b + ^last-disk-moved 2 + ^clear b + + ^clear c + + ^upper-disk 1 + ) + (

                                                                                                                        ^disk 1 ^above 2 ^on a) + (

                                                                                                                        ^disk 2 ^above 3 ^on a) + (

                                                                                                                        ^disk 3 ^above 4 ^on a) + (

                                                                                                                        ^disk 4 ^above 5 ^on a) + (

                                                                                                                        ^disk 5 ^above none ^on a)} + + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk 1 ^on c) + (

                                                                                                                        ^disk 2 ^on c) + (

                                                                                                                        ^disk 3 ^on c) + (

                                                                                                                        ^disk 4 ^on c) + (

                                                                                                                        ^disk 5 ^on c) + --> + (write (crlf) |Success!|) + (halt)} + + +### +### FILE : tower-of-hanoi8.soar +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### This version uses search control rules to solve the TOH in the +### minimum number of moves. +### The search control is as follows: +### Always alternate between moving the smallest disk and +### the other exposed disk that can move. +### Move the exposed disk to the one place it can move (the other disk +### that is bigger than it or an empty peg). +### Move the smallest disk to the peg it was not at last. +### This requires remembering the last peg the smallest disk was on, +### and initializing this to the appropriate peg (the destination peg +### if there is an even number of disks, and the other peg if there is +### an odd number of disks). + + + + +### +### +### TOP GOAL: +### TOWER-OF-HANOI +### + +### +### TOWER-OF-HANOI: +### INITIAL-STATE AND DESIRED-STATE +### + + +### +### PROPOSE OPERATORS TO MOVE DISKS +### +sp { terminate + (state ^operator -^operator +) + --> + ( ^operator @)} + +# 8 7 +sp {tower-of-hanoi*propose*move-disk1 + "Target peg is clear." + (state + ^peg { <> <> } + ^holds + ^last-disk1-peg + ^last-disk-moved <> 1) + ( ^disk 1 + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk 1 + ^from + ^to )} + + +# 7 7 +sp {tower-of-hanoi*propose*move-diskn*target-clear + "Target peg is clear." + (state + ^upper-disk { <> 1 } + ^clear + ^holds + ^last-disk-moved 1) + ( ^disk + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +# 13 10 +sp {tower-of-hanoi*propose*move-diskn*target-not-clear + "Upper disk on the target peg is larger." + (state + ^upper-disk { <> 1 } + ^upper-disk { > } + ^holds { <> } + ^last-disk-moved 1) + ( ^disk + ^on ) + ( ^disk + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + + +### +### OPERATOR APPLICATION +### + +# 10 9 +sp {apply*move-disk*change-slot*on + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^on ) + --> + ( ^on -)} + + +# 10 10 +sp {apply*move-disk*change-slot*above*source-clear*target-clear + (state ^operator + ^holds + ^clear ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk ^above none) +--> + ( ^clear - ^clear + )} + +# 9 10 +sp {apply*move-disk*change-slot*above*source-not-clear*target-clear + (state ^operator + ^holds + ^clear ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk ^above { <> none } ) +--> + ( ^clear - ^upper-disk + ) + ( ^above - ^above none + )} + +# 16 13 +sp {apply*move-disk*change-slot*above*source-clear*target-not-clear + (state ^operator ^holds + ^holds { <>

                                                                                                                        } ^upper-disk ) + ( ^name move-disk + ^disk { <> } + ^from + ^to ) + ( ^disk ^above none) + (

                                                                                                                        ^disk ^on ) + --> + ( ^upper-disk - ^clear + ) + ( ^above none - ^above +)} + +# 15 12 +sp {apply*move-disk*change-slot*above*source-not-clear*target-not-clear + (state ^operator ^holds + ^holds { <>

                                                                                                                        } ^upper-disk ) + ( ^name move-disk + ^disk + ^to ) + ( ^disk ^above { <> none }) + (

                                                                                                                        ^disk ^on ) + --> + ( ^upper-disk - ^upper-disk + ) + ( ^above - ^above +) } + +# 9 9 +sp {apply*move-disk*add-clear-source + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from ) + ( ^disk + ^above none + ^on ) + --> + ( ^clear + )} + +### Maintain last-disk-moved + +# 4 4 +sp {apply*move-disk*record*last-disk-moved + (state ^operator ) + ( ^name move-disk + ^disk ) + --> + ( ^last-disk-moved + )} + +# 5 5 +sp {apply*move-disk*remove*last-disk-moved + (state ^operator + ^last-disk-moved ) + ( ^name move-disk + ^disk <> ) + --> + ( ^last-disk-moved -)} + +### Maintain last peg disk 1 was moved to + +# 4 5 +sp {apply*move-disk*record*last-disk1-peg + (state ^operator ) + ( ^name move-disk + ^disk 1 + ^from ) + --> + ( ^last-disk1-peg + )} + +# 5 6 +sp {apply*move-disk*remove*last-disk1-peg + (state ^operator + ^last-disk1-peg ) + ( ^name move-disk + ^disk 1 + ^from <> ) + --> + ( ^last-disk1-peg -)} + + +### +### TOWER-OF-HANOI MONITOR +### + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk + ^from + ^to ) + --> + (write (crlf) + | Move Disk:| | from peg: | + | to peg | )} + +excise tower-of-hanoi*monitor*operator-execution*move-disk +### eof of tower-of-hanoi.soar + diff --git a/soar-8.5.2/cmdline-interface/ask.c b/soar-8.5.2/cmdline-interface/ask.c new file mode 100644 index 0000000..d0fe5cc --- /dev/null +++ b/soar-8.5.2/cmdline-interface/ask.c @@ -0,0 +1,26 @@ +#include "soar_core_api.h" + + + +void askCallback( soar_callback_agent the_agent, + soar_callback_data data, + soar_call_data call_data ) { + + + int num_candidates; + preference *cand; + + *((soar_apiAskCallbackData *)call_data)->selection = + ((soar_apiAskCallbackData *)call_data)->candidates; + + num_candidates = 0; + + for (cand = ((soar_apiAskCallbackData *)call_data)->candidates; + cand!=NIL; cand=cand->next_candidate) { + num_candidates++; + print( " --> %s\n", symbol_to_string( cand->value, TRUE, NULL, 0 ) ); + } +} + + + diff --git a/soar-8.5.2/cmdline-interface/ask.h b/soar-8.5.2/cmdline-interface/ask.h new file mode 100644 index 0000000..e2ba374 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/ask.h @@ -0,0 +1,4 @@ + +extern void askCallback( soar_callback_agent the_agent, + soar_callback_data data, + soar_call_data call_data ); diff --git a/soar-8.5.2/cmdline-interface/demo_adder.c b/soar-8.5.2/cmdline-interface/demo_adder.c new file mode 100644 index 0000000..c903804 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/demo_adder.c @@ -0,0 +1,158 @@ +#include "soarapi.h" +#include "soar_core_api.h" +#include "soarkernel.h" +#include "demo_adder.h" + + +/* + * two Global variables used to store state information between IO cycles. + */ +int number_received; +int last_tt; + + +/* + * The input function + */ +void io_input_fn( agent *a, soar_callback_data data, + soar_call_data call_data ) { + + char buff[20]; + psoar_wme w; + + + switch ( (int) call_data ) { + + case TOP_STATE_JUST_CREATED: + print( "\nTop state just created\n" ); + break; + + + case NORMAL_INPUT_CYCLE: + print( "\nNormal Input Cycle\n" ); + + /* + * If we received a number on the last DC, increment it and + * add it to the input link + */ + if ( number_received > -1 ) { + + /* + * If we have previously added a wme to the input-link, its + * time-tag will be stored in last_tt and be > -1. In this + * situation, we want to remove it, so that our agent doesn't + * get confused by there being more than one number on the + * input-link at a time. + * + * In general, it is the responsibility of the environment + * to add and remove wmes from the input-link. + */ + if ( last_tt > - 1) { + + /* + * Remove the last wme we added + */ + soar_cRemoveWmeUsingTimetag( last_tt ); + } + + + print( "Adding a number to the input link (%d)\n", number_received+1 ); + + /* + * Get ready to add a new number to the input-link by first + * writing this new number (the number received from the output-link + * plus 1) into a string buffer. + */ + sprintf( buff, "%d", number_received+1); + + /* + * Add the wme. Note that here we assume that I2 is the input-link + * Note that this might not always be the case. A more robust + * version of this code would grab the input-link ID when + * when the input-function is called with the mode + * TOP_STATE_JUST_CREATED + */ + last_tt = soar_cAddWme( "I2", "^number", buff, FALSE, &w); + + print( "Timetag (last_tt) = %d\n", last_tt ); + + } + break; + } + + + +} + + +/* + * The output function + */ +void io_output_fn( agent *a, soar_callback_data data, + soar_call_data call_data ) { + + io_wme *o_wme; + char *buff; + + number_received = -1; + + switch( ((output_call_info *)call_data)->mode ) { + + case MODIFIED_OUTPUT_COMMAND: + case ADDED_OUTPUT_COMMAND: + + /* + * Just to show how the output-function is being invoked... + */ + if ( ((output_call_info *)call_data)->mode == MODIFIED_OUTPUT_COMMAND ) { + print ("\nA command on the output-link has been modified!\n" ); + } + else if (((output_call_info *)call_data)->mode == ADDED_OUTPUT_COMMAND) { + print ("\nA new command has been added to the output-link!\n" ); + } + + + /* + * Cycle through all wmes which were added to the output-link + */ + for( o_wme = ((output_call_info *)call_data)->outputs; + o_wme != NULL; o_wme = o_wme->next ) { + + /* + * Look for a wme whose attribute is "number"...This is the only one + * we care about... + * + * Here we use the soar core api's wme accessor functions to yield + * string representations of the wme's data. It is possible to + * do this in other ways, one useful method is to preallocate + * a buffer "big enough" to hold any attribute, or value, and + * pass this as the second argument to the accessor function. + * This means that a new buffer is not allocated, and does not + * need to be freed, and can result in significant time savings. + * See the documentation in soar_core_api.h for details. + * + */ + buff = soar_cGetWmeAttr( o_wme, NULL, 0 ); + if ( !strcmp( buff, "number")) { + + free( buff ); + buff = soar_cGetWmeValue( o_wme, NULL, 0 ); + number_received = atoi( buff ); + free( buff ); + + print( "Received number %d from the output link\n", number_received); + } + else { + free( buff ); + } + } + break; + + + } + + +} + + + diff --git a/soar-8.5.2/cmdline-interface/demo_adder.h b/soar-8.5.2/cmdline-interface/demo_adder.h new file mode 100644 index 0000000..0670a00 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/demo_adder.h @@ -0,0 +1,11 @@ +extern int number_received; +extern int last_tt; + + +extern void io_input_fn( agent *a, soar_callback_data data, + soar_call_data call_data ); + + +extern void io_output_fn( agent *a, soar_callback_data data, + soar_call_data call_data ); + diff --git a/soar-8.5.2/cmdline-interface/demo_toh.c b/soar-8.5.2/cmdline-interface/demo_toh.c new file mode 100644 index 0000000..deb4d3d --- /dev/null +++ b/soar-8.5.2/cmdline-interface/demo_toh.c @@ -0,0 +1,315 @@ +#include "demo_toh.h" + +glb_info glbInfo; +FILE *moves; + +#define PAUSE_CYCLE 10 + +void update( glb_info *g ); +void printState( glb_info *g ); +io_wme *get_output_wme( char *attribute, io_wme *head ); + +void toh_wait_cb( agent *a, soar_callback_data data, + soar_call_data call_data ) { + + print( "*** Wait Callback Invoked. ***\n" ); + print( " forcing environment to update\n" ); + glbInfo.forceUpdate = 1; + + +} + +void toh_input_fn( agent *a, soar_callback_data data, + soar_call_data call_data ) { + + int pause = (int)data; + + switch ( (int) call_data ) { + + case TOP_STATE_JUST_CREATED: + print( "\nTop state just created\n" ); + toh_initialize( 3 ); + moves = fopen( "toh-moves.mov", "w" ); + break; + + + case NORMAL_INPUT_CYCLE: + print( "\nNormal Input Cycle\n" ); + if ( !pause || (glbInfo.cycle % PAUSE_CYCLE) == 0 || glbInfo.forceUpdate ) + update( &glbInfo ); + + printState( &glbInfo ); + glbInfo.cycle++; + + break; + } + +} + + + + +void toh_output_fn( agent *a, soar_callback_data data, + soar_call_data call_data ) { + + io_wme *o_wme; + char buff[10]; + glb_info *g; + int i; + + + g = &glbInfo; + + + + switch( ((output_call_info *)call_data)->mode ) { + + case MODIFIED_OUTPUT_COMMAND: + case ADDED_OUTPUT_COMMAND: + + /* + * Just to show how the output-function is being invoked... + */ + if ( ((output_call_info *)call_data)->mode == MODIFIED_OUTPUT_COMMAND ) { + print ("\nA command on the output-link has been modified!\n" ); + } + else if (((output_call_info *)call_data)->mode == ADDED_OUTPUT_COMMAND) { + print ("\nA new command has been added to the output-link!\n" ); + } + + if ( !get_output_wme( "status",((output_call_info *)call_data)->outputs )){ + + o_wme = get_output_wme( "move-disk", + ((output_call_info *)call_data)->outputs ); + + if ( o_wme == NULL ) return; + + soar_cGetWmeValue( o_wme, g->moveId, 5 ); + + o_wme = get_output_wme( "size", + ((output_call_info *)call_data)->outputs ); + soar_cGetWmeValue( o_wme, buff, 20 ); + g->cMoveDisk = atoi( buff ); + + + o_wme = get_output_wme( "to", + ((output_call_info *)call_data)->outputs ); + soar_cGetWmeValue( o_wme, buff, 20 ); + + + if ( buff[0] == '|' && buff[2] == '|' ) { + buff[0] = buff[1]; + buff[1] = '\0'; + } + fprintf( moves, "%ld : move-disk ( size = %d, to = %s )\n", + current_agent(d_cycle_count), g->cMoveDisk, buff ); + + g->cMovePeg = -1; + for ( i = 0; i < 3; i++ ) { + if ( !strcmp( g->pegs[i], buff ) ) { g->cMovePeg = i; } + } + + printf( "Got a move --> %d to peg # %d\n", g->cMoveDisk, g->cMovePeg ); + // performMove( &glbInfo ); + } + } +} + +io_wme *get_output_wme( char *attribute, io_wme *head ) { + + char *buff; + /* + * Cycle through all wmes which were added to the output-link + */ + while ( head != NULL ) { + + buff = soar_cGetWmeAttr( head, NULL, 0 ); + if ( !strcmp( buff, attribute ) ) { + free( buff ); + return head; + } + + free( buff ); + head = head->next; + } + return NULL; +} + + + +int performMove ( glb_info *g ) { + + int udSz; + + + if ( g->upper[g->disks[g->cMoveDisk].cOn] != &g->disks[g->cMoveDisk] ) { + printf("Disk %d does not appear to be the upper disk\n", g->cMoveDisk); + return -2; + } + + + if ( g->upper[g->cMovePeg] != NULL ) udSz = g->upper[g->cMovePeg]->cSz; + else udSz = g->nDisks + 10; + + if ( udSz < g->cMoveDisk ) { + printf( "The disk on the destination is too small (%d:%d)\n", udSz, g->cMoveDisk); + return -1; + } + + // make the disk below, the upper disk. + g->upper[g->disks[g->cMoveDisk].cOn] = g->disks[g->cMoveDisk].cAbove; + + // make the disk to move the upper disk on the new peg + g->upper[g->cMovePeg] = &g->disks[g->cMoveDisk]; + g->upper[g->cMovePeg]->cOn = g->cMovePeg; + g->upper[g->cMovePeg]->on = g->pegs[g->cMovePeg]; + + if ( udSz <= g->nDisks ) { + g->upper[g->cMovePeg]->cAbove = &g->disks[udSz]; + sprintf( g->upper[g->cMovePeg]->above, "%d", udSz ); + return udSz; + } + else { + g->upper[g->cMovePeg]->cAbove = NULL; + sprintf( g->upper[g->cMovePeg]->above, "%d", 0 ); + return 0; + } + + +} + +void printState( glb_info *g ) { + + int h; + int maxHeight; + int i, j; + disk *d; + int heights[3]; + + maxHeight = 0; + for( i = 0; i < 3; i++ ) { + + d = g->upper[i]; + h = 0; + while ( d != NULL ) { + d = d->cAbove; + h++; + } + heights[i] = h; + if ( h > maxHeight ) maxHeight = h; + } + printf( "\n" ); + for ( h = maxHeight; h > 0; h-- ) { + + for ( i = 0; i < 3; i++ ) { + printf( " " ); + if ( h <= heights[i] ) { + j = heights[i] - h; + d = g->upper[i]; + while( j > 0 ) { + d = d->cAbove; + j--; + } + printf( "%d", d->cSz ); + } + else printf( " " ); + } + printf( "\n" ); + } + printf( "------------------------------------\n" ); +} + + + + +void update( glb_info *g ) { + + int above; + psoar_wme wme; + + printf( "Updating input link" ); + g->forceUpdate = 0; + + if ( g->cMoveDisk ) { + above = performMove( g ); + + if ( above == -1 ) { + + printf( "Error you can't do such a move\n" ); + return; + } + printf( "You are moving the disk above %d\n", above ); + soar_cRemoveWmeUsingTimetag( g->disks[g->cMoveDisk].onTT ); + soar_cRemoveWmeUsingTimetag( g->disks[g->cMoveDisk].aboveTT ); + + g->disks[g->cMoveDisk].onTT = + soar_cAddWme( g->disks[g->cMoveDisk].wmeID, "^on", + g->disks[g->cMoveDisk].on, FALSE, &wme ); + + + g->disks[g->cMoveDisk].aboveTT = + soar_cAddWme( g->disks[g->cMoveDisk].wmeID, "^above", + g->disks[g->cMoveDisk].above, FALSE, &wme ); + + soar_cAddWme( g->moveId, "^status", "complete", FALSE, &wme ); + + /* Move complete */ + g->cMoveDisk = 0; + + + } +} +void toh_initialize( int n ) { + + int i; + psoar_wme wme; + glb_info *g = &glbInfo; + + memset( g, sizeof( glb_info ), 0 ); + + g->nDisks = n; + strcpy( g->pegs[0], "A" ); + strcpy( g->pegs[1], "B" ); + strcpy( g->pegs[2], "C" ); + + for ( i = 1; i <= n; i++ ) { + + + g->disks[i].cOn = 0; + g->disks[i].cSz = i; + if ( g->disks[i].cSz < n ) g->disks[i].cAbove = &g->disks[i+1]; + else g->disks[i].cAbove = NULL; + + g->disks[i].on = g->pegs[g->disks[i].cOn]; + sprintf( g->disks[i].size, "%d", g->disks[i].cSz ); + + if ( g->disks[i].cAbove ) + sprintf( g->disks[i].above, "%d", i+1 ); + else sprintf( g->disks[i].above, "%d", 0 ); + + soar_cAddWme( "I2", "^disk", "*", FALSE, &wme ); + soar_cGetWmeValue( wme, g->disks[i].wmeID, 6 ); + + g->disks[i].onTT = + soar_cAddWme( g->disks[i].wmeID, "^on", g->disks[i].on, FALSE, &wme); + + g->disks[i].aboveTT = + soar_cAddWme( g->disks[i].wmeID, "^above", g->disks[i].above, FALSE, &wme ); + + soar_cAddWme( g->disks[i].wmeID, "^size", g->disks[i].size, FALSE, &wme ); + + } + + + for( i = 0; i < 3; i++ ) { + soar_cAddWme( "I2", "^peg", g->pegs[i], FALSE, &wme ); + g->upper[i] = NULL; + } + g->upper[0] = &g->disks[1]; + soar_cAddWme( "I2", "^goal-peg", g->pegs[2], FALSE, &wme ); + + +} + + + diff --git a/soar-8.5.2/cmdline-interface/demo_toh.h b/soar-8.5.2/cmdline-interface/demo_toh.h new file mode 100644 index 0000000..c5e137d --- /dev/null +++ b/soar-8.5.2/cmdline-interface/demo_toh.h @@ -0,0 +1,38 @@ +#define MAX_DISKS 4 +#include "soarkernel.h" +#include "soar_core_api.h" + +typedef struct disk_struct { + int cOn; + int cSz; + struct disk_struct *cAbove; + + char *on; + char size[10]; + char above[10]; + char wmeID[6]; + long onTT; + long aboveTT; + +} disk; + +typedef struct global_info_struct { + char inputLinkID[6]; + int nDisks; + disk disks[MAX_DISKS+1]; + disk *upper[3]; + char pegs[3][3]; + char moveId[5]; + int cMoveDisk; + int cMovePeg; + int cycle; + bool forceUpdate; + +} glb_info; + + +extern void toh_input_fn( agent *a, soar_callback_data d, soar_call_data c ); +extern void toh_output_fn( agent *a, soar_callback_data d, soar_call_data c ); +extern void toh_initialize( int ndisks ); +extern void toh_wait_cb( agent *a, soar_callback_data d, soar_call_data c ); +extern glb_info glbInfo; diff --git a/soar-8.5.2/cmdline-interface/license.txt b/soar-8.5.2/cmdline-interface/license.txt new file mode 100644 index 0000000..3ea2d6d --- /dev/null +++ b/soar-8.5.2/cmdline-interface/license.txt @@ -0,0 +1,32 @@ +/* + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ \ No newline at end of file diff --git a/soar-8.5.2/cmdline-interface/main.c b/soar-8.5.2/cmdline-interface/main.c new file mode 100644 index 0000000..f8b17ba --- /dev/null +++ b/soar-8.5.2/cmdline-interface/main.c @@ -0,0 +1,129 @@ +#include "soarapi.h" +#include "soar_core_api.h" +#include "soarkernel.h" +#include "parsing.h" +#include "soarInterfaceCommands.h" +#include "ask.h" +#include + + +#ifdef ADD_TCL_RHS_STUB + +Symbol *tcl_rhs_function_stub ( list *args ) { return NIL; } + +#endif /* ADD_TCL_RHS_STUB */ + + + +/***************************************************************************** + * + * The main routine for the shell interface to Soar. + * + *****************************************************************************/ + +int main( int argc, char **argv ) { + + agent *a; + bool eof_reached; + int i; + soarResult res; + char **temp; + + + /* + * Initialize Soar, this must be called once (and only once) before + * any of Soar's functionality is used. It basically allocates + * memory and initializes some of Soar's internal data structures + */ + soar_cInitializeSoar(); + + /* + * Create an agent. In this example we will only have one agent, + * although more are certainly possible + */ + soar_cCreateAgent( "theAgent" ); + a = soar_cGetAgentByName( "theAgent" ); + + /* + * Register a function (defined by us) which will handle the output + * generated by the kernel. Most (if not all) interfaces need to + * register some type of callback to deal with print calls. In the + * future, it will be easier to avoid this step in the special + * circumstances where it is a burden + */ + soar_cPushCallback( a, PRINT_CALLBACK, (soar_callback_fn) cb_print, + NULL, NULL ); + + + /* + * Register a function to handle clean up when Soar is terminated. + * This is mainly for illustrative purposes. + */ + soar_cPushCallback( a, SYSTEM_TERMINATION_CALLBACK, + (soar_callback_fn) cb_exit, NULL, NULL ); + + soar_cPushCallback( a, ASK_CALLBACK, + (soar_callback_fn) askCallback, NULL, NULL); + /* + * The interface keeps a table of all of the available commands. + * Initialize that table now, before we do anything. + */ + init_soar_command_table(); + + + + +#ifdef ADD_TCL_RHS_STUB + + /* + * This adds a RHS function named 'tcl' to Soar's vocabulary. The + * function, however, is simply a null operation (see the definition + * above) but it will allow this interface to load Soar productions + * which we're built in the TCL environment. However, whether or not + * those applications actually work as intended has a lot to do with + * what the real tcl funtion was supposed to do. (Since here it will do + * nothing) + */ + + add_rhs_function( make_sym_constant( "tcl" ), + tcl_rhs_function_stub, + -1, TRUE, TRUE ); +#endif + + + + /* + * This small block of code allows Soar to deal with command-line + * arguments. At most one argument is expected. If such an argument is + * found, it is taken to be the name of a file which is dealt with as + * though the user had typed "source " at the Soar prompt. + */ + temp = (char **)malloc( 2 * sizeof( char * ) ); + temp[0] = (char *)malloc( 7 * sizeof( char ) ); + + strcpy( temp[0], "source" ); + for( i = 1; i < argc; i++ ) { + print( "Sourcing '%s'\n", argv[i] ); + init_soarResult( res ); + temp[1] = (char *)malloc( (strlen(argv[i]) + 1) * sizeof( char ) ); + strcpy( temp[1], argv[i] ); + interface_Source( 2, temp, &res ); + } + + + /* + * The event loop. Pretty simple. + */ + while( 1 ) { + print( "\nSoar> " ); + executeCommand ( getCommandFromFile( fgetc, stdin, &eof_reached ) ); + } + +} + + + + + + + diff --git a/soar-8.5.2/cmdline-interface/nit1.c b/soar-8.5.2/cmdline-interface/nit1.c new file mode 100644 index 0000000..7122343 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/nit1.c @@ -0,0 +1,120 @@ +#include "soarapi.h" +#include "soar_core_api.h" +#include "soarkernel.h" +#include "parsing.h" +#include "soarInterfaceCommands.h" +#include "ask.h" +#include + + +#ifdef ADD_TCL_RHS_STUB + +Symbol *tcl_rhs_function_stub ( list *args ) { return NIL; } + +#endif /* ADD_TCL_RHS_STUB */ + + +void runEachAgentOnce() { + soar_apiAgentIterator ai; + + printf( "\n\n\n ------- Iterating ------- \n\n\n" ); + soar_cInitAgentIterator( &ai ); + do { + printf( "\n\nrunning 1...\n" ); + soar_cRun( 1, 0, GO_DECISION, NO_SLOT ); + } while ( soar_cStepAgentIterator( &ai ) ); + +} + + +/* + * This funtion is registered with the Soar kernel and called when + * Soar generates output. + */ +void cb_multiagent_print ( agent *the_agent, soar_callback_data d, soar_call_data c ) { + + printf( "%s: %s", the_agent->name, (char *)c ); +} + + +/***************************************************************************** + * + * The main routine for the shell interface to Soar. + * + *****************************************************************************/ + +int main( int argc, char **argv ) { + + agent *a; + int i; + char *names[] = {"AgentA", "AgentB", "AgentC"}; + + + /* + * Initialize Soar, this must be called once (and only once) before + * any of Soar's functionality is used. It basically allocates + * memory and initializes some of Soar's internal data structures + */ + soar_cInitializeSoar(); + + for( i = 0; i < 3; i++ ) { + /* + * Create an agent. In this example we will only have one agent, + * although more are certainly possible + */ + soar_cCreateAgent( names[i] ); + a = soar_cGetAgentByName( names[i] ); + + /* + * Register a function (defined by us) which will handle the output + * generated by the kernel. Most (if not all) interfaces need to + * register some type of callback to deal with print calls. In the + * future, it will be easier to avoid this step in the special + * circumstances where it is a burden + */ + soar_cPushCallback( a, PRINT_CALLBACK, (soar_callback_fn) cb_multiagent_print, + NULL, NULL ); + + + /* + * Register a function to handle clean up when Soar is terminated. + * This is mainly for illustrative purposes. + */ + soar_cPushCallback( a, SYSTEM_TERMINATION_CALLBACK, + (soar_callback_fn) cb_exit, NULL, NULL ); + + soar_cPushCallback( a, ASK_CALLBACK, + (soar_callback_fn) askCallback, NULL, NULL); + + printf( "Initialized %s...\n", names[i] ); + } + + /** + * for this test, we will just be examining the list of agents, and + * modifying its structure by deleting agents... after each operation + * we iterate through the agent list and run each agent 1 cycle, just to + * show they still work... + */ + runEachAgentOnce(); + + printf( "\n\nDeleting agent B\n" ); + soar_cDestroyAllAgentsWithName( "AgentB" ); + runEachAgentOnce(); + + + printf( "\n\nDeleting agent B again\n" ); + soar_cDestroyAllAgentsWithName( "AgentB" ); + runEachAgentOnce(); + + a = soar_cGetAgentByName( "AgentC" ); + printf( "\n\nDestroying agent at head of list!\n"); + soar_cDestroyAgentByAddress( a ); + runEachAgentOnce(); + printf( "\nDone.\n" ); + return 0; +} + + + + + diff --git a/soar-8.5.2/cmdline-interface/parsing.c b/soar-8.5.2/cmdline-interface/parsing.c new file mode 100644 index 0000000..9647741 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/parsing.c @@ -0,0 +1,449 @@ +#include "parsing.h" +#include "soarInterfaceCommands.h" + +/* + * parsing.c + * + * Helper functions to deal with the parsing of commands and arguments. + * + * These functions are not of particular interest to the usage of Soar + * or the API, and are documented somewhat more sparsely than the + * essential aspects of the interface. + * + */ + + +typedef void * string; + +#define memsize_of_string(gs) (*((int *)(gs))) +#define length_of_string(gs) (*(((int *)(gs))+1)) +#define text_of_string(gs) (((char *)(gs)) + 2*sizeof(int *)) + +#define INITIAL_STRING_SIZE 100 + + + +int tokenizeString( char *input, int *ntokens, char ***tokens, + char *token_terminator, soarResult *res ); + +string getCommandFromFile( int (*readCharacter)(FILE *), FILE *f, + bool *eof_reached ); + +string make_blank_string (void); +void add_to_string (string *gs, char *string_to_add); +void clear_string (string gs); +void shorten_string( string *gs ); + + +string gString; + +/* + * execute a command. + * + * The command is expected to be a string suitable for passing to + * tokenizeString. The first word is interpreted as the command name + * and the remaining words are interpreted as arguments to that command + * + */ +int executeCommand( char *command ) { + + char **tokens; + int ntokens; + char token_terminator; + soarResult res; + soar_command *theCommand; + + init_soarResult( res ); + + token_terminator = '\0'; + + /* + * Attempt to break the command into tokens. If its is unparsable, + * i.e. a token is unterminated, the token_terminator character + * will be non-null. + */ + tokenizeString( command, &ntokens, &tokens, &token_terminator, &res ); + + + if ( token_terminator ) { + print( "\n\nError: Token unterminated...\n" ); + return SOAR_ERROR; + } + + /* + * Check for no-op. + */ + if ( ntokens < 1 ) return SOAR_OK; + + + + /* + * the first token is the command name. Look for it in the command + * table. + */ + theCommand = find_soar_command_structure( tokens[0] ); + + /* + * If the command doesn't exist, print an error + */ + if ( !theCommand ) { + print( "Unknown command: '%s'\n", tokens[0] ); + return SOAR_ERROR; + } + + /* + * Otherwise, execute the command, passing the tokens along to it. + */ + if ( (*theCommand->command)( ntokens, tokens, &res ) == SOAR_ERROR ) { + print( "Error evoking command: "); + print ( "%s\n%s\n", theCommand->command_name, res.result ); + } + else if ( *res.result ) { + print ( " %s\n", res.result ); + } + + + return SOAR_OK; +} + + + +/* + * This function performs the majority of the work by breaking a + * single line up into tokens. The line is expected to contain a + * single command and its arguments, so nothing too complex should be + * passed to this function. More complex input can be given to + * getCommandFromFile which deals with multiple lines, and other + * oddities. A simple parsing method is used which is similar to that + * done by the Tcl shell. + * + * Basically, a line is split into words (words being alphanumeric + * strings seperated by whitespace). + * + * Words within double quotes are considered a single token as are + * words within curly braces. + * + */ + +int tokenizeString( char *input, int *ntokens, char ***tokens, + char *token_terminator, soarResult *res ) { + + + char *token_begin, *token_end; /* The beginning and end of a token */ + char *current; /* The current character */ + char *copy; + int brace_level; /* The depth of nested braces */ + + current = input; + +#ifdef DEBUG + printf( "Token Terminator = %c\n", *token_terminator); + printf( "Tokenizing: '%s'\n", input ); +#endif + + /* + * A command line can have at most MAX_TOKENS... beware. + */ + *tokens = (char **)malloc( MAX_TOKENS * sizeof(char *) ); + *ntokens = 0; + + + brace_level = 0; + + while( *current ) { + + /* find token begin */ + while ( !(*token_terminator) && isspace( *current ) ) { + current++; + + if ( *current == '{' ) { + *token_terminator = '}'; + + /* Strip top level braces */ + current++; + brace_level++; + } + else if( *current == '"' ) { + *token_terminator = '"'; + + /* Strip top level quotes */ + current++; + } + } + + token_begin = current; + +#ifdef DEBUG + printf( "Token %d", *ntokens ); +#endif + + if ( *ntokens >= MAX_TOKENS ) { + setSoarResultResult( res, + "Too many tokens in string. Exceeded maximum of %d\n", MAX_TOKENS ); + return SOAR_ERROR; + } + + /* find token end */ + if ( *token_terminator ) { + + if ( *token_terminator == '}' ) { + while( *current) { + if ( *current == '{' ) brace_level++; + if ( *current == '}' ) { + brace_level--; + if ( !brace_level ) break; + } + current++; + } + } + else { + while( *current && *current != *token_terminator ) current++; + } + + /* found terminator */ + if ( *current ) { + + /* Stip off top level token terminator */ + token_end = current; + + current++; + *token_terminator = '\0'; + } + } + else { + + while( *current && !isspace( *current ) ) + current++; + + token_end = current; + } + + + + if ( token_begin != token_end ) { + + /* Allocate memory for token storage */ + (*tokens)[*ntokens] = (char *)malloc( (token_end - token_begin + 1) * + sizeof( char ) ); + + + copy = (*tokens)[*ntokens]; + while( token_begin != token_end ) { + *copy++ = *token_begin++; + } + *copy = '\0'; + + (*ntokens)++; + } + } + +#ifdef DEBUG + { + int i; + for( i = 0; i < (*ntokens); i++ ) { + printf( "Token %d: '%s'\n", i , (*tokens)[i] ); + } + }; + + printf( "Token Terminator = %c\n", *token_terminator); + fflush( stdout ); +#endif + + /* HP: non-void function should return a value */ + return( SOAR_OK ); +} + + + + + + + + + +/* + * getCommandFromFile + * + * This function reads a command line from a file (including stdin) A + * command line is typically terminated by a new-line character. + * However, a semi-colon (;) is interpreted as a psuedo-new-line + * character, thus allowing mutliple 'command lines' to appear + * between new-line characters. + * + * Note that if braces are used, new-line characters are ignored until + * matching close braces are found. This allows single arguments to span + * multiple lines. + */ +string getCommandFromFile( int (*readCharacter)(FILE *), FILE *f, + bool *eof_reached ) { + + static char input_str[LINE_BUFFER_LENGTH]; + + char *input; + int brace_level; + char inQuotedString; + int inputInt; + + + if ( gString == NULL ) gString = make_blank_string(); + else clear_string( gString ); + + inQuotedString = 0; + brace_level = 0; + + *eof_reached = FALSE; + + input = input_str; + while ( (inputInt = (*readCharacter)(f)) ) { + + + if ( inputInt == EOF ) { + *eof_reached = TRUE; + *input = '\0'; + break; + } + + /* convert to char */ + *input = (char) inputInt; + + if ( *input == '#' && !inQuotedString ) { + + /* consume until end of line, without incrementing */ + while( (inputInt = (*readCharacter)(f)) ) { + + /* convert to char */ + *input = (char) inputInt; + + if ( (inputInt == EOF) || (*input == '\n') || (*input == '\0') ) { + *input = '\0'; + break; + } + } + continue; + + } + + /* Look for end of line */ + if ( *input == '\n' || *input == ';' ) { + *input = '\n'; + if ( !inQuotedString && brace_level == 0 ) { + *input = '\0'; + break; + } + } + else if ( *input == '"' ) { + if ( inQuotedString == '"' ) inQuotedString = 0; + else if ( inQuotedString == 0 ) inQuotedString = '"'; + } + else if ( *input == '|' ) { + if ( inQuotedString == '|' ) inQuotedString = 0; + else if ( inQuotedString == 0 ) inQuotedString = '|'; + } + else if ( *input == '{' ) { + brace_level++; + } + else if ( *input == '}' ) { + brace_level--; + + if ( brace_level < 0 ) { + print( "\n extra characters after close-brace\n" ); + + + /* invalidate command & reset */ + input_str[0] = '\0'; + brace_level = 0; + inQuotedString = 0; + + break; + } + } + + input++; + if ( (input - input_str) >= LINE_BUFFER_LENGTH ) { + + /* save the last character */ + inputInt = (int)input_str[LINE_BUFFER_LENGTH - 1]; + input_str[LINE_BUFFER_LENGTH - 1] = '\0'; + add_to_string( &gString, input_str ); + + input = input_str; + *input++ = (char)inputInt; + + } + + } /* end while */ + + if ( input != input_str ) { + /* Then we've read a character */ + add_to_string( &gString, input_str ); + } + +#ifdef DEBUG + print( "Get Command Returns '%s'\n", text_of_string( gString ) ); +#endif + + /* free up unused memory */ + // shorten_string( &gString ); + return text_of_string(gString); + +} + + + + + + +string make_blank_string (void) { + string gs; + + gs = malloc (2*sizeof(int *) + INITIAL_STRING_SIZE ); + memsize_of_string(gs) = INITIAL_STRING_SIZE; + length_of_string(gs) = 0; + *(text_of_string(gs)) = 0; + return gs; +} + +void add_to_string (string *gs, char *string_to_add) { + int current_length, length_to_add, new_length, new_memsize; + string new; + + + current_length = length_of_string(*gs); + length_to_add = strlen (string_to_add); + new_length = current_length + length_to_add; + if (new_length + 1 > memsize_of_string(*gs)) { + new_memsize = memsize_of_string(*gs); + while (new_length + 1 > new_memsize) new_memsize = new_memsize * 2; + new = malloc (new_memsize + 2*sizeof(int *)); + memsize_of_string(new) = new_memsize; + strcpy (text_of_string(new), text_of_string(*gs)); + free (*gs); + *gs = new; + } + strcpy (text_of_string(*gs)+current_length, string_to_add); + length_of_string(*gs) = new_length; + +} + +void clear_string (string gs) { + + length_of_string( gs ) = 0; + *(text_of_string(gs)) = 0; + +} + +void shorten_string( string *gs ) { + + int newlen; + + newlen = length_of_string( *gs ) + ((memsize_of_string( *gs ) - length_of_string( *gs )) / 2); + + + if ( newlen >= memsize_of_string( *gs ) ) return; + *gs = realloc( *gs, newlen + 2*sizeof( int * ) ); + memsize_of_string( *gs ) = newlen; +} + + + + diff --git a/soar-8.5.2/cmdline-interface/parsing.h b/soar-8.5.2/cmdline-interface/parsing.h new file mode 100644 index 0000000..fde1683 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/parsing.h @@ -0,0 +1,16 @@ +#include "soarkernel.h" +#include "soarapi.h" + + +#define MAX_TOKENS 25 +#define LINE_BUFFER_LENGTH 512 + +int tokenizeString( char *input, int *ntokens, char ***tokens, + char *token_terminator, soarResult *res ); + + +growable_string getCommandFromFile( int (*readCharacter)(FILE *), FILE *f, + bool *eof_reached ); + +int executeCommand( char *command ); + diff --git a/soar-8.5.2/cmdline-interface/shell.dsp b/soar-8.5.2/cmdline-interface/shell.dsp new file mode 100644 index 0000000..5bf9dd1 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/shell.dsp @@ -0,0 +1,146 @@ +# Microsoft Developer Studio Project File - Name="shell" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=shell - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "shell.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "shell.mak" CFG="shell - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "shell - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "shell - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "shell - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "..\kernel" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "shell - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\kernel" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ADD_IO_EXAMPLE" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "shell - Win32 Release" +# Name "shell - Win32 Debug" +# Begin Source File + +SOURCE=.\ask.c +# End Source File +# Begin Source File + +SOURCE=.\ask.h +# End Source File +# Begin Source File + +SOURCE=.\demo_adder.c +# End Source File +# Begin Source File + +SOURCE=.\demo_adder.h +# End Source File +# Begin Source File + +SOURCE=.\demo_toh.c +# End Source File +# Begin Source File + +SOURCE=.\demo_toh.h +# End Source File +# Begin Source File + +SOURCE=.\main.c +# End Source File +# Begin Source File + +SOURCE=.\parsing.c +# End Source File +# Begin Source File + +SOURCE=.\parsing.h +# End Source File +# Begin Source File + +SOURCE=..\kernel\soar_core_api.h +# End Source File +# Begin Source File + +SOURCE=..\kernel\soarapi.h +# End Source File +# Begin Source File + +SOURCE=.\soarInterfaceCommands.c +# End Source File +# Begin Source File + +SOURCE=.\soarInterfaceCommands.h +# End Source File +# Begin Source File + +SOURCE=..\kernel\soarkernel.h +# End Source File +# Begin Source File + +SOURCE=..\kernel\soarkernel.lib +# End Source File +# End Target +# End Project diff --git a/soar-8.5.2/cmdline-interface/shell.dsw b/soar-8.5.2/cmdline-interface/shell.dsw new file mode 100644 index 0000000..245f0df --- /dev/null +++ b/soar-8.5.2/cmdline-interface/shell.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "shell"=".\shell.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/soar-8.5.2/cmdline-interface/soarInterfaceCommands.c b/soar-8.5.2/cmdline-interface/soarInterfaceCommands.c new file mode 100644 index 0000000..848bc58 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/soarInterfaceCommands.c @@ -0,0 +1,496 @@ + +#include "soarInterfaceCommands.h" +#include "soarkernel.h" +#include "parsing.h" +#include "demo_adder.h" +#include "demo_toh.h" + + +hash_table *gSoarCommands; +list *gDirectoryStack = NULL; + + + + +/* + * SECTION 1: INTERFACE-DEFINED COMMANDS + * + * Within this first section, we define a number of commands + * particular to this shell-interface to Soar. These include + * callbacks which are registered with the Soar kernel at startup + * as well a few commands which may be invoked directly by the + * user. + * + */ + + +/* + * This function is registered with the Soar kernel, and called + * upon system termination. It is here mainly for illustrative + * purposes. + */ +void cb_exit ( agent *the_agent, soar_callback_data d,soar_call_data c ) { + + if (c == (soar_call_data) TRUE ) { + print ("Bye.\n"); + exit( 0 ); + } +} + +/* + * This funtion is registered with the Soar kernel and called when + * Soar generates output. In this simple shell-interface, we need only + * print that output using standard IO function calls + */ +void cb_print ( agent *the_agent, soar_callback_data d, soar_call_data c ) { + + printf( "%s", (char *)c ); +} + + + +/* + * This is command is invoked by the user with the following + * syntax: + * set + * + * It is intended to help maintain some amount of consistency with + * the Tcl interface but as can be seen, it has only minimal functionality + */ +int interface_Set( int argc, const char **argv, soarResult *res ) { + + if ( argc < 2 ) { + setSoarResultResult( res, "Too few arguments to 'set'\n" ); + return SOAR_ERROR; + } + + if ( !strcmp( argv[1], "max_elaborations" ) ) { + return soar_MaxElaborations( argc-1, &argv[1], res ); + } + setSoarResultResult( res, "Don't know how to set '%s'", argv[1] ); + return SOAR_ERROR; +} + + + +/* + * This is command is invoked by the user with the following + * syntax: + * pushd + * + * It is intended to help maintain some amount of consistency with + * the Tcl interface, this function is not a part of the api because + * the particualr implementation may vary based upon OS and interface + * details. + */ +int interface_pushd( int argc, const char **argv, soarResult *res ) { + + cons *c; + char *cdir; + + + if ( argc < 1 ) { return SOAR_ERROR; } + + c = (cons *) malloc( sizeof( cons ) ); + cdir = (char *) malloc( 1024 * sizeof( char ) ); + sys_getwd( cdir, 1024 ); + c->first = cdir; + c->rest = gDirectoryStack; + gDirectoryStack = c; + + sys_chdir( argv[1] ); + print( "Changing Directory to '%s'\n", argv[1] ); + + return SOAR_OK; +} + + + +/* + * This is command is invoked by the user with the following + * syntax: + * popd + * + * It is intended to help maintain some amount of consistency with + * the Tcl interface, this function is not a part of the api because + * the particualr implementation may vary based upon OS and interface + * details. + */ +int interface_popd ( int argc, const char **argv, soarResult *res ) { + + cons *c; + + if ( gDirectoryStack == NULL ) { + print ( "Directory Stack is empty!\n" ); + return SOAR_ERROR; + } + sys_chdir( (char *)(gDirectoryStack->first) ); + c = gDirectoryStack; + gDirectoryStack = gDirectoryStack->rest; + + free( c ); + return SOAR_OK; +} + + +/* + * This is command is invoked by the user with the following + * syntax: + * source + * + * It is intended to help maintain some amount of consistency with + * the Tcl interface, this function is not a part of the api because + * the particualr implementation may vary based upon OS and interface + * details. + */ +int interface_Source( int argc, const char **argv, soarResult *res ) { + + FILE *f; + bool eof_reached; + + if ( argc < 2 ) { + setSoarResultResult( res, "No Filename specified\n" ); + return SOAR_ERROR; + } + + f = fopen( argv[1], "r" ); + + if ( !f ) { + setSoarResultResult( res, "Could not open file '%s'\n", argv[1] ); + return SOAR_ERROR; + } + + eof_reached = FALSE; + while( !eof_reached ) { + executeCommand( getCommandFromFile( fgetc,f, &eof_reached ) ); + } + + fclose( f ); + clearSoarResultResult( res ); + return SOAR_OK; +} + + +/* + * This is command is invoked by the user with the following + * syntax: + * echo + * + * It is intended to help maintain some amount of consistency with + * the Tcl interface, this function is not a part of the api because + * the particualr implementation may vary based upon OS and interface + * details. We use the soar "print" function to create output that + * is treated in the same manner as that which is generated by the + * soar kernel. + */ +int interface_echo( int argc, const char **argv, soarResult *res ) { + + int i; + + for( i = 1; i < argc; i++ ) { + print( "%s ", argv[i] ); + } + print( "\n" ); + + clearSoarResultResult( res ); + return SOAR_OK; +} + + +/* + * This is command is invoked by the user with the following + * syntax: + * counter-demo + * + * It loads the agent, and initializes soar for running the demo + */ +int interface_counter_demo( int argc, const char **argv, soarResult *res ) { + + + soar_cExciseAllProductions(); + soar_cReInitSoar(); + executeCommand( "source ./agents/adder.soar" ); + + /* + * remove any old input/output functions + */ + soar_cRemoveAllCallbacksForEvent( soar_agent, INPUT_PHASE_CALLBACK ); + soar_cRemoveAllCallbacksForEvent( soar_agent, OUTPUT_PHASE_CALLBACK ); + + /* + * Initialize global variables used by the IO functions + */ + last_tt = -1; + number_received = -1; + + + /* + * Add input and output functions, to illustrate Soar IO. + * Built with this option, Soar can be run with the adder.soar + * agent. This agent reads off the input-link and writes to the + * output-link providing an extremely simple (but still useful) + * example of how to connect Soar to an external environment. + */ + + soar_cAddOutputFunction( soar_cGetCurrentAgent(), + (soar_callback_fn) io_output_fn , + NULL, NULL, "output-link" ); + + soar_cAddInputFunction( soar_cGetCurrentAgent(), + (soar_callback_fn) io_input_fn , + NULL, NULL,"input-link" ); + + + setSoarResultResult( res, "counter demo ready" ); + return SOAR_OK; +} + + + +/* + * This is command is invoked by the user with the following + * syntax: + * toh-demo + * + * It loads the agent, and initializes soar for running the demo + */ +int interface_toh_demo( int argc, const char **argv, soarResult *res ) { + + int type; + + if ( argc == 2 && !strcmp( argv[1], "-pause" ) ) type = 1; + else if ( argc == 2 && !strcmp( argv[1], "-nowait" ) ) type = 2; + else type = 0; + + soar_cExciseAllProductions(); + soar_cReInitSoar(); + executeCommand( "source ./agents/toh.soar" ); + soar_cSetWaitSNC( TRUE ); + /* + * remove any old input/output functions + */ + soar_cRemoveAllCallbacksForEvent( soar_agent, INPUT_PHASE_CALLBACK ); + soar_cRemoveAllCallbacksForEvent( soar_agent, OUTPUT_PHASE_CALLBACK ); + + /* + * Add input and output functions, to illustrate Soar IO. + * Built with this option, Soar can be run with the adder.soar + * agent. This agent reads off the input-link and writes to the + * output-link providing an extremely simple (but still useful) + * example of how to connect Soar to an external environment. + */ + + soar_cAddOutputFunction( soar_cGetCurrentAgent(), + (soar_callback_fn) toh_output_fn , + (soar_callback_data)type, NULL, "output-link" ); + + soar_cAddInputFunction( soar_cGetCurrentAgent(), + (soar_callback_fn) toh_input_fn , + (soar_callback_data) type, NULL,"input-link" ); + + + switch ( type ) { + case 0: + setSoarResultResult( res, "toh demo ready (non-pausing-style)" ); + break; + case 1: + setSoarResultResult( res, "toh demo ready (pausing-style)" ); + break; + case 2: + setSoarResultResult(res,"toh demo ready (pausing-style w/ wait override)"); + soar_cPushCallback( soar_cGetCurrentAgent(), WAIT_CALLBACK, + (soar_callback_fn) toh_wait_cb , + NULL, NULL ); + break; + } + + + + return SOAR_OK; +} + + + + + +/* + * SECTION 2: THE COMMAND TABLE + * + * Within this second section, we define a number of functions + * used to deal with the global command table. In essence functions + * which define the capabilities of the interface. + * + */ + + +/* + * Initialize the command table. + * + * The command table is a global structure (a hash table) which + * stores allows commands to be looked up by name, and invoked via a + * function pointer. This function serves only to initilize this + * command table, and name each one of the commands availble to the + * user. Note that commands may be added under more that one name, + * but that names must be unique. + */ +void init_soar_command_table( void ) { + + gSoarCommands = make_hash_table( 6, (hash_function)hash_soar_command ); + + add_to_hash_table( gSoarCommands, + new_soar_command( ".", interface_Source ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "add-wme", soar_AddWme ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "build-info", soar_BuildInfo ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "counter-demo", interface_counter_demo ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "echo", interface_echo ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "excise", soar_Excise ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "indifferent-selection", + soar_IndifferentSelection ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "init-soar", + soar_ReInitSoar ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "learn", soar_Learn ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "log", soar_Log ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "matches", soar_Matches ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "multi-attributes", + soar_MultiAttributes ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "p", soar_Print ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "pf", soar_ProductionFind ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "popd", interface_popd ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "pref", soar_Preferences ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "print", soar_Print ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "pushd", interface_pushd ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "quit", soar_Quit ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "remove-wme", soar_RemoveWme ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "rete-net", soar_ReteNet ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "run", soar_Run ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "set", interface_Set ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "source", interface_Source ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "sp", soar_Sp ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "stats", soar_Stats ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "toh-demo", interface_toh_demo ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "v", soar_Verbose ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "verbose", soar_Verbose ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "w", soar_Watch ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "watch", soar_Watch ) ); +#ifdef USE_CAPTURE_REPLAY + add_to_hash_table( gSoarCommands, + new_soar_command( "capture", soar_CaptureInput ) ); + add_to_hash_table( gSoarCommands, + new_soar_command( "replay", soar_ReplayInput ) ); +#endif +} + + + + + + +int hash_soar_command_string( char *name, short nbits ) { + + int val, length; + + if ( name == NULL ) return 0; + + length = strlen( name ); + val = length + 26 * (int)name[0]; + + switch (length) { + + default: + val += (int)name[3]; + + case 3: + val += (int)name[2]; + + case 2: + val += (int)name[1]; + + case 1: + break; + } + + return val & masks_for_n_low_order_bits[nbits]; + +} + + +/* + * Return the Hash value for a soar_command structure + */ + +int hash_soar_command ( void *item, short nbits ) { + return hash_soar_command_string( ((soar_command *)item)->command_name, + nbits ); +} + + + +/* + * Create a new command structure, to be added into the global comman table + */ +soar_command *new_soar_command( char *name, + int (*cmd)(int, const char **, soarResult *) ) { + + soar_command *c; + + c = malloc( sizeof( soar_command ) ); + c->command_name = malloc( (strlen( name ) + 1) * sizeof(char) ); + strcpy( c->command_name, name ); + c->command = cmd; + + return c; +} + +/* + * Check for the existence of a command. If the command does indeed + * exist, return a structure containing its registry information + * (including a pointer to the function itself) + */ +soar_command *find_soar_command_structure( char *name ) { + + int commandHash; + soar_command *theCommand; + + commandHash = hash_soar_command_string( name, gSoarCommands->log2size ); + theCommand = (soar_command *) (*(gSoarCommands->buckets + commandHash )); + + for ( ; theCommand != NIL; theCommand = theCommand->next ) { + + if ( !strcmp( name, theCommand->command_name ) ) { + break; + + } + } + return theCommand; +} + diff --git a/soar-8.5.2/cmdline-interface/soarInterfaceCommands.h b/soar-8.5.2/cmdline-interface/soarInterfaceCommands.h new file mode 100644 index 0000000..57cc085 --- /dev/null +++ b/soar-8.5.2/cmdline-interface/soarInterfaceCommands.h @@ -0,0 +1,39 @@ +#include "soarapi.h" + + +void cb_exit ( agent *the_agent, + soar_callback_data data, + soar_call_data call_data ); + + +void cb_print ( agent *the_agent, + soar_callback_data data, + soar_call_data call_data ); + + +typedef struct soar_command_struct { + + /* Warning this MUST be the first field, for the ht routines */ + struct soar_command_struct *next; + + char *command_name; + int (*command)( int, const char **, soarResult * ); + +} soar_command; + + +extern unsigned long masks_for_n_low_order_bits[]; + + + +/* + * Prototypes + */ +soar_command *new_soar_command( char *name, + int (*cmd)(int, const char **, soarResult *) ); + +int hash_soar_command( void * item, short nbits ); +int interface_Source( int argc, const char **argv, soarResult *res ); +soar_command *find_soar_command_structure( char *name ); + +void init_soar_command_table( void ); diff --git a/soar-8.5.2/cmdline-interface/soar_app b/soar-8.5.2/cmdline-interface/soar_app new file mode 100755 index 0000000..220c52a Binary files /dev/null and b/soar-8.5.2/cmdline-interface/soar_app differ diff --git a/soar-8.5.2/demos/blocks-world/blocks-opsub.soar b/soar-8.5.2/demos/blocks-world/blocks-opsub.soar new file mode 100644 index 0000000..cbe3939 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-opsub.soar @@ -0,0 +1,302 @@ +### +### FILE : blocks-opsub.soar +### AUTHOR(1) : John.E.Laird [ Soar 8.2 ] +### CREATED(1) : December 12, 1998 +### Last modified : May 27, 2004 +### +### Uses operator subgoaling to solve blocks-world + +set max_elaborations 10 +alias pref preferences + +## Will not work correctly with chunking +learn -off + +source ../default/simple.soar + +### +### Initialize the state +### + +sp {blocks-world*propose*initialize-blocks-world + (state ^superstate nil + -^name) +--> + ( ^operator ) + ( ^name initialize-blocks-world) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , , ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize-blocks-world) +--> + ( ^name blocks-world + ^world-state + ^ontop + ^clear
                                                                                                                        + ^object
                                                                                                                        ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^name blocks-world + ^object
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        )} + --> + ( ^operator ) + ( ^name build-tower + ^desired ) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^name << move-block build-tower >> + ^world-state ) + ( ^object + { <> }) + ( ^type block) + -{( ^ontop ) + ( ^top-block + ^bottom-block )} + --> + ( ^operator + =) + ( ^name move-block + ^moving-block + ^destination ) + } + +sp {blocks-world*copy*desired-tower + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator.desired ) + --> + ( ^desired )} + +sp {blocks-world*copy*world-state + :default + (state ^impasse no-change + ^attribute operator + ^superstate.world-state ) + --> + ( ^world-state )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator + ^world-state ) + ( ^ontop + ^clear ) + ( ^top-block + -^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^ontop -)} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator + ^world-state ) + ( ^clear ) + ( ^moving-block + ^destination ) +-{( ^ontop ) + ( ^top-block + ^bottom-block )} + --> + ( ^ontop ) + ( ^top-block + ^bottom-block )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator + ^world-state ) + ( ^clear ) + ( ^moving-block + ^destination ) + ( ^type block) + --> + ( ^clear -)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator + ^world-state ) + ( ^ontop ^clear ) + ( ^top-block + ^bottom-block { <> }) + ( ^type block) + ( ^moving-block + ^destination ) + --> + ( ^clear )} + +### +### SEARCH CONTROL +### + +sp {blocks-world*prefer*clear-block + (state ^operator + + ^desired.clear + ^world-state.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination <> ) + --> + ( ^operator >)} + +sp {blocks-world*prefer*clear-block*monitor + (state ^operator + + ^desired.clear + ^world-state.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Prefer move | | --> | | to clear | )} + +sp {blocks-world*prefer*ontop + (state ^operator + + ^desired.ontop + ^world-state ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^operator >)} + +sp {blocks-world*prefer*ontop*monitor + (state ^operator + + ^desired.ontop + ^world-state ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Prefer move | | to | )} + +sp {top-ps*monitor*goal + (state ^ontop ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + --> + (write (crlf) |*** ACHIEVED GOAL ***|) + ( ^success *yes*)} + + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*world-state + (state ^world-state + ^ontop ) + ( ^top-block.name + ^bottom-block.name ) + --> + (write (crlf)| ontop(| |,| |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |SELECT | |: move-block(| |,| |)|)} + + +######### OPERATOR SUBGOALING + +sp {default*opsub*propose*space*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^moving-block + ^destination ) + --> + ( ^problem-space + ^name operator-subgoal + ^desired ) + ( ^clear )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal + ^superstate ) + ( ^ { <> problem-space + <> choices + <> impasse + <> object + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.soar new file mode 100644 index 0000000..8806e1e --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.soar @@ -0,0 +1,3 @@ +pushd blocks-world-look-ahead +source blocks-world-look-ahead_source.soar +popd diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.vsa b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.vsa new file mode 100644 index 0000000..ba4412b --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead.vsa @@ -0,0 +1,15 @@ +VERSION 4 +\blocks-world-look-ahead\blocks-world-look-ahead.dm +0 ROOT blocks-world-look-ahead blocks-world-look-ahead 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR clear clear.soar 5 +5 3 FOPERATOR detect-success detect-success.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 3 FOPERATOR top-state top-state.soar 8 +8 0 FOPERATOR _readme _readme.soar 9 +9 0 FOPERATOR search-control search-control.soar 10 +10 0 OPERATOR initialize-blocks-world-look-ahead initialize-blocks-world-look-ahead.soar 11 +11 0 OPERATOR move-block move-block.soar 12 +END diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_firstload.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_firstload.soar new file mode 100644 index 0000000..f1bd7ff --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_firstload.soar @@ -0,0 +1,14 @@ +### Blocks world that uses the selection problem space (from the default folder) to do +### simple look-ahead search to find path to goal. +### Works with chunking, which builds control rules. + +multi-attributes ontop 3 +multi-attributes clear 3 +multi-attributes objects 4 + +learn -on + +pushd "../../default" +source selection.soar +popd + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_readme.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_readme.soar new file mode 100644 index 0000000..a8fdd3a --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/_readme.soar @@ -0,0 +1,22 @@ +# Classic 3 block blocks world with look ahead +# John E. Laird +# University of Michigan +# May 25, 2004 +# Soar version 8.5.1 + +# This is a simple version of blocks world +# Three blocks and the table. +# Does a look-ahead using the selection space. + +# In this formulation, clear is computed as an elaboration +# (in elaborations/clear). The table is always clear. + +# Change made to blocks-world to enable look ahead: +# 1. Add to elaborations/top-state: blocks-world*elaborate*problem-space +# 2. Change elaborations/detect-success: blocks-world*elaborate*state*success +# so it marks the state with success - this will be used in look-ahead +# 3. Change search-control.soar so it rejects moving the same block twice. +# In look-ahead this will lead to failure when no blocks can be moved and avoid +# some non-optimal solutions. +# 4. Remove = preferences from move-block operator proposals + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/all/all_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead.dm b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead.dm new file mode 100644 index 0000000..f9431ce --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead.dm @@ -0,0 +1,56 @@ +24 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 blocks-world +SOAR_ID 4 +ENUMERATION 5 1 move-block +SOAR_ID 6 +SOAR_ID 7 +SOAR_ID 8 +SOAR_ID 9 +ENUMERATION 10 2 A C +ENUMERATION 11 1 table +ENUMERATION 12 1 table +SOAR_ID 13 +SOAR_ID 14 +SOAR_ID 15 +ENUMERATION 16 1 initialize-blocks-world-look-ahead +ENUMERATION 17 4 A B C table +ENUMERATION 18 2 block table +SOAR_ID 19 +ENUMERATION 20 1 move-blocks +ENUMERATION 21 1 yes +ENUMERATION 22 1 ontop +ENUMERATION 23 1 object +30 +0 clear 14 +0 desired 7 +0 last-moved-block 14 +0 name 3 +0 object 14 +0 ontop 6 +0 operator 4 +0 operator 15 +0 problem-space 19 +0 success 7 +0 superstate 2 +0 type 1 +4 destination 14 +4 moving-block 14 +4 name 5 +6 bottom-block 9 +6 top-block 8 +7 ontop 13 +8 name 10 +9 name 11 +9 type 12 +13 bottom-block 14 +13 top-block 14 +14 name 17 +14 type 18 +15 name 16 +19 default-state-copy 21 +19 name 20 +19 one-level-attributes 23 +19 two-level-attributes 22 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead_source.soar new file mode 100644 index 0000000..d6b02d3 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/blocks-world-look-ahead_source.soar @@ -0,0 +1,11 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source search-control.soar +source initialize-blocks-world-look-ahead.soar +source move-block.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/comment.dm b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/comment.dm new file mode 100644 index 0000000..a0024d7 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/comment.dm @@ -0,0 +1,30 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/clear.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/clear.soar new file mode 100644 index 0000000..b2a593e --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/clear.soar @@ -0,0 +1,19 @@ +# If an blcok does not have another block ontop of it, it is clear. + +sp {blocks-world*elaborate*state*clear + (state ^name blocks-world + ^object + -^ontop.bottom-block ) +--> + ( ^clear ) +} + +# Table is always clear + +sp {blocks-world*elaborate*state*clear-table + (state ^name blocks-world + ^object ) + ( ^type table) +--> + ( ^clear ) +} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/detect-success.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/detect-success.soar new file mode 100644 index 0000000..0c3dd76 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/detect-success.soar @@ -0,0 +1,25 @@ +### Detect Goal Achievement +### + +sp {blocks-world*elaborate*state*success + (state ^desired + ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) +--> + ( ^success )} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/elaborations_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/elaborations_source.soar new file mode 100644 index 0000000..302e66f --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source clear.soar +source detect-success.soar +source monitor.soar +source top-state.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/monitor.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/monitor.soar new file mode 100644 index 0000000..81a8fc2 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/monitor.soar @@ -0,0 +1,21 @@ + +sp {blocks-world*monitor*world-state + (state ^ontop ) + ( ^top-block.name + ^bottom-block.name ) +--> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block.name + ^destination.name ) +--> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/top-state.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/top-state.soar new file mode 100644 index 0000000..5cd1ac6 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/elaborations/top-state.soar @@ -0,0 +1,9 @@ +sp {blocks-world*elaborate*problem-space + (state ^name blocks-world) +--> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name move-blocks + ^default-state-copy yes + ^two-level-attributes ontop + ^one-level-attributes object)} + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize-blocks-world-look-ahead.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize-blocks-world-look-ahead.soar new file mode 100644 index 0000000..3870778 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize-blocks-world-look-ahead.soar @@ -0,0 +1,43 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize-blocks-world-look-ahead + (state ^superstate nil + -^name) +--> + ( ^operator ) + ( ^name initialize-blocks-world-look-ahead)} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,

                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize-blocks-world-look-ahead) +--> + ( ^name blocks-world + ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize.soar new file mode 100644 index 0000000..f333c80 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/initialize.soar @@ -0,0 +1,43 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize + (state ^name blocks-world + -^object) +--> + ( ^operator ) + ( ^name initialize) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,
                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize) +--> + ( ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/move-block.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/move-block.soar new file mode 100644 index 0000000..cba1f2a --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/move-block.soar @@ -0,0 +1,53 @@ +### +### MOVE-BLOCK +### + +# Propose moving a clear block ontop a clear object + +sp {blocks-world*propose*operator*move-clear-block-to-clear-object + (state ^name blocks-world) + ( ^clear + ^clear { <> }) + ( ^type block) + -{( ^ontop ) + ( ^top-block + ^bottom-block )} +--> + ( ^operator +) + ( ^name move-block + ^moving-block + ^destination )} + +sp {blocks-world*apply*operator*move-block*change-ontop + (state ^operator + ^ontop ) + ( ^top-block + ^bottom-block { <> }) + ( ^moving-block + ^destination ) +--> + ( ^bottom-block + ^bottom-block -)} + +## Maintain a history of what block was moved last +## For use by search control + +sp {blocks-world*apply*operator*remember*moved-block + (state ^operator + -^last-moved-block ) + ( ^name move-block + ^moving-block ) +--> + ( ^last-moved-block ) +} + +sp {blocks-world*apply*operator*forget*moved-block + (state ^operator + ^last-moved-block ) + ( ^name move-block + ^moving-block <> ) +--> + ( ^last-moved-block -)} + + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/search-control.soar b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/search-control.soar new file mode 100644 index 0000000..dc01675 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-look-ahead/search-control.soar @@ -0,0 +1,7 @@ +sp {blocks-world*reject*move-block*twice + (state ^name blocks-world + ^operator + + ^last-moved-block ) + ( ^moving-block ) +--> + ( ^operator -)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.soar new file mode 100644 index 0000000..89624f0 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.soar @@ -0,0 +1,3 @@ +pushd blocks-world-operator-subgoaling +source blocks-world-operator-subgoaling_source.soar +popd diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.vsa b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.vsa new file mode 100644 index 0000000..458c365 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling.vsa @@ -0,0 +1,16 @@ +VERSION 4 +\blocks-world-operator-subgoaling\blocks-world-operator-subgoaling.dm +0 ROOT blocks-world-operator-subgoaling blocks-world-operator-subgoaling 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR clear clear.soar 5 +5 3 FOPERATOR detect-success detect-success.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 0 FOPERATOR _readme _readme.soar 8 +8 0 FOPERATOR search-control search-control.soar 9 +9 0 OPERATOR initialize-blocks-world-operator-subgoaling initialize-blocks-world-operator-subgoaling.soar 10 +10 0 HLOPERATOR move-block move-block.soar move-block 19 11 +11 10 FOPERATOR elaborations elaborations.soar 12 +12 10 OPERATOR move-block move-block.soar 13 +END diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_firstload.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_firstload.soar new file mode 100644 index 0000000..81d8933 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_firstload.soar @@ -0,0 +1,12 @@ +### Blocks world that uses the selection problem space (from the default folder) to do +### simple look-ahead search to find path to goal. +### Works with chunking, which builds control rules. + +multi-attributes ontop 3 +multi-attributes clear 3 +multi-attributes objects 4 + +# Operator subgoaling does not work correctly if learning is on. +learn -off + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_readme.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_readme.soar new file mode 100644 index 0000000..12befd3 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/_readme.soar @@ -0,0 +1,29 @@ +# Classic 3 block blocks world with operator subgoaling +# John E. Laird +# University of Michigan +# May 23, 2004 +# Soar version 8.5.1 + +# This is a simple version of blocks world +# Three blocks and the table. +# Uses operator subgoaling where an operator can be selected even if +# it can't apply. +# The whole process works recursively. + + +# In this formulation, clear is computed as an elaboration +# (in elaborations/clear). The table is always clear. + +# Changes made to blocks-world-look-ahead to enable operator subgoaling +# 1. move-block: Change the proposal to move-block so all possible moves are proposed. +# 2. Add search control to prefer selecting operator that achieves desired. +# One for ^ontop relations and one for ^clear relations +# 3. Add some monitoring rules and remove old applied one that is now incorrect. +# 5. Add move-block as suboperator to move-block +# 6. Add rules to initialize substate in move-block/elaborations +# 7. Add tests in move-block application to ensure blocks are clear +# 8. Remove last-move rules (application and search control) - not appropriate + + + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/all/all_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead.dm b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead.dm new file mode 100644 index 0000000..ed3c386 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead.dm @@ -0,0 +1,45 @@ +19 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 blocks-world +SOAR_ID 4 +ENUMERATION 5 1 move-block +SOAR_ID 6 +SOAR_ID 7 +SOAR_ID 8 +SOAR_ID 9 +ENUMERATION 10 2 A C +ENUMERATION 11 1 table +ENUMERATION 12 1 table +SOAR_ID 13 +SOAR_ID 14 +SOAR_ID 15 +ENUMERATION 16 1 initialize +ENUMERATION 17 4 A B C table +ENUMERATION 18 2 block table +24 +0 clear 14 +0 desired 7 +0 last-moved-block 14 +0 name 3 +0 object 14 +0 ontop 6 +0 operator 4 +0 operator 15 +0 superstate 2 +0 type 1 +4 destination 14 +4 moving-block 14 +4 name 5 +6 bottom-block 9 +6 top-block 8 +7 ontop 13 +8 name 10 +9 name 11 +9 type 12 +13 bottom-block 14 +13 top-block 14 +14 name 17 +14 type 18 +15 name 16 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead_source.soar new file mode 100644 index 0000000..a784619 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-look-ahead_source.soar @@ -0,0 +1,11 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source search-control.soar +source initialize.soar +source move-block.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling.dm b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling.dm new file mode 100644 index 0000000..a1fee96 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling.dm @@ -0,0 +1,76 @@ +31 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 blocks-world +SOAR_ID 4 +ENUMERATION 5 1 move-block +SOAR_ID 6 +SOAR_ID 7 +SOAR_ID 8 +SOAR_ID 9 +ENUMERATION 10 2 A C +ENUMERATION 11 1 table +ENUMERATION 12 1 table +SOAR_ID 13 +SOAR_ID 14 +SOAR_ID 15 +ENUMERATION 16 1 initialize-blocks-world-operator-subgoaling +ENUMERATION 17 4 A B C table +ENUMERATION 18 2 block table +SOAR_ID 19 +ENUMERATION 20 1 state +ENUMERATION 21 2 blocks-world move-block +ENUMERATION 22 1 move-block +SOAR_ID 23 +ENUMERATION 24 1 no-change +ENUMERATION 25 1 operator +ENUMERATION 26 1 operator-subgoal +ENUMERATION 27 1 none +ENUMERATION 28 1 no-change +ENUMERATION 29 1 t +ENUMERATION 30 1 operator +43 +0 attribute 30 +0 choices 27 +0 clear 14 +0 desired 7 +0 impasse 28 +0 name 3 +0 object 14 +0 ontop 6 +0 operator 4 +0 operator 15 +0 quiescence 29 +0 success 7 +0 superstate 2 +0 type 1 +4 destination 14 +4 moving-block 14 +4 name 5 +6 bottom-block 9 +6 top-block 8 +7 clear 14 +7 ontop 13 +8 name 10 +9 name 11 +9 type 12 +13 bottom-block 14 +13 top-block 14 +14 name 17 +14 type 18 +15 name 16 +19 attribute 25 +19 clear 14 +19 desired 7 +19 impasse 24 +19 last-moved-block 14 +19 name 21 +19 object 14 +19 ontop 6 +19 operator 23 +19 superstate 0 +19 top-state 0 +19 type 20 +19 type 26 +23 name 22 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling_source.soar new file mode 100644 index 0000000..1f98a6b --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world-operator-subgoaling_source.soar @@ -0,0 +1,14 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source search-control.soar +source initialize-blocks-world-operator-subgoaling.soar +source move-block.soar +pushd move-block +source move-block_source.soar +popd diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world.dm b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world.dm new file mode 100644 index 0000000..ed3c386 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world.dm @@ -0,0 +1,45 @@ +19 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 blocks-world +SOAR_ID 4 +ENUMERATION 5 1 move-block +SOAR_ID 6 +SOAR_ID 7 +SOAR_ID 8 +SOAR_ID 9 +ENUMERATION 10 2 A C +ENUMERATION 11 1 table +ENUMERATION 12 1 table +SOAR_ID 13 +SOAR_ID 14 +SOAR_ID 15 +ENUMERATION 16 1 initialize +ENUMERATION 17 4 A B C table +ENUMERATION 18 2 block table +24 +0 clear 14 +0 desired 7 +0 last-moved-block 14 +0 name 3 +0 object 14 +0 ontop 6 +0 operator 4 +0 operator 15 +0 superstate 2 +0 type 1 +4 destination 14 +4 moving-block 14 +4 name 5 +6 bottom-block 9 +6 top-block 8 +7 ontop 13 +8 name 10 +9 name 11 +9 type 12 +13 bottom-block 14 +13 top-block 14 +14 name 17 +14 type 18 +15 name 16 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world_source.soar new file mode 100644 index 0000000..d2a708d --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/blocks-world_source.soar @@ -0,0 +1,10 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source search-control.soar +source initialize.soar +source move-block.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/comment.dm b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/comment.dm new file mode 100644 index 0000000..65b3b1f --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/comment.dm @@ -0,0 +1,43 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/clear.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/clear.soar new file mode 100644 index 0000000..b2a593e --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/clear.soar @@ -0,0 +1,19 @@ +# If an blcok does not have another block ontop of it, it is clear. + +sp {blocks-world*elaborate*state*clear + (state ^name blocks-world + ^object + -^ontop.bottom-block ) +--> + ( ^clear ) +} + +# Table is always clear + +sp {blocks-world*elaborate*state*clear-table + (state ^name blocks-world + ^object ) + ( ^type table) +--> + ( ^clear ) +} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/detect-success.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/detect-success.soar new file mode 100644 index 0000000..da46e9f --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/detect-success.soar @@ -0,0 +1,27 @@ +### Detect Goal Achievement +### + +sp {blocks-world*elaborate*state*success + (state ^desired + ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) +--> + (halt) + (write (crlf) |Achieved Goal.|) + } \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/elaborations_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/elaborations_source.soar new file mode 100644 index 0000000..fdff00c --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/elaborations_source.soar @@ -0,0 +1,3 @@ +source clear.soar +source detect-success.soar +source monitor.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/monitor.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/monitor.soar new file mode 100644 index 0000000..c31a2aa --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/monitor.soar @@ -0,0 +1,47 @@ + +sp {blocks-world*monitor*world-state + (state ^ontop ) + ( ^top-block.name + ^bottom-block.name ) +--> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*prefer*clear-block + (state ^operator + + ^desired.clear + ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Prefer move | | --> | | to clear | )} + + +sp {blocks-world*monitor*prefer*ontop + (state ^operator + + ^desired.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Prefer move | | to | )} + +sp {blocks-world*monitor*avoid*clobber*clear + (state ^operator + + ^desired.clear ) + ( ^destination + ^moving-block ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Avoid moving | | to | | so don't clobber clear | | goal.|)} + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/top-state.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/top-state.soar new file mode 100644 index 0000000..8ec1042 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/elaborations/top-state.soar @@ -0,0 +1,5 @@ +sp {blocks-world*elaborate*name + (state ^superstate nil) +--> + ( ^name blocks-world) +} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize-blocks-world-operator-subgoaling.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize-blocks-world-operator-subgoaling.soar new file mode 100644 index 0000000..89c6260 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize-blocks-world-operator-subgoaling.soar @@ -0,0 +1,44 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize-blocks-world-operator-subgoalin + (state ^superstate nil + -^name) +--> + ( ^operator ) + ( ^name initialize-blocks-world-operator-subgoaling) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,
                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize-blocks-world-operator-subgoaling + (state ^operator.name initialize-blocks-world-operator-subgoaling) +--> + ( ^name blocks-world + ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize.soar new file mode 100644 index 0000000..f333c80 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/initialize.soar @@ -0,0 +1,43 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize + (state ^name blocks-world + -^object) +--> + ( ^operator ) + ( ^name initialize) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,
                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize) +--> + ( ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block.soar new file mode 100644 index 0000000..be18acd --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block.soar @@ -0,0 +1,34 @@ +### +### MOVE-BLOCK +### + +# Propose moving a clear block ontop a clear object + +sp {blocks-world*propose*operator + (state ^name blocks-world) + ( ^object + ^object { <> }) + ( ^type block) + -{( ^ontop ) + ( ^top-block + ^bottom-block )} +--> + ( ^operator + =) + ( ^name move-block + ^moving-block + ^destination )} + +sp {blocks-world*apply*operator*move-block*change-ontop + (state ^operator + ^clear + ^ontop ) + ( ^top-block + ^bottom-block { <> }) + ( ^moving-block + ^destination ) +--> + ( ^bottom-block + ^bottom-block -)} + + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/elaborations.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/elaborations.soar new file mode 100644 index 0000000..12350c0 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/elaborations.soar @@ -0,0 +1,28 @@ + +sp {move-block*elaborate*operator-subgoal + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^moving-block + ^destination ) + --> + ( ^type operator-subgoal + ^name blocks-world + ^desired ) + ( ^clear )} + +sp {move-block*elaborate*copy*superstate + (state ^type operator-subgoal + ^superstate ) + ( ^ { <> choices + <> impasse + <> clear + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/move-block.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/move-block.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/move-block_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/move-block_source.soar new file mode 100644 index 0000000..dfd1e94 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/move-block/move-block_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-block.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/search-control.soar b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/search-control.soar new file mode 100644 index 0000000..0313443 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world-operator-subgoaling/search-control.soar @@ -0,0 +1,32 @@ +# Prefer moving block that achieves desired state + +sp {blocks-world*prefer*clear-block + (state ^operator + + ^desired.clear + ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination <> ) + --> + ( ^operator >)} + +sp {blocks-world*prefer*ontop + (state ^operator + + ^desired.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^operator >)} + + +sp {blocks-world*avoid*clobbering*clear-block + (state ^operator + + ^desired.clear ) + ( ^destination ) + --> + ( ^operator <)} + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world.soar b/soar-8.5.2/demos/blocks-world/blocks-world.soar new file mode 100644 index 0000000..57f25ca --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world.soar @@ -0,0 +1,3 @@ +pushd blocks-world +source blocks-world_source.soar +popd diff --git a/soar-8.5.2/demos/blocks-world/blocks-world.vsa b/soar-8.5.2/demos/blocks-world/blocks-world.vsa new file mode 100644 index 0000000..9580a36 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world.vsa @@ -0,0 +1,14 @@ +VERSION 4 +\blocks-world\blocks-world.dm +0 ROOT blocks-world blocks-world 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR clear clear.soar 5 +5 3 FOPERATOR detect-success detect-success.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 0 FOPERATOR _readme _readme.soar 8 +8 0 FOPERATOR search-control search-control.soar 9 +9 0 OPERATOR initialize-blocks-world initialize-blocks-world.soar 10 +10 0 OPERATOR move-block move-block.soar 11 +END diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/_firstload.soar b/soar-8.5.2/demos/blocks-world/blocks-world/_firstload.soar new file mode 100644 index 0000000..9f479af --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/_firstload.soar @@ -0,0 +1,9 @@ +# Give information to the rule reording algorithm to make the match more efficient. +multi-attributes ontop 3 +multi-attributes clear 3 +multi-attributes objects 4 + +# learning is irrelevant for this formulation +learn -off + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/_readme.soar b/soar-8.5.2/demos/blocks-world/blocks-world/_readme.soar new file mode 100644 index 0000000..c57515c --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/_readme.soar @@ -0,0 +1,17 @@ +# Classic 3 block blocks world +# John E. Laird +# University of Michigan +# 5/23/04 +# Soar version 8.5.1 + +# This is a simple version of blocks world +# Three blocks and the table. +# Random search within the top space - all operators indifferent. + +# Only search control is to avoid moving the same block twice in a row. + +# In this formulation, clear is computed as an elaboration +# (in elaborations/clear). The table is always clear. + + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/all/all_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world.dm b/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world.dm new file mode 100644 index 0000000..2ab355f --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world.dm @@ -0,0 +1,45 @@ +19 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 blocks-world +SOAR_ID 4 +ENUMERATION 5 1 move-block +SOAR_ID 6 +SOAR_ID 7 +SOAR_ID 8 +SOAR_ID 9 +ENUMERATION 10 2 A C +ENUMERATION 11 1 table +ENUMERATION 12 1 table +SOAR_ID 13 +SOAR_ID 14 +SOAR_ID 15 +ENUMERATION 16 1 initialize-blocks-world +ENUMERATION 17 4 A B C table +ENUMERATION 18 2 block table +24 +0 clear 14 +0 desired 7 +0 last-moved-block 14 +0 name 3 +0 object 14 +0 ontop 6 +0 operator 4 +0 operator 15 +0 superstate 2 +0 type 1 +4 destination 14 +4 moving-block 14 +4 name 5 +6 bottom-block 9 +6 top-block 8 +7 ontop 13 +8 name 10 +9 name 11 +9 type 12 +13 bottom-block 14 +13 top-block 14 +14 name 17 +14 type 18 +15 name 16 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world_source.soar new file mode 100644 index 0000000..ba83dbb --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/blocks-world_source.soar @@ -0,0 +1,11 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source search-control.soar +source initialize-blocks-world.soar +source move-block.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/comment.dm b/soar-8.5.2/demos/blocks-world/blocks-world/comment.dm new file mode 100644 index 0000000..59df4f7 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/comment.dm @@ -0,0 +1,24 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/clear.soar b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/clear.soar new file mode 100644 index 0000000..b2a593e --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/clear.soar @@ -0,0 +1,19 @@ +# If an blcok does not have another block ontop of it, it is clear. + +sp {blocks-world*elaborate*state*clear + (state ^name blocks-world + ^object + -^ontop.bottom-block ) +--> + ( ^clear ) +} + +# Table is always clear + +sp {blocks-world*elaborate*state*clear-table + (state ^name blocks-world + ^object ) + ( ^type table) +--> + ( ^clear ) +} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/detect-success.soar b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/detect-success.soar new file mode 100644 index 0000000..ac13aeb --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/detect-success.soar @@ -0,0 +1,26 @@ +### Detect Goal Achievement +### + +sp {blocks-world*elaborate*state*success + (state ^desired + ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) +--> + (write (crlf) |Finished Stacking the Blocks.|) + (halt)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/elaborations_source.soar b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/elaborations_source.soar new file mode 100644 index 0000000..fdff00c --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/elaborations_source.soar @@ -0,0 +1,3 @@ +source clear.soar +source detect-success.soar +source monitor.soar diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/monitor.soar b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/monitor.soar new file mode 100644 index 0000000..81a8fc2 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/monitor.soar @@ -0,0 +1,21 @@ + +sp {blocks-world*monitor*world-state + (state ^ontop ) + ( ^top-block.name + ^bottom-block.name ) +--> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block.name + ^destination.name ) +--> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/top-state.soar b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/top-state.soar new file mode 100644 index 0000000..86ac56b --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/elaborations/top-state.soar @@ -0,0 +1,5 @@ +sp {elaborate*top-state*name + (state ^superstate nil) +--> + ( ^name blocks-world) +} diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/initialize-blocks-world.soar b/soar-8.5.2/demos/blocks-world/blocks-world/initialize-blocks-world.soar new file mode 100644 index 0000000..51d9a8f --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/initialize-blocks-world.soar @@ -0,0 +1,44 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize-blocks-world + (state ^superstate nil + -^name) +--> + ( ^operator ) + ( ^name initialize-blocks-world) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,
                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize-blocks-world) +--> + ( ^name blocks-world + ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/initialize.soar b/soar-8.5.2/demos/blocks-world/blocks-world/initialize.soar new file mode 100644 index 0000000..f333c80 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/initialize.soar @@ -0,0 +1,43 @@ +### +### Initialize the state +### + +sp {blocks-world*propose*initialize + (state ^name blocks-world + -^object) +--> + ( ^operator ) + ( ^name initialize) +} + +## Modify the following rule to change the initial state or the goal. +## It is necessary for the initial state and the desired state to share the same +## identifiers for the objects (, , ,
                                                                                                                        ) because of +## the way the goal is detected (in elaborations/detect-success). + +sp {blocks-world*apply*initialize + (state ^operator.name initialize) +--> + ( ^ontop + ^object
                                                                                                                        + ^desired ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Simple Blocks World - just move blocks.|) + (write (crlf) |Initial state has A on B, B on table, and C on the table.|) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/move-block.soar b/soar-8.5.2/demos/blocks-world/blocks-world/move-block.soar new file mode 100644 index 0000000..7f92f74 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/move-block.soar @@ -0,0 +1,53 @@ +### +### MOVE-BLOCK +### + +# Propose moving a clear block ontop a clear object + +sp {blocks-world*propose*operator*move-clear-block-to-clear-object + (state ^name blocks-world) + ( ^clear + ^clear { <> }) + ( ^type block) + -{( ^ontop ) + ( ^top-block + ^bottom-block )} +--> + ( ^operator + =) + ( ^name move-block + ^moving-block + ^destination )} + +sp {blocks-world*apply*operator*move-block*change-ontop + (state ^operator + ^ontop ) + ( ^top-block + ^bottom-block { <> }) + ( ^moving-block + ^destination ) +--> + ( ^bottom-block + ^bottom-block -)} + +## Maintain a history of what block was moved last +## For use by search control + +sp {blocks-world*apply*operator*remember*moved-block + (state ^operator + -^last-moved-block ) + ( ^name move-block + ^moving-block ) +--> + ( ^last-moved-block ) +} + +sp {blocks-world*apply*operator*forget*moved-block + (state ^operator + ^last-moved-block ) + ( ^name move-block + ^moving-block <> ) +--> + ( ^last-moved-block -)} + + + diff --git a/soar-8.5.2/demos/blocks-world/blocks-world/search-control.soar b/soar-8.5.2/demos/blocks-world/blocks-world/search-control.soar new file mode 100644 index 0000000..06a2760 --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/blocks-world/search-control.soar @@ -0,0 +1,7 @@ +sp {blocks-world*reject*move-block*twice + (state ^name blocks-world + ^operator + + ^last-moved-block ) + ( ^moving-block ) +--> + ( ^operator < )} \ No newline at end of file diff --git a/soar-8.5.2/demos/blocks-world/readme b/soar-8.5.2/demos/blocks-world/readme new file mode 100644 index 0000000..d70ab4a --- /dev/null +++ b/soar-8.5.2/demos/blocks-world/readme @@ -0,0 +1,19 @@ +# blocks-world/README +# John Laird +# March 8, 1999 +# +# blocks-world.soar +# Straight forward implementation of blocks-world +# Uses look-ahead search to stack three blocks. +# Look-ahead search is implemented in ../default/selection.soar +# +# blocks-opsub.soar +# Demonstrates means-ends analysis and operator-subgoaling. +# Will select operators that cannot apply and must then +# generate subgoals in which other operators are applied +# to modify the state so the preconditions of the originally +# selected operator are achieved. Does not chunk correctly - +# a continual problem with operator subgoaling. +# Does not use ../default/opsub.soar but uses a simplier +# version included in the file. +# diff --git a/soar-8.5.2/demos/default/operator-subgoaling.soar b/soar-8.5.2/demos/default/operator-subgoaling.soar new file mode 100644 index 0000000..90c40e1 --- /dev/null +++ b/soar-8.5.2/demos/default/operator-subgoaling.soar @@ -0,0 +1,198 @@ + +### +### 7.4 Operator Subgoaling (modified extensively by JEL/mvp 07-Nov-93) +####################################################################################### +### RESTRICTIONS ON USE: +### +### 1. The problem space used for operator implmentation can not be exactly +### the same problem space used for operator subgoaling (or the original +### task problem space). It can be a duplicate, but can not have the same +### identifier. This is because operator subgoaling is signalled by the +### selection of the task space as the problem space in the operator +### no-change subgoal. +### +### 2. For operator subgoaling and operator implementation to work +### together, there must be a production that tests when the preconditions +### of the operator have been achieved (operator subgoaling is successful) +### and whose action is to reconsider the problem space. This is necessary +### so that the switch can be made from the operator subgoaling problem +### space (the original task space) and the operator implementation problem +### space. +### +### 3. All operators must be augmented with ^achieved when they have +### successfully applied. This helps avoid problems where chunks learned +### through operator subgoaling, can undo operator actions, and vice +### versa. +### +### 4. Operators must apply by changing existing structures on the state, +### not by creating new ones, or destroying existing ones. +### +##################################################################################### + +##################################################################################### +### OVERVIEW +### +### For look-ahead searches, always select the operator that subgoaling on +### after another operator has applied. If it then sucessfully applied, the +### look-ahead search was a success. +### +##################################################################################### + + +### make the super-problem space the default +### when there is a no-change for the operator +### make is worst so operator implementation will win out + +sp {default*generic*opsub*propose*space*generic + :default + (state ^impasse no-change ^attribute operator + ^superstate ) + (state ^problem-space ) + --> + ( ^problem-space )} + +###if the superproblem-space is selected as the +### current problem space then operator subgoaling +### is being used so select the superstate - +### the super-operator becomes the desired) +### +### The name gets a parallel preference because the state +### above (which is being copied down to this state) may +### also have a name. + +sp {default*generic*opsub*elaborate*state*name*operator-subgoal + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + (state ^problem-space

                                                                                                                        ) + --> + ( ^name operator-subgoal)} + +sp {default*generic*opsub*elaborate*state*desired + :default + (state ^problem-space

                                                                                                                        ^name operator-subgoal ^superstate ) + (state ^operator ) + --> + ( ^desired )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal ^superstate ) + ( ^ { <> problem-space <> impasse <> object <> name + <> superstate <> attribute <> operator <> desired } + ) + --> + ( ^ )} + +### The following is commented out; it would provide for keeping track +### of all levels of operator subgoaling, not just the most recent. +### Pass down all super operator subgoals as well. +# +# sp {default*generic*opsub*goal*elaborate*all-desireds +# :default +# (state ^problem-space

                                                                                                                        +# ^impasse no-change ^attribute operator ^superstate ) +# (state ^problem-space

                                                                                                                        ^desired ) +# --> +# (state ^desired )} +# +# +###don't select the operator for the operator that we are +### subgoaling on. + +sp {default*generic*select*reject-desired + :default + (state ^name operator-subgoal ^problem-space

                                                                                                                        ^desired ) + --> + ( ^operator -)} + +##if there is an evaluation subgoal within +### an operator subgoal and the operator being +### subgoaled on is applied - success + +sp {default*generic*opsub*detect*state*success + :default + (state ^problem-space

                                                                                                                        ^desired ^applied ) + ( ^achieved ) + --> + ( ^success )} + +sp {opsub*select-operator*subgoaling + :default + (state ^name implement-evaluate-object ^problem-space

                                                                                                                        + ^operator <> ^desired ) + ( ^name) + --> + ( ^operator !)} + +sp {default*generic*opsub*failure*no-operator + :default + (state ^superstate ^impasse no-change ^attribute state ^quiescence t) + ( ^name operator-subgoal ^desired ) + --> + ( ^failure )} + +sp {default*generic*evaluation*failure*no-operator + :default + (state ^superstate ^impasse no-change ^name operator-subgoal + ^attribute operator ^desired ^quiescence t + ^failure ) + ( ^operator ^desired ) + --> + ( ^failure )} + + +sp {default*generic*opsub*avoid*duplicate-operator + :default + (state ^impasse no-change ^name operator-subgoal + ^attribute operator ^operator + ^super-desired ) + ( ^name ) + ( ^name ) + --> + ( ^operator -)} + +#sp {default*generic*opsub*operator-subgoals +# :default +# (state ^name implement-evaluate-object ^problem-space

                                                                                                                        +# ^operator ^desired ) +# (state ^name operator-subgoal ^superstate ) +# --> +# ( ^operator @)} + +## These maintain the super-desireds + +sp {default*generic*opsub*subgoal-on-all-desired-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^desired ) + --> + ( ^super-desired &)} + +sp {default*generic*opsub*subgoal-on-all-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^super-desired ) + --> + ( ^super-desired &)} + +sp {default*apply*evaluate*augment*evaluation-operator-super-desired + :default + (state ^operator ^superstate ) + ( ^super-desired ) + ( ^evaluation ^type evaluation) + --> + ( ^super-desired &)} + +sp {default*elaborate*state*eval*super-desired + :default + (state ^impasse no-change ^attribute operator ^superstate ) + ( ^operator ) + ( ^type evaluation ^super-desired ) + --> + ( ^super-desired &)} + + + + diff --git a/soar-8.5.2/demos/default/readme b/soar-8.5.2/demos/default/readme new file mode 100644 index 0000000..b3ac69e --- /dev/null +++ b/soar-8.5.2/demos/default/readme @@ -0,0 +1,14 @@ +# default/README +# John Laird +# March 8, 1999 +# +#There are now three separate default files: + +# simple.soar holds the basics rules that you probably want to use in +# every Soar system. + +# selection.soar holds the rules to support lookahead search using the +# selection problem space. + +# opsub.soar holds the rules to support operator subgoaling + diff --git a/soar-8.5.2/demos/default/readme.txt b/soar-8.5.2/demos/default/readme.txt new file mode 100644 index 0000000..ad2f251 --- /dev/null +++ b/soar-8.5.2/demos/default/readme.txt @@ -0,0 +1,17 @@ +# default/README +# John Laird + +#Updated Oct. 27, 2003 +# + +#There are now two separate default files: + +# simple.soar holds the basic rules that you probably want to use in +# every Soar system. + +# selection.soar holds the rules to support lookahead search using the +# selection problem space. + + + + diff --git a/soar-8.5.2/demos/default/selection.soar b/soar-8.5.2/demos/default/selection.soar new file mode 100644 index 0000000..9a5bbcd --- /dev/null +++ b/soar-8.5.2/demos/default/selection.soar @@ -0,0 +1,1043 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default/selection.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified On: 26 October, 2003 +## +## Contents: Default productions for selection problem space for Soar 8.5 +## +###################################################################### +### Change made for Soar 8.5 +### +### Significant Changes made to Convert to Soar 8.2 +### 1. evaluate-object -> evaluate-operator +### 2. Removed other types of evaulate- +### 3. Change from problem-space.name selection -> name selection +### 4. Simplified so only handles vanillia evaluate-operator +### 5. Don't copy down problem space, just copy down name and +### assume problem space will be regenerated in subgoal based on name +### 6. Added some documentation +### + +### + +### State structure: +### (state ^evaluation +### ^not-all-operators-evaulated true +### ^operator-selection not-indifferent +### ^found-value true) +### ( ^numeric-value novalue +### ^symbolic-value novalue/success/failure +### ^value true +### ^operator (identifier of operator being evaluated) +### ^desired +### +### +### ( ^name evaluate-operator +### ^operator +### ^evaluation ;# same as on state +### ^superproblem-space +### ^superstate + + + +### Use selection for all choice multiple, impasses + +sp {selection*elaborate*name*selection + :default + (state ^choices multiple) + --> + ( ^name selection)} + + +### +### 7.3.1 The evaluate-operator operator +### + +### Create evaluate operator in selection problem space. + +sp {selection*propose*evaluate-operator + :default + (state ^name selection + ^item ) + -{(state ^evaluation ) + ( ^superoperator + ^value true)} + --> + ( ^operator +) + ( ^name evaluate-operator + ^superoperator )} + + +### Make them indifferent if not ^operator-selection not-indifferent. + +sp {selection*select*evaluate-operator*indifferent + :default + (state ^name selection + - ^operator-selection not-indifferent + ^operator +) + ( ^name evaluate-operator) + --> + ( ^operator =)} + +### Create evaluation once the eval operator is selected. + +sp {selection*apply*state*evaluation + :default + (state ^name selection + ^operator ) + ( ^name evaluate-operator + ^superoperator ) + --> + ( ^evaluation ) + ( ^superoperator )} + +sp {selection*elaborate*evaluate-operator*evaluation + :default + (state ^name selection + ^operator + ^evaluation ) + ( ^name evaluate-operator + ^superoperator ) + ( ^superoperator ) + --> + ( ^evaluation )} + + + +sp {selection*elaborate*evaluate-operator*superproblem-space + :default + (state ^name selection + ^operator + ^superstate.problem-space ) + ( ^name evaluate-operator) + --> + ( ^superproblem-space )} + +sp {selection*elaborate*evaluate-operator*superstate + :default + (state ^name selection + ^operator + ^superstate ) + ( ^name evaluate-operator) + --> + ( ^superstate )} + +### +### 7.3.1.1 Evaluation Objects +### + +sp {selection*elaborate*evaluation*value + :default + (state ^evaluation ) + ( ^ << numeric-value symbolic-value >>) + --> + ( ^value true)} + +sp {selection*elaborate*evaluation*desired + :default + (state ^superstate.desired + ^evaluation ) + --> + ( ^desired )} + + +### +### 7.3.1.2 Applying the evaluate-operator operator +### +### Domain specific code may directly implement an evaluation, or an operator no-change may occur +### to do the job, see the next section. + + + +### +### 7.3.2 The evaluation subgoal +### + +### +### These productions which fire once an evaluation subgoal has been created +### have also been generalized. + +sp {evaluate-operator*elaborate*state*desired + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( -^default-desired-copy yes + ^name evaluate-operator + ^evaluation.desired ) + --> + ( ^desired )} + +sp {evaluate-operator*elaborate*state*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^name evaluate-operator + ^superstate.name ) + --> + ( ^name )} + +## install a copy of the state, when ^default-state-copying and there +## is an operator tie. + +sp {evaluate-operator*elaborate*state*duplicate-of + :default + (state ^superstate + ^default-state-copy yes) + (state ^operator ) + ( ^name evaluate-operator + ^superstate ) + --> + ( ^duplicate-of* )} + +### Copy down operator + +sp {evaluate-operator*elaborate*state*look-ahead-operator*copy + :default + (state ^problem-space.name + ^default-operator-copy yes + ^superstate.operator ) + ( ^name evaluate-operator + ^superoperator + ^superproblem-space.name ) + --> + ( ^look-ahead-operator ) + ( ^duplicate-of* )} + + +## Create pointer for uniform access even in no copy + +### Added test for superproblem-space. This restricts these productions +### to only fire in a lookahead. Previously, these productions made it +### impossible to use evaluation problem spaces other than lookahead. + +sp {evaluate-operator*elaborate*state*look-ahead-operator*no-copy + :default + (state ^problem-space.name

                                                                                                                        + ^default-operator-copy no + ^superstate.operator ) + ( ^name evaluate-operator + ^superoperator + ^superproblem-space.name

                                                                                                                        ) + --> + ( ^look-ahead-operator )} + +### install copy of operator in lookahead context. + +sp {evaluate-operator*propose*look-ahead + :default + (state ^look-ahead-operator + -^tried-tied-operator ) + --> + ( ^operator +)} + +sp {evaluate-operator*propose*look-ahead*reject-all-others + :default + (state ^look-ahead-operator + ^operator { <> } +) + -( ^tried-tied-operator ) + --> + ( ^operator -)} + +### Detect that the operator has been tried. + +sp {evaluate-operator*elaborate*state*tried-tied-operator + :default + (state ^operator + ^look-ahead-operator ) + --> + ( ^tried-tied-operator )} + + +### Give symbol-value failure when no operators are proposed in subgoals + +sp {evaluate-operator*elaborate*evaluation*failure*no-operators + :default + (state ^operator + ^evaluation ) + ( ^name evaluate-operator + ^evaluation ) + (state ^superstate + ^quiescence t) + (state ^superstate + ^attribute state + ^impasse no-change + ^quiescence t) + (state ^superstate + ^attribute state + ^impasse no-change + ^quiescence t) + --> + ( ^symbolic-value failure)} + +sp {evaluate-operator*elaborate*evaluation*failure*constraint-failure + :default + (state ^operator ) + ( ^evaluation ) + ( ^name evaluate-operator + ^evaluation ) + (state ^superstate ) + (state ^superstate + ^attribute operator + ^impasse constraint-failure) + --> + ( ^symbolic-value failure)} + +sp {evaluate-operator*elaborate*symbolic-evaluation*from-subgoal + :default + (state ^operator + ^evaluation ) + ( ^name evaluate-operator + ^evaluation + ^evaluation.desired ) + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + --> + ( ^symbolic-value )} + + +sp {evaluate-operator*elaborate*numeric-evaluation*from-subgoal + :default + (state ^operator + ^evaluation ) + ( ^name evaluate-operator + ^evaluation + ^evaluation.desired ) + (state ^superstate + ^desired + ^numeric-value ) + --> + ( ^numeric-value )} + + +## Added to handle duplicated desireds +sp {evaluate-operator*elaborate*evaluation*from-subgoal*duplicate-desired + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator + ^evaluation ) + ( ^name evaluate-operator + ^evaluation + ^evaluation.desired ) + ( ^duplicate-of* ) + --> + ( ^symbolic-value )} + + +### +### 7.3.2.1. State Copying +### + +## Switch to look at current problem space, not super +## If no signals on problem space, the default is to copy both state and operator + +sp {evaluate-operator*elaborate*default-for-default-state-copy-is-yes + :default + (state ^superstate.operator.name evaluate-operator + ^problem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-state-copy no) + --> + ( ^default-state-copy yes)} + +sp {evaluate-operator*elaborate*default-state-copy-from-problem-space + :default + (state ^superstate.operator.name evaluate-operator + ^problem-space.default-state-copy ) + --> + ( ^default-state-copy )} + +### Default is that all-attributes-at-level are copied + +sp {evaluate-operator*elaborate*state*default-copy-is-all-attributes-at-level-one + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator.name evaluate-operator + ^problem-space

                                                                                                                        ) + (

                                                                                                                        -^all-attributes-at-level two + -^one-level-attributes + -^two-level-attributes + -^dont-copy + -^dont-copy-anything) + --> + ( ^all-attributes-at-level one)} + +sp {evaluate-operator*elaborate*state*default-copy-is-all-attributes-at-level-one*no-problem-space + :default + (state ^impasse no-change + -^problem-space + ^attribute operator + ^superstate.operator ) + ( ^name evaluate-operator + -^superproblem-space

                                                                                                                        ) + --> + ( ^all-attributes-at-level one)} + +### We want ^all-attributes-at-level one to be on the goal, but if someone +### puts it on the space along with the other copying flags, we should allow +### that. So, copy it from the space to the goal. + +sp {evaluate-operator*elaborate*state*copy-all-attributes-at-level-one-from-problem-space + :default + (state ^problem-space.all-attributes-at-level one + ^default-state-copy yes) + --> + ( ^all-attributes-at-level one)} + +### Set up identifier mapping table for state duplication. + +sp {evaluate-operator*elaborate*state*create-duplicates-table + :default + (state ^impasse no-change + ^attribute operator + ^default-state-copy yes + ^superstate.operator.name evaluate-operator) + --> + ( ^duplicates* )} + +### Copy one-level-attributes. + +sp {evaluate-operator*elaborate*state*add-one-level-attributes + :default + (state ^problem-space.one-level-attributes + ^duplicate-of*. + ^default-state-copy yes) + --> + ( ^ )} + +## Copy all attributes, when ^all-attributes-at-level one. + +sp {evaluate-operator*elaborate*state*add-all-attributes-at-level-one + :default + (state ^problem-space

                                                                                                                        + ^default-state-copy yes + ^all-attributes-at-level one + ^duplicate-of* ) + (

                                                                                                                        -^dont-copy-anything + -^dont-copy ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate <> type <> name <> look-ahead-operator + } ) + --> + ( ^ )} + +### If we copied a one-level-attribute, and it later turned +### out that its value happened to be something that was pointed to by a +### two-level-attribute, change its value to be the copied object. + +sp {evaluate-operator*elaborate*state*change-one-level-attribute-to-duplicate + :default + (state ^problem-space.one-level-attributes + ^duplicates*. + ^default-state-copy yes + ^duplicate-of*. ) + --> + ( ^ - + ^ )} + +### Fixes, when all-attributess-at-level one. + +sp {evaluate-operator*elaborate*state*change-all-attributes-at-level-one-to-duplicate + :default + (state -^problem-space.dont-copy + ^default-state-copy yes + ^all-attributes-at-level one + ^duplicates*. + ^duplicate-of*.{ <> tried-tied-operator } ) + --> + ( ^ - + ^ )} + +### Create new ids for two-level-attributes. + +sp {evaluate-operator*elaborate*state*duplicate-id-for-attribute + :default + (state ^problem-space.two-level-attributes + ^duplicates* + ^default-state-copy yes + ^duplicate-of*. ) + --> + ( ^ )} + +### Create new ids for all attributes, when ^all-attributes-at-level two. + +sp {evaluate-operator*elaborate*state*duplicate-id-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        -^dont-copy-anything + -^dont-copy + ^all-attributes-at-level two + -^one-level-attributes ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +### Create a copy of the old object on the new link. First copy +### augmentations that don't point to objects that have been +### duplicated. + +set warnings off +sp {evaluate-operator*elaborate*add-attribute-to-duplicate + :default + (state ^duplicates* + -^problem-space.dont-copy + ^default-state-copy yes) + ( ^ + - ^) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Next copy augmentations that point to duplicated objects: + +set warnings off +sp {evaluate-operator*elaborate*add-duplicated-attribute-to-duplicate + :default + (state ^duplicates* + ^default-state-copy yes) + ( ^ + ^ ) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Added ^two-level-attributes . Previously, it +### would copy any attribute that happened to point to the same value as +### one of the two-level-attributes. + +sp {evaluate-operator*elaborate*state*add-duplicate-to-state + :default + (state ^problem-space.two-level-attributes + ^duplicates*. + ^default-state-copy yes + ^duplicate-of*. ) + --> + ( ^ )} + + +### moves the new links to the state when ^all-atts two. + +sp {evaluate-operator*elaborate*state*add-duplicates-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates*. + ^default-state-copy yes + ^duplicate-of*.{ <> tried-tied-operator } ) + (

                                                                                                                        ^all-attributes-at-level two + - ^dont-copy-anything + - ^dont-copy + - ^one-level-attributes ) + --> + ( ^ )} + +## ------------------------------- +## Desired copying: +## ------------------------------- + +## Copy attributes to the duplicate desired state. We +## do this after the state is installed so that the duplicates table +## will already have been filled in. We just copy all attributes over +## from the original operator, except that attributes that pointed to +## objects that have been duplicated (on the state) are modified to point +## to the duplicate objects. + +sp {evaluate-operator*elaborate*state*eval*desired + :default + (state ^superstate ) + (state ^operator ) + ( ^name evaluate-operator + ^evaluation.desired + ^default-desired-copy yes) + --> + ( ^desired ) + ( ^duplicate-of* )} + + +## Copy attributes whose values haven't been duplicated. + +### SBH/mvp 9-2-94 +### Also, added the condition that the desired be attached to +### an evaluation superoperator. This is because if we use the same +### desired in a lower lookahead context, this production re-firing +### can cause stupid chunks. + +sp {duplicate-desired*copy-old-value + :default + (state ^superstate.operator + ^problem-space

                                                                                                                        + ^duplicates* + ^desired ) + ( ^name evaluate-operator + ^evaluation.desired ) + ( ^duplicate-of* ) + ( ^{ <> duplicate-of* } ) + - (

                                                                                                                        ^dont-copy ) + - ( ^) + --> + ( ^ )} + +## Copy attributes whose values have been duplicated. + +sp {duplicate-desired*replace-old-value + :default + (state ^duplicates*. + ^problem-space

                                                                                                                        + ^desired ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } ) + (

                                                                                                                        - ^dont-copy ) + --> + ( ^ )} + + + +### 7.3.2.3 Operator copying +### +### Copy attributes to the duplicate operator. We +### do this after the state is installed so that the duplicates table +### will already have been filled in. We just copy all attributes over +### from the original operator, except that attributes that pointed to +### objects that have been duplicated (on the state) are modified to point +### to the duplicate objects. + + +sp {evaluate-operator*elaborate*operator*default-operator-copy-is-yes + :default + (state ^superstate.operator.name evaluate-operator + ^problem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-operator-copy no) + --> + ( ^default-operator-copy yes)} + + +sp {evaluate-operator*elaborate*operator*copy-default-operator-copy-from-problem-space + :default + (state ^superstate.operator.name evaluate-operator + ^problem-space.default-operator-copy ) + --> + ( ^default-operator-copy )} + +### Set up identifier mapping table for operator + +sp {evaluate-operator*elaborate*state*create-duplicates-table-for-operator-only + :default + (state ^impasse no-change + ^attribute operator + ^default-operator-copy yes + - ^default-state-copy yes) + --> + ( ^duplicates* )} + +### Copy attributes whose values haven't been duplicated. +### + +sp {evaluate-operator*elaborate*operator*add-attribute-to-duplicate-operator + :default + (state ^duplicates* + ^problem-space

                                                                                                                        + ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } ) + (

                                                                                                                        - ^ dont-copy ) + ( - ^) + --> + ( ^ )} + +### Copy attributes whose values have been duplicated. + +sp {evaluate-operator*elaborate*operator*add-duplicated-attribute-to-duplicate-operator + :default + (state ^duplicates* + ^problem-space

                                                                                                                        + ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } ) + (

                                                                                                                        - ^ dont-copy ) + ( ^ ) + --> + ( ^ )} + + +### +### 7.3.3 Computing evaluations +### +### +### 7.3.3.1 Computing numeric evaluations +### +### This is domain specific, so there are no default productions for this. + +### +### 7.3.3.2 Comparing numeric evaluations +### + +### If two operators have equal evaluations they are indifferent. + +sp {selection*compare*equal-evaluation-indifferent + :default + (state ^name selection + ^superstate + ^evaluation { <> }) + ( ^desired ) + ( ^superoperator + ^numeric-value + ^desired ) + ( ^superoperator + ^numeric-value + ^desired ) + - ( ^equal not-indifferent) + --> + ( ^operator = )} + + +### +### Generate operator preferences based on their evaluations and info +### as to whether higher or lower evaluations are better. + +sp {selection*compare*higher-evaluation-better + :default + (state ^name selection + ^superstate + ^evaluation + ^evaluation { <> }) + (state ^problem-space + ^desired ) + ( ^superoperator + ^numeric-value + ^desired ) + ( ^superoperator + ^numeric-value < + ^desired ) + ( ^better higher) + --> + ( ^operator < )} + +sp {selection*compare*prefer-lower-evaluation + :default + (state ^name selection + ^superstate + ^evaluation + ^evaluation { <> }) + (state ^problem-space + ^desired ) + ( ^superoperator + ^numeric-value + ^desired ) + ( ^superoperator + ^numeric-value > + ^desired ) + ( ^better lower) + --> + ( ^operator < )} + + +### +### 7.3.3.3 Computing symbolic evaluations +### + + +sp {selection*compare*same-symbolic-evaluations-are-indifferent + :default + (state ^name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^superoperator + ^symbolic-value + ^desired ) + ( ^superoperator + ^symbolic-value + ^desired ) + --> + ( ^operator = )} + +sp {selection*compare*success-evaluation-better-than-partial-success + :default + (state ^name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^superoperator + ^symbolic-value success + ^desired ) + ( ^sueproperator { <> } + ^symbolic-value partial-success + ^desired ) + --> + ( ^operator > )} + +sp {selection*compare*partial-failure-evaluation-better-than-failure + :default + (state ^name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^superoperator + ^symbolic-value partial-failure + ^desired ) + ( ^superoperator { <> } + ^symbolic-value failure + ^desired ) + --> + ( ^operator > )} + +sp {selection*select*required-success-evaluation-becomes-required-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value required-success + ^desired + ^superoperator ) + --> + ( ^operator !)} + +sp {selection*select*success-evaluation-becomes-best-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value << partial-success success >> + ^desired + ^superoperator ) + --> + ( ^operator >)} + +sp {selection*select*indifferent-evaluation-becomes-indifferent-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value indifferent + ^desired + ^superoperator ) + --> + ( ^operator =)} + +sp {selection*select*partial-failure-evaluation-becomes-worst-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value partial-failure + ^desired + ^superoperator ) + --> + ( ^operator <)} + +sp {selection*select*failure-evaluation-becomes-reject-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value << lose failure >> + ^desired + ^superoperator ) + --> + ( ^operator -)} + +sp {selection*select*prohibit-failure-evaluation-becomes-prohibit-preference + :default + (state ^name selection + ^superstate + ^evaluation ) + (state ^desired ) + ( ^symbolic-value prohibit-failure + ^desired + ^superoperator ) + --> + ( ^operator ~)} + + + +### +### 7.3.3.4 Default evaluations +### + +### A. pass-back-success +## if an operator leads to success and it is being +## tried out in a subgoal to evaluate another operator - +## give that second operator a success evaluation also + + +sp {selection*pass-back-success + :default + (state ^superstate.superstate.operator + ^evaluation.symbolic-value << required-success success-success >>) + ( ^name evaluate-operator + ^evaluation + ^superoperator.name) + --> + ( ^symbolic-value partial-success)} + + + +### +### 7.3.3.5 Novalue evaluations +### + +### Signal that there are still objects to evaluate. + +sp {selection*elaborate*state*all-objects-evaluated + :default + (state ^name selection + ^operator +) +- {( ^name evaluate-operator + ^evaluation.value true)} + --> + ( ^not-all-operators-evaluated true)} + +### Signal that a value other than novalue has been assigned. + +sp {selection*elaborate*state*found-value-true + :default + (state ^name selection + ^evaluation ) + ( ^ << numeric-value symbolic-value >> <> novalue) + --> + ( ^found-value true)} + +### If all operators have been evaluated, and all have value novalue, and +### there is a operator being evaluated in a higher context, assign that +### operator novalue. + +sp {selection*elaborate*evaluate-operator*all-operators-novalue + :default + (state ^superstate.superstate + ^operator + -^not-all-operators-evaluated + -^found-value + ^quiescence t + ^choices multiple) + (state ^name selection + ^operator ) + ( ^name evaluate-operator + ^evaluation ) + --> + ( ^numeric-value novalue)} + +### Make novalue worse than any other value. + +sp {selection*compare*novalue-evaluation-always-worse + :default + (state ^name selection + ^superstate + ^evaluation + ^evaluation { <> }) + (state ^desired ) + ( ^superoperator + ^numeric-value novalue + ^desired ) + ( ^superoperator + ^numeric-value <> novalue + ^desired ) + --> + ( ^operator > )} + + +### +### 7.3.4 Halting Soar with success or failure +### + +### A. top-goal*halt*state*success +### Handle state augmentations dealing with goal termination for the top-level goal. + +sp {top-goal*halt*success + :default + (state ^name + ^desired + ^superstate nil + ^<< required-success success >> ) + --> + (write (crlf) | achieved |) + (halt)} + +### B. top-goal*halt*state*failure + +sp {top-goal*halt*failure + :default + (state ^superstate nil + ^desired + ^name + ^ << prohibit-failure failure >> ) + --> + (write (crlf) | failed|) + (halt)} + +### +### 7.5 Execution monitoring +### + +### If the state is marked with ^success , the goal succeeds. + +sp {monitor*goal*success + :default + (state ^superstate nil + -^verbose false) + (state ^top-state + ^name + ^desired + ^<< partial-success required-success success >> ) + --> + (write (crlf) | Goal | | succeeded. |)} + +### If the state is marked with ^failure , the goal fails. + +sp {monitor*goal*failure + :default + (state ^superstate nil + -^verbose false) + (state ^top-state + ^name + ^desired + ^<< partial-failure failure prohibit-failure >> ) + --> + (write (crlf) | Goal | | failed. |)} + +### Print the evaluation of any operator that has a name (which doesn't +### get states). + +sp {monitor*operator*evaluation + :default + (state ^superstate nil + -^verbose false) + (state ^top-state + ^operator ) + ( ^name evaluate-operator + ^superoperator + ^evaluation. << numeric-value symbolic-value >> ) + ( ^name ) + --> + (write (crlf) | Evaluation of | | (| + |) is | )} + + + + + + + + \ No newline at end of file diff --git a/soar-8.5.2/demos/default/simple.soar b/soar-8.5.2/demos/default/simple.soar new file mode 100644 index 0000000..1b311d0 --- /dev/null +++ b/soar-8.5.2/demos/default/simple.soar @@ -0,0 +1,115 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default/simple.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified By: +## Last Modified On: 28 Sep 1999, 12:40:13 +## +## Contents: Simple Default productions for Soar 8.1 +## +############################################################################### +## +## Significant Changes made to Convert to Soar 8.1 +## Removed names on top state (top-state, top-goal). +## Causes problems with other default rules +### +### +### 7.1 Default knowledge for the top context +### + +## Elaborate every substate with io pointer. + +sp {default*elaborate*state*io + "Elaborate each substate with io pointer." + :default + (state ^impasse no-change + ^superstate.io ) + --> + ( ^io )} + +## Elaborate a state with the name of the superoperator + +sp {elaborate*state*operator*name + "Elaborate substates with name of operator." + :default + (state ^superstate.operator.name ) +--> + ( ^name )} + +### Propose wait for a state no-change + +sp {top-ps*propose*wait + "Propose wait if there is a state no-change." + :default + (state ^attribute state + ^choices none + -^operator.name wait) +--> + ( ^operator + <) + ( ^name wait)} + +### This avoids a operator no-change after wait is selected +### I've included it just to keep the trace simple - it never fires + +sp {top-ps*apply*wait*random + "Fake production just to avoid extra operator no-change." + :default + (state ^operator ) + ( ^name wait) +--> + ( ^random elaboration)} + +sp {default*top-goal*halt*operator*failure + "Halt if no operator can be selected for the top goal." + :default + (state ^superstate nil) + (state ^impasse constraint-failure ^superstate ) + --> + (write (crlf) |No operator can be selected for top goal.| ) + (write (crlf) |Soar must halt.| ) + (halt)} + +sp {default*select*indifferent-and-worst*tied + "Indifferent an object if it leads to a tie that can not be resolved." + :default + (state ^operator +) + (state ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + --> + ( ^operator =, < )} + +### If the problem space for handling the subgoal fails, signified by +### the choices none impasse below it, make a reject-preference for each +### conflicted object. + +sp {default*select*reject*conflict + "Reject an object if it leads to a conflict that can not be resolved." + :default + (state ^operator +) + (state ^impasse conflict + ^attribute operator + ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + --> + ( ^operator -)} + + + + + + + + diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.soar new file mode 100644 index 0000000..faaa108 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.soar @@ -0,0 +1,3 @@ +pushd eight-puzzle +source eight-puzzle_source.soar +popd diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle.tcl b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.tcl new file mode 100644 index 0000000..c444bb6 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.tcl @@ -0,0 +1,178 @@ +# +# Eight puzzle demo +# +#----------------------------------------------------------------------- +# +# Create top-level window for 8 puzzle demo. +# +# Any existing widget with the same name is destroyed. The window +# consists of a title at the top, a panel of three boards and some +# control buttons. The panel contains the starting state, current +# state, and goal state of the puzzle. +package require Soar + + +proc make8Puzzle {{w .8} + {start {2 8 3 1 6 4 7 0 5}} + {goal {1 2 3 8 0 4 7 6 5}}} { + global solveslow + + catch {destroy $w} + toplevel $w + wm title $w "8-Puzzle Demonstration" + wm iconname $w "8-Puzzle" + + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "8-Puzzle Demonstration" + + frame $w.frame -width 360 -height 120 -borderwidth 4 \ + -relief ridge -bg Grey70 + + make8Board "Starting \nState" $w.frame.ss $start + make8Board "Current \nState" $w.frame.cs $start + make8Board "Goal \nState" $w.frame.gs $goal + + button $w.solve -text Solve -command "run" + checkbutton $w.speed -text Slowly -variable solveslow + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" \ + -command "init-soar; puzzleSet $w.frame.cs \{$start\}" + button $w.reset -text Reset \ + -command "reset8Puzzle $w \{$start\}" + button $w.ok -text Dismiss -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame.ss $w.frame.cs $w.frame.gs -side left + pack $w.frame -side top -padx 20 + pack $w.solve $w.speed $w.stop $w.init $w.reset \ + -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m +} + +# Procedure to make a single 8-puzzle board. The name of +# the state is used as a title for the board. The board +# itself is simply nine titles in a square. + +proc make8Board {title w state} { + frame $w -width 160 -height 120 -borderwidth 0 + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 300 -text $title + frame $w.board -width 110 -height 110 -borderwidth 5 \ + -relief groove -bg Grey70 + + for {set i 0} {$i < 9} {incr i} { + set num [lindex $state $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + button $w.board.$num -relief raised -text $num + place $w.board.$num -relx $xpos($num) -rely $ypos($num) \ + -relwidth .33 -relheight .33 + } + } + + pack $w.msg $w.board -side top -pady 5 +} + +#----------------------------------------------------------------------- +# +# Procedure to reorder the puzzle entries. The buttons are +# moved to correspond to the given order. After the buttons +# are moved, the windows are updated to show the new positions +# (the Tk call "update" flushes pending updates to the X server). +# If the user has requested that the process move slowly, then +# sleep for a second. It actually takes a little longer to +# exec the process, but whatever. + +proc puzzleSet {w order} { + global solveslow + for {set i 0} {$i < 9} {incr i} { + set num [lindex $order $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + place $w.board.$num -relx $xpos($num) -rely $ypos($num) + } + } + + update + + if {$solveslow != 0} { + after 1000 + } +} + +# This procedure resets a puzzle to the initial state. It also +# removes all chunks and initializes Soar so that the puzzle can +# be run again. + +proc reset8Puzzle {w start} { + excise -chunks + init-soar + puzzleSet $w.frame.cs $start +} + +# This procedure dismisses the 8puzzle demo. It excises all +# productions (maybe not a good thing to do? +# and does an init-soar so other demos can be run from the gui. + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining eight puzzle solution method + +global soar_library +global interp_type + +excise -all +source eight-puzzle.soar + +set solveslow 0 + +make8Puzzle +reset8Puzzle .8 {2 8 3 1 6 4 7 0 5} + +# Redefine one rule to use a Tcl call to update GUI: + +sp {eight*monitor*state + (state ^problem-space

                                                                                                                        + ^binding + + ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) + --> + (tcl |puzzleSet .8.frame.cs {| + | | | | | | + | | | | | | + | | | | |}|) + (write (crlf) | -------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | -------------| | | (crlf) | | )} diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle.vsa b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.vsa new file mode 100644 index 0000000..e99bb0c --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle.vsa @@ -0,0 +1,18 @@ +VERSION 4 +\eight-puzzle\eight-puzzle.dm +0 ROOT eight-puzzle eight-puzzle 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR goal-test goal-test.soar 5 +5 3 FOPERATOR monitor monitor.soar 6 +6 3 FOPERATOR search-control search-control.soar 7 +7 3 FOPERATOR top-state top-state.soar 8 +8 0 FOPERATOR _readme _readme.soar 9 +9 0 HLIOPERATOR Impasse__Operator_Tie Impasse__Operator_Tie.soar Impasse__Operator_Tie 8 10 +10 9 HLOPERATOR evaluate-operator evaluate-operator.soar evaluate-operator 13 11 +11 10 FOPERATOR elaborations elaborations.soar 12 +12 10 OPERATOR move-tile move-tile.soar 13 +13 0 OPERATOR initialize-eight-puzzle initialize-eight-puzzle.soar 14 +14 0 OPERATOR move-tile move-tile.soar 15 +END diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar new file mode 100644 index 0000000..1a48d18 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar @@ -0,0 +1,4 @@ +source evaluate-operator.soar +pushd evaluate-operator +source evaluate-operator_source.soar +popd diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar new file mode 100644 index 0000000..4274f8d --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar @@ -0,0 +1,60 @@ +### +### EIGHT-PUZZLE PROBLEM SPACE: +### STATE EVALUATION +### + + ## A numeric evaluation function, + ## based on changes by operators, is used + ## to evaluate state. + +### +### EVALUATION: STATE POSITIVE +### + +sp {eight*elaborate*state*evaluation*positive*one + (state ^desired.binding + ^tried-tied-operator + ^tile-cell + ^binding ) + ( ^cell ^tile ) + ( ^cell ^tile ) +--> + ( ^numeric-value 1)} + +### +### EVALUATION: STATE NEUTRAL +### + + ## 0 points for not moving tile in or out of its desired cell + # +sp {eight*elaborate*state*evaluation*neutral*zero + (state ^desired + ^tried-tied-operator + ^tile-cell + ^blank-cell + ^binding { <> } { <> <> }) + ( ^binding { <> }) + ( ^cell ^tile ) + ( ^tile ) + ( ^tile ) + ( ^cell ^tile { <> }) + ( ^cell ^tile { <> }) +--> + ( ^numeric-value 0)} + +### +### EVALUATION: STATE NEGATIVE +### + + ## -1 points for moving tile out of its desired cell + # +sp {eight*elaborate*state*evaluation*negative*one + (state ^desired.binding + ^tried-tied-operator + ^tile-cell + ^binding + ^blank-cell ) + ( ^cell ^tile ) + ( ^cell ^tile ) +--> + ( ^numeric-value -1)} diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar new file mode 100644 index 0000000..d2b788e --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/move-tile.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/Impasse__Operator_Tie/evaluate-operator/move-tile.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_firstload.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_firstload.soar new file mode 100644 index 0000000..bd96fef --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_firstload.soar @@ -0,0 +1,9 @@ + +learn -on + +pushd "../../default" +source selection.soar +popd + +multi-attributes binding 10 +multi-attributes operator 4 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_readme.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_readme.soar new file mode 100644 index 0000000..676bc29 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/_readme.soar @@ -0,0 +1,30 @@ +# eight-puzzle/README +# John Laird +# May 23, 2004 +# +# eight-puzzle.soar +# Straight forward implementation of eight-puzzle +# Uses look-ahead search to solve puzzle with simple +# evaluation function - demonstrates chunking. +# Look-ahead search is implemented in ../default/selection.soar +# +# eight-puzzle.tcl +# Simple graphic depiction of eight puzzle states as +# problem is solved. Source this file instead of eight-puzzle.soar +# if you want the graphical interface. + +### +### Modifies the bindings, but does not create new bindings. +### State Structure: + ## Each state contains nine bindings. + ## The bindings connect together a cell, one of the nine positions on + ## the board and a tile, one of the movable pieces. + ## The cells have pointers, ^cell, to each of their adjacent cells. + ## The state also has a pointer to the blank-cell and the cell + ## that the last moved tile is in -- this improves efficiency and + ## simplify computations that depend on the previous operator. +### Operator Staructure: + ## Each operator contains a pointer to the cell with the blank + ## and the cell with the tile to be moved. +### + diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/all/all_source.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/comment.dm b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/comment.dm new file mode 100644 index 0000000..47d9606 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/comment.dm @@ -0,0 +1,52 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle.dm b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle.dm new file mode 100644 index 0000000..3e484dd --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle.dm @@ -0,0 +1,90 @@ +36 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 eight-puzzle +SOAR_ID 4 +ENUMERATION 5 1 initialize-eight-puzzle +SOAR_ID 6 +ENUMERATION 7 1 move-tile +SOAR_ID 8 +ENUMERATION 9 1 state +ENUMERATION 10 1 Impasse__Operator_Tie +ENUMERATION 11 1 evaluate-operator +SOAR_ID 12 +SOAR_ID 13 +ENUMERATION 14 1 state +ENUMERATION 15 2 eight-puzzle evaluate-object +ENUMERATION 16 1 move-tile +SOAR_ID 17 +SOAR_ID 18 +STRING 19 +ENUMERATION 20 1 nil +SOAR_ID 21 +SOAR_ID 22 +ENUMERATION 23 9 0 1 2 3 4 5 6 7 8 +SOAR_ID 24 +ENUMERATION 25 1 higher +SOAR_ID 26 +ENUMERATION 27 1 eight-puzzle +ENUMERATION 28 1 yes +ENUMERATION 29 2 no yes +ENUMERATION 30 1 blank-cell +ENUMERATION 31 1 binding +SOAR_ID 32 +INTEGER_RANGE 33 -1 1 +STRING 34 +INTEGER_RANGE 35 -1 1 +52 +0 binding 21 +0 blank-cell 18 +0 desired 24 +0 name 3 +0 operator 4 +0 operator 6 +0 problem-space 26 +0 success 24 +0 superstate 2 +0 tile-cell 18 +0 tile-cell 20 +0 type 1 +4 name 5 +6 blank-cell 18 +6 name 7 +6 tile-cell 18 +8 evaluation 32 +8 name 10 +8 operator 12 +8 superstate 0 +8 top-state 0 +8 type 9 +12 desired 24 +12 evaluation 32 +12 name 11 +13 binding 21 +13 blank-cell 18 +13 desired 24 +13 name 15 +13 numeric-value 35 +13 operator 17 +13 problem-space 26 +13 success 24 +13 superstate 8 +13 tile-cell 18 +13 top-state 0 +13 tried-tied-operator 34 +13 type 14 +17 name 16 +18 cell 18 +18 name 19 +21 cell 18 +21 tile 22 +22 name 23 +24 better 25 +24 binding 21 +26 default-operator-copy 29 +26 default-state-copy 28 +26 name 27 +26 one-level-attributes 30 +26 two-level-attributes 31 +32 numeric-value 33 diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle_source.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle_source.soar new file mode 100644 index 0000000..58921fb --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/eight-puzzle_source.soar @@ -0,0 +1,14 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize-eight-puzzle.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/elaborations_source.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/elaborations_source.soar new file mode 100644 index 0000000..13f4262 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source goal-test.soar +source monitor.soar +source search-control.soar +source top-state.soar diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/goal-test.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/goal-test.soar new file mode 100644 index 0000000..822af4a --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/goal-test.soar @@ -0,0 +1,34 @@ + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + +sp {eight*detect*state*success + (state ^problem-space.name eight-puzzle + ^desired + ^binding + + ) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) + ( ^binding + + ) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) +--> + ( ^success )} diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/monitor.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/monitor.soar new file mode 100644 index 0000000..e6f9bfa --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/monitor.soar @@ -0,0 +1,40 @@ +### +### EIGHT-PUZZLE PROBLEM SPACE: +### MONITOR STATE +### + + ## Want this to fire whenever an op is installed or + ## whenever op is applied (bindings change) but NOT both. + ## Try requiring that operator be finished. + # + +sp {eight*monitor*state + (state ^binding + + ) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) +--> + (write (crlf) | -------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | -------------| | | (crlf) | | )} \ No newline at end of file diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/search-control.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/search-control.soar new file mode 100644 index 0000000..7770bfa --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/search-control.soar @@ -0,0 +1,14 @@ + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {eight*operator*move-tile*inverse*reject + "Reject the operator that was applied to create this state." + (state ^problem-space.name eight-puzzle + ^operator + + ^tile-cell ) + ( ^tile-cell ) +--> + ( ^operator - )} diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/top-state.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/top-state.soar new file mode 100644 index 0000000..4802c2c --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/elaborations/top-state.soar @@ -0,0 +1,11 @@ +sp {eight*elaborate*problem-space + (state ^name eight-puzzle) +--> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name eight-puzzle + ^default-state-copy yes + ^default-operator-copy no + ^one-level-attributes blank-cell + ^two-level-attributes binding)} + + diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize-eight-puzzle.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize-eight-puzzle.soar new file mode 100644 index 0000000..fdb916c --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize-eight-puzzle.soar @@ -0,0 +1,71 @@ +### INITIAL STATE AND DESIRED STATE +### + + ## Define the initial state and the desired state: + ## each state is a set of bindings# + ## each binding points to a cell and a tile# + ## each cell points to its neighboring cells. + +sp {eight-puzzle*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-eight-puzzle)} + +## To modify the initial state, you must move the tiles +## that are part of the bindings. The same tile +## must not be in two cells and every cell must have different +## tiles. +## The blank-cell attribute on the state must have +## the cell that has the block (tile ) in it. + +sp {eight*create*state*initial-and-desired-states + (state ^operator.name initialize-eight-puzzle) +--> + ( ^name eight-puzzle + ^desired + ^blank-cell + ^tile-cell nil + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^name c11 ^cell ^cell ) + ( ^name c12 ^cell ^cell ^cell ) + ( ^name c13 ^cell ^cell ) + ( ^name c21 ^cell ^cell ^cell ) + ( ^name c22 ^cell ^cell + ^cell ^cell ) + ( ^name c23 ^cell ^cell ^cell ) + ( ^name c31 ^cell ^cell ) + ( ^name c32 ^cell ^cell ^cell ) + ( ^name c33 ^cell ^cell ) + ( ^name 0) + ( ^name 1) + ( ^name 2) + ( ^name 3) + ( ^name 4) + ( ^name 5) + ( ^name 6) + ( ^name 7) + ( ^name 8) + ( ^better higher + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile )} \ No newline at end of file diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize.soar new file mode 100644 index 0000000..9a8a51c --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/initialize.soar @@ -0,0 +1,70 @@ +### INITIAL STATE AND DESIRED STATE +### + + ## Define the initial state and the desired state: + ## each state is a set of bindings# + ## each binding points to a cell and a tile# + ## each cell points to its neighboring cells. + +sp {eight-puzzle*propose*initialize + (state ^name eight-puzzle + -^blank-cell) +--> + ( ^operator +) + ( ^name initialize)} + +## To modify the initial state, you must move the tiles +## that are part of the bindings. The same tile +## must not be in two cells and every cell must have different +## tiles. +## The blank-cell attribute on the state must have +## the cell that has the block (tile ) in it. + +sp {eight*create*state*initial-and-desired-states + (state ^operator.name initialize + ^desired ) +--> + ( ^blank-cell + ^tile-cell nil + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^name c11 ^cell ^cell ) + ( ^name c12 ^cell ^cell ^cell ) + ( ^name c13 ^cell ^cell ) + ( ^name c21 ^cell ^cell ^cell ) + ( ^name c22 ^cell ^cell + ^cell ^cell ) + ( ^name c23 ^cell ^cell ^cell ) + ( ^name c31 ^cell ^cell ) + ( ^name c32 ^cell ^cell ^cell ) + ( ^name c33 ^cell ^cell ) + ( ^name 0) + ( ^name 1) + ( ^name 2) + ( ^name 3) + ( ^name 4) + ( ^name 5) + ( ^name 6) + ( ^name 7) + ( ^name 8) + ( ^better higher + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile )} \ No newline at end of file diff --git a/soar-8.5.2/demos/eight-puzzle/eight-puzzle/move-tile.soar b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/move-tile.soar new file mode 100644 index 0000000..8278d99 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/eight-puzzle/move-tile.soar @@ -0,0 +1,50 @@ + +### +### EIGHT-PUZZLE PROBLEM SPACE OPERATOR: +### MOVE-TILE +### + +sp {eight*create*operator*move-tile + (state ^name eight-puzzle + ^blank-cell ) + ( ^cell ) +--> + ( ^operator ) + ( ^name move-tile + ^tile-cell + ^blank-cell )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {eight*apply*operator*move-tile + (state ^operator + ^binding { <> } + ^blank-cell ) + ( ^name move-tile + ^tile-cell + ^blank-cell ) + ( ^tile ^cell ) + ( ^tile ^cell ) +--> + ( ^blank-cell - ) + ( ^tile - ) + ( ^tile - )} + +sp {eight*apply*operator*remove-tile-cell + (state ^operator + ^tile-cell ) + ( ^name move-tile + ^blank-cell <> ) +--> + ( ^tile-cell -)} + +sp {eight*apply*operator*add-tile-cell + (state ^operator + ^blank-cell ) + ( ^name move-tile + ^blank-cell ) +--> + ( ^tile-cell )} diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.soar new file mode 100644 index 0000000..8f614b7 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.soar @@ -0,0 +1,3 @@ +pushd fifteen-puzzle +source fifteen-puzzle_source.soar +popd diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.vsa b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.vsa new file mode 100644 index 0000000..dca5993 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle.vsa @@ -0,0 +1,18 @@ +VERSION 4 +\fifteen-puzzle\fifteen-puzzle.dm +0 ROOT fifteen-puzzle fifteen-puzzle 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR goal-test goal-test.soar 5 +5 3 FOPERATOR monitor monitor.soar 6 +6 3 FOPERATOR search-control search-control.soar 7 +7 3 FOPERATOR top-state top-state.soar 8 +8 0 FOPERATOR _readme _readme.soar 9 +9 0 HLIOPERATOR Impasse__Operator_Tie Impasse__Operator_Tie.soar Impasse__Operator_Tie 8 10 +10 9 HLOPERATOR evaluate-operator evaluate-operator.soar evaluate-operator 13 11 +11 10 FOPERATOR elaborations elaborations.soar 12 +12 10 OPERATOR move-tile move-tile.soar 13 +13 0 OPERATOR initialize-fifteen-puzzle initialize-fifteen-puzzle.soar 14 +14 0 OPERATOR move-tile move-tile.soar 15 +END diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar new file mode 100644 index 0000000..1a48d18 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar @@ -0,0 +1,4 @@ +source evaluate-operator.soar +pushd evaluate-operator +source evaluate-operator_source.soar +popd diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar new file mode 100644 index 0000000..93d3502 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/elaborations.soar @@ -0,0 +1,60 @@ +### +### fifteen-puzzle PROBLEM SPACE: +### STATE EVALUATION +### + + ## A numeric evaluation function, + ## based on changes by operators, is used + ## to evaluate state. + +### +### EVALUATION: STATE POSITIVE +### + +sp {eight*elaborate*state*evaluation*positive*one + (state ^desired.binding + ^tried-tied-operator + ^tile-cell + ^binding ) + ( ^cell ^tile ) + ( ^cell ^tile ) +--> + ( ^numeric-value 1)} + +### +### EVALUATION: STATE NEUTRAL +### + + ## 0 points for not moving tile in or out of its desired cell + # +sp {eight*elaborate*state*evaluation*neutral*zero + (state ^desired + ^tried-tied-operator + ^tile-cell + ^blank-cell + ^binding { <> } { <> <> }) + ( ^binding { <> }) + ( ^cell ^tile ) + ( ^tile ) + ( ^tile ) + ( ^cell ^tile { <> }) + ( ^cell ^tile { <> }) +--> + ( ^numeric-value 0)} + +### +### EVALUATION: STATE NEGATIVE +### + + ## -1 points for moving tile out of its desired cell + # +sp {eight*elaborate*state*evaluation*negative*one + (state ^desired.binding + ^tried-tied-operator + ^tile-cell + ^binding + ^blank-cell ) + ( ^cell ^tile ) + ( ^cell ^tile ) +--> + ( ^numeric-value -1)} diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-object_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-object_source.soar new file mode 100644 index 0000000..d2b788e --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-object_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar new file mode 100644 index 0000000..d2b788e --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/move-tile.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/Impasse__Operator_Tie/evaluate-operator/move-tile.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_firstload.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_firstload.soar new file mode 100644 index 0000000..bd96fef --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_firstload.soar @@ -0,0 +1,9 @@ + +learn -on + +pushd "../../default" +source selection.soar +popd + +multi-attributes binding 10 +multi-attributes operator 4 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_readme.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_readme.soar new file mode 100644 index 0000000..1c85bb4 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/_readme.soar @@ -0,0 +1,29 @@ +# fifteen-puzzle/README +# John Laird +# October 27, 2003 +# +# fifteen-puzzle.soar +# Straight forward implementation of fifteen-puzzle +# Uses look-ahead search to solve puzzle with simple +# evaluation function - demonstrates chunking. +# Look-ahead search is implemented in ../default/selection.soar +# +# Modifies eight-puzzle with change to desired state (in elaborations/goal-test) +# can creation of initial state (in initialize). + + +### +### Modifies the bindings, but does not create new bindings. +### State Structure: + ## Each state contains nine bindings. + ## The bindings connect together a cell, one of the nine positions on + ## the board and a tile, one of the movable pieces. + ## The cells have pointers, ^cell, to each of their adjacent cells. + ## The state also has a pointer to the blank-cell and the cell + ## that the last moved tile is in -- this improves efficiency and + ## simplify computations that depend on the previous operator. +### Operator Staructure: + ## Each operator contains a pointer to the cell with the blank + ## and the cell with the tile to be moved. +### + diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/all/all_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/comment.dm b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/comment.dm new file mode 100644 index 0000000..47d9606 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/comment.dm @@ -0,0 +1,52 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle.dm b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle.dm new file mode 100644 index 0000000..684d801 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle.dm @@ -0,0 +1,90 @@ +36 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 eight-puzzle +SOAR_ID 4 +ENUMERATION 5 1 initialize +SOAR_ID 6 +ENUMERATION 7 1 move-tile +SOAR_ID 8 +ENUMERATION 9 1 state +ENUMERATION 10 1 Impasse__Operator_Tie +ENUMERATION 11 1 evaluate-operator +SOAR_ID 12 +SOAR_ID 13 +ENUMERATION 14 1 state +ENUMERATION 15 2 eight-puzzle evaluate-object +ENUMERATION 16 1 move-tile +SOAR_ID 17 +SOAR_ID 18 +STRING 19 +ENUMERATION 20 1 nil +SOAR_ID 21 +SOAR_ID 22 +ENUMERATION 23 9 0 1 2 3 4 5 6 7 8 +SOAR_ID 24 +ENUMERATION 25 1 higher +SOAR_ID 26 +ENUMERATION 27 1 eight-puzzle +ENUMERATION 28 1 yes +ENUMERATION 29 2 no yes +ENUMERATION 30 1 blank-cell +ENUMERATION 31 1 binding +SOAR_ID 32 +INTEGER_RANGE 33 -1 1 +STRING 34 +INTEGER_RANGE 35 -1 1 +52 +0 binding 21 +0 blank-cell 18 +0 desired 24 +0 name 3 +0 operator 4 +0 operator 6 +0 problem-space 26 +0 success 24 +0 superstate 2 +0 tile-cell 18 +0 tile-cell 20 +0 type 1 +4 name 5 +6 blank-cell 18 +6 name 7 +6 tile-cell 18 +8 evaluation 32 +8 name 10 +8 operator 12 +8 superstate 0 +8 top-state 0 +8 type 9 +12 desired 24 +12 evaluation 32 +12 name 11 +13 binding 21 +13 blank-cell 18 +13 desired 24 +13 name 15 +13 numeric-value 35 +13 operator 17 +13 problem-space 26 +13 success 24 +13 superstate 8 +13 tile-cell 18 +13 top-state 0 +13 tried-tied-operator 34 +13 type 14 +17 name 16 +18 cell 18 +18 name 19 +21 cell 18 +21 tile 22 +22 name 23 +24 better 25 +24 binding 21 +26 default-operator-copy 29 +26 default-state-copy 28 +26 name 27 +26 one-level-attributes 30 +26 two-level-attributes 31 +32 numeric-value 33 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle_source.soar new file mode 100644 index 0000000..eb29b6f --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/eight-puzzle_source.soar @@ -0,0 +1,14 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/elaborations_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/elaborations_source.soar new file mode 100644 index 0000000..13f4262 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source goal-test.soar +source monitor.soar +source search-control.soar +source top-state.soar diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/goal-test.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/goal-test.soar new file mode 100644 index 0000000..74494d6 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/goal-test.soar @@ -0,0 +1,50 @@ + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + +sp {eight*detect*state*success + (state ^problem-space.name fifteen-puzzle + ^desired + ^binding + + + ) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c14 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c24 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) + ( ^cell.name c34 ^tile ) + ( ^cell.name c41 ^tile ) + ( ^cell.name c42 ^tile ) + ( ^cell.name c43 ^tile ) + ( ^cell.name c44 ^tile ) + ( ^binding + + + ) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c14 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c24 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) + ( ^cell.name c34 ^tile ) + ( ^cell.name c41 ^tile ) + ( ^cell.name c42 ^tile ) + ( ^cell.name c43 ^tile ) + ( ^cell.name c44 ^tile ) +--> + ( ^success )} diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/monitor.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/monitor.soar new file mode 100644 index 0000000..cb46ac5 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/monitor.soar @@ -0,0 +1,51 @@ +### +### MONITOR STATE +### + +sp {eight*monitor*state + (state ^binding + + + ) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c14 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c24 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) + ( ^cell.name c34 ^tile ) + ( ^name ) + ( ^cell.name c41 ^tile ) + ( ^name ) + ( ^cell.name c42 ^tile ) + ( ^name ) + ( ^cell.name c43 ^tile ) + ( ^name ) + ( ^cell.name c44 ^tile ) + ( ^name ) +--> + (write (crlf) | ---------------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|----\|----\|----\|----\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|----\|----\|----\|----\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|----\|----\|----\|----\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | ---------------------| | | (crlf) | | )} diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/search-control.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/search-control.soar new file mode 100644 index 0000000..0037fd2 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/search-control.soar @@ -0,0 +1,14 @@ + +### +### fifteen-puzzle PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {eight*operator*move-tile*inverse*reject + "Reject the operator that was applied to create this state." + (state ^problem-space.name fifteen-puzzle + ^operator + + ^tile-cell ) + ( ^tile-cell ) +--> + ( ^operator - )} diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/top-state.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/top-state.soar new file mode 100644 index 0000000..0224e4f --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/elaborations/top-state.soar @@ -0,0 +1,11 @@ +sp {eight*elaborate*problem-space + (state ^name fifteen-puzzle) +--> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name fifteen-puzzle + ^default-state-copy yes + ^default-operator-copy no + ^one-level-attributes blank-cell + ^two-level-attributes binding)} + + diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle.dm b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle.dm new file mode 100644 index 0000000..2879697 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle.dm @@ -0,0 +1,90 @@ +36 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 fifteen-puzzle +SOAR_ID 4 +ENUMERATION 5 1 initialize-fifteen-puzzle +SOAR_ID 6 +ENUMERATION 7 1 move-tile +SOAR_ID 8 +ENUMERATION 9 1 state +ENUMERATION 10 1 Impasse__Operator_Tie +ENUMERATION 11 1 evaluate-operator +SOAR_ID 12 +SOAR_ID 13 +ENUMERATION 14 1 state +ENUMERATION 15 2 eight-puzzle evaluate-object +ENUMERATION 16 1 move-tile +SOAR_ID 17 +SOAR_ID 18 +STRING 19 +ENUMERATION 20 1 nil +SOAR_ID 21 +SOAR_ID 22 +SOAR_ID 23 +ENUMERATION 24 1 higher +SOAR_ID 25 +ENUMERATION 26 1 fifteen-puzzle +ENUMERATION 27 1 yes +ENUMERATION 28 2 no yes +ENUMERATION 29 1 blank-cell +ENUMERATION 30 1 binding +SOAR_ID 31 +INTEGER_RANGE 32 -1 1 +STRING 33 +INTEGER_RANGE 34 -1 1 +STRING 35 +52 +0 binding 21 +0 blank-cell 18 +0 desired 23 +0 name 3 +0 operator 4 +0 operator 6 +0 problem-space 25 +0 success 23 +0 superstate 2 +0 tile-cell 18 +0 tile-cell 20 +0 type 1 +4 name 5 +6 blank-cell 18 +6 name 7 +6 tile-cell 18 +8 evaluation 31 +8 name 10 +8 operator 12 +8 superstate 0 +8 top-state 0 +8 type 9 +12 desired 23 +12 evaluation 31 +12 name 11 +13 binding 21 +13 blank-cell 18 +13 desired 23 +13 name 15 +13 numeric-value 34 +13 operator 17 +13 problem-space 25 +13 success 23 +13 superstate 8 +13 tile-cell 18 +13 top-state 0 +13 tried-tied-operator 33 +13 type 14 +17 name 16 +18 cell 18 +18 name 19 +21 cell 18 +21 tile 22 +22 name 35 +23 better 24 +23 binding 21 +25 default-operator-copy 28 +25 default-state-copy 27 +25 name 26 +25 one-level-attributes 29 +25 two-level-attributes 30 +31 numeric-value 32 diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle_source.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle_source.soar new file mode 100644 index 0000000..9e49cb1 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/fifteen-puzzle_source.soar @@ -0,0 +1,14 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize-fifteen-puzzle.soar +source move-tile.soar diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize-fifteen-puzzle.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize-fifteen-puzzle.soar new file mode 100644 index 0000000..5c07392 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize-fifteen-puzzle.soar @@ -0,0 +1,98 @@ +### INITIAL STATE AND DESIRED STATE +### + + ## Define the initial state and the desired state: + ## each state is a set of bindings# + ## each binding points to a cell and a tile# + ## each cell points to its neighboring cells. + +sp {fifteen-puzzle*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-fifteen-puzzle)} + +## To modify the initial state, you must move the tiles +## that are part of the bindings. The same tile +## must not be in two cells and every cell must have different +## tiles. +## The blank-cell attribute on the state must have +## the cell that has the block (tile ) in it. + +sp {eight*create*state*initial-and-desired-states + (state ^operator.name initialize-fifteen-puzzle) +--> + ( ^name fifteen-puzzle + ^desired + ^blank-cell ^tile-cell nil + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^name c11 ^cell ^cell ) + ( ^name c12 ^cell ^cell ^cell ) + ( ^name c13 ^cell ^cell ^cell ) + ( ^name c14 ^cell ^cell ) + ( ^name c21 ^cell ^cell ^cell ) + ( ^name c22 ^cell ^cell ^cell ^cell ) + ( ^name c23 ^cell ^cell ^cell ^cell ) + ( ^name c24 ^cell ^cell ^cell ) + ( ^name c31 ^cell ^cell ^cell ) + ( ^name c32 ^cell ^cell ^cell ^cell ) + ( ^name c33 ^cell ^cell ^cell ) + ( ^name c34 ^cell ^cell ^cell ) + ( ^name c41 ^cell ^cell ) + ( ^name c42 ^cell ^cell ^cell ) + ( ^name c43 ^cell ^cell ^cell ) + ( ^name c44 ^cell ^cell ) + ( ^name |0 |) + ( ^name |1 |) + ( ^name |2 |) + ( ^name |3 |) + ( ^name |4 |) + ( ^name |5 |) + ( ^name |6 |) + ( ^name |7 |) + ( ^name |8 |) + ( ^name |9 |) + ( ^name |10|) + ( ^name |11|) + ( ^name |12|) + ( ^name |13|) + ( ^name |14|) + ( ^name |15|) + ( ^better higher + ^binding + + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile )} \ No newline at end of file diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize.soar new file mode 100644 index 0000000..8a4c6cf --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/initialize.soar @@ -0,0 +1,97 @@ +### INITIAL STATE AND DESIRED STATE +### + + ## Define the initial state and the desired state: + ## each state is a set of bindings# + ## each binding points to a cell and a tile# + ## each cell points to its neighboring cells. + +sp {fifteen-puzzle*propose*initialize + (state ^name fifteen-puzzle + -^blank-cell) +--> + ( ^operator +) + ( ^name initialize)} + +## To modify the initial state, you must move the tiles +## that are part of the bindings. The same tile +## must not be in two cells and every cell must have different +## tiles. +## The blank-cell attribute on the state must have +## the cell that has the block (tile ) in it. + +sp {eight*create*state*initial-and-desired-states + (state ^operator.name initialize + ^desired ) +--> + ( ^blank-cell ^tile-cell nil + ^binding + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^name c11 ^cell ^cell ) + ( ^name c12 ^cell ^cell ^cell ) + ( ^name c13 ^cell ^cell ^cell ) + ( ^name c14 ^cell ^cell ) + ( ^name c21 ^cell ^cell ^cell ) + ( ^name c22 ^cell ^cell ^cell ^cell ) + ( ^name c23 ^cell ^cell ^cell ^cell ) + ( ^name c24 ^cell ^cell ^cell ) + ( ^name c31 ^cell ^cell ^cell ) + ( ^name c32 ^cell ^cell ^cell ^cell ) + ( ^name c33 ^cell ^cell ^cell ) + ( ^name c34 ^cell ^cell ^cell ) + ( ^name c41 ^cell ^cell ) + ( ^name c42 ^cell ^cell ^cell ) + ( ^name c43 ^cell ^cell ^cell ) + ( ^name c44 ^cell ^cell ) + ( ^name |0 |) + ( ^name |1 |) + ( ^name |2 |) + ( ^name |3 |) + ( ^name |4 |) + ( ^name |5 |) + ( ^name |6 |) + ( ^name |7 |) + ( ^name |8 |) + ( ^name |9 |) + ( ^name |10|) + ( ^name |11|) + ( ^name |12|) + ( ^name |13|) + ( ^name |14|) + ( ^name |15|) + ( ^better higher + ^binding + + ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile )} \ No newline at end of file diff --git a/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/move-tile.soar b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/move-tile.soar new file mode 100644 index 0000000..4154883 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/fifteen-puzzle/move-tile.soar @@ -0,0 +1,50 @@ + +### +### fifteen-puzzle PROBLEM SPACE OPERATOR: +### MOVE-TILE +### + +sp {eight*create*operator*move-tile + (state ^name fifteen-puzzle + ^blank-cell ) + ( ^cell ) +--> + ( ^operator ) + ( ^name move-tile + ^tile-cell + ^blank-cell )} + +### +### fifteen-puzzle PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {eight*apply*operator*move-tile + (state ^operator + ^binding { <> } + ^blank-cell ) + ( ^name move-tile + ^tile-cell + ^blank-cell ) + ( ^tile ^cell ) + ( ^tile ^cell ) +--> + ( ^blank-cell - ) + ( ^tile - ) + ( ^tile - )} + +sp {eight*apply*operator*remove-tile-cell + (state ^operator + ^tile-cell ) + ( ^name move-tile + ^blank-cell <> ) +--> + ( ^tile-cell -)} + +sp {eight*apply*operator*add-tile-cell + (state ^operator + ^blank-cell ) + ( ^name move-tile + ^blank-cell ) +--> + ( ^tile-cell )} diff --git a/soar-8.5.2/demos/eight-puzzle/readme.txt b/soar-8.5.2/demos/eight-puzzle/readme.txt new file mode 100644 index 0000000..c464939 --- /dev/null +++ b/soar-8.5.2/demos/eight-puzzle/readme.txt @@ -0,0 +1,15 @@ +# eight-puzzle/README +# John Laird +# October 27, 2003 +# +# eight-puzzle.soar +# Straight forward implementation of eight-puzzle +# Uses look-ahead search to solve puzzle with simple +# evaluation function - demonstrates chunking. +# Look-ahead search is implemented in ../default/selection.soar +# +# eight-puzzle.tcl +# Simple graphic depiction of eight puzzle states as +# problem is solved. Source this file instead of eight-puzzle.soar +# if you want the graphical interface. + diff --git a/soar-8.5.2/demos/mac/boat.gif b/soar-8.5.2/demos/mac/boat.gif new file mode 100644 index 0000000..6a781e3 Binary files /dev/null and b/soar-8.5.2/demos/mac/boat.gif differ diff --git a/soar-8.5.2/demos/mac/cannibal.gif b/soar-8.5.2/demos/mac/cannibal.gif new file mode 100644 index 0000000..ea53654 Binary files /dev/null and b/soar-8.5.2/demos/mac/cannibal.gif differ diff --git a/soar-8.5.2/demos/mac/land.gif b/soar-8.5.2/demos/mac/land.gif new file mode 100644 index 0000000..1c97d38 Binary files /dev/null and b/soar-8.5.2/demos/mac/land.gif differ diff --git a/soar-8.5.2/demos/mac/mac-planning.soar b/soar-8.5.2/demos/mac/mac-planning.soar new file mode 100644 index 0000000..80d4ba4 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning.soar @@ -0,0 +1,3 @@ +pushd mac-planning +source mac-planning_source.soar +popd diff --git a/soar-8.5.2/demos/mac/mac-planning.vsa b/soar-8.5.2/demos/mac/mac-planning.vsa new file mode 100644 index 0000000..ee66d5d --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning.vsa @@ -0,0 +1,18 @@ +VERSION 4 +\mac-planning\mac-planning.dm +0 ROOT mac-planning mac-planning 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR goal-test goal-test.soar 5 +5 3 FOPERATOR monitor monitor.soar 6 +6 3 FOPERATOR problem-space problem-space.soar 7 +7 0 FOPERATOR _readme _readme.soar 9 +8 0 HLIOPERATOR Impasse__Operator_Tie Impasse__Operator_Tie.soar Impasse__Operator_Tie 21 10 +9 8 FOPERATOR elaborations elaborations.soar 11 +10 8 HLOPERATOR evaluate-operator evaluate-operator.soar evaluate-operator 26 12 +11 10 FOPERATOR elaborations elaborations.soar 13 +12 10 OPERATOR move-boat move-boat.soar 14 +13 0 OPERATOR initialize-mac initialize-mac.soar 15 +14 0 OPERATOR move-boat move-boat.soar 16 +END diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar new file mode 100644 index 0000000..3a24a07 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar @@ -0,0 +1,5 @@ +source elaborations.soar +source evaluate-operator.soar +pushd evaluate-operator +source evaluate-operator_source.soar +popd diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/elaborations.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/elaborations.soar new file mode 100644 index 0000000..761991c --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/elaborations.soar @@ -0,0 +1,8 @@ +sp {monitor*move-mac-boat*evaluation + (state ^operator ) + ( ^name evaluate-operator + ^operator ) + ( ^name move-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Evaluate move | | | )} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/elaborations.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/elaborations.soar new file mode 100644 index 0000000..09bd653 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/elaborations.soar @@ -0,0 +1,30 @@ +# this rule will cause a warning during loading in Soar; that warning can be ignored +set warnings off +sp {mac*evaluate*state*failure*duplicate + (state ^desired + ^right-bank + ^left-bank ) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + ( { <> } + ^right-bank + ^left-bank + ^tried-tied-operator) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + -(state ^superstate ) + --> + (write (crlf) |Duplicate State Detected.|) + ( ^failure )} +set warnings on + +sp {mac*evaluate*state*failure*state-no-change + (state ^desired + ^problem-space.name missionaries-and-cannibals) + (state ^superstate + ^attribute state + ^quiescence t + ^impasse no-change) +--> + (write (crlf) |######## STATE NO-CHANGE Failure! #########|) + ( ^failure )} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar new file mode 100644 index 0000000..304886e --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/evaluate-operator_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-boat.soar diff --git a/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/move-boat.soar b/soar-8.5.2/demos/mac/mac-planning/Impasse__Operator_Tie/evaluate-operator/move-boat.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac-planning/_firstload.soar b/soar-8.5.2/demos/mac/mac-planning/_firstload.soar new file mode 100644 index 0000000..2c10466 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/_firstload.soar @@ -0,0 +1,4 @@ +learn -on +pushd "../../default" +source selection.soar +popd \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/_readme.soar b/soar-8.5.2/demos/mac/mac-planning/_readme.soar new file mode 100644 index 0000000..7eaa84e --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/_readme.soar @@ -0,0 +1,21 @@ +### ABSTRACT. +### This file provides a Soar system to solve the missionaries and +### cannibals problem. +### +### PROBLEM STATEMENT +### Three missionaries and three cannibals come to a river. There is a a +### boat on their bank of the river that can be used by either one or +### two persons at a time. This boat must be used to cross the river in +### such a way that cannibals never outnumber missionaries on either +### bank of the river. +### + +### DESCRIPTION. +### Simple state representation where the state has two objects: one for +### each bank of the river. Each of these has augmentations for +### missionaries, cannibals, and the boat; with their values being the +### number of the entity type on that bank of the river. This is the +### version covered in Soar 8 Tutorial. Copying the states is more +### complex (two-level-attributes) than other versions, but initial +### state definition, operator proposal and application are simplier. +### diff --git a/soar-8.5.2/demos/mac/mac-planning/all/all_source.soar b/soar-8.5.2/demos/mac/mac-planning/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac-planning/comment.dm b/soar-8.5.2/demos/mac/mac-planning/comment.dm new file mode 100644 index 0000000..65b3b1f --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/comment.dm @@ -0,0 +1,43 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/mac/mac-planning/elaborations/elaborations_source.soar b/soar-8.5.2/demos/mac/mac-planning/elaborations/elaborations_source.soar new file mode 100644 index 0000000..ae6049b --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/elaborations/elaborations_source.soar @@ -0,0 +1,3 @@ +source goal-test.soar +source monitor.soar +source problem-space.soar diff --git a/soar-8.5.2/demos/mac/mac-planning/elaborations/goal-test.soar b/soar-8.5.2/demos/mac/mac-planning/elaborations/goal-test.soar new file mode 100644 index 0000000..141c157 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/elaborations/goal-test.soar @@ -0,0 +1,29 @@ + +#### +### STATE SUCCESS/GOAL DETECTION +### + +sp {mac*detect*state*success + (state ^desired + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + ( ^missionaries + ^cannibals ) + --> + ( ^success ) + (write (crlf) |Success!|)} + +### +### STATE FAILURE DETECTION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^<< right-bank left-bank >> ) + ( ^missionaries { > 0 } + ^cannibals > ) + --> + (write (crlf) |Failure!|) + ( ^failure )} diff --git a/soar-8.5.2/demos/mac/mac-planning/elaborations/monitor.soar b/soar-8.5.2/demos/mac/mac-planning/elaborations/monitor.soar new file mode 100644 index 0000000..c7e1d47 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/elaborations/monitor.soar @@ -0,0 +1,39 @@ + +### +### move-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-boat + (state ^operator ) + ( ^name move-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} diff --git a/soar-8.5.2/demos/mac/mac-planning/elaborations/problem-space.soar b/soar-8.5.2/demos/mac/mac-planning/elaborations/problem-space.soar new file mode 100644 index 0000000..a6b8c1e --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/elaborations/problem-space.soar @@ -0,0 +1,7 @@ +sp {mac*elaborate*problem-space + (state ^name mac) +--> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals + ^default-state-copy yes + ^two-level-attributes right-bank left-bank)} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/elaborations/top-state.soar b/soar-8.5.2/demos/mac/mac-planning/elaborations/top-state.soar new file mode 100644 index 0000000..e08a0c4 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/elaborations/top-state.soar @@ -0,0 +1,6 @@ +sp {elaborate*top-state*name + (state ^superstate nil) +--> + ( ^name mac) +} + diff --git a/soar-8.5.2/demos/mac/mac-planning/initialize-mac.soar b/soar-8.5.2/demos/mac/mac-planning/initialize-mac.soar new file mode 100644 index 0000000..d28226e --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/initialize-mac.soar @@ -0,0 +1,28 @@ +sp {mac*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator + =) + ( ^name initialize-mac-planning) +} + +sp {mac*apply*initialize + (state ^operator.name initialize-mac-planning) +--> + ( ^name mac + ^left-bank + ^right-bank + ^desired ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^right-bank

                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) +} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/initialize.soar b/soar-8.5.2/demos/mac/mac-planning/initialize.soar new file mode 100644 index 0000000..1329486 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/initialize.soar @@ -0,0 +1,28 @@ +sp {mac*propose*initialize + (state ^name mac + -^left-bank) +--> + ( ^operator + =) + ( ^name initialize) +} + +sp {mac*apply*initialize + (state ^operator.name initialize) +--> + ( ^name mac + ^left-bank + ^right-bank + ^desired ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^right-bank
                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) +} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac-planning/mac-planning.dm b/soar-8.5.2/demos/mac/mac-planning/mac-planning.dm new file mode 100644 index 0000000..8dd6f30 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/mac-planning.dm @@ -0,0 +1,76 @@ +31 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 mac +SOAR_ID 4 +ENUMERATION 5 1 initialize-mac-planning +SOAR_ID 6 +ENUMERATION 7 1 move-boat +SOAR_ID 8 +INTEGER_RANGE 9 0 3 +INTEGER_RANGE 10 0 1 +SOAR_ID 11 +INTEGER_RANGE 12 1 2 +INTEGER_RANGE 13 -2147483648 2147483647 +INTEGER_RANGE 14 0 3 +INTEGER_RANGE 15 0 3 +ENUMERATION 16 2 cannibals missionaries +SOAR_ID 17 +ENUMERATION 18 1 missionaries-and-cannibals +ENUMERATION 19 1 yes +ENUMERATION 20 2 left-bank right-bank +SOAR_ID 21 +ENUMERATION 22 1 state +ENUMERATION 23 1 Impasse__Operator_Tie +ENUMERATION 24 1 evaluate-operator +SOAR_ID 25 +SOAR_ID 26 +ENUMERATION 27 1 state +ENUMERATION 28 1 evaluate-operator +ENUMERATION 29 1 move-boat +SOAR_ID 30 +43 +0 desired 11 +0 failure 11 +0 left-bank 8 +0 name 3 +0 operator 4 +0 operator 6 +0 problem-space 17 +0 right-bank 8 +0 success 11 +0 superstate 2 +0 top-state 0 +0 type 1 +4 name 5 +6 bank 8 +6 boat 13 +6 cannibals 14 +6 missionaries 9 +6 name 7 +6 number 15 +6 type 16 +6 types 12 +8 boat 10 +8 cannibals 9 +8 missionaries 9 +8 other-bank 8 +11 left-bank 8 +11 right-bank 8 +17 default-state-copy 19 +17 name 18 +17 two-level-attributes 20 +21 name 23 +21 operator 25 +21 superstate 0 +21 top-state 0 +21 type 22 +25 name 24 +25 operator 6 +26 name 28 +26 operator 30 +26 superstate 21 +26 top-state 0 +26 type 27 +30 name 29 diff --git a/soar-8.5.2/demos/mac/mac-planning/mac-planning_source.soar b/soar-8.5.2/demos/mac/mac-planning/mac-planning_source.soar new file mode 100644 index 0000000..d5268fb --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/mac-planning_source.soar @@ -0,0 +1,14 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize-mac.soar +source move-boat.soar diff --git a/soar-8.5.2/demos/mac/mac-planning/mac.dm b/soar-8.5.2/demos/mac/mac-planning/mac.dm new file mode 100644 index 0000000..b84fdad --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/mac.dm @@ -0,0 +1,45 @@ +17 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 mac +SOAR_ID 4 +ENUMERATION 5 1 initialize +SOAR_ID 6 +ENUMERATION 7 1 move-boat +SOAR_ID 8 +INTEGER_RANGE 9 0 3 +INTEGER_RANGE 10 0 1 +SOAR_ID 11 +INTEGER_RANGE 12 1 2 +INTEGER_RANGE 13 -2147483648 2147483647 +INTEGER_RANGE 14 0 3 +INTEGER_RANGE 15 0 3 +ENUMERATION 16 2 cannibals missionaries +26 +0 desired 11 +0 failure 11 +0 last-operator 6 +0 left-bank 8 +0 name 3 +0 operator 4 +0 operator 6 +0 right-bank 8 +0 superstate 2 +0 top-state 0 +0 type 1 +4 name 5 +6 bank 8 +6 boat 13 +6 cannibals 14 +6 missionaries 9 +6 name 7 +6 number 15 +6 type 16 +6 types 12 +8 boat 10 +8 cannibals 9 +8 missionaries 9 +8 other-bank 8 +11 left-bank 8 +11 right-bank 8 diff --git a/soar-8.5.2/demos/mac/mac-planning/mac_source.soar b/soar-8.5.2/demos/mac/mac-planning/mac_source.soar new file mode 100644 index 0000000..daf964c --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/mac_source.soar @@ -0,0 +1,10 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source initialize.soar +source move-boat.soar diff --git a/soar-8.5.2/demos/mac/mac-planning/move-boat.soar b/soar-8.5.2/demos/mac/mac-planning/move-boat.soar new file mode 100644 index 0000000..2619939 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac-planning/move-boat.soar @@ -0,0 +1,64 @@ + +sp {mac*propose*operator*move-boat1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^<< right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 0 + ^boat 1) +--> + ( ^operator +) + ( ^name move-boat + ^bank + ^ 1 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-boat2 + "Moves two missionaries or two cannibals." + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 1 + ^boat 1) +--> + ( ^operator +) + ( ^name move-boat + ^bank + ^ 2 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-boat11 + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^missionaries > 0 + ^cannibals > 0 + ^boat 1) +--> + ( ^operator +) + ( ^name move-boat + ^bank + ^missionaries 1 + ^cannibals 1 + ^boat 1 + ^types 2)} + +### +### move-boat OPERATOR IMPLEMENTATION +### + +sp {apply*move-boat + (state ^operator ) + ( ^name move-boat + ^{ << missionaries cannibals boat >> } + ^bank + ^types ) + ( ^ + ^other-bank ) + ( ^ ) +--> + ( ^ - + (- )) + ( ^ - + (+ ))} + + diff --git a/soar-8.5.2/demos/mac/mac.soar b/soar-8.5.2/demos/mac/mac.soar new file mode 100644 index 0000000..7a68a61 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac.soar @@ -0,0 +1,3 @@ +pushd mac +source mac_source.soar +popd diff --git a/soar-8.5.2/demos/mac/mac.vsa b/soar-8.5.2/demos/mac/mac.vsa new file mode 100644 index 0000000..875363b --- /dev/null +++ b/soar-8.5.2/demos/mac/mac.vsa @@ -0,0 +1,14 @@ +VERSION 4 +\mac\mac.dm +0 ROOT mac mac 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR goal-test goal-test.soar 5 +5 3 FOPERATOR monitor monitor.soar 6 +6 3 FOPERATOR search-control search-control.soar 7 +7 3 FOPERATOR top-state top-state.soar 8 +8 0 FOPERATOR _readme _readme.soar 9 +9 0 OPERATOR initialize-mac initialize-mac.soar 10 +10 0 OPERATOR move-boat move-boat.soar 11 +END diff --git a/soar-8.5.2/demos/mac/mac/_firstload.soar b/soar-8.5.2/demos/mac/mac/_firstload.soar new file mode 100644 index 0000000..f0f6ad4 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/_firstload.soar @@ -0,0 +1 @@ +learn -off \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac/_readme.soar b/soar-8.5.2/demos/mac/mac/_readme.soar new file mode 100644 index 0000000..7eaa84e --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/_readme.soar @@ -0,0 +1,21 @@ +### ABSTRACT. +### This file provides a Soar system to solve the missionaries and +### cannibals problem. +### +### PROBLEM STATEMENT +### Three missionaries and three cannibals come to a river. There is a a +### boat on their bank of the river that can be used by either one or +### two persons at a time. This boat must be used to cross the river in +### such a way that cannibals never outnumber missionaries on either +### bank of the river. +### + +### DESCRIPTION. +### Simple state representation where the state has two objects: one for +### each bank of the river. Each of these has augmentations for +### missionaries, cannibals, and the boat; with their values being the +### number of the entity type on that bank of the river. This is the +### version covered in Soar 8 Tutorial. Copying the states is more +### complex (two-level-attributes) than other versions, but initial +### state definition, operator proposal and application are simplier. +### diff --git a/soar-8.5.2/demos/mac/mac/all/all_source.soar b/soar-8.5.2/demos/mac/mac/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac/comment.dm b/soar-8.5.2/demos/mac/mac/comment.dm new file mode 100644 index 0000000..22e33ef --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/comment.dm @@ -0,0 +1,26 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/mac/mac/elaborations/elaborations_source.soar b/soar-8.5.2/demos/mac/mac/elaborations/elaborations_source.soar new file mode 100644 index 0000000..13f4262 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source goal-test.soar +source monitor.soar +source search-control.soar +source top-state.soar diff --git a/soar-8.5.2/demos/mac/mac/elaborations/goal-test.soar b/soar-8.5.2/demos/mac/mac/elaborations/goal-test.soar new file mode 100644 index 0000000..46c3d0d --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/elaborations/goal-test.soar @@ -0,0 +1,29 @@ + +### +### STATE SUCCESS/GOAL DETECTION +### + +sp {mac*detect*state*success + (state ^desired + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + ( ^missionaries + ^cannibals ) +--> + (write (crlf) |The problem has been solved.|) + (halt)} + +### +### STATE FAILURE DETECTION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^<< right-bank left-bank >> ) + ( ^missionaries { > 0 } + ^cannibals > ) +--> + (write (crlf) |Failure State.|) + ( ^failure )} diff --git a/soar-8.5.2/demos/mac/mac/elaborations/monitor.soar b/soar-8.5.2/demos/mac/mac/elaborations/monitor.soar new file mode 100644 index 0000000..c7e1d47 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/elaborations/monitor.soar @@ -0,0 +1,39 @@ + +### +### move-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-boat + (state ^operator ) + ( ^name move-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} diff --git a/soar-8.5.2/demos/mac/mac/elaborations/search-control.soar b/soar-8.5.2/demos/mac/mac/elaborations/search-control.soar new file mode 100644 index 0000000..1197f06 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/elaborations/search-control.soar @@ -0,0 +1,49 @@ + +## If failure, undo last opertor + +sp {mac*select*operator*prefer*inverse*failure*types*1 + (state ^name mac + ^operator + + ^failure + ^last-operator ) + ( ^name move-boat + ^ + ^types 1) + ( ^types 1 + ^type + ^number ) +--> + ( ^operator >)} + +sp {mac*select*operator*prefer*inverse*failure*types*2 + (state ^name mac + ^operator + + ^failure + ^last-operator.types 2) + ( ^types 2) +--> + ( ^operator >)} + +## If not failure, avoid last operator + +sp {mac*select*operator*avoid*inverse*not*failure*1 + (state ^name mac + ^operator + + -^failure + ^last-operator ) + ( ^types 1 + ^ ) + ( ^types 1 + ^type + ^number ) +--> + ( ^operator < )} + +sp {mac*select*operator*avoid*inverse*not*failure*2 + (state ^name mac + ^operator + + -^failure + ^last-operator.types 2) + ( ^types 2) +--> + ( ^operator < )} diff --git a/soar-8.5.2/demos/mac/mac/elaborations/top-state.soar b/soar-8.5.2/demos/mac/mac/elaborations/top-state.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/mac/mac/initialize-mac.soar b/soar-8.5.2/demos/mac/mac/initialize-mac.soar new file mode 100644 index 0000000..c008224 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/initialize-mac.soar @@ -0,0 +1,28 @@ +sp {mac*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator + =) + ( ^name initialize-mac) +} + +sp {mac*apply*initialize + (state ^operator.name initialize-mac) +--> + ( ^name mac + ^left-bank + ^right-bank + ^desired ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^right-bank
                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) +} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac/initialize.soar b/soar-8.5.2/demos/mac/mac/initialize.soar new file mode 100644 index 0000000..1329486 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/initialize.soar @@ -0,0 +1,28 @@ +sp {mac*propose*initialize + (state ^name mac + -^left-bank) +--> + ( ^operator + =) + ( ^name initialize) +} + +sp {mac*apply*initialize + (state ^operator.name initialize) +--> + ( ^name mac + ^left-bank + ^right-bank + ^desired ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^right-bank
                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) +} \ No newline at end of file diff --git a/soar-8.5.2/demos/mac/mac/mac.dm b/soar-8.5.2/demos/mac/mac/mac.dm new file mode 100644 index 0000000..0c45caf --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/mac.dm @@ -0,0 +1,45 @@ +17 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 mac +SOAR_ID 4 +ENUMERATION 5 1 initialize-mac +SOAR_ID 6 +ENUMERATION 7 1 move-boat +SOAR_ID 8 +INTEGER_RANGE 9 0 3 +INTEGER_RANGE 10 0 1 +SOAR_ID 11 +INTEGER_RANGE 12 1 2 +INTEGER_RANGE 13 -2147483648 2147483647 +INTEGER_RANGE 14 0 3 +INTEGER_RANGE 15 0 3 +ENUMERATION 16 2 cannibals missionaries +26 +0 desired 11 +0 failure 11 +0 last-operator 6 +0 left-bank 8 +0 name 3 +0 operator 4 +0 operator 6 +0 right-bank 8 +0 superstate 2 +0 top-state 0 +0 type 1 +4 name 5 +6 bank 8 +6 boat 13 +6 cannibals 14 +6 missionaries 9 +6 name 7 +6 number 15 +6 type 16 +6 types 12 +8 boat 10 +8 cannibals 9 +8 missionaries 9 +8 other-bank 8 +11 left-bank 8 +11 right-bank 8 diff --git a/soar-8.5.2/demos/mac/mac/mac_source.soar b/soar-8.5.2/demos/mac/mac/mac_source.soar new file mode 100644 index 0000000..f24852a --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/mac_source.soar @@ -0,0 +1,10 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source initialize-mac.soar +source move-boat.soar diff --git a/soar-8.5.2/demos/mac/mac/move-boat.soar b/soar-8.5.2/demos/mac/mac/move-boat.soar new file mode 100644 index 0000000..bd90f45 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac/move-boat.soar @@ -0,0 +1,102 @@ + +sp {mac*propose*operator*move-boat1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^<< right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 0 + ^boat 1) +--> + ( ^operator + =) + ( ^name move-boat + ^bank + ^ 1 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-boat2 + "Moves two missionaries or two cannibals." + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 1 + ^boat 1) +--> + ( ^operator + =) + ( ^name move-boat + ^bank + ^ 2 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-boat11 + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^missionaries > 0 + ^cannibals > 0 + ^boat 1) +--> + ( ^operator + =) + ( ^name move-boat + ^bank + ^missionaries 1 + ^cannibals 1 + ^boat 1 + ^types 2)} + +### +### move-boat OPERATOR IMPLEMENTATION +### + +sp {apply*move-boat + (state ^operator ) + ( ^name move-boat + ^{ << missionaries cannibals boat >> } + ^bank ) + ( ^ + ^other-bank ) + ( ^ ) +--> + ( ^ - + (- )) + ( ^ - + (+ ))} + + +### +### SEARCH CONTROL +### + + +sp {mac*apply*move-boat*record*last-operator*types*1 + (state ^name mac + ^operator ) + ( ^name move-boat + ^bank + ^{ << missionaries cannibals >> } + ^types 1) + --> + ( ^last-operator ) + ( ^types 1 + ^bank + ^type + ^number )} + +sp {mac*apply*move-boat*record*last-operator*types*2 + (state ^name mac + ^operator ) + ( ^name move-boat + ^boat + ^types 2) + --> + ( ^last-operator ) + ( ^types 2 + ^bank )} + +sp {mac*apply*move-boat*remove*old*last-operator + (state ^name mac + ^operator + ^.other-bank + ^last-operator ) + ( ^bank ) + --> + ( ^last-operator -)} + diff --git a/soar-8.5.2/demos/mac/mac1-planning-numeric.soar b/soar-8.5.2/demos/mac/mac1-planning-numeric.soar new file mode 100644 index 0000000..08be448 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1-planning-numeric.soar @@ -0,0 +1,261 @@ +### +### FILE : mac1.soar +### +### +### AUTHOR : John Laird +### +### Last Modified: : September 16, 1999 +### +### ABSTRACT. +### This file provides a Soar system to solve the missionaries and +### cannibals problem. +### +### PROBLEM STATEMENT +### Three missionaries and three cannibals come to a river. There is a a +### boat on their bank of the river that can be used by either one or +### two persons at a time. This boat must be used to cross the river in +### such a way that cannibals never outnumber missionaries on either +### bank of the river. +### + +### DESCRIPTION. +### Simple state representation where the state has two objects: one for +### each bank of the river. Each of these has augmentations for +### missionaries, cannibals, and the boat; with their values being the +### number of the entity type on that bank of the river. This is the +### version covered in Soar 8 Tutorial. Copying the states is more +### complex (two-level-attributes) than other versions, but initial +### state definition, operator proposal and application is simplier. +### + + +learn -on +pushd ../default +source simple.soar +source selection.soar +popd + +### +### MISSIONARIES-AND-CANNIBALS NAME +### + +sp {top-state*elaborate*missionaries-and-cannibals + (state ^superstate nil) + --> + ( ^name mac)} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE +### + +sp {mac*elaborate*problem-space + (state ^name mac) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals + ^default-state-copy yes + ^two-level-attributes right-bank left-bank)} + +### +### MISSIONARIES-AND-CANNIBALS INITIAL-STATE +### + +sp {mac*elaborate*initial-state + (state ^superstate nil) + --> + ( ^right-bank + ^left-bank + ^desired ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^right-bank

                                                                                                                        + ^better higher) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) + } + +### +### MISSIONARIES-AND-CANNIBALS OPERATORS: +### + +sp {mac*propose*operator*move-mac-boat1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^<< right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 0 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^ 1 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat2 + "Moves two missionaries or two cannibals." + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 1 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^ 2 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat11 + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^missionaries > 0 + ^cannibals > 0 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^missionaries 1 + ^cannibals 1 + ^boat 1 + ^types 2)} + +### +### MOVE OPERATOR IMPLEMENTATION +### + +sp {apply*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << missionaries cannibals boat >> } + ^bank + ^types ) + ( ^ + ^other-bank ) + ( ^ ) + --> + ( ^ - + (- )) + ( ^ - + (+ ))} + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### +### STATE SUCCESS/GOAL DETECTION +### + +sp {mac*detect*state*success + (state ^desired + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + ( ^missionaries + ^cannibals ) + --> + ( ^success ) + (write (crlf) |Success!|)} + +### +### STATE FAILURE DETECTION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^<< right-bank left-bank >> ) + ( ^missionaries { > 0 } + ^cannibals > ) + --> + (write (crlf) |Failure!|) + ( ^failure )} + +### +### DUPLICATE STATE DETECTION +### + +sp {mac*evaluate*state*failure*duplicate + (state ^desired + ^right-bank + ^left-bank ) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + (state { <> } + ^right-bank + ^left-bank + ^tried-tied-operator) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + -(state ^superstate ) + --> + (write (crlf) |Duplicate State Detected.|) + ( ^failure )} + +## Numeric Evaluation + +sp {mac*evaluate*state*number + (state ^desired + ^tried-tied-operator + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + --> + ( ^numeric-value (+ )) + (write (crlf) |Evaluation: | (+ ))} + +####### + +sp {monitor*move-mac-boat*evaluation + (state ^operator ) + ( ^name evaluate-operator + ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Evaluate move | | | )} diff --git a/soar-8.5.2/demos/mac/mac1-planning-numeric.tcl b/soar-8.5.2/demos/mac/mac1-planning-numeric.tcl new file mode 100644 index 0000000..9e28160 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1-planning-numeric.tcl @@ -0,0 +1,424 @@ +# +# Missionaries and Cannibals Demonstration +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the Missionaries and Cannibals Demonstration. +# +# last update: 6.9.00 Acar Altinsel +# + +package require Soar + +set boatsent 0 + +proc releaseboat {} { + global boatsent + set boatsent 0 +} + +proc sendboat {bank passenger num numtypes ml cl mr cr} { + global boatsent + if {$boatsent == 0} { + if {$numtypes == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] [expr $cl - 1] $mr $cr 0 + animate 1 1 l + + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] [expr $cr - 1] 0 + animate 1 1 r + } + } + if {$numtypes == 1} { + if {$passenger == "missionaries"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] $cl $mr $cr 0 + animate 1 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] $cr 0 + animate 1 0 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 2] $cl $mr $cr 0 + animate 2 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 2] $cr 0 + animate 2 0 r + } + } + } + + if {$passenger == "cannibals"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 1] $mr $cr 0 + animate 0 1 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 1] 0 + animate 0 1 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 2] $mr $cr 0 + animate 0 2 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 2] 0 + animate 0 2 r + } + } + } + } + } + set boatsent 1 +} + +proc animate {m c b} { + + set i 0 + if {$b == "l"} { + if {$m == 2} { + .mac.frame.can create image 200 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 230 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 203 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 243 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 216 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 202 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 242 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 224 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + } + } + if {$b == "r"} { + if {$m == 2} { + .mac.frame.can create image 420 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 450 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 423 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 463 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 436 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 422 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 462 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 443 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + } + } +} + + + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Missionaries and Cannibals Demonstration" + wm iconname $w "Missionaries and Cannibals" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Missionaries and Cannibals Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; drawstate 3 3 0 0 l" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + drawstate 3 3 0 0 l +} + +proc dismiss {w} { + stop-soar + excise -all + #init-soar + destroy $w +} + + +#----------------------------------------------------------------------- +# The test.tcl stuff... +# + +proc drawstate {ml cl mr cr b} { +global soar_library + +catch {destroy .mac.frame.can} +canvas .mac.frame.can -width 640 -height 480 -background white +pack .mac.frame.can + +image create photo land -file "[file join $soar_library .. demos mac land.gif]" +.mac.frame.can create image 0 0 -image land -anchor nw + +image create photo cannibal -file "[file join $soar_library .. demos mac cannibal.gif]" +image create photo missionary -file "[file join $soar_library .. demos mac missionary.gif]" +image create photo boat -file "[file join $soar_library .. demos mac boat.gif]" + + +if {$ml >= 1} { + .mac.frame.can create image 90 375 -image missionary -tag move_m1 +} +if {$ml >= 2} { + .mac.frame.can create image 60 375 -image missionary -tag move_m2 +} +if {$ml >= 3} { + .mac.frame.can create image 30 375 -image missionary -tag move_m3 +} + +if {$cl >= 1} { + .mac.frame.can create image 170 310 -image cannibal -tag move_c1 +} +if {$cl >= 2} { + .mac.frame.can create image 130 310 -image cannibal -tag move_c2 +} +if {$cl >= 3} { + .mac.frame.can create image 90 310 -image cannibal -tag move_c3 +} + +if {$b == "l"} { + .mac.frame.can create image 200 365 -image boat -tag move_b +} + + +if {$mr >= 1} { + .mac.frame.can create image 540 375 -image missionary -tag move_m1 +} +if {$mr >= 2} { + .mac.frame.can create image 570 375 -image missionary -tag move_m2 +} +if {$mr >= 3} { + .mac.frame.can create image 600 375 -image missionary -tag move_m3 +} + +if {$cr >= 1} { + .mac.frame.can create image 490 310 -image cannibal -tag move_c1 +} +if {$cr >= 2} { + .mac.frame.can create image 530 310 -image cannibal -tag move_c2 +} +if {$cr >= 3} { + .mac.frame.can create image 570 310 -image cannibal -tag move_c3 +} + +if {$b == "r"} { + .mac.frame.can create image 420 365 -image boat -tag move_b +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set c1x %x + set c1y %y +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set newx %x + set newy %y + + set distx [expr $newx - $c1x] + set disty [expr $newy - $c1y] + + .mac.frame.can move move_c1 $distx $disty + + set c1x $newx + set c1y $newy +} + +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining missionaries and cannibals solution method + +global soar_library +global interp_type + +set ml 3 +set cl 3 +set bl 1 + +set mr 0 +set cr 0 +set br 0 + +excise -all +source mac1-planning-numeric.soar + +drawscreen .mac + + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals ) + ( ^missionaries + ^cannibals ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } + ^types + ^bank ) + --> + (tcl | sendboat | | | | | | | | | | | | | | | ) + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (tcl | drawstate | | | | | | | | l |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (tcl | drawstate | | | | | | | | r |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### diff --git a/soar-8.5.2/demos/mac/mac1-planning.soar b/soar-8.5.2/demos/mac/mac1-planning.soar new file mode 100644 index 0000000..3665683 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1-planning.soar @@ -0,0 +1,325 @@ +### +### FILE : mac1.soar +### +### +### AUTHOR : John Laird +### +### Last Modified: : September 16, 1999 +### +### ABSTRACT. +### This file provides a Soar system to solve the missionaries and +### cannibals problem. +### +### PROBLEM STATEMENT +### Three missionaries and three cannibals come to a river. There is a a +### boat on their bank of the river that can be used by either one or +### two persons at a time. This boat must be used to cross the river in +### such a way that cannibals never outnumber missionaries on either +### bank of the river. +### + +### DESCRIPTION. +### Simple state representation where the state has two objects: one for +### each bank of the river. Each of these has augmentations for +### missionaries, cannibals, and the boat; with their values being the +### number of the entity type on that bank of the river. This is the +### version covered in Soar 8 Tutorial. Copying the states is more +### complex (two-level-attributes) than other versions, but initial +### state definition, operator proposal and application is simplier. +### + + +learn -on +pushd ../default +source simple.soar +source selection.soar +popd + +### +### MISSIONARIES-AND-CANNIBALS NAME +### + +sp {top-state*elaborate*missionaries-and-cannibals + (state ^superstate nil) + --> + ( ^name mac)} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE +### + +sp {mac*elaborate*problem-space + (state ^name mac) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals + ^default-state-copy yes + ^two-level-attributes right-bank left-bank)} + +### +### MISSIONARIES-AND-CANNIBALS INITIAL-STATE +### + +sp {mac*elaborate*initial-state + (state ^superstate nil + ^name mac) + --> + ( ^right-bank + ^left-bank + ^desired ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^right-bank

                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) + } + +### +### MISSIONARIES-AND-CANNIBALS OPERATORS: +### + +sp {mac*propose*operator*move-mac-boat1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^<< right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 0 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^ 1 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat2 + "Moves two missionaries or two cannibals." + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 1 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^ 2 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat11 + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^missionaries > 0 + ^cannibals > 0 + ^boat 1) + --> + ( ^operator ) + ( ^name move-mac-boat + ^bank + ^missionaries 1 + ^cannibals 1 + ^boat 1 + ^types 2)} + +### +### MOVE OPERATOR IMPLEMENTATION +### + +sp {apply*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << missionaries cannibals boat >> } + ^bank + ^types ) + ( ^ + ^other-bank ) + ( ^ ) + --> + ( ^ - + (- )) + ( ^ - + (+ ))} + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### +### STATE SUCCESS/GOAL DETECTION +### + +sp {mac*detect*state*success + (state ^desired + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + ( ^missionaries + ^cannibals ) + --> + ( ^success ) + (write (crlf) |Success!|)} + +### +### STATE FAILURE DETECTION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^<< right-bank left-bank >> ) + ( ^missionaries { > 0 } + ^cannibals > ) + --> + (write (crlf) |Failure!|) + ( ^failure )} + +sp {mac*evaluate*state*failure*state-no-change + (state ^desired + ^problem-space.name missionaries-and-cannibals) + (state ^superstate + ^attribute state + ^quiescence t + ^impasse no-change) +--> + (write (crlf) |######## STATE NO-CHANGE Failure! #########|) + ( ^failure )} + +### +### DUPLICATE STATE DETECTION +### + +sp {mac*evaluate*state*failure*duplicate + (state ^desired + ^right-bank + ^left-bank ) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + (state { <> } + ^right-bank + ^left-bank + ^tried-tied-operator) + ( ^missionaries ^cannibals ^boat ) + ( ^missionaries ^cannibals ^boat ) + -(state ^superstate ) + --> + (write (crlf) |Duplicate State Detected.|) + ( ^failure )} + +### +### SEARCH CONTROL +### Commented out because not required with look-ahead + +#sp {mac*apply*move-mac-boat*record*last-operator*types*1 +# (state ^name mac +# ^operator ) +# ( ^name move-mac-boat +# ^bank +# ^{ << missionaries cannibals >> } +# ^types 1) +# --> +# ( ^last-operator ) +# ( ^types 1 +# ^bank +# ^type +# ^number )} + +#sp {mac*apply*move-mac-boat*record*last-operator*types*2 +# (state ^name mac +# ^operator ) +# ( ^name move-mac-boat +# ^boat +# ^types 2) +# --> +# ( ^last-operator ) +# ( ^types 2 +# ^bank )} + +#sp {mac*apply*move-mac-boat*remove*old*last-operator +# (state ^name mac +# ^operator +# ^.other-bank +# ^last-operator ) +# ( ^bank ) +# --> +# ( ^last-operator -)} + +### If not failure, avoid last operator + +#sp {mac*select*operator*avoid*inverse*not*failure*1 +# (state ^name mac +# ^operator + +# -^failure +# ^last-operator ) +# ( ^types 1 +# ^ ) +# ( ^types 1 +# ^type +# ^number ) +# --> +# ( ^operator -)} + +#sp {mac*select*operator*avoid*inverse*not*failure*2 +# (state ^name mac +# ^operator + +# -^failure +# ^last-operator.types 2) +# ( ^types 2) +# --> +# ( ^operator -)} + + + + +####### + + +sp {monitor*move-mac-boat*evaluation + (state ^operator ) + ( ^name evaluate-operator + ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Evaluate move | | | )} diff --git a/soar-8.5.2/demos/mac/mac1-planning.tcl b/soar-8.5.2/demos/mac/mac1-planning.tcl new file mode 100644 index 0000000..cf6343f --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1-planning.tcl @@ -0,0 +1,423 @@ +# +# Missionaries and Cannibals Demonstration +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the Missionaries and Cannibals Demonstration. +# +# last update: 6.9.00 Acar Altinsel +# + +package require Soar + +set boatsent 0 + +proc releaseboat {} { + global boatsent + set boatsent 0 +} + +proc sendboat {bank passenger num numtypes ml cl mr cr} { + global boatsent + if {$boatsent == 0} { + if {$numtypes == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] [expr $cl - 1] $mr $cr 0 + animate 1 1 l + + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] [expr $cr - 1] 0 + animate 1 1 r + } + } + if {$numtypes == 1} { + if {$passenger == "missionaries"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] $cl $mr $cr 0 + animate 1 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] $cr 0 + animate 1 0 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 2] $cl $mr $cr 0 + animate 2 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 2] $cr 0 + animate 2 0 r + } + } + } + + if {$passenger == "cannibals"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 1] $mr $cr 0 + animate 0 1 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 1] 0 + animate 0 1 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 2] $mr $cr 0 + animate 0 2 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 2] 0 + animate 0 2 r + } + } + } + } + } + set boatsent 1 +} + +proc animate {m c b} { + + set i 0 + if {$b == "l"} { + if {$m == 2} { + .mac.frame.can create image 200 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 230 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 203 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 243 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 216 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 202 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 242 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 224 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + } + } + if {$b == "r"} { + if {$m == 2} { + .mac.frame.can create image 420 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 450 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 423 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 463 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 436 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 422 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 462 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 443 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + } + } +} + + + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Missionaries and Cannibals Demonstration" + wm iconname $w "Missionaries and Cannibals" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Missionaries and Cannibals Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; drawstate 3 3 0 0 l" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + drawstate 3 3 0 0 l +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + + +#----------------------------------------------------------------------- +# The test.tcl stuff... +# + +proc drawstate {ml cl mr cr b} { + global soar_library + +catch {destroy .mac.frame.can} +canvas .mac.frame.can -width 640 -height 480 -background white +pack .mac.frame.can + +image create photo land -file "[file join $soar_library .. demos mac land.gif]" +.mac.frame.can create image 0 0 -image land -anchor nw + +image create photo cannibal -file "[file join $soar_library .. demos mac cannibal.gif]" +image create photo missionary -file "[file join $soar_library .. demos mac missionary.gif]" +image create photo boat -file "[file join $soar_library .. demos mac boat.gif]" + + +if {$ml >= 1} { + .mac.frame.can create image 90 375 -image missionary -tag move_m1 +} +if {$ml >= 2} { + .mac.frame.can create image 60 375 -image missionary -tag move_m2 +} +if {$ml >= 3} { + .mac.frame.can create image 30 375 -image missionary -tag move_m3 +} + +if {$cl >= 1} { + .mac.frame.can create image 170 310 -image cannibal -tag move_c1 +} +if {$cl >= 2} { + .mac.frame.can create image 130 310 -image cannibal -tag move_c2 +} +if {$cl >= 3} { + .mac.frame.can create image 90 310 -image cannibal -tag move_c3 +} + +if {$b == "l"} { + .mac.frame.can create image 200 365 -image boat -tag move_b +} + + +if {$mr >= 1} { + .mac.frame.can create image 540 375 -image missionary -tag move_m1 +} +if {$mr >= 2} { + .mac.frame.can create image 570 375 -image missionary -tag move_m2 +} +if {$mr >= 3} { + .mac.frame.can create image 600 375 -image missionary -tag move_m3 +} + +if {$cr >= 1} { + .mac.frame.can create image 490 310 -image cannibal -tag move_c1 +} +if {$cr >= 2} { + .mac.frame.can create image 530 310 -image cannibal -tag move_c2 +} +if {$cr >= 3} { + .mac.frame.can create image 570 310 -image cannibal -tag move_c3 +} + +if {$b == "r"} { + .mac.frame.can create image 420 365 -image boat -tag move_b +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set c1x %x + set c1y %y +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set newx %x + set newy %y + + set distx [expr $newx - $c1x] + set disty [expr $newy - $c1y] + + .mac.frame.can move move_c1 $distx $disty + + set c1x $newx + set c1y $newy +} + +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining missionaries and cannibals solution method + +global soar_library +global interp_type + +set ml 3 +set cl 3 +set bl 1 + +set mr 0 +set cr 0 +set br 0 + +excise -all +source mac1-planning.soar + +drawscreen .mac + + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals ) + ( ^missionaries + ^cannibals ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } + ^types + ^bank ) + --> + (tcl | sendboat | | | | | | | | | | | | | | | ) + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (tcl | drawstate | | | | | | | | l |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (tcl | drawstate | | | | | | | | r |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### diff --git a/soar-8.5.2/demos/mac/mac1.soar b/soar-8.5.2/demos/mac/mac1.soar new file mode 100644 index 0000000..aa361d2 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1.soar @@ -0,0 +1,280 @@ +### +### FILE : mac1.soar +### +### +### AUTHOR : John Laird +### +### Last Modified: : September 17, 1999 +### +### ABSTRACT. +### This file provides a Soar system to solve the missionaries and +### cannibals problem. +### +### PROBLEM STATEMENT +### Three missionaries and three cannibals come to a river. There is a a +### boat on their bank of the river that can be used by either one or +### two persons at a time. This boat must be used to cross the river in +### such a way that cannibals never outnumber missionaries on either +### bank of the river. +### + +### DESCRIPTION. +### Simple state representation where the state has two objects: one for +### each bank of the river. Each of these has augmentations for +### missionaries, cannibals, and the boat; with their values being the +### number of the entity type on that bank of the river. This is the +### version covered in Soar 8 Tutorial. Copying the states is more +### complex (two-level-attributes) than other versions, but initial +### state definition, operator proposal and application are simplier. +### + + +#learn -off + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### INITIAL-STATE +### + +sp {mac*elaborate*initial*desired-state + (state ^superstate nil) + --> + ( ^name mac + ^left-bank + ^right-bank + ^desired ) + ( ^missionaries 3 + ^cannibals 3 + ^boat 1 + ^other-bank ) + ( ^missionaries 0 + ^cannibals 0 + ^boat 0 + ^other-bank ) + ( ^right-bank
                                                                                                                        ) + (
                                                                                                                        ^missionaries 3 + ^cannibals 3 + ^boat 1) + } + +### +### PROPOSE MISSIONARIES-AND-CANNIBALS OPERATORS: +### MOVE-MAC-BOAT +### + +sp {mac*propose*operator*move-mac-boat1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^<< right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 0 + ^boat 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^bank + ^ 1 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat2 + "Moves two missionaries or two cannibals." + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^{ << cannibals missionaries >> } > 1 + ^boat 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^bank + ^ 2 + ^boat 1 + ^types 1)} + +sp {mac*propose*operator*move-mac-boat11 + (state ^name mac + ^ << right-bank left-bank >> ) + ( ^missionaries > 0 + ^cannibals > 0 + ^boat 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^bank + ^missionaries 1 + ^cannibals 1 + ^boat 1 + ^types 2)} + +### +### MOVE-MAC-BOAT OPERATOR IMPLEMENTATION +### + +sp {apply*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << missionaries cannibals boat >> } + ^bank ) + ( ^ + ^other-bank ) + ( ^ ) + --> + ( ^ - + (- )) + ( ^ - + (+ ))} + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### +### STATE SUCCESS/GOAL DETECTION +### + +sp {mac*detect*state*success + (state ^desired + ^ ) + ( ^missionaries + ^cannibals ) + ( ^{ << right-bank left-bank >> } ) + ( ^missionaries + ^cannibals ) + --> + (write (crlf) |The problem has been solved.|) + (halt)} + +### +### STATE FAILURE DETECTION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^<< right-bank left-bank >> ) + ( ^missionaries { > 0 } + ^cannibals > ) + --> + (write (crlf) |Failure State.|) + ( ^failure )} + +### +### SEARCH CONTROL +### + + +sp {mac*apply*move-mac-boat*record*last-operator*types*1 + (state ^name mac + ^operator ) + ( ^name move-mac-boat + ^bank + ^{ << missionaries cannibals >> } + ^types 1) + --> + ( ^last-operator ) + ( ^types 1 + ^bank + ^type + ^number )} + +sp {mac*apply*move-mac-boat*record*last-operator*types*2 + (state ^name mac + ^operator ) + ( ^name move-mac-boat + ^boat + ^types 2) + --> + ( ^last-operator ) + ( ^types 2 + ^bank )} + +sp {mac*apply*move-mac-boat*remove*old*last-operator + (state ^name mac + ^operator + ^.other-bank + ^last-operator ) + ( ^bank ) + --> + ( ^last-operator -)} + +## If failure, undo last opertor + +sp {mac*select*operator*prefer*inverse*failure*types*1 + (state ^name mac + ^operator + + ^failure + ^last-operator ) + ( ^name move-mac-boat + ^ + ^types 1) + ( ^types 1 + ^type + ^number ) + --> + ( ^operator >)} + +sp {mac*select*operator*prefer*inverse*failure*types*2 + (state ^name mac + ^operator + + ^failure + ^last-operator.types 2) + ( ^types 2) + --> + ( ^operator >)} + +## If not failure, avoid last operator + +sp {mac*select*operator*avoid*inverse*not*failure*1 + (state ^name mac + ^operator + + -^failure + ^last-operator ) + ( ^types 1 + ^ ) + ( ^types 1 + ^type + ^number ) + --> + ( ^operator < )} + +sp {mac*select*operator*avoid*inverse*not*failure*2 + (state ^name mac + ^operator + + -^failure + ^last-operator.types 2) + ( ^types 2) + --> + ( ^operator < )} diff --git a/soar-8.5.2/demos/mac/mac1.tcl b/soar-8.5.2/demos/mac/mac1.tcl new file mode 100644 index 0000000..16a0772 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac1.tcl @@ -0,0 +1,377 @@ +# +# Missionaries and Cannibals Demonstration +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the Missionaries and Cannibals Demonstration. +# +# last update: 6.15.00 Acar Altinsel +# + +package require Soar + +set boatsent 0 + +proc releaseboat {} { + global boatsent + set boatsent 0 +} + +proc sendboat {bank passenger num numtypes ml cl mr cr} { + global noanim + global boatsent + if {$boatsent == 0} { + if {$numtypes == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] [expr $cl - 1] $mr $cr 0 + if { $noanim == 0 } { + animate 1 1 l + } + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] [expr $cr - 1] 0 + if { $noanim == 0 } { + animate 1 1 r + } + } + } + if {$numtypes == 1} { + if {$passenger == "missionaries"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] $cl $mr $cr 0 + if { $noanim == 0 } { + animate 1 0 l + } + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] $cr 0 + if { $noanim == 0 } { + animate 1 0 r + } + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 2] $cl $mr $cr 0 + if { $noanim == 0 } { + animate 2 0 l + } + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 2] $cr 0 + if { $noanim == 0 } { + animate 2 0 r + } + } + } + } + + if {$passenger == "cannibals"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 1] $mr $cr 0 + if { $noanim == 0 } { + animate 0 1 l + } + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 1] 0 + if { $noanim == 0 } { + animate 0 1 r + } + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 2] $mr $cr 0 + if { $noanim == 0 } { + animate 0 2 l + } + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 2] 0 + if { $noanim == 0 } { + animate 0 2 r + } + } + } + } + } + } + set boatsent 1 +} + +proc animate {m c b} { + + + if {$b == "l"} { + if {$m == 2} { + .mac.frame.can create image 200 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 230 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + move r + } + if {$c == 2} { + .mac.frame.can create image 203 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 243 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + move r + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 216 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + move r + } + if {$c == 1} { + .mac.frame.can create image 202 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 242 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + move r + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 224 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + move r + } + } + } + if {$b == "r"} { + if {$m == 2} { + .mac.frame.can create image 420 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 450 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + move l + } + if {$c == 2} { + .mac.frame.can create image 423 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 463 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + move l + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 436 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + move l + } + if {$c == 1} { + .mac.frame.can create image 422 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 462 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + move l + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 443 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + move l + + } + } + } +} + +proc move { sign } { + set i 0 + while {$i < 220} { + set i [expr $i + 2] + set j 0 + after 1 set j 1 + vwait j + if { $sign == "l"} { + .mac.frame.can move onboat -2 0 + } + if { $sign == "r" } { + .mac.frame.can move onboat 2 0 + } + } +} + + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + global noanim + + wm title $w "Missionaries and Cannibals Demonstration" + wm iconname $w "Missionaries and Cannibals" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Missionaries and Cannibals Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; drawstate 3 3 0 0 l" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + checkbutton $w.speed -text "No Animation" -variable noanim + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch $w.speed -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + drawstate 3 3 0 0 l +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + + +#----------------------------------------------------------------------- +# The test.tcl stuff... +# + +proc drawstate {ml cl mr cr b} { + global soar_library + + catch {destroy .mac.frame.can} + canvas .mac.frame.can -width 640 -height 480 -background white + pack .mac.frame.can + + image create photo land -file "[file join $soar_library .. demos mac land.gif]" + .mac.frame.can create image 0 0 -image land -anchor nw + + image create photo cannibal -file "[file join $soar_library .. demos mac cannibal.gif]" + image create photo missionary -file "[file join $soar_library .. demos mac missionary.gif]" + image create photo boat -file "[file join $soar_library .. demos mac boat.gif]" + + + if {$ml >= 1} { + .mac.frame.can create image 90 375 -image missionary + } + if {$ml >= 2} { + .mac.frame.can create image 60 375 -image missionary + } + if {$ml >= 3} { + .mac.frame.can create image 30 375 -image missionary + } + + if {$cl >= 1} { + .mac.frame.can create image 170 310 -image cannibal + } + if {$cl >= 2} { + .mac.frame.can create image 130 310 -image cannibal + } + if {$cl >= 3} { + .mac.frame.can create image 90 310 -image cannibal + } + + if {$b == "l"} { + .mac.frame.can create image 200 365 -image boat + } + + + if {$mr >= 1} { + .mac.frame.can create image 540 375 -image missionary + } + if {$mr >= 2} { + .mac.frame.can create image 570 375 -image missionary + } + if {$mr >= 3} { + .mac.frame.can create image 600 375 -image missionary + } + + if {$cr >= 1} { + .mac.frame.can create image 490 310 -image cannibal + } + if {$cr >= 2} { + .mac.frame.can create image 530 310 -image cannibal + } + if {$cr >= 3} { + .mac.frame.can create image 570 310 -image cannibal + } + + if {$b == "r"} { + .mac.frame.can create image 420 365 -image boat + } + +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining missionaries and cannibals solution method + +global soar_library +global interp_type + +set ml 3 +set cl 3 +set bl 1 + +set mr 0 +set cr 0 +set br 0 + +excise -all +source mac1.soar + +drawscreen .mac + + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals ) + ( ^missionaries + ^cannibals ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } + ^types + ^bank ) + --> + (tcl | sendboat | | | | | | | | | | | | | | | ) + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (tcl | drawstate | | | | | | | | l |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (tcl | drawstate | | | | | | | | r |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### diff --git a/soar-8.5.2/demos/mac/mac2.soar b/soar-8.5.2/demos/mac/mac2.soar new file mode 100644 index 0000000..94ab556 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac2.soar @@ -0,0 +1,270 @@ +### +### FILE : mac2.soar +### + +### +### AUTHOR(1) : John Laird [ Soar 8.2 ] +### + +### +### CREATED(3) : Feb 2, 99 +### Modified : Aug 3, 99 +### + +### +### ABSTRACT. This file provides a Soar system to solve +### the missionaries and cannibals problem. Three missionaries and +### three cannibals come to a river. There is a a boat on their bank of +### the river that can be used by either one or two persons at a time. +### This boat must be used to cross the river in such a way that +### cannibals never outnumber missionaries on either bank of the river. +### + + +### This version has a simpler state representation than mac1.soar. +### There is only a representation of what is on the left bank and +### the right. +### Copying the states would be more complex, (two-level-attributes) +### but initial state definition, operator proposal and +### application are simplier. + +### Does not include planning and chunking. + +learn -off + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### INITIAL-STATE +### +sp {mac*elaborate*state*name + (state ^superstate nil) + --> + ( ^name mac)} + + +sp {mac*elaborate*initial-state + (state ^name mac) + --> + ( ^missionaries + ^cannibals + ^boat ) + ( ^left 1 + ^right 0) + ( ^left 3 + ^right 0) + ( ^left 3 + ^right 0) + } + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE OPERATORS: +### MOVE1, MOVE2, AND MOVE11 +### + +sp {mac*propose*move-mac-boat*1 + "Moves either a single missionary or a cannibal." + (state ^name mac + ^{ << cannibals missionaries >> }. > 0 + ^boat. 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^types 1 + ^boat 1 + ^ 1)} + +sp {mac*propose*move-mac-boat*2 + "Moves either a two missionaries or two cannibals." + (state ^name mac + ^{ << cannibals missionaries >> }. > 1 + ^boat. 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^types 1 + ^boat 1 + ^ 2)} + +sp {mac*propose*move-mac-boat*11 + (state ^name mac + ^cannibals. > 0 + ^missionaries. > 0 + ^boat. 1) + --> + ( ^operator + =) + ( ^name move-mac-boat + ^types 2 + ^boat 1 + ^missionaries 1 + ^cannibals 1)} + +### +### MOVE OPERATOR IMPLEMENTATION +### + +sp {apply*move-mac-boat + (state ^operator + ^ + ^boat ) + ( ^{ << left right >> } 1 + ^{ << left right >> } 0) + ( ^name move-mac-boat + ^{ << boat missionaries cannibals >> } ) + ( ^ + ^ ) + --> + ( ^ - + (- ) + ^ - + (+ ))} + +### +### Record last operator +### + +sp {mac*apply*move-mac-boat*record*last-operator*types*1 + (state ^name mac + ^operator + ^boat. 1) + ( ^name move-mac-boat + ^{ << missionaries cannibals >> } + ^types 1) + --> + ( ^last-operator ) + ( ^boat + ^types 1 + ^type + ^number )} + +sp {mac*apply*move-mac-boat*record*last-operator*types*2 + (state ^name mac + ^operator + ^boat. 1) + ( ^name move-mac-boat + ^types 2) + --> + ( ^last-operator ) + ( ^types 2 + ^boat )} + +sp {mac*apply*move-mac-boat*remove*old*last-operator + (state ^name mac + ^operator.name move-mac-boat + ^boat. 0 + ^last-operator ) + ( ^boat ) + --> + ( ^last-operator -)} + +## Prefer inverse of failed last operator. + +sp {mac*select*operator*inverse*failure*types*1 + (state ^name mac + ^operator + + ^failure true + ^last-operator ) + ( ^name move-mac-boat + ^ + ^types 1) + ( ^types 1 + ^type + ^number ) + --> + # (write (crlf) |Undo last move.|) + ( ^operator > )} + +sp {mac*select*operator*inverse*types*2 + (state ^name mac + ^operator + + ^failure true + ^last-operator ) + ( ^types 2) + ( ^types 2) + --> +# (write (crlf) |Undo last move.|) + ( ^operator > )} + +## Avoid inverse if no failure + +sp {mac*select*operator*inverse*not*failure*types*1 + (state ^name mac + ^operator + + -^failure true + ^last-operator ) + ( ^types 1 + ^ ) + ( ^types 1 + ^type + ^number ) + --> + ( ^operator < )} + +sp {mac*select*operator*inverse*not*failure*types*2 + (state ^name mac + ^operator + + -^failure true + ^last-operator ) + ( ^types 2) + ( ^types 2) + --> + ( ^operator < )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### STATE EVALUATION +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^name mac + ^missionaries + ^cannibals ) + ( ^ { > 0 }) + ( ^ > ) + --> + (write (crlf) |Failure State.|) + ( ^failure true)} + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + + ## This implicitly defines the desired state of the problem. + # + +sp {mac*detect*state*success + (state ^name mac + ^missionaries.right 3 + ^cannibals.right 3) + --> + (write (crlf) |Success!|) + (halt)} + +sp {monitor*move + (state ^name mac + ^operator ) + ( ^{ << missionaries cannibals >> } ) + --> + (write | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^boat.left 1 + ^missionaries.left + ^missionaries.right + ^cannibals.left + ^cannibals.right ) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^boat.right 1 + ^missionaries.left + ^missionaries.right + ^cannibals.left + ^cannibals.right ) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + diff --git a/soar-8.5.2/demos/mac/mac2.tcl b/soar-8.5.2/demos/mac/mac2.tcl new file mode 100644 index 0000000..69b9c07 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac2.tcl @@ -0,0 +1,423 @@ +# +# Missionaries and Cannibals Demonstration +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the Missionaries and Cannibals Demonstration. +# +# last update: 6.9.00 Acar Altinsel +# + +package require Soar + +set boatsent 0 + +proc releaseboat {} { + global boatsent + set boatsent 0 +} + +proc sendboat {bank passenger num numtypes ml cl mr cr} { + global boatsent + if {$boatsent == 0} { + if {$numtypes == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] [expr $cl - 1] $mr $cr 0 + animate 1 1 l + + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] [expr $cr - 1] 0 + animate 1 1 r + } + } + if {$numtypes == 1} { + if {$passenger == "missionaries"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] $cl $mr $cr 0 + animate 1 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] $cr 0 + animate 1 0 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 2] $cl $mr $cr 0 + animate 2 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 2] $cr 0 + animate 2 0 r + } + } + } + + if {$passenger == "cannibals"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 1] $mr $cr 0 + animate 0 1 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 1] 0 + animate 0 1 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 2] $mr $cr 0 + animate 0 2 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 2] 0 + animate 0 2 r + } + } + } + } + } + set boatsent 1 +} + +proc animate {m c b} { + + set i 0 + if {$b == "l"} { + if {$m == 2} { + .mac.frame.can create image 200 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 230 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 203 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 243 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 216 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 202 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 242 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 224 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + } + } + if {$b == "r"} { + if {$m == 2} { + .mac.frame.can create image 420 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 450 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 423 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 463 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 436 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 422 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 462 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 443 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + } + } +} + + + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Missionaries and Cannibals Demonstration" + wm iconname $w "Missionaries and Cannibals" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Missionaries and Cannibals Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; drawstate 3 3 0 0 l" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + drawstate 3 3 0 0 l +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + + +#----------------------------------------------------------------------- +# The test.tcl stuff... +# + +proc drawstate {ml cl mr cr b} { +global soar_library + +catch {destroy .mac.frame.can} +canvas .mac.frame.can -width 640 -height 480 -background white +pack .mac.frame.can + +image create photo land -file "[file join $soar_library .. demos mac land.gif]" +.mac.frame.can create image 0 0 -image land -anchor nw + +image create photo cannibal -file "[file join $soar_library .. demos mac cannibal.gif]" +image create photo missionary -file "[file join $soar_library .. demos mac missionary.gif]" +image create photo boat -file "[file join $soar_library .. demos mac boat.gif]" + + +if {$ml >= 1} { + .mac.frame.can create image 90 375 -image missionary -tag move_m1 +} +if {$ml >= 2} { + .mac.frame.can create image 60 375 -image missionary -tag move_m2 +} +if {$ml >= 3} { + .mac.frame.can create image 30 375 -image missionary -tag move_m3 +} + +if {$cl >= 1} { + .mac.frame.can create image 170 310 -image cannibal -tag move_c1 +} +if {$cl >= 2} { + .mac.frame.can create image 130 310 -image cannibal -tag move_c2 +} +if {$cl >= 3} { + .mac.frame.can create image 90 310 -image cannibal -tag move_c3 +} + +if {$b == "l"} { + .mac.frame.can create image 200 365 -image boat -tag move_b +} + + +if {$mr >= 1} { + .mac.frame.can create image 540 375 -image missionary -tag move_m1 +} +if {$mr >= 2} { + .mac.frame.can create image 570 375 -image missionary -tag move_m2 +} +if {$mr >= 3} { + .mac.frame.can create image 600 375 -image missionary -tag move_m3 +} + +if {$cr >= 1} { + .mac.frame.can create image 490 310 -image cannibal -tag move_c1 +} +if {$cr >= 2} { + .mac.frame.can create image 530 310 -image cannibal -tag move_c2 +} +if {$cr >= 3} { + .mac.frame.can create image 570 310 -image cannibal -tag move_c3 +} + +if {$b == "r"} { + .mac.frame.can create image 420 365 -image boat -tag move_b +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set c1x %x + set c1y %y +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set newx %x + set newy %y + + set distx [expr $newx - $c1x] + set disty [expr $newy - $c1y] + + .mac.frame.can move move_c1 $distx $disty + + set c1x $newx + set c1y $newy +} + +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining missionaries and cannibals solution method + +global soar_library +global interp_type + +set ml 3 +set cl 3 +set bl 1 + +set mr 0 +set cr 0 +set br 0 + +excise -all +source mac2.soar + +drawscreen .mac + + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals ) + ( ^missionaries + ^cannibals ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } + ^types + ^bank ) + --> + (tcl | sendboat | | | | | | | | | | | | | | | ) + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (tcl | drawstate | | | | | | | | l |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (tcl | drawstate | | | | | | | | r |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### diff --git a/soar-8.5.2/demos/mac/mac3-planning.soar b/soar-8.5.2/demos/mac/mac3-planning.soar new file mode 100644 index 0000000..f7191f0 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac3-planning.soar @@ -0,0 +1,315 @@ +### +### FILE : mac3-planning.soar +### + +### +### AUTHOR(3) : John Laird [ Soar 8.1 ] +### AUTHOR(2) : Sayan Bhattacharyya [ Soar 7.0.3 ] +### AUTHOR(1) : Aladin.Akyurek [ Soar 5.1.1 ] +### + +### +### CREATED(4) : May 27, 2004 +### CREATED(3) : Aug 22, 1996 +### CREATED(2) : May 10, 1993 +### CREATED(1) : May 21, 1991 +### + +### +### ABSTRACT. This file provides a Soar system to solve +### the missionaries and cannibals problem. Three missionaries and +### three cannibals come to a river. There is a a boat on their side of +### the river that can be used by either one or two persons at a time. +### This boat must be used to cross the river in such a way that cannibals +### never outnumber missionaries on either side of the river. +### + +### This version has a more complex state representation than mac1 and +### mac2.soar +### Copying the states is simplier (only copy the holds), +### but operator application is more complex. + +multi-attributes holds 3 + +learn -off +pushd ../default +source simple.soar +source selection.soar +popd + +### +### MISSIONARIES-AND-CANNIBALS NAME +### +sp {mac*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator + =) + ( ^name initialize-mac) +} + +sp {mac*apply*initialize + (state ^operator.name initialize-mac) +--> + ( ^name mac + ^holds

                                                                                                                        + ^boat + ^desired ) + (

                                                                                                                        ^type missionaries + ^number 3 + ^opposite

                                                                                                                        + ^side ) + (

                                                                                                                        ^type cannibals + ^number 3 + ^opposite

                                                                                                                        + ^side ) + (

                                                                                                                        ^type missionaries + ^number 0 + ^opposite

                                                                                                                        + ^side ) + (

                                                                                                                        ^type cannibals + ^number 0 + ^opposite

                                                                                                                        + ^side ) + ( ^name leftbank + ^opposite-of ) + ( ^name rightbank + ^opposite-of ) + } + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE +### + +sp {mac*elaborate*problem-space + (state ^name mac) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals + ^default-state-copy yes + ^one-level-attributes boat + ^two-level-attributes holds)} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE OPERATORS: +### MOVE1, MOVE2, AND MOVE11 +### + +sp {mac*propose*operator*move1 + "Moves either a single missionary or a cannibal." + (state ^problem-space.name missionaries-and-cannibals + ^holds

                                                                                                                        + ^boat ) + (

                                                                                                                        ^number { <> 0 } + ^side ) + --> + ( ^operator ) + ( ^name move1 + ^holds

                                                                                                                        )} + +sp {mac*propose*operator*move2 + "Moves either a single missionary or a cannibal." + (state ^problem-space.name missionaries-and-cannibals + ^holds

                                                                                                                        + ^boat ) + (

                                                                                                                        ^number > 1 + ^side ) + --> + ( ^operator ) + ( ^name move2 + ^holds

                                                                                                                        )} + +sp {mac*propose*operator*move11 + "Moves either a single missionary or a cannibal." + (state ^problem-space.name missionaries-and-cannibals + ^holds

                                                                                                                        + ^boat ) + (

                                                                                                                        ^type cannibals + ^number { <> 0} + ^side ) + (

                                                                                                                        ^type missionaries + ^number { <> 0 } + ^side ) + --> + ( ^operator ) + ( ^name move11 + ^holds

                                                                                                                        )} + +### +### MOVE OPERATOR IMPLEMENTATION +### + +sp {apply*move1 + (state ^operator ) + ( ^name << move1 move11 >> + ^holds

                                                                                                                        ) + (

                                                                                                                        ^number + ^opposite ) + ( ^number ) + --> + (

                                                                                                                        ^number - + (- 1)) + ( ^number - + (+ 1))} + +sp {apply*move2 + (state ^operator ) + ( ^name move2 + ^holds

                                                                                                                        ) + (

                                                                                                                        ^number + ^opposite

                                                                                                                        ) + (

                                                                                                                        ^number ) + --> + (

                                                                                                                        ^number - + (- 2)) + (

                                                                                                                        ^number - + (+ 2))} + +sp {apply*move-boat + (state ^operator + ^boat ) + ( ^name << move1 move2 move11 >> + ^holds.side ) + ( ^opposite-of ) + --> + ( ^boat -)} + +sp {monitor*move1 + (state ^operator ) + ( ^name << move1 move11 >> + ^holds.type ) + --> + (write (crlf) | Move one | )} + +sp {monitor*move2 + (state ^operator ) + ( ^name move2 + ^holds.type ) + --> + (write (crlf) | Move two | )} + +sp {monitor*move-side + (state ^operator ) + ( ^name << move1 move2 move11 >> + ^holds.side ) + ( ^opposite-of.name + ^name ) + --> + (write (crlf) | From | | to | )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### STATE EVALUATION +### + +### +### EVALUATION: STATE FAILURE +### + +sp {mac*evaluate*state*failure*more*cannibals + (state ^desired + ^holds

                                                                                                                        ) + (

                                                                                                                        ^type missionaries + ^number { > 0 } + ^side ) + (

                                                                                                                        ^type cannibals + ^number > + ^side ) + --> + ( ^failure ) + (write (crlf) |Failure - too many cannibals on side:| )} + +sp {mac*evaluate*state*failure*state-no-change + (state ^desired + ^problem-space.name missionaries-and-cannibals) + (state ^superstate + ^attribute state + ^quiescence t + ^impasse no-change) + --> + ( ^failure ) + (write (crlf) |Failure - no operators can apply.|)} + +sp {mac*evaluate*state*failure*detect-state-duplicate + (state ^holds + ^desired ) + ( ^type missionaries + ^number 0 + ^side ) + ( ^type cannibals + ^number 0 + ^side ) + (state { <> } ^desired + ^holds + ^tried-tied-operator) + ( ^type missionaries + ^number 0 + ^side ) + ( ^type cannibals + ^number 0 + ^side ) + -(state ^superstate ) + --> + ( ^failure ) + (write (crlf) |Failure - Duplicate State.|)} + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + + ## This also defines implicitly the desired state + ## of the problem. + # + +sp {mac*detect*state*success + (state ^desired + ^holds

                                                                                                                        ) + (

                                                                                                                        ^type missionaries + ^number 3 + ^side ) + (

                                                                                                                        ^type cannibals + ^number 3 + ^side ) + ( ^name rightbank) + --> + ( ^success ) + (write (crlf) |Success.|)} +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } ) + --> + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + diff --git a/soar-8.5.2/demos/mac/mac3-planning.tcl b/soar-8.5.2/demos/mac/mac3-planning.tcl new file mode 100644 index 0000000..cf9eb03 --- /dev/null +++ b/soar-8.5.2/demos/mac/mac3-planning.tcl @@ -0,0 +1,422 @@ +# +# Missionaries and Cannibals Demonstration +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the Missionaries and Cannibals Demonstration. +# +# last update: 6.9.00 Acar Altinsel +# + +package require Soar + +set boatsent 0 + +proc releaseboat {} { + global boatsent + set boatsent 0 +} + +proc sendboat {bank passenger num numtypes ml cl mr cr} { + global boatsent + if {$boatsent == 0} { + if {$numtypes == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] [expr $cl - 1] $mr $cr 0 + animate 1 1 l + + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] [expr $cr - 1] 0 + animate 1 1 r + } + } + if {$numtypes == 1} { + if {$passenger == "missionaries"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate [expr $ml - 1] $cl $mr $cr 0 + animate 1 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 1] $cr 0 + animate 1 0 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate [expr $ml - 2] $cl $mr $cr 0 + animate 2 0 l + } + if {$bank == "R1"} { + drawstate $ml $cl [expr $mr - 2] $cr 0 + animate 2 0 r + } + } + } + + if {$passenger == "cannibals"} { + if {$num == 1} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 1] $mr $cr 0 + animate 0 1 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 1] 0 + animate 0 1 r + } + } + if {$num == 2} { + if {$bank == "L1"} { + drawstate $ml [expr $cl - 2] $mr $cr 0 + animate 0 2 l + } + if {$bank == "R1"} { + drawstate $ml $cl $mr [expr $cr - 2] 0 + animate 0 2 r + } + } + } + } + } + set boatsent 1 +} + +proc animate {m c b} { + + set i 0 + if {$b == "l"} { + if {$m == 2} { + .mac.frame.can create image 200 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 230 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 203 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 243 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 216 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 202 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 242 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 224 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 200 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat 1 0 + } + } + } + } + if {$b == "r"} { + if {$m == 2} { + .mac.frame.can create image 420 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 450 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 2} { + .mac.frame.can create image 423 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 463 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$m == 1} { + if {$c == 0} { + + .mac.frame.can create image 436 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + if {$c == 1} { + .mac.frame.can create image 422 370 -anchor se -image missionary -tag onboat + .mac.frame.can create image 462 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + + } + } + if {$c == 1} { + if {$m == 0} { + .mac.frame.can create image 443 370 -anchor se -image cannibal -tag onboat + .mac.frame.can create image 420 365 -image boat -tag onboat + while {$i < 220} { + set i [expr $i + 1] + set j 0 + after 1 set j 1 + vwait j + .mac.frame.can move onboat -1 0 + } + } + } + } +} + + + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Missionaries and Cannibals Demonstration" + wm iconname $w "Missionaries and Cannibals" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Missionaries and Cannibals Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; drawstate 3 3 0 0 l" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + drawstate 3 3 0 0 l +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + + +#----------------------------------------------------------------------- +# The test.tcl stuff... +# + +proc drawstate {ml cl mr cr b} { + +catch {destroy .mac.frame.can} +canvas .mac.frame.can -width 640 -height 480 -background white +pack .mac.frame.can + +image create photo land -file "[file join $soar_library .. demos mac land.gif]" +.mac.frame.can create image 0 0 -image land -anchor nw + +image create photo cannibal -file "[file join $soar_library .. demos mac cannibal.gif]" +image create photo missionary -file "[file join $soar_library .. demos mac missionary.gif]" +image create photo boat -file "[file join $soar_library .. demos mac boat.gif]" + + +if {$ml >= 1} { + .mac.frame.can create image 90 375 -image missionary -tag move_m1 +} +if {$ml >= 2} { + .mac.frame.can create image 60 375 -image missionary -tag move_m2 +} +if {$ml >= 3} { + .mac.frame.can create image 30 375 -image missionary -tag move_m3 +} + +if {$cl >= 1} { + .mac.frame.can create image 170 310 -image cannibal -tag move_c1 +} +if {$cl >= 2} { + .mac.frame.can create image 130 310 -image cannibal -tag move_c2 +} +if {$cl >= 3} { + .mac.frame.can create image 90 310 -image cannibal -tag move_c3 +} + +if {$b == "l"} { + .mac.frame.can create image 200 365 -image boat -tag move_b +} + + +if {$mr >= 1} { + .mac.frame.can create image 540 375 -image missionary -tag move_m1 +} +if {$mr >= 2} { + .mac.frame.can create image 570 375 -image missionary -tag move_m2 +} +if {$mr >= 3} { + .mac.frame.can create image 600 375 -image missionary -tag move_m3 +} + +if {$cr >= 1} { + .mac.frame.can create image 490 310 -image cannibal -tag move_c1 +} +if {$cr >= 2} { + .mac.frame.can create image 530 310 -image cannibal -tag move_c2 +} +if {$cr >= 3} { + .mac.frame.can create image 570 310 -image cannibal -tag move_c3 +} + +if {$b == "r"} { + .mac.frame.can create image 420 365 -image boat -tag move_b +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set c1x %x + set c1y %y +} + +.mac.frame.can bind move_c1 { + global c1x c1y + + set newx %x + set newy %y + + set distx [expr $newx - $c1x] + set disty [expr $newy - $c1y] + + .mac.frame.can move move_c1 $distx $disty + + set c1x $newx + set c1y $newy +} + +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining missionaries and cannibals solution method + +global soar_library +global interp_type + +set ml 3 +set cl 3 +set bl 1 + +set mr 0 +set cr 0 +set br 0 + +excise -all +source mac3-planning.soar + +drawscreen .mac + + +### +### MOVE-MAC-BOAT MONITOR OPERATOR AND STATE +### + +sp {monitor*move-mac-boat + (state ^operator + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals ) + ( ^missionaries + ^cannibals ) + ( ^name move-mac-boat + ^{ << cannibals missionaries >> } + ^types + ^bank ) + --> + (tcl | sendboat | | | | | | | | | | | | | | | ) + (write (crlf) | Move | | | )} + +sp {monitor*state*left + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 1) + ( ^missionaries + ^cannibals + ^boat 0) + --> + (tcl | drawstate | | | | | | | | l |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | B ~~~ | + | M: | |, C: | | |)} + +sp {monitor*state*right + (state ^name mac + ^left-bank + ^right-bank ) + ( ^missionaries + ^cannibals + ^boat 0) + ( ^missionaries + ^cannibals + ^boat 1) + --> + (tcl | drawstate | | | | | | | | r |) + (tcl | releaseboat |) + (write (crlf) | M: | |, C: | | ~~~ B | + | M: | |, C: | | |)} + +### diff --git a/soar-8.5.2/demos/mac/missionary.gif b/soar-8.5.2/demos/mac/missionary.gif new file mode 100644 index 0000000..5127643 Binary files /dev/null and b/soar-8.5.2/demos/mac/missionary.gif differ diff --git a/soar-8.5.2/demos/mac/readme b/soar-8.5.2/demos/mac/readme new file mode 100644 index 0000000..0b9f594 --- /dev/null +++ b/soar-8.5.2/demos/mac/readme @@ -0,0 +1,46 @@ +# mac/README +# John Laird +# October 20, 1999 +# +# ABSTRACT. This file provides a Soar system to solve the missionaries +# and cannibals problem. Three missionaries and three cannibals come to +# a river. There is a a boat on their side of the river that can be used +# by either one or two persons at a time. This boat must be used to +# cross the river in such a way that cannibals never outnumber +# missionaries on either side of the river. +# +# +# Missionaries and Cannibals +# +# Three versions, using different state representations showing +# tradeoffs in state representations for operator application +# vs. state copying, and generality of chunking. +# +# mac1.soar: +# Simple state representation where the state has two objects: one for +# each side of the river. Each of these has augmentations for +# missionaries, cannibals, and the boat; with their values being the +# number of the entity type on that side of the river. This is the +# version covered in Soar 8 Tutorial. +# +# mac1-planning.soar: +# Same state representation but with additional rules to support +# planning and chunking. +# +# mac1-planning-numeric.soar: +# Same as mac1-planning but with a numeric evaluation during lookahead. +# Numeric evaluation leads to shallower look-ahead and less planning, +# but not as good learning - evaluation function is only a heuristic +# and chunking captures that. +# +# mac2.soar: +# Simple state representation where the state has three objects: +# missionaries, cannibals, and boat. Each of these has subobjects for +# the number of that entity type on each side of the river. +# Does not support planning. Let to an exercise to the reader to +# incorporate planning. +# +# mac3-planning.soar: +# State representation and operator application is more complex in +# support of more generality in learning using the current version of +# chunking. Supports planning and chunking diff --git a/soar-8.5.2/demos/mac/test.tcl b/soar-8.5.2/demos/mac/test.tcl new file mode 100644 index 0000000..f08d510 --- /dev/null +++ b/soar-8.5.2/demos/mac/test.tcl @@ -0,0 +1,205 @@ + +set c1x 0 +set c1y 0 +global c1x c1y + +set c2x 0 +set c2y 0 +global c2x c2y + +set c3x 0 +set c3y 0 +global c3x c3y + +set m1x 0 +set m1y 0 +global m1x m1y + +set m2x 0 +set m2y 0 +global m2x m2y + +set m3x 0 +set m3y 0 +global m3x m3y + +set bx 0 +set by 0 +global bx + +catch {destroy .can} +canvas .can -width 640 -height 480 -background white +pack .can + + +image create photo land -file land.gif +.can create image 0 0 -image land -anchor nw + +image create photo cannibal -file cannibal.gif +image create photo missionary -file missionary.gif + +.can create image 90 310 -image cannibal -tag move_c1 +.can create image 130 310 -image cannibal -tag move_c2 +.can create image 170 310 -image cannibal -tag move_c3 + +.can create image 30 375 -image missionary -tag move_m1 +.can create image 60 375 -image missionary -tag move_m2 +.can create image 90 375 -image missionary -tag move_m3 + +image create photo boat -file boat.gif +.can create image 200 365 -image boat -tag move_b + +.can bind move_c1 { + global c1x c1y + + set c1x %x + set c1y %y +} + +.can bind move_c1 { + global c1x c1y + + set newx %x + set newy %y + + set distx [expr $newx - $c1x] + set disty [expr $newy - $c1y] + + .can move move_c1 $distx $disty + + set c1x $newx + set c1y $newy +} + +.can bind move_c2 { + global c2x c2y + + set c2x %x + set c2y %y +} + +.can bind move_c2 { + global c2x c2y + + set newx %x + set newy %y + + set distx [expr $newx - $c2x] + set disty [expr $newy - $c2y] + + .can move move_c2 $distx $disty + + set c2x $newx + set c2y $newy +} +.can bind move_c3 { + global c3x c3y + + set c3x %x + set c3y %y +} + +.can bind move_c3 { + global c3x c3y + + set newx %x + set newy %y + + set distx [expr $newx - $c3x] + set disty [expr $newy - $c3y] + + .can move move_c3 $distx $disty + + set c3x $newx + set c3y $newy +} + +.can bind move_m1 { + global m1x m1y + + set m1x %x + set m1y %y +} + +.can bind move_m1 { + global m1x m1y + + set newx %x + set newy %y + + set distx [expr $newx - $m1x] + set disty [expr $newy - $m1y] + + .can move move_m1 $distx $disty + + set m1x $newx + set m1y $newy +} + + +.can bind move_m2 { + global m2x m2y + + set m2x %x + set m2y %y +} + +.can bind move_m2 { + global m2x m2y + + set newx %x + set newy %y + + set distx [expr $newx - $m2x] + set disty [expr $newy - $m2y] + + .can move move_m2 $distx $disty + + set m2x $newx + set m2y $newy +} + +.can bind move_m3 { + global m3x m3y + + set m3x %x + set m3y %y +} + +.can bind move_m3 { + global m3x m3y + + set newx %x + set newy %y + + set distx [expr $newx - $m3x] + set disty [expr $newy - $m3y] + + .can move move_m3 $distx $disty + + set m3x $newx + set m3y $newy +} + +.can bind move_b { + global bx by + + set bx %x + set by %y +} + +.can bind move_b { + global bx by + + set newx %x + set newy %y + + set distx [expr $newx - $bx] + set disty [expr $newy - $by] + + .can move move_b $distx $disty + + set bx $newx + set by $newy +} + diff --git a/soar-8.5.2/demos/readme.txt b/soar-8.5.2/demos/readme.txt new file mode 100644 index 0000000..a600fbf --- /dev/null +++ b/soar-8.5.2/demos/readme.txt @@ -0,0 +1,29 @@ +# Soar8demos/README +# John Laird +# May 25, 2004 +# +# Classic AI problems implemented for Soar 8 (8.5.1) +# +# Blocks-World: Stack blocks +# Demonstrates means-ends analysis and operator-subgoaling. +# Eight-Puzzle: Sliding tile puzzle. +# Demonstrates look-ahead search and chunking. +# Has graphical interface using tcl +# MAC: Missionaries and Cannibals +# Has two versions, both of which using look-ahead search +# and chunking showing tradeoffs in state representations for +# operator application vs. state copying. +# Towers-of-hanoi: Classic disk and peg problem +# Two strategies implemented - no search or learning. +# Multiple implementations of one of the strategies using +# different representations with different generality and different +# execution costs +# Water-jug: +# Has two versions, both of which using look-ahead search +# and chunking showing tradeoffs in state representations for +# operator application vs. state copying. +# +# Default: +# Holds rules used for implementing common problem solving +# strategies including look-ahead search and operator subgoaling. + diff --git a/soar-8.5.2/demos/towers-of-hanoi/monitor.soar b/soar-8.5.2/demos/towers-of-hanoi/monitor.soar new file mode 100644 index 0000000..5b87d67 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/monitor.soar @@ -0,0 +1,91 @@ + + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {tower-of-hanoi*monitor*state*holds*above*disk + (state ^superstate nil + ^holds ) + ( ^disk.size + ^above.size + ^on.name ) + --> + (write (crlf) + | On(| + |,| + |),Above(| + |).|)} + +sp {tower-of-hanoi*monitor*state*holds*above*none + (state ^superstate nil + ^holds ) + ( ^disk.size + ^above none + ^on.name ) + --> + (write (crlf) + | On(| + |,| + |).|)} + +sp {tower-of-hanoi*monitor*state*upper-disk + (state ^superstate nil + ^upper-disk.size ) + --> + (write (crlf) + | Upper-Disk(| + |).|)} + +sp {tower-of-hanoi*monitor*state*clear + (state ^superstate nil + ^clear.name ) + --> + (write (crlf) + | Clear(Peg(| + |)).|)} + + +sp {tower-of-hanoi*desired-state*above*disk + (state ^desired + ^superstate nil) + ( ^disk ^above ^on ) + ( ^size ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | Desired/On(| + |,| + |),Above(| + |,| + |)/.|)} + +sp {tower-of-hanoi*desired-state*above*none + (state ^desired ^superstate nil) + ( ^disk ^above none ^on ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | Desired[On(| + |,| + |),Above(| + |,-)].|)} + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk.size + ^from.name + ^to.name ) + --> + (write (crlf) + | Executing(Move-Disk(| + |,| + |,| + |)).|)} + +### eof of tower-of-hanoi.soar + diff --git a/soar-8.5.2/demos/towers-of-hanoi/readme b/soar-8.5.2/demos/towers-of-hanoi/readme new file mode 100644 index 0000000..20d773e --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/readme @@ -0,0 +1,45 @@ +# towers-of-hanoi/README +# John Laird +# March 8, 1999 +# +# ABSTRACT. This file provides a Soar system to solve the Tower +# of Hanoi problems. This puzzle "involves three vertical pegs or +# posts and a number of doughnut-like disks of graduated sizes that +# fit on the pegs. At the outset, all the disks are arranged pyrami- +# dally on one of the pegs, say A, with the largest disk on the bottom. +# The task is to move all of the disks to another peg, C, say, under +# the constraints that (1) only one disk may be moved at a time, and +# (2) a disk may never be placed on top of another smaller than itself. +# Any number of disks may be used; the minimum number of moves for +# a solution is (2**n - 1), where n is the number of disks" (Simon, +# 1975/1979, pp. 230-231). +# +# +# Towers of Hanoi puzzle +# Two strategies implemented - no search or learning. +# Multiple implementations of one of the strategies using +# different representations with different generality and different +# execution costs +# +# towers-of-hanoi-recur.soar +# Uses the disk recursive strategy to solve the towers-of-hanoi. +# Tries to always moves the biggest out of place disk into +# its correct position +# +# all of the others use the same strategy which does not +# require subgoals and is all done by search control +# +# towers-of-hanoi.soar: +# Uses a general representation of the state that makes +# state copying easy (but is not used here!). +# towers-of-hanoi-fast.soar: +# Uses a less general representation, but is a faster implementation +# than above. +# towers-of-hanoi-fast.soar: +# Uses a even more task specific representation, and is even faster. +# towers-of-hanoi-no-op.soar +# Uses mutually exclusive elaboration to solve the problem +# in a single decision - this is *not* the way to write Soar +# programs, but is used for comparison with the others +# monitor.soar: Monitoring rules for tracing movement of disks +# for towers-of-hanoi.soar diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-fast.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-fast.soar new file mode 100644 index 0000000..dd21ce3 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-fast.soar @@ -0,0 +1,365 @@ + +### +### FILE : tower-of-hanoi8.soar +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### This version uses search control rules to solve the TOH in the +### minimum number of moves. +### The search control is as follows: +### Always alternate between moving the smallest disk and +### the other exposed disk that can move. +### Move the exposed disk to the one place it can move (the other disk +### that is bigger than it or an empty peg). +### Move the smallest disk to the peg it was not at last. +### This requires remembering the last peg the smallest disk was on, +### and initializing this to the appropriate peg (the destination peg +### if there is an even number of disks, and the other peg if there is +### an odd number of disks). + + +### These declaration help Soar reorder the conditions of the rules +multi-attributes operator 2 +multi-attributes disk 7 +multi-attributes peg 4 +multi-attributes holds 10 +#multi-attributes upper-disk +multi-attributes clear 3 + +learn -off + +### +### +### TOP GOAL: +### TOWER-OF-HANOI +### + +sp {top-goal*elaborate*goal*tower-of-hanoi + (state ^superstate nil) + --> + ( ^name tower-of-hanoi)} + +### +### TOWER-OF-HANOI: +### INITIAL-STATE AND DESIRED-STATE +### + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi) + --> + ( ^disk + + ^peg + ^holds

                                                                                                                        + ^last-disk1-peg ;# peg-b if odd number of disks, peg-c if even + ^last-disk-moved + ^clear + ^upper-disk ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name 8 ^size 8) + ( ^name 9 ^size 9) + ( ^name 10 ^size 10) + ( ^name 11 ^size 11) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + +### +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND CLEAR +### These are relations and properties used by other rules + +sp {tower-of-hanoi*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^name tower-of-hanoi + ^disk { <> }) + ( ^size ) + ( ^size > ) + --> + ( ^larger )} + +### +### PROPOSE OPERATORS TO MOVE DISKS +### + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*onto + "Target peg is clear." + (state ^name tower-of-hanoi + ^upper-disk + ^clear { <> } + ^holds + ^last-disk1-peg + ^last-disk-moved.name <> 1) + ( ^name 1) + ( ^disk + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*above + "Upper disk on the target peg is larger." + (state ^name tower-of-hanoi) + ( ^upper-disk { <> } + ^holds { <> } + ^last-disk1-peg + ^last-disk-moved.name <> 1) + ( ^disk + ^on ) + ( ^disk + ^on { <> }) + ( ^larger ) + ( ^name 1) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*onto2 + "Target peg is clear." + (state ^name tower-of-hanoi + ^upper-disk + ^clear + ^holds + ^last-disk-moved.name 1) + ( ^disk + ^on ) + ( ^name <> 1) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*above2 + "Upper disk on the target peg is larger." + (state ^name tower-of-hanoi) + ( ^upper-disk { <> } + ^holds { <> } + ^last-disk-moved.name 1) + ( ^disk + ^on ) + ( ^disk + ^on ) + ( ^larger ) + ( ^name <> 1) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + + +### +### OPERATOR APPLICATION +### + +sp {apply*move-disk*source-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above none + ^on ) + --> + ( ^on -) + ( ^clear -)} + +sp {apply*move-disk*source-not-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above { <> none } + ^on ) + --> + ( ^clear -) + ( ^above none - + ^on - )} + +sp {apply*move-disk*target-not-clear + (state ^operator + ^upper-disk + ^holds { <> }) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above + ^on ) + ( ^disk + ^on ) + --> + ( ^upper-disk -) + ( ^above - + ^on - )} + +sp {apply*move-disk*add-clear-source + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from ) + ( ^disk + ^above none + ^on ) + --> + ( ^clear )} + +sp {apply*move-disk*add*upper-disk*source + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from ) + ( ^disk + ^above { <> none } + ^on ) + --> + ( ^upper-disk )} + +### Maintain last-disk-moved + +sp {apply*move-disk*record*last-disk-moved + (state ^operator ) + ( ^name move-disk + ^disk ) + --> + ( ^last-disk-moved )} + +sp {apply*move-disk*remove*last-disk-moved + (state ^operator + ^last-disk-moved ) + ( ^name move-disk + ^disk <> ) + --> + ( ^last-disk-moved -)} + +### Maintain last peg disk 1 was moved to + +sp {apply*move-disk*record*last-disk1-peg + (state ^operator ) + ( ^name move-disk + ^disk.name 1 + ^from ) + --> + ( ^last-disk1-peg )} + +sp {apply*move-disk*remove*last-disk1-peg + (state ^operator + ^last-disk1-peg ) + ( ^name move-disk + ^disk.name 1 + ^from <> ) + --> + ( ^last-disk1-peg -)} + +### +### TOWER-OF-HANOI GOAL-TEST +### + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^name 1 ) + ( ^name 2 ) + ( ^name 3 ) + ( ^name 4 ) + ( ^name 5 ) + ( ^name 6 ) + ( ^name 7 ) + ( ^name 8) + ( ^name 9) + ( ^name 10) + ( ^name 11) + ( ^name |C|) + --> + (write (crlf) |Success!|) + (halt)} + +### +### TOWER-OF-HANOI MONITOR +### + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk.size + ^to.name ) + --> + (write (crlf) + | Move Disk:| + | to peg | )} + +excise tower-of-hanoi*monitor*operator-execution*move-disk +### eof of tower-of-hanoi.soar + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-faster.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-faster.soar new file mode 100644 index 0000000..9a0c91a --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-faster.soar @@ -0,0 +1,255 @@ + +### +### FILE : tower-of-hanoi8.soar +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### This version uses search control rules to solve the TOH in the +### minimum number of moves. +### The search control is as follows: +### Always alternate between moving the smallest disk and +### the other exposed disk that can move. +### Move the exposed disk to the one place it can move (the other disk +### that is bigger than it or an empty peg). +### Move the smallest disk to the peg it was not at last. +### This requires remembering the last peg the smallest disk was on, +### and initializing this to the appropriate peg (the destination peg +### if there is an even number of disks, and the other peg if there is +### an odd number of disks). + + +### These declaration help Soar reorder the conditions of the rules +multi-attributes operator 2 +multi-attributes disk 7 +multi-attributes peg 4 +multi-attributes holds 10 +#multi-attributes upper-disk +multi-attributes clear 3 + +learn -off + +### +### TOWER-OF-HANOI: +### INITIAL-STATE AND DESIRED-STATE +### + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^superstate nil) + --> + ( ^peg a b c + ^holds

                                                                                                                        + ^last-disk1-peg b + ^last-disk-moved 2 + ^clear b c) + (

                                                                                                                        ^disk 1 ^above 2 ^on a) + (

                                                                                                                        ^disk 2 ^above 3 ^on a) + (

                                                                                                                        ^disk 3 ^above 4 ^on a) + (

                                                                                                                        ^disk 4 ^above 5 ^on a) + (

                                                                                                                        ^disk 5 ^above 6 ^on a) + (
                                                                                                                        ^disk 6 ^above 7 ^on a) + ( ^disk 7 ^above 8 ^on a) + ( ^disk 8 ^above 9 ^on a) + ( ^disk 9 ^above 10 ^on a) + ( ^disk 10 ^above 11 ^on a) + ( ^disk 11 ^above none ^on a)} + +### +### PROPOSE OPERATORS TO MOVE DISKS +### + +sp {tower-of-hanoi*propose*move-disk1 + (state ^holds + ^peg { <> <> } + ^last-disk1-peg + ^last-disk-moved <> 1) + ( ^disk 1 + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk 1 + ^from + ^to )} + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*onto2 + "Target peg is clear." + (state ^upper-disk + ^clear + ^holds + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {tower-of-hanoi*propose*move-disk*disk-to-move*above2 + "Upper disk on the target peg is larger." + (state ^upper-disk { > } + ^holds { <> } + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^on ) + ( ^disk { > } + ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} +### +### OPERATOR APPLICATION +### + +sp {apply*move-disk*source-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above none + ^on ) + --> + ( ^on -) + ( ^clear -)} + +sp {apply*move-disk*source-not-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above { <> none } + ^on ) + --> + ( ^clear -) + ( ^above none - + ^on - )} + +sp {apply*move-disk*target-not-clear + (state ^operator + ^upper-disk + ^holds { <> }) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above + ^on ) + ( ^disk + ^on ) + --> + ( ^upper-disk -) + ( ^above - + ^on - )} + +sp {apply*move-disk*add-clear-source + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from ) + ( ^disk + ^above none + ^on ) + --> + ( ^clear )} + +sp {apply*move-disk*add*upper-disk*source + (state ^operator + ^holds ) + ( ^name move-disk + ^disk + ^from ) + ( ^disk + ^above { <> none } + ^on ) + --> + ( ^upper-disk )} + +### Maintain last-disk-moved + +sp {apply*move-disk*record*last-disk-moved + (state ^operator + ^last-disk-moved { <> }) + ( ^name move-disk + ^disk ) + --> + ( ^last-disk-moved + ^last-disk-moved -)} + +### Maintain last peg disk 1 was moved to + +sp {apply*move-disk*record*last-disk1-peg + (state ^operator + ^last-disk1-peg { <> }) + ( ^name move-disk + ^disk 1 + ^from ) + --> + ( ^last-disk1-peg + ^last-disk1-peg -)} + +### +### TOWER-OF-HANOI GOAL-TEST +### + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk 1 ^on c) + (

                                                                                                                        ^disk 2 ^on c) + (

                                                                                                                        ^disk 3 ^on c) + (

                                                                                                                        ^disk 4 ^on c) + (

                                                                                                                        ^disk 5 ^on c) + (
                                                                                                                        ^disk 6 ^on c) + ( ^disk 7 ^on c) + ( ^disk 8 ^on c) + ( ^disk 9 ^on c) + ( ^disk 10 ^on c) + ( ^disk 11 ^on c) + --> + (write (crlf) |Success!|) + (halt)} + +### +### TOWER-OF-HANOI MONITOR +### + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk + ^to ) + --> + (write (crlf) + | Move Disk:| + | to peg | )} + +excise tower-of-hanoi*monitor*operator-execution*move-disk +### eof of tower-of-hanoi.soar + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-no-ops.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-no-ops.soar new file mode 100644 index 0000000..1ad2825 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-no-ops.soar @@ -0,0 +1,228 @@ + +### +### FILE : tower-of-hanoi8.soar +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### This version uses search control rules to solve the TOH in the +### minimum number of moves. +### The search control is as follows: +### Always alternate between moving the smallest disk and +### the other exposed disk that can move. +### Move the exposed disk to the one place it can move (the other disk +### that is bigger than it or an empty peg). +### Move the smallest disk to the peg it was not at last. +### This requires remembering the last peg the smallest disk was on, +### and initializing this to the appropriate peg (the destination peg +### if there is an even number of disks, and the other peg if there is +### an odd number of disks). + + +### These declaration help Soar reorder the conditions of the rules +set max_elaborations 50000 +multi-attributes on 3 +multi-attributes peg 4 +multi-attributes holds 10 +#multi-attributes upper-disk +multi-attributes clear 3 + +learn -off + +### +### TOWER-OF-HANOI: +### INITIAL-STATE AND DESIRED-STATE +### + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^superstate nil) + --> + ( ^operator + ^peg a b c + ^holds

                                                                                                                        + ^last-disk1-peg b + ^last-disk-moved 2 + ^clear b c) + ( ^name doit) + (

                                                                                                                        ^disk 1 ^above 2 ^on a) + (

                                                                                                                        ^disk 2 ^above 3 ^on a) + (

                                                                                                                        ^disk 3 ^above 4 ^on a) + (

                                                                                                                        ^disk 4 ^above 5 ^on a) + (

                                                                                                                        ^disk 5 ^above 6 ^on a) + (
                                                                                                                        ^disk 6 ^above 7 ^on a) + ( ^disk 7 ^above 8 ^on a) + ( ^disk 8 ^above 9 ^on a) + ( ^disk 9 ^above 10 ^on a) + ( ^disk 10 ^above 11 ^on a) + ( ^disk 11 ^above none ^on a)} + +### +### PROPOSE OPERATORS TO MOVE DISKS +### + +sp {tower-of-hanoi*move-disk1*source-clear*target-not-clear + (state ^operator.name doit + ^holds

                                                                                                                        + ^upper-disk + ^peg { <> <> } + ^last-disk1-peg + ^last-disk-moved {<> 1 }) + ( ^disk 1 + ^above none + ^on ) + (

                                                                                                                        ^disk + ^on ) + --> +# (write (crlf) |Move 1 from | | to | ) + ( ^on - + ^above none -) + ( ^clear + ^upper-disk - + ^last-disk1-peg - + ^last-disk-moved 1 -)} + +sp {tower-of-hanoi*move-disk1*source-not-clear*target-clear + (state ^operator.name doit + ^holds + ^clear + ^peg { <> <> } + ^last-disk1-peg + ^last-disk-moved {<> 1 }) + ( ^disk 1 + ^above + ^on ) + --> +# (write (crlf) |Move 1 from | | to | ) + ( ^on - + ^above - none) + ( ^clear - + ^upper-disk + ^last-disk1-peg - + ^last-disk-moved 1 -)} + +sp {tower-of-hanoi*move-disk1*source-not-clear*target-not-clear + (state ^operator.name doit + ^holds

                                                                                                                        + ^upper-disk + ^peg { <> <> } + ^last-disk1-peg + ^last-disk-moved {<> 1 }) + ( ^disk 1 + ^above { <> none } + ^on ) + (

                                                                                                                        ^disk + ^on ) + --> +# (write (crlf) |Move 1 from | | to | ) + ( ^on - + ^above -) + ( ^upper-disk + ^upper-disk - + ^last-disk1-peg - + ^last-disk-moved 1 -)} +### + +sp {tower-of-hanoi*move-diskn*source-clear*target-clear + (state ^operator.name doit + ^upper-disk + ^holds + ^clear + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^above none + ^on ) + --> +# (write (crlf) |Move | | from | | to | ) + ( ^on -) + ( ^clear - + ^last-disk-moved 1 -)} + +sp {tower-of-hanoi*move-diskn*source-clear*target-not-clear + (state ^operator.name doit + ^upper-disk + ^holds

                                                                                                                        + ^upper-disk + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^above none + ^on ) + (

                                                                                                                        ^disk { > } + ^on ) + --> +# (write (crlf) |Move | | from | | to | ) + ( ^on - + ^above none -) + ( ^clear + ^upper-disk - + ^last-disk-moved 1 -)} + +sp {tower-of-hanoi*move-diskn*source-not-clear*target-clear + (state ^operator.name doit + ^upper-disk + ^holds + ^clear + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^above { <> none } + ^on ) + --> +# (write (crlf) |Move | | from | | to | ) + ( ^on - + ^above - none) + ( ^clear - + ^upper-disk + ^last-disk-moved 1 -)} + +sp {tower-of-hanoi*move-diskn*source-not-clear*target-not-clear + (state ^operator.name doit + ^upper-disk + ^upper-disk + ^holds

                                                                                                                        + ^last-disk-moved 1) + ( ^disk { <> 1 } + ^above { <> none } + ^on ) + (

                                                                                                                        ^disk { > } + ^on { <> }) + --> +# (write (crlf) |Move | | from | | to | ) + ( ^on - + ^above -) + ( ^upper-disk + ^upper-disk - + ^last-disk-moved 1 -)} + +### +### TOWER-OF-HANOI GOAL-TEST +### + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk 1 ^on c) + (

                                                                                                                        ^disk 2 ^on c) + (

                                                                                                                        ^disk 3 ^on c) + (

                                                                                                                        ^disk 4 ^on c) + (

                                                                                                                        ^disk 5 ^on c) + (
                                                                                                                        ^disk 6 ^on c) + ( ^disk 7 ^on c) + ( ^disk 8 ^on c) + ( ^disk 9 ^on c) + ( ^disk 10 ^on c) + ( ^disk 11 ^on c) + --> + (write (crlf) |Success!|) + (halt)} + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recur.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recur.soar new file mode 100644 index 0000000..1ac253f --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recur.soar @@ -0,0 +1,346 @@ + +### +### FILE : tower-of-hanoi.soar +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### MEA Recursive Stratgey +### Operators proposed to achieve current goal +### + +### These help Soar reorder the conditions of rules + +multi-attributes disk 3 +multi-attributes peg 3 +multi-attributes holds 4 +multi-attributes upper-disk 2 +multi-attributes clear 2 + +learn -off + +### +### +### TOP GOAL: TOWER-OF-HANOI +### + +sp {top-goal*elaborate*goal*tower-of-hanoi + (state ^superstate nil) + --> + ( ^name tower-of-hanoi)} + + +### +### INITIAL-STATE AND DESIRED-STATE +### + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi) + --> + ( ^disk + ^peg + ^holds

                                                                                                                        + ^top-state ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired ) + ( ^holds ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + +### +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND +### CLEAR +### + +sp {tower-of-hanoi*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^name tower-of-hanoi + ^disk { <> }) + ( ^size ) + ( ^size > ) + --> + ( ^larger )} + +sp {tower-of-hanoi*object*disk*elaborate*state*upper-disk + "If not(above(x,disk)), then upper-disk(disk)." + (state ^name tower-of-hanoi + ^disk ) + -{ ( ^holds.above ) } + --> + ( ^upper-disk )} + +sp {tower-of-hanoi*object*peg*elaborate*state*clear + "If not(on(x,peg)), then clear(peg)." + (state ^name tower-of-hanoi + ^peg ) + -{ ( ^holds.on ) } + --> + ( ^clear )} + +### +### OPERATOR PROPOSAL +### + +## Desired is to have disk on a peg so propose operator to do it +## Desired comes from original goal. + +sp {tower-of-hanoi*propose*move-disk*mea*onpeg + (state ^desired ) + ( ^holds ) + ( ^disk + ^on + ^satisfied *no*) + -{( ^holds ) + ( ^disk + ^satisfied *no*) + ( ^larger )} + --> + ( ^operator ) + ( ^name move-disk + ^type put-on-peg + ^disk + ^to )} + +## Desired is to have disk clear (so it can move) +## Propose moving disk above it + +sp {tower-of-hanoi*propose*move-disk*mea*clear-disk + (state ^desired + ^top-state ) + ( ^holds + ^peg { <> <> }) + ( ^disk + ^above + ^on ) + ( ^move-disk ) + ( ^disk + ^peg ) + --> + ( ^operator ) + ( ^name move-disk + ^type clear-disk + ^disk + ^to )} + +## +## Clear off smaller disk in the way of a larger disk + +sp {tower-of-hanoi*propose*move-disk*mea*clear-smaller + (state ^desired + ^top-state ) + ( ^holds

                                                                                                                        + ^peg { <> <> }) + (

                                                                                                                        ^disk + ^on ) + (

                                                                                                                        ^disk + ^on ) + ( ^move-disk ) + ( ^disk + ^peg ) + ( ^larger ) + -{( ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk + ^on ) + ( ^larger ) + ( ^larger )} + --> + ( ^operator +) + ( ^name move-disk + ^type clear-smaller + ^disk + ^to )} + +### +### SEARCH CONTROL +### MAINTAIN OPERATOR IN GOAL STACK IF IT HAS BEEN SELECTED +### otherwise, new proposed operators would tie with it + +sp {tower-of-hanoi*select*maintain*operator + (state ^operator ) + --> + ( ^operator >)} + +### + +sp {tower-of-hanoi*elaborate*desired*not-statisfied + (state ^name tower-of-hanoi + ^desired + ^top-state ) + -{( ^holds ) + ( ^disk + ^on )} + ( ^holds ) + ( ^disk + ^on ) + --> + ( ^satisfied *no*)} + +sp {tower-of-hanoi*elaborate*desired*statisfied + (state ^name tower-of-hanoi + ^desired.holds + ^top-state.holds ) + ( ^disk + ^on ) + ( ^disk + ^on ) + --> + ( ^satisfied *yes*)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR APPLICATION +### + +sp {apply*move-disk*source-clear*target-clear + (state ^operator + ^top-state ) + ( ^name move-disk + ^disk + ^to ) + ( ^clear + ^upper-disk + ^holds ) + ( ^disk + ^above none + ^on { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Move | | from | | to | ) + ( ^on - )} + +sp {apply*move-disk*source-not-clear*target-clear + (state ^operator + ^top-state ) + ( ^clear + ^upper-disk + ^holds ) + ( ^name move-disk + ^disk + ^to ) + ( ^disk + ^above { <> none } + ^on { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Move | | from | | to | ) + ( ^above none - + ^on - )} + +sp {apply*move-disk*target-not-clear + (state ^operator + ^top-state ) + ( ^upper-disk + ^upper-disk + ^holds { <> }) + ( ^name move-disk + ^disk + ^to ) + ( ^disk + ^above + ^on { <> }) + ( ^disk + ^on ) + ( ^larger ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |Move | | from | | to | ) + ( ^above - + ^on - )} + +### +### TOWER-OF-HANOI: GOAL-TEST +### + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + ( ^disk ^on ) + ( ^name 1 ) + ( ^name 2 ) + ( ^name 3 ) + ( ^name 4 ) + ( ^name 5 ) + ( ^name 6 ) + ( ^name 7 ) + ( ^name |C|) + --> + (write (crlf) |Success!|) + (halt)} + +### ELABORATIONS +sp {elaborate*state*top-state + (state ^superstate ) + ( ^top-state ) + --> + ( ^top-state )} + +### CREATE DESIRED + +sp {elaborate*state*desired + (state ^superstate ) + ( ^operator ) + ( ^disk + ^to ) + --> + ( ^desired.move-disk ) + ( ^disk + ^peg )} + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk.size + ^to.name ) + --> + (write (crlf) + | Goal Move Disk:| + | to peg | )} + +### eof of tower-of-hanoi.soar + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.soar new file mode 100644 index 0000000..d53e0c7 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.soar @@ -0,0 +1,3 @@ +pushd towers-of-hanoi-recursive +source towers-of-hanoi-recursive_source.soar +popd diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.vsa b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.vsa new file mode 100644 index 0000000..d3fee68 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive.vsa @@ -0,0 +1,16 @@ +VERSION 4 +\towers-of-hanoi-recursive\towers-of-hanoi-recursive.dm +0 ROOT towers-of-hanoi-recursive towers-of-hanoi-recursive 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR disk-relations disk-relations.soar 5 +5 3 FOPERATOR goal-test goal-test.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 3 FOPERATOR top-state top-state.soar 13 +8 0 FOPERATOR _readme _readme.soar 8 +9 0 OPERATOR initialize-toh-recursive initialize-toh-recursive.soar 9 +10 0 HLOPERATOR move-disk move-disk.soar move-disk 23 10 +11 10 FOPERATOR elaborations elaborations.soar 11 +12 10 OPERATOR move-disk move-disk.soar 12 +END diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_firstload.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_firstload.soar new file mode 100644 index 0000000..f7b0106 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_firstload.soar @@ -0,0 +1,9 @@ +### These declaration help Soar reorder the conditions of the rules + +multi-attributes disk 7 +multi-attributes peg 3 +multi-attributes holds 8 +multi-attributes upper-disk 2 +multi-attributes clear 2 + +learn -off diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_readme.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_readme.soar new file mode 100644 index 0000000..17bf467 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/_readme.soar @@ -0,0 +1,17 @@ +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### MEA Recursive Stratgey +### Operators proposed to achieve current goal +### diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/all/all_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/comment.dm b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/comment.dm new file mode 100644 index 0000000..111eb5e --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/comment.dm @@ -0,0 +1,42 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/disk-relations.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/disk-relations.soar new file mode 100644 index 0000000..e8fc280 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/disk-relations.soar @@ -0,0 +1,29 @@ +### +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND CLEAR +### These are relations and properties used by other rules + +sp {towers-of-hanoi*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^name towers-of-hanoi + ^disk { <> }) + ( ^size ) + ( ^size > ) +--> + ( ^larger )} + +sp {towers-of-hanoi*object*disk*elaborate*state*upper-disk + "If not(above(x,disk)), then upper-disk(disk)." + (state ^name towers-of-hanoi + ^disk ) + -{ ( ^holds.above ) } +--> + ( ^upper-disk )} + +sp {towers-of-hanoi*object*peg*elaborate*state*clear + "If not(on(x,peg)), then clear(peg)." + (state ^name towers-of-hanoi + ^peg ) + -{ ( ^holds.on ) } +--> + ( ^clear )} \ No newline at end of file diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/elaborations_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/elaborations_source.soar new file mode 100644 index 0000000..8df9dd3 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source disk-relations.soar +source goal-test.soar +source monitor.soar +source top-state.soar diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/goal-test.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/goal-test.soar new file mode 100644 index 0000000..f84957e --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/goal-test.soar @@ -0,0 +1,60 @@ + +### +### towers-of-hanoi GOAL-TEST +### + +sp {towers-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        +

                                                                                                                        + ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^name 1 ) + ( ^name 2 ) + ( ^name 3 ) + ( ^name 4 ) + ( ^name 5 ) + ( ^name 6 ) + ( ^name 7 ) + ( ^name 8) + ( ^name 9) + ( ^name 10) + ( ^name 11) + ( ^name |C|) +--> + (write (crlf) |Success!|) + (halt)} + + +sp {tower-of-hanoi*elaborate*desired*not-statisfied + (state ^name towers-of-hanoi + ^desired + ^top-state ) + -{( ^holds ) + ( ^disk + ^on )} + ( ^holds ) + ( ^disk + ^on ) +--> + ( ^satisfied *no*)} + +sp {tower-of-hanoi*elaborate*desired*statisfied + (state ^name towers-of-hanoi + ^desired.holds + ^top-state.holds ) + ( ^disk + ^on ) + ( ^disk + ^on ) +--> + ( ^satisfied *yes*)} diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/monitor.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/monitor.soar new file mode 100644 index 0000000..4ae45b9 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/monitor.soar @@ -0,0 +1,9 @@ +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk.size + ^to.name ) + --> + (write (crlf) + | Goal Move Disk:| + | to peg | )} \ No newline at end of file diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/top-state.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/top-state.soar new file mode 100644 index 0000000..555fb22 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/elaborations/top-state.soar @@ -0,0 +1,10 @@ +sp {elaborations*elaborate*top-state + (state ^superstate nil) +--> + ( ^top-state )} + +sp {elaborations*elaborate*super*top-state + (state ^superstate.top-state ) +--> + ( ^top-state ) +} \ No newline at end of file diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize-toh-recursive.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize-toh-recursive.soar new file mode 100644 index 0000000..d35f7ac --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize-toh-recursive.soar @@ -0,0 +1,60 @@ +sp {towers-of-hanoi*propose*initialize-recursive + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-toh-recursive)} + +# 11 disks +sp {towers-of-hanoi*apply*initialize-recursive + (state ^operator.name initialize-toh-recursive) +--> + ( ^name towers-of-hanoi + ^disk + + ^peg + ^holds

                                                                                                                        +

                                                                                                                        + ^desired ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name 8 ^size 8) + ( ^name 9 ^size 9) + ( ^name 10 ^size 10) + ( ^name 11 ^size 11) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^holds + + ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) +} + +### diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize.soar new file mode 100644 index 0000000..f77b79e --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/initialize.soar @@ -0,0 +1,59 @@ +sp {towers-of-hanoi*propose*initialize + (state ^name towers-of-hanoi + -^disk) +--> + ( ^operator +) + ( ^name initialize)} + +# 11 disks +sp {towers-of-hanoi*apply*initialize + (state ^operator.name initialize) +--> + ( ^disk + + ^peg + ^holds

                                                                                                                        +

                                                                                                                        + ^desired ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name 8 ^size 8) + ( ^name 9 ^size 9) + ( ^name 10 ^size 10) + ( ^name 11 ^size 11) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^holds + + ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) +} + +### diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk.soar new file mode 100644 index 0000000..254c78d --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk.soar @@ -0,0 +1,153 @@ +### +### OPERATOR PROPOSAL +### + +## Desired is to have disk on a peg so propose operator to do it +## Desired comes from original goal. + +sp {tower-of-hanoi*propose*move-disk*mea*onpeg + (state ^desired ) + ( ^holds ) + ( ^disk + ^on + ^satisfied *no*) + -{( ^holds ) + ( ^disk + ^satisfied *no*) + ( ^larger )} + --> + ( ^operator ) + ( ^name move-disk + ^type put-on-peg + ^disk + ^to )} + +## Desired is to have disk clear (so it can move) +## Propose moving disk above it + +sp {tower-of-hanoi*propose*move-disk*mea*clear-disk + (state ^desired + ^top-state ) + ( ^holds + ^peg { <> <> }) + ( ^disk + ^above + ^on ) + ( ^move-disk ) + ( ^disk + ^peg ) + --> + ( ^operator ) + ( ^name move-disk + ^type clear-disk + ^disk + ^to )} + +## +## Clear off smaller disk in the way of a larger disk + +sp {tower-of-hanoi*propose*move-disk*mea*clear-smaller + (state ^desired + ^top-state ) + ( ^holds

                                                                                                                        + ^peg { <> <> }) + (

                                                                                                                        ^disk + ^on ) + (

                                                                                                                        ^disk + ^on ) + ( ^move-disk ) + ( ^disk + ^peg ) + ( ^larger ) + -{( ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk + ^on ) + ( ^larger ) + ( ^larger )} + --> + ( ^operator +) + ( ^name move-disk + ^type clear-smaller + ^disk + ^to )} + +### +### SEARCH CONTROL +### MAINTAIN OPERATOR IN GOAL STACK IF IT HAS BEEN SELECTED +### otherwise, new proposed operators would tie with it + +sp {tower-of-hanoi*select*maintain*operator + (state ^operator ) + --> + ( ^operator >)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR APPLICATION +### + +sp {apply*move-disk*source-clear*target-clear + (state ^operator + ^top-state ) + ( ^name move-disk + ^disk + ^to ) + ( ^clear + ^upper-disk + ^holds ) + ( ^disk + ^above none + ^on { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> + # (write (crlf) |Move | | from | | to | ) + ( ^on - )} + +sp {apply*move-disk*source-not-clear*target-clear + (state ^operator + ^top-state ) + ( ^clear + ^upper-disk + ^holds ) + ( ^name move-disk + ^disk + ^to ) + ( ^disk + ^above { <> none } + ^on { <> }) + ( ^name ) + ( ^name ) + ( ^name ) + --> +# (write (crlf) |Move | | from | | to | ) + ( ^above none - + ^on - )} + +sp {apply*move-disk*target-not-clear + (state ^operator + ^top-state ) + ( ^upper-disk + ^upper-disk + ^holds { <> }) + ( ^name move-disk + ^disk + ^to ) + ( ^disk + ^above + ^on { <> }) + ( ^disk + ^on ) + ( ^larger ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + # (write (crlf) |Move | | from | | to | ) + ( ^above - + ^on - )} + + + + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/elaborations.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/elaborations.soar new file mode 100644 index 0000000..15ba860 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/elaborations.soar @@ -0,0 +1,9 @@ +sp {elaborate*state*desired + (state ^superstate ) + ( ^operator ) + ( ^disk + ^to ) + --> + ( ^desired.move-disk ) + ( ^disk + ^peg )} \ No newline at end of file diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/move-disk.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/move-disk.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/move-disk_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/move-disk_source.soar new file mode 100644 index 0000000..5b8d4fa --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/move-disk/move-disk_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source move-disk.soar diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/readme.txt b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/readme.txt new file mode 100644 index 0000000..29768b9 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/readme.txt @@ -0,0 +1,47 @@ +# towers-of-hanoi/README +# John Laird +# March 8, 1999 +# +# ABSTRACT. This file provides a Soar system to solve the Tower +# of Hanoi problems. This puzzle "involves three vertical pegs or +# posts and a number of doughnut-like disks of graduated sizes that +# fit on the pegs. At the outset, all the disks are arranged pyrami- +# dally on one of the pegs, say A, with the largest disk on the bottom. +# The task is to move all of the disks to another peg, C, say, under +# the constraints that (1) only one disk may be moved at a time, and +# (2) a disk may never be placed on top of another smaller than itself. +# Any number of disks may be used; the minimum number of moves for +# a solution is (2**n - 1), where n is the number of disks" (Simon, +# 1975/1979, pp. 230-231). +# +# +# Towers of Hanoi puzzle +# Two strategies implemented - no search or learning. +# Multiple implementations of one of the strategies using +# different representations with different generality and different +# execution costs +# +# towers-of-hanoi-recur.soar +# Uses the disk recursive strategy to solve the towers-of-hanoi. +# Tries to always moves the biggest out of place disk into +# its correct position +# +# all of the others use the same strategy which does not +# require subgoals and is all done by search control +# +# towers-of-hanoi.soar: +# Uses a general representation of the state that makes +# state copying easy (but is not used here!). +# towers-of-hanoi-fast.soar: +# Uses a less general representation, but is a faster implementation +# than above. +# towers-of-hanoi-fast.soar: +# Uses a even more task specific representation, and is even faster. +# towers-of-hanoi-no-op.soar +# Uses mutually exclusive elaboration to solve the problem +# in a single decision - this is *not* the way to write Soar +# programs, but is used for comparison with the others +# monitor.soar: Monitoring rules for tracing movement of disks +# for towers-of-hanoi.soar + + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive.dm b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive.dm new file mode 100644 index 0000000..4239065 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive.dm @@ -0,0 +1,72 @@ +28 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 towers-of-hanoi +SOAR_ID 4 +ENUMERATION 5 1 initialize-toh-recursive +SOAR_ID 6 +ENUMERATION 7 1 move-disk +SOAR_ID 8 +SOAR_ID 9 +INTEGER_RANGE 10 -2147483648 2147483647 +SOAR_ID 11 +SOAR_ID 12 +SOAR_ID 13 +ENUMERATION 14 11 1 10 11 2 3 4 5 6 7 8 9 +SOAR_ID 15 +ENUMERATION 16 3 |A| |B| |C| +SOAR_ID 17 +ENUMERATION 18 1 none +SOAR_ID 19 +SOAR_ID 20 +ENUMERATION 21 2 *no* *yes* +ENUMERATION 22 3 clear-disk clear-smaller put-on-peg +SOAR_ID 23 +ENUMERATION 24 1 state +ENUMERATION 25 1 move-disk +ENUMERATION 26 1 move-disk +SOAR_ID 27 +42 +0 clear 15 +0 desired 19 +0 disk 13 +0 holds 17 +0 larger 13 +0 name 3 +0 operator 4 +0 operator 6 +0 peg 15 +0 superstate 2 +0 top-state 0 +0 type 1 +0 upper-disk 13 +4 name 5 +6 disk 8 +6 name 7 +6 to 9 +6 type 22 +8 name 10 +8 size 11 +9 name 12 +13 holds 17 +13 larger 13 +13 name 14 +13 size 14 +15 name 16 +17 above 13 +17 above 18 +17 disk 13 +17 on 15 +17 satisfied 21 +19 holds 17 +19 move-disk 20 +20 disk 13 +20 peg 15 +23 desired 19 +23 name 25 +23 operator 27 +23 superstate 0 +23 top-state 0 +23 type 24 +27 name 26 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive_source.soar new file mode 100644 index 0000000..3b6c449 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi-recursive_source.soar @@ -0,0 +1,13 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source initialize-toh-recursive.soar +source move-disk.soar +pushd move-disk +source move-disk_source.soar +popd diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi.dm b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi.dm new file mode 100644 index 0000000..c300087 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi.dm @@ -0,0 +1,63 @@ +26 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 towers-of-hanoi +SOAR_ID 4 +ENUMERATION 5 1 initialize +SOAR_ID 6 +ENUMERATION 7 1 move-disk +SOAR_ID 8 +SOAR_ID 9 +SOAR_ID 10 +SOAR_ID 11 +SOAR_ID 12 +SOAR_ID 13 +INTEGER_RANGE 14 -2147483648 2147483647 +INTEGER_RANGE 15 -2147483648 2147483647 +SOAR_ID 16 +SOAR_ID 17 +SOAR_ID 18 +SOAR_ID 19 +SOAR_ID 20 +ENUMERATION 21 11 1 10 11 2 3 4 5 6 7 8 9 +SOAR_ID 22 +ENUMERATION 23 3 |A| |B| |C| +SOAR_ID 24 +ENUMERATION 25 1 none +35 +0 clear 22 +0 desired 24 +0 disk 20 +0 holds 24 +0 last-disk-moved 20 +0 last-disk1-peg 22 +0 name 3 +0 operator 4 +0 operator 6 +0 peg 22 +0 superstate 2 +0 type 1 +0 upper-disk 20 +4 disk 8 +4 from 10 +4 name 5 +4 to 12 +6 disk 9 +6 from 11 +6 name 7 +6 to 13 +8 name 15 +8 size 17 +9 name 14 +9 size 16 +12 name 19 +13 name 18 +20 larger 20 +20 name 21 +20 size 21 +22 name 23 +24 above 20 +24 above 25 +24 disk 20 +24 on 22 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi_source.soar new file mode 100644 index 0000000..d781bfd --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi-recursive/towers-of-hanoi_source.soar @@ -0,0 +1,10 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source initialize.soar +source move-disk.soar diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.soar new file mode 100644 index 0000000..158f76e --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.soar @@ -0,0 +1,3 @@ +pushd towers-of-hanoi +source towers-of-hanoi_source.soar +popd diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.vsa b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.vsa new file mode 100644 index 0000000..d7aa6e5 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi.vsa @@ -0,0 +1,13 @@ +VERSION 4 +\towers-of-hanoi\towers-of-hanoi.dm +0 ROOT towers-of-hanoi towers-of-hanoi 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR disk-relations disk-relations.soar 5 +5 3 FOPERATOR goal-test goal-test.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 0 FOPERATOR _readme _readme.soar 8 +8 0 OPERATOR initialize-toh initialize-toh.soar 9 +9 0 OPERATOR move-disk move-disk.soar 10 +END diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_firstload.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_firstload.soar new file mode 100644 index 0000000..f7b0106 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_firstload.soar @@ -0,0 +1,9 @@ +### These declaration help Soar reorder the conditions of the rules + +multi-attributes disk 7 +multi-attributes peg 3 +multi-attributes holds 8 +multi-attributes upper-disk 2 +multi-attributes clear 2 + +learn -off diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_readme.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_readme.soar new file mode 100644 index 0000000..8f0037a --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/_readme.soar @@ -0,0 +1,26 @@ +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### This version uses search control rules to solve the TOH in the +### minimum number of moves. +### The search control is as follows: +### Always alternate between moving the smallest disk and +### the other exposed disk that can move. +### Move the exposed disk to the one place it can move (the other disk +### that is bigger than it or an empty peg). +### Move the smallest disk to the peg it was not at last. +### This requires remembering the last peg the smallest disk was on, +### and initializing this to the appropriate peg (the destination peg +### if there is an even number of disks, and the other peg if there is +### an odd number of disks). diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/all/all_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/comment.dm b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/comment.dm new file mode 100644 index 0000000..9da0ee8 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/comment.dm @@ -0,0 +1,35 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/disk-relations.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/disk-relations.soar new file mode 100644 index 0000000..e8fc280 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/disk-relations.soar @@ -0,0 +1,29 @@ +### +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND CLEAR +### These are relations and properties used by other rules + +sp {towers-of-hanoi*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^name towers-of-hanoi + ^disk { <> }) + ( ^size ) + ( ^size > ) +--> + ( ^larger )} + +sp {towers-of-hanoi*object*disk*elaborate*state*upper-disk + "If not(above(x,disk)), then upper-disk(disk)." + (state ^name towers-of-hanoi + ^disk ) + -{ ( ^holds.above ) } +--> + ( ^upper-disk )} + +sp {towers-of-hanoi*object*peg*elaborate*state*clear + "If not(on(x,peg)), then clear(peg)." + (state ^name towers-of-hanoi + ^peg ) + -{ ( ^holds.on ) } +--> + ( ^clear )} \ No newline at end of file diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/elaborations_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/elaborations_source.soar new file mode 100644 index 0000000..c9b44b3 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/elaborations_source.soar @@ -0,0 +1,3 @@ +source disk-relations.soar +source goal-test.soar +source monitor.soar diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/goal-test.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/goal-test.soar new file mode 100644 index 0000000..1d9f4d4 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/goal-test.soar @@ -0,0 +1,34 @@ + +### +### towers-of-hanoi GOAL-TEST +### + +sp {towers-of-hanoi*desired-of-disk*satisfied + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (

                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + (
                                                                                                                        ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^name 1 ) + ( ^name 2 ) + ( ^name 3 ) + ( ^name 4 ) + ( ^name 5 ) + ( ^name 6 ) + ( ^name 7 ) + ( ^name 8) + ( ^name 9) + ( ^name 10) + ( ^name 11) + ( ^name |C|) + --> + (write (crlf) |Success!|) + (halt)} + diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/monitor.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/monitor.soar new file mode 100644 index 0000000..6a1e732 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/monitor.soar @@ -0,0 +1,13 @@ +### +### towers-of-hanoi MONITOR +### + +sp {towers-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + ( ^name move-disk + ^disk.size + ^to.name ) + --> + (write (crlf) + | Move Disk:| + | to peg | )} diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/top-state.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/top-state.soar new file mode 100644 index 0000000..1a972a3 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/elaborations/top-state.soar @@ -0,0 +1,5 @@ +sp {elaborate*top-state*name + (state ^superstate nil) +--> + ( ^name towers-of-hanoi) +} diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize-toh.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize-toh.soar new file mode 100644 index 0000000..e02191f --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize-toh.soar @@ -0,0 +1,57 @@ +sp {towers-of-hanoi*propose*initialize + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-toh)} + +# 11 disks +sp {towers-of-hanoi*apply*initialize-toh + (state ^operator.name initialize-toh) +--> + ( ^name towers-of-hanoi + ^disk + + ^peg + ^holds

                                                                                                                        + ^last-disk1-peg ; # peg-b if odd number of disks, peg-c if even + ^last-disk-moved ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name 8 ^size 8) + ( ^name 9 ^size 9) + ( ^name 10 ^size 10) + ( ^name 11 ^size 11) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + +### diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize.soar new file mode 100644 index 0000000..0424e53 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/initialize.soar @@ -0,0 +1,56 @@ +sp {towers-of-hanoi*propose*initialize + (state ^name towers-of-hanoi + -^disk) +--> + ( ^operator +) + ( ^name initialize)} + +# 11 disks +sp {towers-of-hanoi*apply*initialize + (state ^operator.name initialize) +--> + ( ^disk + + ^peg + ^holds

                                                                                                                        + ^last-disk1-peg ; # peg-b if odd number of disks, peg-c if even + ^last-disk-moved ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name 6 ^size 6) + ( ^name 7 ^size 7) + ( ^name 8 ^size 8) + ( ^name 9 ^size 9) + ( ^name 10 ^size 10) + ( ^name 11 ^size 11) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + +### diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/move-disk.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/move-disk.soar new file mode 100644 index 0000000..cec8b34 --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/move-disk.soar @@ -0,0 +1,164 @@ +### +### PROPOSE OPERATORS TO MOVE DISKS +### + +sp {towers-of-hanoi*propose*move-disk*disk-to-move*onto + "Target peg is clear." + (state ^name towers-of-hanoi + ^upper-disk + ^clear { <> } + ^holds + ^last-disk1-peg + ^last-disk-moved.name <> 1) + ( ^name 1) + ( ^disk + ^on ) +--> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {towers-of-hanoi*propose*move-disk*disk-to-move*above + "Upper disk on the target peg is larger." + (state ^name towers-of-hanoi) + ( ^upper-disk { <> } + ^holds { <> } + ^last-disk1-peg + ^last-disk-moved.name <> 1) + ( ^disk + ^on ) + ( ^disk + ^on { <> }) + ( ^larger ) + ( ^name 1) +--> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {towers-of-hanoi*propose*move-disk*disk-to-move*onto2 + "Target peg is clear." + (state ^name towers-of-hanoi + ^upper-disk + ^clear + ^holds + ^last-disk-moved.name 1) + ( ^disk + ^on ) + ( ^name <> 1) +--> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + +sp {towers-of-hanoi*propose*move-disk*disk-to-move*above2 + "Upper disk on the target peg is larger." + (state ^name towers-of-hanoi) + ( ^upper-disk { <> } + ^holds { <> } + ^last-disk-moved.name 1) + ( ^disk + ^on ) + ( ^disk + ^on ) + ( ^larger ) + ( ^name <> 1) +--> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to )} + + +### +### OPERATOR APPLICATION +### + +sp {apply*move-disk*source-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above none + ^on ) +--> + ( ^on - )} + +sp {apply*move-disk*source-not-clear*target-clear + (state ^operator + ^clear + ^holds ) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above { <> none } + ^on ) +--> + ( ^above none - + ^on - )} + +sp {apply*move-disk*target-not-clear + (state ^operator + ^upper-disk + ^holds { <> }) + ( ^name move-disk + ^disk + ^from + ^to ) + ( ^disk + ^above + ^on ) + ( ^disk + ^on ) +--> + ( ^above - + ^on - )} + +### Maintain last-disk-moved + +sp {apply*move-disk*record*last-disk-moved + (state ^operator ) + ( ^name move-disk + ^disk ) +--> + ( ^last-disk-moved )} + +sp {apply*move-disk*remove*last-disk-moved + (state ^operator + ^last-disk-moved ) + ( ^name move-disk + ^disk <> ) +--> + ( ^last-disk-moved -)} + +### Maintain last peg disk 1 was moved to + +sp {apply*move-disk*record*last-disk1-peg + (state ^operator ) + ( ^name move-disk + ^disk.name 1 + ^from ) +--> + ( ^last-disk1-peg )} + +sp {apply*move-disk*remove*last-disk1-peg + (state ^operator + ^last-disk1-peg ) + ( ^name move-disk + ^disk.name 1 + ^from <> ) +--> + ( ^last-disk1-peg -)} diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi.dm b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi.dm new file mode 100644 index 0000000..021d2ca --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi.dm @@ -0,0 +1,63 @@ +26 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 towers-of-hanoi +SOAR_ID 4 +ENUMERATION 5 1 initialize-toh +SOAR_ID 6 +ENUMERATION 7 1 move-disk +SOAR_ID 8 +SOAR_ID 9 +SOAR_ID 10 +SOAR_ID 11 +SOAR_ID 12 +SOAR_ID 13 +INTEGER_RANGE 14 -2147483648 2147483647 +INTEGER_RANGE 15 -2147483648 2147483647 +SOAR_ID 16 +SOAR_ID 17 +SOAR_ID 18 +SOAR_ID 19 +SOAR_ID 20 +ENUMERATION 21 11 1 10 11 2 3 4 5 6 7 8 9 +SOAR_ID 22 +ENUMERATION 23 3 |A| |B| |C| +SOAR_ID 24 +ENUMERATION 25 1 none +35 +0 clear 22 +0 desired 24 +0 disk 20 +0 holds 24 +0 last-disk-moved 20 +0 last-disk1-peg 22 +0 name 3 +0 operator 4 +0 operator 6 +0 peg 22 +0 superstate 2 +0 type 1 +0 upper-disk 20 +4 disk 8 +4 from 10 +4 name 5 +4 to 12 +6 disk 9 +6 from 11 +6 name 7 +6 to 13 +8 name 15 +8 size 17 +9 name 14 +9 size 16 +12 name 19 +13 name 18 +20 larger 20 +20 name 21 +20 size 21 +22 name 23 +24 above 20 +24 above 25 +24 disk 20 +24 on 22 diff --git a/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi_source.soar b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi_source.soar new file mode 100644 index 0000000..a13365b --- /dev/null +++ b/soar-8.5.2/demos/towers-of-hanoi/towers-of-hanoi/towers-of-hanoi_source.soar @@ -0,0 +1,10 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source initialize-toh.soar +source move-disk.soar diff --git a/soar-8.5.2/demos/water-jug/images/00.gif b/soar-8.5.2/demos/water-jug/images/00.gif new file mode 100644 index 0000000..7ac6847 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/00.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/01.gif b/soar-8.5.2/demos/water-jug/images/01.gif new file mode 100644 index 0000000..38de52e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/01.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/02.gif b/soar-8.5.2/demos/water-jug/images/02.gif new file mode 100644 index 0000000..faddf27 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/02.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/03.gif b/soar-8.5.2/demos/water-jug/images/03.gif new file mode 100644 index 0000000..5a564f5 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/03.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/04.gif b/soar-8.5.2/demos/water-jug/images/04.gif new file mode 100644 index 0000000..eb423d6 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/04.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/05.gif b/soar-8.5.2/demos/water-jug/images/05.gif new file mode 100644 index 0000000..c61437f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/05.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/10.gif b/soar-8.5.2/demos/water-jug/images/10.gif new file mode 100644 index 0000000..152e43d Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/10.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/11.gif b/soar-8.5.2/demos/water-jug/images/11.gif new file mode 100644 index 0000000..74bd0d2 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/11.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/12.gif b/soar-8.5.2/demos/water-jug/images/12.gif new file mode 100644 index 0000000..68bb614 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/12.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/13.gif b/soar-8.5.2/demos/water-jug/images/13.gif new file mode 100644 index 0000000..306dc2e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/13.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/14.gif b/soar-8.5.2/demos/water-jug/images/14.gif new file mode 100644 index 0000000..767a136 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/14.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/15.gif b/soar-8.5.2/demos/water-jug/images/15.gif new file mode 100644 index 0000000..d4f25fa Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/15.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/20.gif b/soar-8.5.2/demos/water-jug/images/20.gif new file mode 100644 index 0000000..62d8535 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/20.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/21.gif b/soar-8.5.2/demos/water-jug/images/21.gif new file mode 100644 index 0000000..307562f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/21.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/22.gif b/soar-8.5.2/demos/water-jug/images/22.gif new file mode 100644 index 0000000..e20f7df Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/22.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/23.gif b/soar-8.5.2/demos/water-jug/images/23.gif new file mode 100644 index 0000000..1a91c84 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/23.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/24.gif b/soar-8.5.2/demos/water-jug/images/24.gif new file mode 100644 index 0000000..5e150e3 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/24.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/25.gif b/soar-8.5.2/demos/water-jug/images/25.gif new file mode 100644 index 0000000..a556e04 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/25.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/30.gif b/soar-8.5.2/demos/water-jug/images/30.gif new file mode 100644 index 0000000..2f22514 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/30.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/31.gif b/soar-8.5.2/demos/water-jug/images/31.gif new file mode 100644 index 0000000..e94eac3 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/31.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/32.gif b/soar-8.5.2/demos/water-jug/images/32.gif new file mode 100644 index 0000000..35ad076 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/32.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/33.gif b/soar-8.5.2/demos/water-jug/images/33.gif new file mode 100644 index 0000000..d315df5 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/33.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/34.gif b/soar-8.5.2/demos/water-jug/images/34.gif new file mode 100644 index 0000000..9a6386c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/34.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/35.gif b/soar-8.5.2/demos/water-jug/images/35.gif new file mode 100644 index 0000000..cc05fb1 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/35.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-00.gif b/soar-8.5.2/demos/water-jug/images/3pour5-00.gif new file mode 100644 index 0000000..a87ff1f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-00.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-01.gif b/soar-8.5.2/demos/water-jug/images/3pour5-01.gif new file mode 100644 index 0000000..d52c58b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-01.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-02.gif b/soar-8.5.2/demos/water-jug/images/3pour5-02.gif new file mode 100644 index 0000000..3ee072a Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-02.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-03.gif b/soar-8.5.2/demos/water-jug/images/3pour5-03.gif new file mode 100644 index 0000000..4da0ec1 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-03.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-04.gif b/soar-8.5.2/demos/water-jug/images/3pour5-04.gif new file mode 100644 index 0000000..28e63c3 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-04.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-05.gif b/soar-8.5.2/demos/water-jug/images/3pour5-05.gif new file mode 100644 index 0000000..e4b763c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-05.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-10.gif b/soar-8.5.2/demos/water-jug/images/3pour5-10.gif new file mode 100644 index 0000000..fdc7e54 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-10.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-11.gif b/soar-8.5.2/demos/water-jug/images/3pour5-11.gif new file mode 100644 index 0000000..58aab78 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-11.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-12.gif b/soar-8.5.2/demos/water-jug/images/3pour5-12.gif new file mode 100644 index 0000000..6357c40 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-12.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-13.gif b/soar-8.5.2/demos/water-jug/images/3pour5-13.gif new file mode 100644 index 0000000..8ace100 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-13.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-14.gif b/soar-8.5.2/demos/water-jug/images/3pour5-14.gif new file mode 100644 index 0000000..7d093e7 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-14.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-15.gif b/soar-8.5.2/demos/water-jug/images/3pour5-15.gif new file mode 100644 index 0000000..1c5a1cf Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-15.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-20.gif b/soar-8.5.2/demos/water-jug/images/3pour5-20.gif new file mode 100644 index 0000000..677b303 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-20.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-21.gif b/soar-8.5.2/demos/water-jug/images/3pour5-21.gif new file mode 100644 index 0000000..7595e7f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-21.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-22.gif b/soar-8.5.2/demos/water-jug/images/3pour5-22.gif new file mode 100644 index 0000000..f9b3e60 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-22.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-23.gif b/soar-8.5.2/demos/water-jug/images/3pour5-23.gif new file mode 100644 index 0000000..fd80c99 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-23.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-24.gif b/soar-8.5.2/demos/water-jug/images/3pour5-24.gif new file mode 100644 index 0000000..458ebc9 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-24.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-25.gif b/soar-8.5.2/demos/water-jug/images/3pour5-25.gif new file mode 100644 index 0000000..9a9b3d0 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-25.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-30.gif b/soar-8.5.2/demos/water-jug/images/3pour5-30.gif new file mode 100644 index 0000000..f385ee9 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-30.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-31.gif b/soar-8.5.2/demos/water-jug/images/3pour5-31.gif new file mode 100644 index 0000000..a8c5245 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-31.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-32.gif b/soar-8.5.2/demos/water-jug/images/3pour5-32.gif new file mode 100644 index 0000000..e11837a Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-32.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-33.gif b/soar-8.5.2/demos/water-jug/images/3pour5-33.gif new file mode 100644 index 0000000..0ec521f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-33.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-34.gif b/soar-8.5.2/demos/water-jug/images/3pour5-34.gif new file mode 100644 index 0000000..357628b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-34.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/3pour5-35.gif b/soar-8.5.2/demos/water-jug/images/3pour5-35.gif new file mode 100644 index 0000000..910a734 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/3pour5-35.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-01.gif b/soar-8.5.2/demos/water-jug/images/5pour3-01.gif new file mode 100644 index 0000000..6f66901 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-01.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-02.gif b/soar-8.5.2/demos/water-jug/images/5pour3-02.gif new file mode 100644 index 0000000..83047ff Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-02.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-03.gif b/soar-8.5.2/demos/water-jug/images/5pour3-03.gif new file mode 100644 index 0000000..ffe487f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-03.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-04.gif b/soar-8.5.2/demos/water-jug/images/5pour3-04.gif new file mode 100644 index 0000000..0ce2bf6 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-04.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-05.gif b/soar-8.5.2/demos/water-jug/images/5pour3-05.gif new file mode 100644 index 0000000..190c1b0 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-05.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-10.gif b/soar-8.5.2/demos/water-jug/images/5pour3-10.gif new file mode 100644 index 0000000..54b66cf Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-10.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-11.gif b/soar-8.5.2/demos/water-jug/images/5pour3-11.gif new file mode 100644 index 0000000..3208ad2 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-11.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-12.gif b/soar-8.5.2/demos/water-jug/images/5pour3-12.gif new file mode 100644 index 0000000..0e0fb5c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-12.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-13.gif b/soar-8.5.2/demos/water-jug/images/5pour3-13.gif new file mode 100644 index 0000000..03aa40e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-13.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-14.gif b/soar-8.5.2/demos/water-jug/images/5pour3-14.gif new file mode 100644 index 0000000..e23d82c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-14.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-15.gif b/soar-8.5.2/demos/water-jug/images/5pour3-15.gif new file mode 100644 index 0000000..f2cfb4a Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-15.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-20.gif b/soar-8.5.2/demos/water-jug/images/5pour3-20.gif new file mode 100644 index 0000000..28c5eb3 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-20.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-21.gif b/soar-8.5.2/demos/water-jug/images/5pour3-21.gif new file mode 100644 index 0000000..238f69a Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-21.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-22.gif b/soar-8.5.2/demos/water-jug/images/5pour3-22.gif new file mode 100644 index 0000000..335ba01 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-22.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-23.gif b/soar-8.5.2/demos/water-jug/images/5pour3-23.gif new file mode 100644 index 0000000..9defef9 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-23.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-24.gif b/soar-8.5.2/demos/water-jug/images/5pour3-24.gif new file mode 100644 index 0000000..ab95acc Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-24.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-25.gif b/soar-8.5.2/demos/water-jug/images/5pour3-25.gif new file mode 100644 index 0000000..26ad419 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-25.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-30.gif b/soar-8.5.2/demos/water-jug/images/5pour3-30.gif new file mode 100644 index 0000000..e233961 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-30.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-31.gif b/soar-8.5.2/demos/water-jug/images/5pour3-31.gif new file mode 100644 index 0000000..3efff37 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-31.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-32.gif b/soar-8.5.2/demos/water-jug/images/5pour3-32.gif new file mode 100644 index 0000000..1b14fb7 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-32.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-33.gif b/soar-8.5.2/demos/water-jug/images/5pour3-33.gif new file mode 100644 index 0000000..08d74ea Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-33.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/5pour3-34.gif b/soar-8.5.2/demos/water-jug/images/5pour3-34.gif new file mode 100644 index 0000000..0b0b3d0 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/5pour3-34.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-00.gif b/soar-8.5.2/demos/water-jug/images/dump3-00.gif new file mode 100644 index 0000000..bfdd3e8 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-00.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-01.gif b/soar-8.5.2/demos/water-jug/images/dump3-01.gif new file mode 100644 index 0000000..1d46b29 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-01.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-02.gif b/soar-8.5.2/demos/water-jug/images/dump3-02.gif new file mode 100644 index 0000000..455f03b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-02.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-03.gif b/soar-8.5.2/demos/water-jug/images/dump3-03.gif new file mode 100644 index 0000000..b5fa192 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-03.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-04.gif b/soar-8.5.2/demos/water-jug/images/dump3-04.gif new file mode 100644 index 0000000..4ea0f9b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-04.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-05.gif b/soar-8.5.2/demos/water-jug/images/dump3-05.gif new file mode 100644 index 0000000..07d945b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-05.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-10.gif b/soar-8.5.2/demos/water-jug/images/dump3-10.gif new file mode 100644 index 0000000..770f174 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-10.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-11.gif b/soar-8.5.2/demos/water-jug/images/dump3-11.gif new file mode 100644 index 0000000..8dfbaf1 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-11.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-12.gif b/soar-8.5.2/demos/water-jug/images/dump3-12.gif new file mode 100644 index 0000000..627e174 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-12.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-13.gif b/soar-8.5.2/demos/water-jug/images/dump3-13.gif new file mode 100644 index 0000000..8ea92a6 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-13.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-14.gif b/soar-8.5.2/demos/water-jug/images/dump3-14.gif new file mode 100644 index 0000000..3b61619 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-14.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-15.gif b/soar-8.5.2/demos/water-jug/images/dump3-15.gif new file mode 100644 index 0000000..bdf47a4 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-15.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-20.gif b/soar-8.5.2/demos/water-jug/images/dump3-20.gif new file mode 100644 index 0000000..6d6cc6e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-20.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-21.gif b/soar-8.5.2/demos/water-jug/images/dump3-21.gif new file mode 100644 index 0000000..cc46e6c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-21.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-22.gif b/soar-8.5.2/demos/water-jug/images/dump3-22.gif new file mode 100644 index 0000000..ffed910 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-22.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-23.gif b/soar-8.5.2/demos/water-jug/images/dump3-23.gif new file mode 100644 index 0000000..687437d Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-23.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-24.gif b/soar-8.5.2/demos/water-jug/images/dump3-24.gif new file mode 100644 index 0000000..a125177 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-24.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-25.gif b/soar-8.5.2/demos/water-jug/images/dump3-25.gif new file mode 100644 index 0000000..31dc1aa Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-25.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-30.gif b/soar-8.5.2/demos/water-jug/images/dump3-30.gif new file mode 100644 index 0000000..7d51e1b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-30.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-31.gif b/soar-8.5.2/demos/water-jug/images/dump3-31.gif new file mode 100644 index 0000000..171721e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-31.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-32.gif b/soar-8.5.2/demos/water-jug/images/dump3-32.gif new file mode 100644 index 0000000..ffe0be8 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-32.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-33.gif b/soar-8.5.2/demos/water-jug/images/dump3-33.gif new file mode 100644 index 0000000..d1bb81c Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-33.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-34.gif b/soar-8.5.2/demos/water-jug/images/dump3-34.gif new file mode 100644 index 0000000..e6eef26 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-34.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump3-35.gif b/soar-8.5.2/demos/water-jug/images/dump3-35.gif new file mode 100644 index 0000000..3274c5a Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump3-35.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-00.gif b/soar-8.5.2/demos/water-jug/images/dump5-00.gif new file mode 100644 index 0000000..e4565a2 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-00.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-01.gif b/soar-8.5.2/demos/water-jug/images/dump5-01.gif new file mode 100644 index 0000000..ad7f080 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-01.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-02.gif b/soar-8.5.2/demos/water-jug/images/dump5-02.gif new file mode 100644 index 0000000..65a96d5 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-02.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-03.gif b/soar-8.5.2/demos/water-jug/images/dump5-03.gif new file mode 100644 index 0000000..082e0c0 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-03.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-04.gif b/soar-8.5.2/demos/water-jug/images/dump5-04.gif new file mode 100644 index 0000000..6354e08 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-04.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-05.gif b/soar-8.5.2/demos/water-jug/images/dump5-05.gif new file mode 100644 index 0000000..07ef1bf Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-05.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-10.gif b/soar-8.5.2/demos/water-jug/images/dump5-10.gif new file mode 100644 index 0000000..190a350 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-10.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-11.gif b/soar-8.5.2/demos/water-jug/images/dump5-11.gif new file mode 100644 index 0000000..6e01c7f Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-11.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-12.gif b/soar-8.5.2/demos/water-jug/images/dump5-12.gif new file mode 100644 index 0000000..cb07adb Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-12.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-13.gif b/soar-8.5.2/demos/water-jug/images/dump5-13.gif new file mode 100644 index 0000000..92abf0b Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-13.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-14.gif b/soar-8.5.2/demos/water-jug/images/dump5-14.gif new file mode 100644 index 0000000..422fd04 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-14.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-15.gif b/soar-8.5.2/demos/water-jug/images/dump5-15.gif new file mode 100644 index 0000000..76455e6 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-15.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-20.gif b/soar-8.5.2/demos/water-jug/images/dump5-20.gif new file mode 100644 index 0000000..68659d1 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-20.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-21.gif b/soar-8.5.2/demos/water-jug/images/dump5-21.gif new file mode 100644 index 0000000..ddb7f37 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-21.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-22.gif b/soar-8.5.2/demos/water-jug/images/dump5-22.gif new file mode 100644 index 0000000..312a2aa Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-22.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-23.gif b/soar-8.5.2/demos/water-jug/images/dump5-23.gif new file mode 100644 index 0000000..390e336 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-23.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-24.gif b/soar-8.5.2/demos/water-jug/images/dump5-24.gif new file mode 100644 index 0000000..e30895d Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-24.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-25.gif b/soar-8.5.2/demos/water-jug/images/dump5-25.gif new file mode 100644 index 0000000..75d51b5 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-25.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-30.gif b/soar-8.5.2/demos/water-jug/images/dump5-30.gif new file mode 100644 index 0000000..c37e9ca Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-30.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-31.gif b/soar-8.5.2/demos/water-jug/images/dump5-31.gif new file mode 100644 index 0000000..38454be Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-31.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-32.gif b/soar-8.5.2/demos/water-jug/images/dump5-32.gif new file mode 100644 index 0000000..586ce93 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-32.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-33.gif b/soar-8.5.2/demos/water-jug/images/dump5-33.gif new file mode 100644 index 0000000..5b7c1e7 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-33.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-34.gif b/soar-8.5.2/demos/water-jug/images/dump5-34.gif new file mode 100644 index 0000000..9949390 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-34.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/dump5-35.gif b/soar-8.5.2/demos/water-jug/images/dump5-35.gif new file mode 100644 index 0000000..6c46ed5 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/dump5-35.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-0.gif b/soar-8.5.2/demos/water-jug/images/fill3-0.gif new file mode 100644 index 0000000..823f13e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-0.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-1.gif b/soar-8.5.2/demos/water-jug/images/fill3-1.gif new file mode 100644 index 0000000..1e2f418 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-1.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-2.gif b/soar-8.5.2/demos/water-jug/images/fill3-2.gif new file mode 100644 index 0000000..af9d021 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-2.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-3.gif b/soar-8.5.2/demos/water-jug/images/fill3-3.gif new file mode 100644 index 0000000..8d6fc81 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-3.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-4.gif b/soar-8.5.2/demos/water-jug/images/fill3-4.gif new file mode 100644 index 0000000..73efe56 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-4.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill3-5.gif b/soar-8.5.2/demos/water-jug/images/fill3-5.gif new file mode 100644 index 0000000..95c1e4e Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill3-5.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill5-0.gif b/soar-8.5.2/demos/water-jug/images/fill5-0.gif new file mode 100644 index 0000000..8a91b05 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill5-0.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill5-1.gif b/soar-8.5.2/demos/water-jug/images/fill5-1.gif new file mode 100644 index 0000000..4afc7bf Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill5-1.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill5-2.gif b/soar-8.5.2/demos/water-jug/images/fill5-2.gif new file mode 100644 index 0000000..3806366 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill5-2.gif differ diff --git a/soar-8.5.2/demos/water-jug/images/fill5-3.gif b/soar-8.5.2/demos/water-jug/images/fill5-3.gif new file mode 100644 index 0000000..5e008c2 Binary files /dev/null and b/soar-8.5.2/demos/water-jug/images/fill5-3.gif differ diff --git a/soar-8.5.2/demos/water-jug/readme b/soar-8.5.2/demos/water-jug/readme new file mode 100644 index 0000000..ea3001c --- /dev/null +++ b/soar-8.5.2/demos/water-jug/readme @@ -0,0 +1,15 @@ +# waterjug/README +# John Laird +# May 25, 2004 +# # ABSTRACT. These Soar productions implement the waterjug task. +# The task is to find the sequence of steps that fill the three-gallon +# jug with one gallon of water. There is a well that has an infinite +# amount of water, a five-gallon jug, and a three-gallon jug. +# # Two versions: +# # water-jug.soar +# Simple impasse-free problem solving without planning. +# # water-jug-look-ahead.soar +# Same formulation as in waterjug.soar, but has additional +# rules to support lookahead planning. Automatically loads +# in required default rules. Chunking also works with this. +# # These systems are covered in the Soar 8 Tutorial Part I and V. \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.soar new file mode 100644 index 0000000..d8a2b1d --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.soar @@ -0,0 +1,3 @@ +pushd water-jug-look-ahead +source water-jug-look-ahead_source.soar +popd diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead.tcl b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.tcl new file mode 100644 index 0000000..076d0f3 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.tcl @@ -0,0 +1,233 @@ +# +# Water Jug puzzle +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the water jug puzzle. +# +# last update: 5.26.00 Acar Altinsel +# + +package require Soar + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Water Jugs Demonstration" + wm iconname $w "Water Jugs" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Water Jugs Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; picture 0 0 state" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + picture 0 0 state +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + +proc timer {pic} { + global solveslow + catch {destroy .water.frame.picture} + image create photo test -file $pic + label .water.frame.picture -image test -height 360 -width 480 + pack .water.frame.picture + set m 1 + after 100 set m 0 + vwait m +} + +proc picture {vol3 vol5 action} { +global soar_library + +switch $action { + 3pour5 { + for {set i $vol5} {$i <= 5} {incr i} { + if {$vol3 >=0} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol3 [expr $vol3 - 1] + incr vol5 + + } + } + + } + 5pour3 { + for {set i $vol3} {$i <= 3} {incr i} { + if {$vol5 >= 0} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol5 [expr $vol5 - 1] + incr vol3 + } + } + + } + dump3 { + for {set i $vol3} {$i >= 0} {set i [expr $i - 1]} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol3 [expr $vol3 - 1] + } + + } + dump5 { + + for {set i $vol5} {$i >= 0} {set i [expr $i - 1]} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol5 [expr $vol5 - 1] + } + + + } + fill3 { + set filename "[file join $soar_library .. demos water-jug images $action-$vol5.gif]" + timer $filename + + + } + fill5 { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3.gif]" + timer $filename + } + state { + + set filename "[file join $soar_library .. demos water-jug images $vol3$vol5.gif]" + timer $filename + } + } +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining water-jug solution method + +global soar_library +global interp_type + +excise -all +source water-jug-look-ahead.soar + +drawscreen .water + +### +### WATER JUG: +### MONITOR STATE AND +### OPERATORS +### + +sp {water-jug*monitor*state*pic + (state ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl |picture | | | | state|) +} + +sp {water-jug*monitor*operator-application*empty*pic + (state ^operator ) + ( ^name empty + ^jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + + + --> + (tcl | picture | | | | dump| ) +} + +sp {water-jug*monitor*operator-application*fill*pic + (state ^operator ) + ( ^name fill + ^jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | fill| ) +} + +sp {water-jug*monitor*operator-application*pour*pic + (state ^operator ) + ( ^name pour + ^jug + ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | | |pour| ) +} + +sp {water-jug*monitor*tied-operator*empty*pic + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name empty ^jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + + --> + (tcl | picture | | | | dump| ) +} + +sp {water-jug*monitor*tied-operator*fill*pic + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name fill ^jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | fill| ) +} + +sp {water-jug*monitor*tied-operator*pour*pic + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name pour ^jug ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | | |pour| ) +} + +### eof of water-jug.soar (Version Type: Soar8) diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead.vsa b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.vsa new file mode 100644 index 0000000..e01e395 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead.vsa @@ -0,0 +1,19 @@ +VERSION 4 +\water-jug-look-ahead\water-jug-look-ahead.dm +0 ROOT water-jug-look-ahead water-jug-look-ahead 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR empty empty.soar 5 +5 3 FOPERATOR goal-test goal-test.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 3 FOPERATOR problem-space problem-space.soar 8 +8 0 FOPERATOR _readme _readme.soar 9 +9 0 OPERATOR empty empty.soar 10 +10 0 OPERATOR fill fill.soar 11 +11 0 HLIOPERATOR Impasse__Operator_Tie Impasse__Operator_Tie.soar Impasse__Operator_Tie 17 12 +12 11 FOPERATOR elaborations elaborations.soar 13 +13 11 FOPERATOR monitor monitor.soar 14 +14 0 OPERATOR initialize initialize.soar 15 +15 0 OPERATOR pour pour.soar 16 +END diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar new file mode 100644 index 0000000..7c47ec5 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/Impasse__Operator_Tie_source.soar @@ -0,0 +1,2 @@ +source elaborations.soar +source monitor.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/elaborations.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/elaborations.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/monitor.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/monitor.soar new file mode 100644 index 0000000..85ea5f9 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/Impasse__Operator_Tie/monitor.soar @@ -0,0 +1,29 @@ + +sp {water-jug*monitor*tied-operator*empty + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name empty + ^jug.volume ) +--> + (write (crlf) | | |: empty(| |)|)} + +sp {water-jug*monitor*tied-operator*fill + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name fill + ^jug.volume ) +--> + (write (crlf) | | |: fill(| |)|)} + +sp {water-jug*monitor*tied-operator*pour + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name pour + ^jug ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) +--> + (write (crlf) | | |: pour(| |:| |,| |:| |)|)} diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_firstload.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_firstload.soar new file mode 100644 index 0000000..3638747 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_firstload.soar @@ -0,0 +1,10 @@ +multi-attributes jug 3 + +echo "learning is on" +learn -on +pushd "../../default" +source selection.soar +popd + + +# to get graphics, load water-jug.tcl instead diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_readme.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_readme.soar new file mode 100644 index 0000000..acb3f33 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/_readme.soar @@ -0,0 +1,35 @@ +# water-jug +# John E. Laird +# University of Michigan +# May 25, 2004 +# Soar version 8.5.1 + +### +### ABSTRACT. These Soar productions implement the water-jug task. +### The task is to find the sequence of steps that fill the three gallon +### jug with one gallon of water. There are a well that has an infinite +### amount of water, a five gallon jug, and a three gallon jug. +### + +### +### DESCRIPTION. The task problem space has three operators: empty, +### fill, and pour. Empty empties a jug into the well. Fill fills up +### a jug from the well. Pour pours some or all of the contents +### from one jug into the other jug. Pour can only pour out the contents +### of the jug until the source is empty or the destination is full. +### State Structure: Each jug has slots to record its capacity [volume], +### the amount of water it contains [contents], and the capacity +### available [empty] which is the volume minus the contents. +### (state s1 ^jug j1) +### (jug j1 ^volume v1 ^contents c1 ^empty f1), +### where v1, c1, and f1 are numbers. +### + + +# Change made to water-jug to enable look ahead: +# 1. Add to elaborations/top-state: water-jug*elaborate*problem-space +# 2. Change elaborations/goal-test +# 3. Added desired in initialize so easier to change desired state. +# 4. Remove = preferences from operator proposals + + diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/all/all_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/comment.dm b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/comment.dm new file mode 100644 index 0000000..6cae789 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/comment.dm @@ -0,0 +1,36 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/elaborations_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/elaborations_source.soar new file mode 100644 index 0000000..f986444 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/elaborations_source.soar @@ -0,0 +1,4 @@ +source empty.soar +source goal-test.soar +source monitor.soar +source problem-space.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/empty.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/empty.soar new file mode 100644 index 0000000..cd80592 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/empty.soar @@ -0,0 +1,7 @@ +sp {water-jug*elaborate*empty + (state ^name water-jug + ^jug ) + ( ^contents + ^volume ) +--> + ( ^empty (- ))} diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/goal-test.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/goal-test.soar new file mode 100644 index 0000000..ba88ec1 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/goal-test.soar @@ -0,0 +1,28 @@ + +sp {water-jug*evaluate*state*success + (state ^desired + ^name water-jug + ^jug ) + ( ^jug ) + ( ^volume ^contents ) + ( ^volume ^contents ) +--> + ( ^success )} + +set warnings off +sp {water-jug*evaluate*state*failure*duplicate + (state ^name water-jug + ^desired + ^jug + ^jug ) + ( ^volume 5 ^contents ) + ( ^volume 3 ^contents ) + ({ <> } ^jug + ^jug + ^tried-tied-operator) + ( ^volume 5 ^contents ) + ( ^volume 3 ^contents ) + -(state ^superstate ) +--> + ( ^failure )} +set warnings on \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/monitor.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/monitor.soar new file mode 100644 index 0000000..2a67a1d --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/monitor.soar @@ -0,0 +1,41 @@ + +### +### water-jug: +### MONITOR STATE AND +### OPERATORS +### + +sp {water-jug*monitor*state + (state ^name water-jug + ^jug ) + ( ^volume 5 ^contents ) + ( ^volume 3 ^contents ) +--> + (write (crlf) | 5:| | 3:| )} + +sp {water-jug*monitor*operator-application*empty + (state ^name water-jug + ^operator ) + ( ^name empty + ^jug.volume ) +--> + (write (crlf) | EMPTY(| |)|)} + +sp {water-jug*monitor*operator-application*fill + (state ^name water-jug + ^operator ) + ( ^name fill + ^jug.volume ) +--> + (write (crlf) | FILL(| |)|)} + +sp {water-jug*monitor*operator-application*pour + (state ^name water-jug + ^operator ) + ( ^name pour + ^jug + ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) +--> + (write (crlf) | POUR(| |:| |,| |:| |)|)} \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/problem-space.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/problem-space.soar new file mode 100644 index 0000000..8a14d8c --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/elaborations/problem-space.soar @@ -0,0 +1,8 @@ +sp {water-jug*elaborate*problem-space + (state ^name water-jug) +--> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name water-jug + ^default-state-copy yes + ^two-level-attributes jug + ^dont-copy empty)} \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/empty.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/empty.soar new file mode 100644 index 0000000..de85d9c --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/empty.soar @@ -0,0 +1,20 @@ + +sp {water-jug*propose*empty + (state ^name water-jug + ^jug ) + ( ^contents > 0) +--> + ( ^operator +) + ( ^name empty + ^jug )} + +sp {water-jug*apply*empty + (state ^name water-jug + ^operator + ^jug ) + ( ^name empty + ^jug ) + ( ^volume + ^contents ) +--> + ( ^contents 0 - )} \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/fill.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/fill.soar new file mode 100644 index 0000000..c58c1ef --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/fill.soar @@ -0,0 +1,22 @@ + +sp {water-jug*propose*fill + (state ^name water-jug + ^jug ) + ( ^empty > 0) +--> + ( ^operator +) + ( ^name fill + ^jug )} + + +sp {water-jug*apply*fill + (state ^name water-jug + ^operator + ^jug ) + ( ^name fill + ^jug ) + ( ^volume + ^contents ) +--> + ( ^contents + -)} diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/initialize.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/initialize.soar new file mode 100644 index 0000000..d60dd7a --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/initialize.soar @@ -0,0 +1,19 @@ +sp {water-jug*propose*initialize-water-jug-look-ahead + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-water-jug-look-ahead)} + +sp {water-jug*apply*initialize-water-jug-look-ahead + (state ^operator.name initialize-water-jug-look-ahead) +--> + ( ^name water-jug + ^jug + ^desired.jug ) + ( ^volume 3 + ^contents 0) + ( ^volume 5 + ^contents 0) + ( ^volume 3 + ^contents 1)} diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/pour.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/pour.soar new file mode 100644 index 0000000..a5cd39c --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/pour.soar @@ -0,0 +1,47 @@ + +sp {water-jug*propose*pour + (state ^name water-jug + ^jug { <> }) + ( ^contents > 0 ) + ( ^empty > 0) +--> + ( ^operator +) + ( ^name pour + ^jug + ^into )} + +## Apply pour when contents of source jug i is less than or equal to the +## capacity available of the destination jug j. + +sp {water-jug*apply*pour*not-empty-source + (state ^name water-jug + ^operator ) + ( ^name pour + ^jug + ^into ) + ( ^volume + ^contents + ^empty ) + ( ^volume + ^contents { <= }) +--> + ( ^contents 0 -) + ( ^contents (+ ) - )} + +## Implement pour when contents of source jug i is more than the +## capacity available of the destination jug j. + +sp {water-jug*apply*pour*empty-source + (state ^name water-jug + ^operator ) + ( ^name pour + ^jug + ^into ) + ( ^volume + ^contents { > }) + ( ^volume + ^contents + ^empty ) +--> + ( ^contents (- ) - ) + ( ^contents -)} diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead.dm b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead.dm new file mode 100644 index 0000000..9c99a61 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead.dm @@ -0,0 +1,63 @@ +25 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 water-jug +SOAR_ID 4 +ENUMERATION 5 2 initialize initialize-water-jug-look-ahead +SOAR_ID 6 +ENUMERATION 7 1 empty +SOAR_ID 8 +ENUMERATION 9 1 pour +SOAR_ID 10 +INTEGER_RANGE 11 -2147483648 2147483647 +INTEGER_RANGE 12 -2147483648 2147483647 +SOAR_ID 13 +ENUMERATION 14 1 fill +INTEGER_RANGE 15 -2147483648 2147483647 +SOAR_ID 16 +SOAR_ID 17 +ENUMERATION 18 1 tie +ENUMERATION 19 1 operator +SOAR_ID 20 +ENUMERATION 21 1 water-jug +ENUMERATION 22 1 yes +ENUMERATION 23 1 jug +ENUMERATION 24 1 empty +36 +0 desired 16 +0 jug 10 +0 name 3 +0 operator 4 +0 operator 6 +0 operator 8 +0 operator 13 +0 problem-space 20 +0 success 16 +0 superstate 2 +0 type 1 +4 into 10 +4 jug 10 +4 name 5 +6 into 10 +6 jug 10 +6 name 7 +8 into 10 +8 jug 10 +8 name 9 +10 contents 11 +10 empty 12 +10 volume 15 +13 into 10 +13 name 14 +16 jug 10 +17 attribute 19 +17 impasse 18 +17 item 8 +17 item 13 +17 item 6 +17 superstate 0 +20 default-state-copy 22 +20 dont-copy 24 +20 name 21 +20 two-level-attributes 23 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead_source.soar new file mode 100644 index 0000000..ebde12b --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/water-jug-look-ahead_source.soar @@ -0,0 +1,16 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source empty.soar +source fill.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize.soar +source pour.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead.dm b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead.dm new file mode 100644 index 0000000..67b7a19 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead.dm @@ -0,0 +1,62 @@ +25 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 water-jug +SOAR_ID 4 +ENUMERATION 5 2 initialize initialize-water-jug-look-ahead +SOAR_ID 6 +ENUMERATION 7 1 empty +SOAR_ID 8 +ENUMERATION 9 1 pour +SOAR_ID 10 +INTEGER_RANGE 11 -2147483648 2147483647 +INTEGER_RANGE 12 -2147483648 2147483647 +SOAR_ID 13 +ENUMERATION 14 1 fill +INTEGER_RANGE 15 -2147483648 2147483647 +SOAR_ID 16 +SOAR_ID 17 +ENUMERATION 18 1 tie +ENUMERATION 19 1 operator +SOAR_ID 20 +ENUMERATION 21 1 water-jug +ENUMERATION 22 1 yes +ENUMERATION 23 1 jug +ENUMERATION 24 1 empty +35 +0 desired 16 +0 jug 10 +0 name 3 +0 operator 4 +0 operator 6 +0 operator 8 +0 operator 13 +0 problem-space 20 +0 superstate 2 +0 type 1 +4 into 10 +4 jug 10 +4 name 5 +6 into 10 +6 jug 10 +6 name 7 +8 into 10 +8 jug 10 +8 name 9 +10 contents 11 +10 empty 12 +10 volume 15 +13 into 10 +13 name 14 +16 jug 10 +17 attribute 19 +17 impasse 18 +17 item 8 +17 item 13 +17 item 6 +17 superstate 0 +20 default-state-copy 22 +20 dont-copy 24 +20 name 21 +20 two-level-attributes 23 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead_source.soar new file mode 100644 index 0000000..ebde12b --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug-look-ahead_source.soar @@ -0,0 +1,16 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source empty.soar +source fill.soar +source Impasse__Operator_Tie.soar +pushd Impasse__Operator_Tie +source Impasse__Operator_Tie_source.soar +popd +source initialize.soar +source pour.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug.dm b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug.dm new file mode 100644 index 0000000..e596379 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug.dm @@ -0,0 +1,40 @@ +16 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 waterjug +SOAR_ID 4 +ENUMERATION 5 1 initialize +SOAR_ID 6 +ENUMERATION 7 1 empty +SOAR_ID 8 +ENUMERATION 9 1 pour +SOAR_ID 10 +INTEGER_RANGE 11 -2147483648 2147483647 +INTEGER_RANGE 12 -2147483648 2147483647 +SOAR_ID 13 +ENUMERATION 14 1 fill +INTEGER_RANGE 15 -2147483648 2147483647 +22 +0 jug 10 +0 name 3 +0 operator 4 +0 operator 6 +0 operator 8 +0 operator 13 +0 superstate 2 +0 type 1 +4 into 10 +4 jug 10 +4 name 5 +6 into 10 +6 jug 10 +6 name 7 +8 into 10 +8 jug 10 +8 name 9 +10 contents 11 +10 empty 12 +10 volume 15 +13 into 10 +13 name 14 diff --git a/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug_source.soar b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug_source.soar new file mode 100644 index 0000000..281ba7d --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug-look-ahead/waterjug_source.soar @@ -0,0 +1,12 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source empty.soar +source fill.soar +source initialize.soar +source pour.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug.soar b/soar-8.5.2/demos/water-jug/water-jug.soar new file mode 100644 index 0000000..1c29318 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug.soar @@ -0,0 +1,3 @@ +pushd water-jug +source water-jug_source.soar +popd diff --git a/soar-8.5.2/demos/water-jug/water-jug.tcl b/soar-8.5.2/demos/water-jug/water-jug.tcl new file mode 100644 index 0000000..15dc24e --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug.tcl @@ -0,0 +1,233 @@ +# +# Water Jug puzzle +# +#----------------------------------------------------------------------- +# +# Tcl/Tk implementation of the water jug puzzle. +# +# last update: 5.26.00 Acar Altinsel +# + +package require Soar + +proc drawscreen {w} { + catch {destroy $w} + toplevel $w + + wm title $w "Water Jugs Demonstration" + wm iconname $w "Water Jugs" + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "Water Jugs Demonstration" + frame $w.frame -width 480 -height 360 -borderwidth 4 \ + -relief ridge -bg Grey70 + + button $w.solve -text Solve -command "run" + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" -command "init-soar; picture 0 0 state" + button $w.exch -text "Excise Chunks" -command "excise -chunks" + button $w.ok -text Close -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame -side top -padx 20 + pack $w.solve $w.stop $w.init $w.exch -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m + + picture 0 0 state +} + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} + +proc timer {pic} { + global solveslow + catch {destroy .water.frame.picture} + image create photo test -file $pic + label .water.frame.picture -image test -height 360 -width 480 + pack .water.frame.picture + set m 1 + after 100 set m 0 + vwait m +} + +proc picture {vol3 vol5 action} { +global soar_library + +switch $action { + 3pour5 { + for {set i $vol5} {$i <= 5} {incr i} { + if {$vol3 >=0} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol3 [expr $vol3 - 1] + incr vol5 + + } + } + + } + 5pour3 { + for {set i $vol3} {$i <= 3} {incr i} { + if {$vol5 >= 0} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol5 [expr $vol5 - 1] + incr vol3 + } + } + + } + dump3 { + for {set i $vol3} {$i >= 0} {set i [expr $i - 1]} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol3 [expr $vol3 - 1] + } + + } + dump5 { + + for {set i $vol5} {$i >= 0} {set i [expr $i - 1]} { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3$vol5.gif]" + timer $filename + set vol5 [expr $vol5 - 1] + } + + + } + fill3 { + set filename "[file join $soar_library .. demos water-jug images $action-$vol5.gif]" + timer $filename + + + } + fill5 { + set filename "[file join $soar_library .. demos water-jug images $action-$vol3.gif]" + timer $filename + } + state { + + set filename "[file join $soar_library .. demos water-jug images $vol3$vol5.gif]" + timer $filename + } + } +} + +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining water-jug solution method + +global soar_library +global interp_type + +excise -all +source water-jug.soar + +drawscreen .water + +### +### WATER JUG: +### MONITOR STATE AND +### OPERATORS +### + +sp {water-jug*monitor*state*picture + (state ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl |picture | | | | state|) +} + +sp {water-jug*monitor*operator-application*empty*picture + (state ^operator ) + ( ^name empty + ^empty-jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + + + --> + (tcl | picture | | | | dump| ) +} + +sp {water-jug*monitor*operator-application*fill*picture + (state ^operator ) + ( ^name fill + ^fill-jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | fill| ) +} + +sp {water-jug*monitor*operator-application*pour*picture + (state ^operator ) + ( ^name pour + ^empty-jug + ^fill-jug ) + ( ^volume ^contents ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | | |pour| ) +} + +sp {water-jug*monitor*tied-operator*empty*picture + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name empty ^empty-jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + + --> + (tcl | picture | | | | dump| ) +} + +sp {water-jug*monitor*tied-operator*fill*picture + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name fill ^fill-jug ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | fill| ) +} + +sp {water-jug*monitor*tied-operator*pour*picture + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name pour ^empty-jug ^fill-jug ) + ( ^volume ^contents ) + ( ^volume ^contents ) + + ( ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (tcl | picture | | | | | |pour| ) +} + +### eof of water-jug.soar (Version Type: Soar8) diff --git a/soar-8.5.2/demos/water-jug/water-jug.vsa b/soar-8.5.2/demos/water-jug/water-jug.vsa new file mode 100644 index 0000000..1edac52 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug.vsa @@ -0,0 +1,15 @@ +VERSION 4 +\water-jug\water-jug.dm +0 ROOT water-jug water-jug 1 +1 0 FOPERATOR _firstload _firstload.soar 2 +2 0 FOLDER all all 3 +3 0 FOLDER elaborations elaborations 4 +4 3 FOPERATOR empty empty.soar 5 +5 3 FOPERATOR goal-test goal-test.soar 6 +6 3 FOPERATOR monitor monitor.soar 7 +7 0 FOPERATOR _readme _readme.soar 8 +8 0 OPERATOR empty empty.soar 9 +9 0 OPERATOR fill fill.soar 10 +10 0 OPERATOR initialize-water-jug initialize-water-jug.soar 11 +11 0 OPERATOR pour pour.soar 12 +END diff --git a/soar-8.5.2/demos/water-jug/water-jug/_firstload.soar b/soar-8.5.2/demos/water-jug/water-jug/_firstload.soar new file mode 100644 index 0000000..561eed7 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/_firstload.soar @@ -0,0 +1,5 @@ +# learning is irrelevant for this formulation +learn -off + +# this helps Soar reorder conditions so matching is more efficient +multi-attributes jug 3 diff --git a/soar-8.5.2/demos/water-jug/water-jug/_readme.soar b/soar-8.5.2/demos/water-jug/water-jug/_readme.soar new file mode 100644 index 0000000..3d14d29 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/_readme.soar @@ -0,0 +1,27 @@ +# water-jug +# John E. Laird +# University of Michigan +# May 25, 2004 +# Soar version 8.5.1 + +### +### ABSTRACT. These Soar productions implement the water-jug task. +### The task is to find the sequence of steps that fill the three gallon +### jug with one gallon of water. There are a well that has an infinite +### amount of water, a five gallon jug, and a three gallon jug. +### + +### +### DESCRIPTION. The task problem space has three operators: empty, +### fill, and pour. Empty empties a jug into the well. Fill fills up +### a jug from the well. Pour pours some or all of the contents +### from one jug into the other jug. Pour can only pour out the contents +### of the jug until the source is empty or the destination is full. +### State Structure: Each jug has slots to record its capacity [volume], +### the amount of water it contains [contents], and the capacity +### available [empty] which is the volume minus the contents. +### (state s1 ^jug j1) +### (jug j1 ^volume v1 ^contents c1 ^empty f1), +### where v1, c1, and f1 are numbers. +### + diff --git a/soar-8.5.2/demos/water-jug/water-jug/all/all_source.soar b/soar-8.5.2/demos/water-jug/water-jug/all/all_source.soar new file mode 100644 index 0000000..e69de29 diff --git a/soar-8.5.2/demos/water-jug/water-jug/comment.dm b/soar-8.5.2/demos/water-jug/water-jug/comment.dm new file mode 100644 index 0000000..d38d768 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/comment.dm @@ -0,0 +1,20 @@ +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 diff --git a/soar-8.5.2/demos/water-jug/water-jug/elaborations/elaborations_source.soar b/soar-8.5.2/demos/water-jug/water-jug/elaborations/elaborations_source.soar new file mode 100644 index 0000000..29ea54e --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/elaborations/elaborations_source.soar @@ -0,0 +1,3 @@ +source empty.soar +source goal-test.soar +source monitor.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug/elaborations/empty.soar b/soar-8.5.2/demos/water-jug/water-jug/elaborations/empty.soar new file mode 100644 index 0000000..baec60c --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/elaborations/empty.soar @@ -0,0 +1,11 @@ +# If the state is named water-jug and a jug can hold volume v and +# currently has contents c, +# then add that it has v – c available (empty) space. + +sp {water-jug*elaborate*empty + (state ^name water-jug + ^jug ) + ( ^contents + ^volume ) +--> + ( ^empty (- ))} diff --git a/soar-8.5.2/demos/water-jug/water-jug/elaborations/goal-test.soar b/soar-8.5.2/demos/water-jug/water-jug/elaborations/goal-test.soar new file mode 100644 index 0000000..604e688 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/elaborations/goal-test.soar @@ -0,0 +1,10 @@ +# If the task is water-jug and there is a jug with volume three and +# contents one, write that the problem has been solved and halt. + +sp {water-jug*detect*goal*achieved + (state ^name water-jug + ^jug ) + ( ^volume 3 ^contents 1) +--> + (write (crlf) |The problem has been solved.|) + (halt)} diff --git a/soar-8.5.2/demos/water-jug/water-jug/elaborations/monitor.soar b/soar-8.5.2/demos/water-jug/water-jug/elaborations/monitor.soar new file mode 100644 index 0000000..c26cbb2 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/elaborations/monitor.soar @@ -0,0 +1,41 @@ + +### +### water-jug: +### MONITOR STATE AND +### OPERATORS +### + +sp {water-jug*monitor*state + (state ^name water-jug + ^jug ) + ( ^volume 5 ^contents ) + ( ^volume 3 ^contents ) + --> + (write (crlf) | 5:| | 3:| )} + +sp {water-jug*monitor*operator-application*empty + (state ^name water-jug + ^operator ) + ( ^name empty + ^empty-jug.volume ) + --> + (write (crlf) | EMPTY(| |)|)} + +sp {water-jug*monitor*operator-application*fill + (state ^name water-jug + ^operator ) + ( ^name fill + ^fill-jug.volume ) + --> + (write (crlf) | FILL(| |)|)} + +sp {water-jug*monitor*operator-application*pour + (state ^name water-jug + ^operator ) + ( ^name pour + ^empty-jug + ^fill-jug ) + ( ^volume ^contents ) + ( ^volume ^contents ) + --> + (write (crlf) | POUR(| |:| |,| |:| |)|)} diff --git a/soar-8.5.2/demos/water-jug/water-jug/empty.soar b/soar-8.5.2/demos/water-jug/water-jug/empty.soar new file mode 100644 index 0000000..464a4f6 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/empty.soar @@ -0,0 +1,25 @@ +# If the task is water-jug and there is a jug that is not empty, +# then propose emptying that jug. + +sp {water-jug*propose*empty + (state ^name water-jug + ^jug ) + ( ^contents > 0) +--> + ( ^operator + =) + ( ^name empty + ^empty-jug )} + +# If the task is water-jug and the empty operator is selected for a given jug, +# then set that jug’s contents to be 0 and its empty to be its volume. +sp {water-jug*apply*empty + (state ^name water-jug + ^operator + ^jug ) + ( ^name empty + ^empty-jug ) + ( ^volume + ^contents ) +--> + ( ^contents 0 + ^contents - )} \ No newline at end of file diff --git a/soar-8.5.2/demos/water-jug/water-jug/fill.soar b/soar-8.5.2/demos/water-jug/water-jug/fill.soar new file mode 100644 index 0000000..3633957 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/fill.soar @@ -0,0 +1,26 @@ +# If the task is water-jug and there is a jug that is not full, +# then propose filling that jug. + +sp {water-jug*propose*fill + (state ^name water-jug + ^jug ) + ( ^empty > 0) +--> + ( ^operator + =) + ( ^name fill + ^fill-jug )} + +# If the task is water-jug and the fill operator is selected for a given jug, +# then set that jug’s contents to be its volume. + +sp {water-jug*apply*fill + (state ^name water-jug + ^operator + ^jug ) + ( ^name fill + ^fill-jug ) + ( ^volume + ^contents ) +--> + ( ^contents + -)} diff --git a/soar-8.5.2/demos/water-jug/water-jug/initialize-water-jug.soar b/soar-8.5.2/demos/water-jug/water-jug/initialize-water-jug.soar new file mode 100644 index 0000000..d2c20cc --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/initialize-water-jug.soar @@ -0,0 +1,25 @@ +# Operator that initializes the water jug task +# initialize-water-jug + +# If no task is selected, +# then propose the initialize-water-jug operator. + +sp {water-jug*propose*initialize-water-jug + (state ^superstate nil + -^name) +--> + ( ^operator +) + ( ^name initialize-water-jug)} + +# If the initialize-water-jug operator is selected, +# then create an empty 5 gallon jug and an empty 3 gallon jug. + +sp {water-jug*apply*initialize-water-jug + (state ^operator.name initialize-water-jug) +--> + ( ^name water-jug + ^jug ) + ( ^volume 3 + ^contents 0) + ( ^volume 5 + ^contents 0)} diff --git a/soar-8.5.2/demos/water-jug/water-jug/pour.soar b/soar-8.5.2/demos/water-jug/water-jug/pour.soar new file mode 100644 index 0000000..caf9092 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/pour.soar @@ -0,0 +1,56 @@ +# If the task is water-jug and there is a jug that is not full and the other jug is not empty, +# then propose pouring water from the second jug into the first jug. + +sp {water-jug*propose*pour + (state ^name water-jug + ^jug { <> }) + ( ^contents > 0 ) + ( ^empty > 0) +--> + ( ^operator + =) + ( ^name pour + ^empty-jug + ^fill-jug )} + +# If the task is water-jug and the pour operator is selected, +# and the contents of the jug being emptied are less than or equal to +# the empty amount of the jug being filled, +# then set the contents of the jug being emptied to 0; +# set the contents of the jug being filled to the sum of the two jugs. + +sp {water-jug*apply*pour*not-empty-source + (state ^name water-jug + ^operator ) + ( ^name pour + ^empty-jug + ^fill-jug ) + ( ^volume + ^contents + ^empty ) + ( ^volume + ^contents { <= }) +--> + ( ^contents 0 -) + ( ^contents (+ ) - )} + +# If the task is water-jug and the pour operator is selected, and +# the contents of the jug being emptied are greater than the empty amount +# of the jug being filled, +# then set the contents of the jug being emptied to its contents minus the +# empty of the jug being filled; +# set the contents of the jug filled to its volume. + +sp {water-jug*apply*pour*empty-source + (state ^name water-jug + ^operator ) + ( ^name pour + ^empty-jug + ^fill-jug ) + ( ^volume + ^contents { > }) + ( ^volume + ^contents + ^empty ) +--> + ( ^contents (- ) - ) + ( ^contents -)} diff --git a/soar-8.5.2/demos/water-jug/water-jug/water-jug.dm b/soar-8.5.2/demos/water-jug/water-jug/water-jug.dm new file mode 100644 index 0000000..6d53a4d --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/water-jug.dm @@ -0,0 +1,38 @@ +16 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 water-jug +SOAR_ID 4 +ENUMERATION 5 1 initialize-water-jug +SOAR_ID 6 +ENUMERATION 7 1 empty +SOAR_ID 8 +ENUMERATION 9 1 pour +SOAR_ID 10 +INTEGER_RANGE 11 -2147483648 2147483647 +INTEGER_RANGE 12 -2147483648 2147483647 +SOAR_ID 13 +ENUMERATION 14 1 fill +INTEGER_RANGE 15 -2147483648 2147483647 +20 +0 jug 10 +0 name 3 +0 operator 4 +0 operator 6 +0 operator 8 +0 operator 13 +0 superstate 2 +0 type 1 +4 name 5 +6 empty-jug 10 +6 name 7 +8 empty-jug 10 +8 fill-jug 10 +8 fill-jug 10 +8 name 9 +10 contents 11 +10 empty 12 +10 volume 15 +13 fill-jug 10 +13 name 14 diff --git a/soar-8.5.2/demos/water-jug/water-jug/water-jug_source.soar b/soar-8.5.2/demos/water-jug/water-jug/water-jug_source.soar new file mode 100644 index 0000000..4805419 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/water-jug_source.soar @@ -0,0 +1,12 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source empty.soar +source fill.soar +source initialize-water-jug.soar +source pour.soar diff --git a/soar-8.5.2/demos/water-jug/water-jug/waterjug.dm b/soar-8.5.2/demos/water-jug/water-jug/waterjug.dm new file mode 100644 index 0000000..6d53a4d --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/waterjug.dm @@ -0,0 +1,38 @@ +16 +SOAR_ID 0 +ENUMERATION 1 1 state +ENUMERATION 2 1 nil +ENUMERATION 3 1 water-jug +SOAR_ID 4 +ENUMERATION 5 1 initialize-water-jug +SOAR_ID 6 +ENUMERATION 7 1 empty +SOAR_ID 8 +ENUMERATION 9 1 pour +SOAR_ID 10 +INTEGER_RANGE 11 -2147483648 2147483647 +INTEGER_RANGE 12 -2147483648 2147483647 +SOAR_ID 13 +ENUMERATION 14 1 fill +INTEGER_RANGE 15 -2147483648 2147483647 +20 +0 jug 10 +0 name 3 +0 operator 4 +0 operator 6 +0 operator 8 +0 operator 13 +0 superstate 2 +0 type 1 +4 name 5 +6 empty-jug 10 +6 name 7 +8 empty-jug 10 +8 fill-jug 10 +8 fill-jug 10 +8 name 9 +10 contents 11 +10 empty 12 +10 volume 15 +13 fill-jug 10 +13 name 14 diff --git a/soar-8.5.2/demos/water-jug/water-jug/waterjug_source.soar b/soar-8.5.2/demos/water-jug/water-jug/waterjug_source.soar new file mode 100644 index 0000000..4805419 --- /dev/null +++ b/soar-8.5.2/demos/water-jug/water-jug/waterjug_source.soar @@ -0,0 +1,12 @@ +source _firstload.soar +pushd all +source all_source.soar +popd +pushd elaborations +source elaborations_source.soar +popd +source _readme.soar +source empty.soar +source fill.soar +source initialize-water-jug.soar +source pour.soar diff --git a/soar-8.5.2/demos_soar7/FSBox/FSBox.ps b/soar-8.5.2/demos_soar7/FSBox/FSBox.ps new file mode 100644 index 0000000..630679f Binary files /dev/null and b/soar-8.5.2/demos_soar7/FSBox/FSBox.ps differ diff --git a/soar-8.5.2/demos_soar7/FSBox/FSBox.tcl b/soar-8.5.2/demos_soar7/FSBox/FSBox.tcl new file mode 100644 index 0000000..3eb9b0f --- /dev/null +++ b/soar-8.5.2/demos_soar7/FSBox/FSBox.tcl @@ -0,0 +1,988 @@ +# XFNoParsing +# Program: template +# Description: file selector box +# +# $Header: /cvsroot/soar/soar/demos_soar7/FSBox/FSBox.tcl,v 1.1.1.1 2003/06/16 14:03:11 swallace Exp $ + +global fsBox +set fsBox(activeBackground) "" +set fsBox(activeForeground) "" +set fsBox(background) "" +set fsBox(font) "" +set fsBox(foreground) "" +set fsBox(scrollActiveForeground) "" +set fsBox(scrollBackground) "" +set fsBox(scrollForeground) "" +set fsBox(scrollSide) left +set fsBox(showPixmap) 0 +set fsBox(name) "" +set fsBox(path) [pwd] +set fsBox(pattern) * +set fsBox(all) 0 +set fsBox(button) 0 +set fsBox(extensions) 0 +set fsBox(internalPath) [pwd] + +proc FSBox {{fsBoxMessage "Select file:"} {fsBoxFileName ""} {fsBoxActionOk ""} {fsBoxActionCancel ""}} {# xf ignore me 5 +########## +# Procedure: FSBox +# Description: show file selector box +# Arguments: fsBoxMessage - the text to display +# fsBoxFileName - a file name that should be selected +# fsBoxActionOk - the action that should be performed on ok +# fsBoxActionCancel - the action that should be performed on cancel +# Returns: the filename that was selected, or nothing +# Sideeffects: none +########## +# +# global fsBox(activeBackground) - active background color +# global fsBox(activeForeground) - active foreground color +# global fsBox(background) - background color +# global fsBox(font) - text font +# global fsBox(foreground) - foreground color +# global fsBox(extensions) - scan directory for extensions +# global fsBox(scrollActiveForeground) - scrollbar active background color +# global fsBox(scrollBackground) - scrollbar background color +# global fsBox(scrollForeground) - scrollbar foreground color +# global fsBox(scrollSide) - side where scrollbar is located + + global fsBox + + set tmpButtonOpt "" + set tmpFrameOpt "" + set tmpMessageOpt "" + set tmpScaleOpt "" + set tmpScrollOpt "" + if {"$fsBox(activeBackground)" != ""} { + append tmpButtonOpt "-activebackground \"$fsBox(activeBackground)\" " + } + if {"$fsBox(activeForeground)" != ""} { + append tmpButtonOpt "-activeforeground \"$fsBox(activeForeground)\" " + } + if {"$fsBox(background)" != ""} { + append tmpButtonOpt "-background \"$fsBox(background)\" " + append tmpFrameOpt "-background \"$fsBox(background)\" " + append tmpMessageOpt "-background \"$fsBox(background)\" " + } + if {"$fsBox(font)" != ""} { + append tmpButtonOpt "-font \"$fsBox(font)\" " + append tmpMessageOpt "-font \"$fsBox(font)\" " + } + if {"$fsBox(foreground)" != ""} { + append tmpButtonOpt "-foreground \"$fsBox(foreground)\" " + append tmpMessageOpt "-foreground \"$fsBox(foreground)\" " + } + if {"$fsBox(scrollActiveForeground)" != ""} { + append tmpScrollOpt "-activeforeground \"$fsBox(scrollActiveForeground)\" " + } + if {"$fsBox(scrollBackground)" != ""} { + append tmpScrollOpt "-background \"$fsBox(scrollBackground)\" " + } + if {"$fsBox(scrollForeground)" != ""} { + append tmpScrollOpt "-foreground \"$fsBox(scrollForeground)\" " + } + + if {[file exists [file tail $fsBoxFileName]] && + [IsAFile [file tail $fsBoxFileName]]} { + set fsBox(name) [file tail $fsBoxFileName] + } { + set fsBox(name) "" + } + if {[file exists $fsBoxFileName] && [IsADir $fsBoxFileName]} { + set fsBox(path) $fsBoxFileName + } { + if {"[file rootname $fsBoxFileName]" != "."} { + set fsBox(path) [file rootname $fsBoxFileName] + } + } + if {$fsBox(showPixmap)} { + set fsBox(path) [string trimleft $fsBox(path) @] + } + if {"$fsBox(path)" != "" && [file exists $fsBox(path)] && + [IsADir $fsBox(path)]} { + set fsBox(internalPath) $fsBox(path) + } { + if {"$fsBox(internalPath)" == "" || + ![file exists $fsBox(internalPath)]} { + set fsBox(internalPath) [pwd] + } + } + # build widget structure + + # start build of toplevel + if {"[info commands XFDestroy]" != ""} { + catch {XFDestroy .fsBox} + } { + catch {destroy .fsBox} + } + toplevel .fsBox \ + -borderwidth 0 + catch ".fsBox config $tmpFrameOpt" + wm geometry .fsBox 350x300 + wm title .fsBox {File select box} + wm maxsize .fsBox 1000 1000 + wm minsize .fsBox 100 100 + # end build of toplevel + + label .fsBox.message1 \ + -anchor c \ + -relief raised \ + -text "$fsBoxMessage" + catch ".fsBox.message1 config $tmpMessageOpt" + + frame .fsBox.frame1 \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.frame1 config $tmpFrameOpt" + + button .fsBox.frame1.ok \ + -text "OK" \ + -command " + global fsBox + set fsBox(name) \[.fsBox.file.file get\] + if {$fsBox(showPixmap)} { + set fsBox(path) @\[.fsBox.path.path get\] + } { + set fsBox(path) \[.fsBox.path.path get\] + } + set fsBox(internalPath) \[.fsBox.path.path get\] + $fsBoxActionOk + if {\"\[info commands XFDestroy\]\" != \"\"} { + catch {XFDestroy .fsBox} + } { + catch {destroy .fsBox} + }" + catch ".fsBox.frame1.ok config $tmpButtonOpt" + + button .fsBox.frame1.rescan \ + -text "Rescan" \ + -command { + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all)} + catch ".fsBox.frame1.rescan config $tmpButtonOpt" + + button .fsBox.frame1.cancel \ + -text "Cancel" \ + -command " + global fsBox + set fsBox(name) {} + set fsBox(path) {} + $fsBoxActionCancel + if {\"\[info commands XFDestroy\]\" != \"\"} { + catch {XFDestroy .fsBox} + } { + catch {destroy .fsBox} + }" + catch ".fsBox.frame1.cancel config $tmpButtonOpt" + + if {$fsBox(showPixmap)} { + frame .fsBox.frame2 \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.frame2 config $tmpFrameOpt" + + scrollbar .fsBox.frame2.scrollbar3 \ + -command {.fsBox.frame2.canvas2 xview} \ + -orient {horizontal} \ + -relief {raised} + catch ".fsBox.frame2.scrollbar3 config $tmpScrollOpt" + + scrollbar .fsBox.frame2.scrollbar1 \ + -command {.fsBox.frame2.canvas2 yview} \ + -relief {raised} + catch ".fsBox.frame2.scrollbar1 config $tmpScrollOpt" + + canvas .fsBox.frame2.canvas2 \ + -confine {true} \ + -relief {raised} \ + -scrollregion {0c 0c 20c 20c} \ + -width {100} \ + -xscrollcommand {.fsBox.frame2.scrollbar3 set} \ + -yscrollcommand {.fsBox.frame2.scrollbar1 set} + catch ".fsBox.frame2.canvas2 config $tmpFrameOpt" + + .fsBox.frame2.canvas2 addtag currentBitmap withtag [.fsBox.frame2.canvas2 create bitmap 5 5 -anchor nw] + } + + frame .fsBox.path \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.path config $tmpFrameOpt" + + frame .fsBox.path.paths \ + -borderwidth 2 \ + -relief raised + catch ".fsBox.path.paths config $tmpFrameOpt" + + menubutton .fsBox.path.paths.paths \ + -borderwidth 0 \ + -menu ".fsBox.path.paths.paths.menu" \ + -relief flat \ + -text "Pathname:" + catch ".fsBox.path.paths.paths config $tmpButtonOpt" + + menu .fsBox.path.paths.paths.menu + catch ".fsBox.path.paths.paths.menu config $tmpButtonOpt" + + .fsBox.path.paths.paths.menu add command \ + -label "[string trimright $fsBox(internalPath) {/@}]" \ + -command " + global fsBox + FSBoxFSShow \[.fsBox.path.path get\] \ + \[.fsBox.pattern.pattern get\] \$fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 [string trimright $fsBox(internalPath) {/@}]" + + entry .fsBox.path.path \ + -relief raised + catch ".fsBox.path.path config $tmpMessageOpt" + + if {![IsADir $fsBox(internalPath)]} { + set $fsBox(internalPath) [pwd] + } + .fsBox.path.path insert 0 $fsBox(internalPath) + + frame .fsBox.pattern \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.pattern config $tmpFrameOpt" + + frame .fsBox.pattern.patterns \ + -borderwidth 2 \ + -relief raised + catch ".fsBox.pattern.patterns config $tmpFrameOpt" + + menubutton .fsBox.pattern.patterns.patterns \ + -borderwidth 0 \ + -menu ".fsBox.pattern.patterns.patterns.menu" \ + -relief flat \ + -text "Selection pattern:" + catch ".fsBox.pattern.patterns.patterns config $tmpButtonOpt" + + menu .fsBox.pattern.patterns.patterns.menu + catch ".fsBox.pattern.patterns.patterns.menu config $tmpButtonOpt" + + .fsBox.pattern.patterns.patterns.menu add checkbutton \ + -label "Scan extensions" \ + -variable fsBoxExtensions \ + -command { + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all)} + + entry .fsBox.pattern.pattern \ + -relief raised + catch ".fsBox.pattern.pattern config $tmpMessageOpt" + + .fsBox.pattern.pattern insert 0 $fsBox(pattern) + + frame .fsBox.files \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.files config $tmpFrameOpt" + + scrollbar .fsBox.files.vscroll \ + -relief raised \ + -command ".fsBox.files.files yview" + catch ".fsBox.files.vscroll config $tmpScrollOpt" + + scrollbar .fsBox.files.hscroll \ + -orient horiz \ + -relief raised \ + -command ".fsBox.files.files xview" + catch ".fsBox.files.hscroll config $tmpScrollOpt" + + listbox .fsBox.files.files \ + -exportselection false \ + -relief raised \ + -xscrollcommand ".fsBox.files.hscroll set" \ + -yscrollcommand ".fsBox.files.vscroll set" + catch ".fsBox.files.files config $tmpMessageOpt" + + frame .fsBox.file \ + -borderwidth 0 \ + -relief raised + catch ".fsBox.file config $tmpFrameOpt" + + label .fsBox.file.labelfile \ + -relief raised \ + -text "Filename:" + catch ".fsBox.file.labelfile config $tmpMessageOpt" + + entry .fsBox.file.file \ + -relief raised + catch ".fsBox.file.file config $tmpMessageOpt" + + .fsBox.file.file delete 0 end + .fsBox.file.file insert 0 $fsBox(name) + + checkbutton .fsBox.pattern.all \ + -offvalue 0 \ + -onvalue 1 \ + -text "Show all files" \ + -variable fsBox(all) \ + -command { + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all)} + catch ".fsBox.pattern.all config $tmpButtonOpt" + + FSBoxFSShow $fsBox(internalPath) $fsBox(pattern) $fsBox(all) + + # bindings + bind .fsBox.files.files " + FSBoxFSFileSelectDouble %W $fsBox(showPixmap) \{$fsBoxActionOk\} %y" + bind .fsBox.files.files " + FSBoxFSFileSelect %W $fsBox(showPixmap) %y" + bind .fsBox.files.files " + FSBoxFSFileSelect %W $fsBox(showPixmap) %y" + bind .fsBox.files.files " + FSBoxFSFileSelect %W $fsBox(showPixmap) %y" + bind .fsBox.files.files " + FSBoxFSFileSelect %W $fsBox(showPixmap) %y" + + bind .fsBox.path.path { + FSBoxFSNameComplete path} + bind .fsBox.path.path { + global tkVersion + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all) + FSBoxFSInsertPath + if {$tkVersion >= 3.0} { + .fsBox.file.file icursor end + } { + .fsBox.file.file cursor end + } + focus .fsBox.file.file} + catch "bind .fsBox.path.path {}" + bind .fsBox.path.path { + global tkVersion + if {$tkVersion >= 3.0} { + .fsBox.file.file icursor end + } { + .fsBox.file.file cursor end + } + focus .fsBox.file.file} + + bind .fsBox.file.file { + FSBoxFSNameComplete file} + bind .fsBox.file.file " + global fsBox + set fsBox(name) \[.fsBox.file.file get\] + if {$fsBox(showPixmap)} { + set fsBox(path) @\[.fsBox.path.path get\] + } { + set fsBox(path) \[.fsBox.path.path get\] + } + set fsBox(internalPath) \[.fsBox.path.path get\] + $fsBoxActionOk + if {\"\[info commands XFDestroy\]\" != \"\"} { + catch {XFDestroy .fsBox} + } { + catch {destroy .fsBox} + }" + bind .fsBox.file.file { + global tkVersion + if {$tkVersion >= 3.0} { + .fsBox.path.path icursor end + } { + .fsBox.path.path cursor end + } + focus .fsBox.path.path} + bind .fsBox.file.file { + global tkVersion + if {$tkVersion >= 3.0} { + .fsBox.pattern.pattern icursor end + } { + .fsBox.pattern.pattern cursor end + } + focus .fsBox.pattern.pattern} + + bind .fsBox.pattern.pattern { + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all)} + bind .fsBox.pattern.pattern { + global tkVersion + if {$tkVersion >= 3.0} { + .fsBox.file.file icursor end + } { + .fsBox.file.file cursor end + } + focus .fsBox.file.file} + catch "bind .fsBox.pattern.pattern {}" + + # packing + pack append .fsBox.files \ + .fsBox.files.vscroll "$fsBox(scrollSide) filly" \ + .fsBox.files.hscroll {bottom fillx} \ + .fsBox.files.files {left fill expand} + pack append .fsBox.file \ + .fsBox.file.labelfile {left} \ + .fsBox.file.file {left fill expand} + pack append .fsBox.frame1 \ + .fsBox.frame1.ok {left fill expand} \ + .fsBox.frame1.rescan {left fill expand} \ + .fsBox.frame1.cancel {left fill expand} + pack append .fsBox.path.paths \ + .fsBox.path.paths.paths {left} + pack append .fsBox.pattern.patterns \ + .fsBox.pattern.patterns.patterns {left} + pack append .fsBox.path \ + .fsBox.path.paths {left} \ + .fsBox.path.path {left fill expand} + pack append .fsBox.pattern \ + .fsBox.pattern.patterns {left} \ + .fsBox.pattern.all {right fill} \ + .fsBox.pattern.pattern {left fill expand} + if {$fsBox(showPixmap)} { + pack append .fsBox.frame2 \ + .fsBox.frame2.scrollbar1 {left filly} \ + .fsBox.frame2.canvas2 {top expand fill} \ + .fsBox.frame2.scrollbar3 {top fillx} + + pack append .fsBox \ + .fsBox.message1 {top fill} \ + .fsBox.frame1 {bottom fill} \ + .fsBox.pattern {bottom fill} \ + .fsBox.file {bottom fill} \ + .fsBox.path {bottom fill} \ + .fsBox.frame2 {right fill} \ + .fsBox.files {left fill expand} + } { + pack append .fsBox \ + .fsBox.message1 {top fill} \ + .fsBox.frame1 {bottom fill} \ + .fsBox.pattern {bottom fill} \ + .fsBox.file {bottom fill} \ + .fsBox.path {bottom fill} \ + .fsBox.files {left fill expand} + } + + if {"$fsBoxActionOk" == "" && "$fsBoxActionCancel" == ""} { + # wait for the box to be destroyed + update idletask + grab .fsBox + tkwait window .fsBox + + if {"[string trim $fsBox(path)]" != "" || + "[string trim $fsBox(name)]" != ""} { + if {"[string trimleft [string trim $fsBox(name)] /]" == ""} { + return [string trimright [string trim $fsBox(path)] /] + } { + return [string trimright [string trim $fsBox(path)] /]/[string trimleft [string trim $fsBox(name)] /] + } + } + } +} + +########## +# Procedure: FSBoxFSFileSelect +# Description: select file name +# Arguments: fsBoxW - the widget +# fsBoxShowPixmap - show pixmaps +# fsBoxY - the y position in the listbox +# Returns: none +# Sideeffects: none +########## +proc FSBoxFSFileSelect {fsBoxW fsBoxShowPixmap fsBoxY} {# xf ignore me 6 + global fsBox + + FSBoxBindSelectOne $fsBoxW $fsBoxY + set fsBoxNearest [$fsBoxW nearest $fsBoxY] + if {$fsBoxNearest >= 0} { + set fsBoxTmpEntry [$fsBoxW get $fsBoxNearest] + if {"[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "/" || + "[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "@"} { + set fsBoxFileName [string range $fsBoxTmpEntry 0 \ + [expr [string length $fsBoxTmpEntry]-2]] + if {![IsADir [string trimright $fsBox(internalPath)/$fsBoxFileName @]] && + ![IsASymlink [string trimright $fsBox(internalPath)/$fsBoxFileName @]]} { + set fsBoxFileName $fsBoxTmpEntry + } + } { + if {"[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "*"} { + set fsBoxFileName [string range $fsBoxTmpEntry 0 \ + [expr [string length $fsBoxTmpEntry]-2]] + if {![file executable $fsBox(internalPath)/$fsBoxFileName]} { + set fsBoxFileName $fsBoxTmpEntry + } + } { + set fsBoxFileName $fsBoxTmpEntry + } + } + if {![IsADir [string trimright $fsBox(internalPath)/$fsBoxFileName @]]} { + set fsBox(name) $fsBoxFileName + .fsBox.file.file delete 0 end + .fsBox.file.file insert 0 $fsBox(name) + if {$fsBoxShowPixmap} { + catch ".fsBox.frame2.canvas2 itemconfigure currentBitmap -bitmap \"@$fsBox(internalPath)/$fsBox(name)\"" + } + } + } +} + +########## +# Procedure: FSBoxFSFileSelectDouble +# Description: select file when double clicked +# Arguments: fsBoxW - the widget +# fsBoxShowPixmap - show pixmaps +# fsBoxAction - the action bound to the ok button +# fsBoxY - the y position in the listbox +# Returns: none +# Sideeffects: none +########## +proc FSBoxFSFileSelectDouble {fsBoxW fsBoxShowPixmap fsBoxAction fsBoxY} {# xf ignore me 6 + global fsBox + + FSBoxBindSelectOne $fsBoxW $fsBoxY + set fsBoxNearest [$fsBoxW nearest $fsBoxY] + if {$fsBoxNearest >= 0} { + set fsBoxTmpEntry [$fsBoxW get $fsBoxNearest] + if {"$fsBoxTmpEntry" == "../"} { + set fsBoxTmpEntry [string trimright [string trim $fsBox(internalPath)] "@/"] + if {"$fsBoxTmpEntry" == ""} { + return + } + FSBoxFSShow [file dirname $fsBoxTmpEntry] \ + [.fsBox.pattern.pattern get] $fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 $fsBox(internalPath) + } { + if {"[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "/" || + "[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "@"} { + set fsBoxFileName [string range $fsBoxTmpEntry 0 \ + [expr [string length $fsBoxTmpEntry]-2]] + if {![IsADir [string trimright $fsBox(internalPath)/$fsBoxFileName @]] && + ![IsASymlink [string trimright $fsBox(internalPath)/$fsBoxFileName @]]} { + set fsBoxFileName $fsBoxTmpEntry + } + } { + if {"[string index $fsBoxTmpEntry \ + [expr [string length $fsBoxTmpEntry]-1]]" == "*"} { + set fsBoxFileName [string range $fsBoxTmpEntry 0 \ + [expr [string length $fsBoxTmpEntry]-2]] + if {![file executable $fsBox(internalPath)/$fsBoxFileName]} { + set fsBoxFileName $fsBoxTmpEntry + } + } { + set fsBoxFileName $fsBoxTmpEntry + } + } + if {[IsADir [string trimright $fsBox(internalPath)/$fsBoxFileName @]]} { + set fsBox(internalPath) "[string trimright $fsBox(internalPath) {/@}]/$fsBoxFileName" + FSBoxFSShow $fsBox(internalPath) \ + [.fsBox.pattern.pattern get] $fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 $fsBox(internalPath) + } { + set fsBox(name) $fsBoxFileName + if {$fsBoxShowPixmap} { + set fsBox(path) @$fsBox(internalPath) + } { + set fsBox(path) $fsBox(internalPath) + } + if {"$fsBoxAction" != ""} { + eval "global fsBox; $fsBoxAction" + } + if {"[info commands XFDestroy]" != ""} { + catch {XFDestroy .fsBox} + } { + catch {destroy .fsBox} + } + } + } + } +} + +########## +# Procedure: FSBoxFSInsertPath +# Description: insert current pathname into menu +# Arguments: none +# Returns: none +# Sideeffects: none +########## +proc FSBoxFSInsertPath {} {# xf ignore me 6 + global fsBox + + set fsBoxLast [.fsBox.path.paths.paths.menu index last] + set fsBoxNewEntry [string trimright [.fsBox.path.path get] "/@"] + for {set fsBoxCounter 0} {$fsBoxCounter <= $fsBoxLast} {incr fsBoxCounter 1} { + if {"$fsBoxNewEntry" == \ + "[lindex [.fsBox.path.paths.paths.menu entryconfigure \ + $fsBoxCounter -label] 4]"} { + return + } + } + if {$fsBoxLast < 9} { + .fsBox.path.paths.paths.menu add command \ + -label "$fsBoxNewEntry" \ + -command " + global fsBox + FSBoxFSShow $fsBoxNewEntry \ + \[.fsBox.pattern.pattern get\] \$fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 $fsBoxNewEntry" + } { + for {set fsBoxCounter 0} {$fsBoxCounter < $fsBoxLast} {incr fsBoxCounter 1} { + .fsBox.path.paths.paths.menu entryconfigure \ + $fsBoxCounter -label \ + [lindex [.fsBox.path.paths.paths.menu entryconfigure \ + [expr $fsBoxCounter+1] -label] 4] + .fsBox.path.paths.paths.menu entryconfigure $fsBoxCounter \ + -command " + global fsBox + FSBoxFSShow [lindex [.fsBox.path.paths.paths.menu entryconfigure \ + [expr $fsBoxCounter+1] -label] 4] \ + \[.fsBox.pattern.pattern get\] \$fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 [lindex \ + [.fsBox.path.paths.paths.menu entryconfigure \ + [expr $fsBoxCounter+1] -label] 4]" + } + .fsBox.path.paths.paths.menu entryconfigure $fsBoxLast \ + -label "$fsBoxNewEntry" + .fsBox.path.paths.paths.menu entryconfigure $fsBoxCounter \ + -command " + global fsBox + FSBoxFSShow \[.fsBox.path.path get\] \ + \[.fsBox.pattern.pattern get\] \$fsBox(all) + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 $fsBoxNewEntry" + } +} + +########## +# Procedure: FSBoxFSNameComplete +# Description: perform name completion for fs box +# Arguments: fsBoxType - the type we want to complete (path or file) +# Returns: none +# Sideeffects: none +########## +proc FSBoxFSNameComplete {fsBoxType} {# xf ignore me 6 + global tkVersion + global fsBox + + set fsBoxNewFile "" + if {"$fsBoxType" == "path"} { + set fsBoxDirName [file dirname [.fsBox.path.path get]] + set fsBoxFileName [file tail [.fsBox.path.path get]] + } { + set fsBoxDirName [file dirname [.fsBox.path.path get]/] + set fsBoxFileName [file tail [.fsBox.file.file get]] + } + + set fsBoxNewFile "" + if {[IsADir [string trimright $fsBoxDirName @]]} { + catch "glob -nocomplain $fsBoxDirName/${fsBoxFileName}*" fsBoxResult + foreach fsBoxCounter $fsBoxResult { + if {"$fsBoxNewFile" == ""} { + set fsBoxNewFile [file tail $fsBoxCounter] + } { + if {"[string index [file tail $fsBoxCounter] 0]" != + "[string index $fsBoxNewFile 0]"} { + set fsBoxNewFile "" + break + } + set fsBoxCounter1 0 + set fsBoxTmpFile1 $fsBoxNewFile + set fsBoxTmpFile2 [file tail $fsBoxCounter] + set fsBoxLength1 [string length $fsBoxTmpFile1] + set fsBoxLength2 [string length $fsBoxTmpFile2] + set fsBoxNewFile "" + if {$fsBoxLength1 > $fsBoxLength2} { + set fsBoxLength1 $fsBoxLength2 + } + while {$fsBoxCounter1 < $fsBoxLength1} { + if {"[string index $fsBoxTmpFile1 $fsBoxCounter1]" == \ + "[string index $fsBoxTmpFile2 $fsBoxCounter1]"} { + append fsBoxNewFile [string index $fsBoxTmpFile1 $fsBoxCounter1] + } { + break + } + incr fsBoxCounter1 1 + } + } + } + } + if {"$fsBoxNewFile" != ""} { + if {[IsADir [string trimright $fsBoxDirName/$fsBoxNewFile @]] || + ![IsAFile [string trimright $fsBoxDirName/$fsBoxNewFile @]]} { + if {[IsADir [string trimright $fsBoxDirName/$fsBoxNewFile @]]} { + if {"$fsBoxDirName" == "/"} { + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 "/[string trimright [string trim $fsBoxNewFile /] @]/" + } { + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 "[string trimright $fsBoxDirName /]/[string trimright [string trim $fsBoxNewFile /] @]/" + } + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all) + FSBoxFSInsertPath + } { + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 "[string trimright $fsBoxDirName /]/[string trimright [string trim $fsBoxNewFile /] @]" + } + } { + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 "[string trimright $fsBoxDirName {@/}]/" + .fsBox.file.file delete 0 end + .fsBox.file.file insert 0 $fsBoxNewFile + if {$tkVersion >= 3.0} { + .fsBox.file.file icursor end + } { + .fsBox.file.file cursor end + } + focus .fsBox.file.file + } + } +} + +########## +# Procedure: FSBoxFSShow +# Description: show the file list +# Arguments: fsBoxPath - the path to show +# fsBoxPattern - selection pattern +# fsBoxAll - show all files +# Returns: none +# Sideeffects: none +########## +proc FSBoxFSShow {fsBoxPath fsBoxPattern fsBoxAll} {# xf ignore me 6 + global fsBox + + set tmpButtonOpt "" + if {"$fsBox(activeBackground)" != ""} { + append tmpButtonOpt "-activebackground \"$fsBox(activeBackground)\" " + } + if {"$fsBox(activeForeground)" != ""} { + append tmpButtonOpt "-activeforeground \"$fsBox(activeForeground)\" " + } + if {"$fsBox(background)" != ""} { + append tmpButtonOpt "-background \"$fsBox(background)\" " + } + if {"$fsBox(font)" != ""} { + append tmpButtonOpt "-font \"$fsBox(font)\" " + } + if {"$fsBox(foreground)" != ""} { + append tmpButtonOpt "-foreground \"$fsBox(foreground)\" " + } + + set fsBox(pattern) $fsBoxPattern + if {[file exists $fsBoxPath] && [file readable $fsBoxPath] && + [IsADir $fsBoxPath]} { + set fsBox(internalPath) $fsBoxPath + } { + if {[file exists $fsBoxPath] && [file readable $fsBoxPath] && + [IsAFile $fsBoxPath]} { + set fsBox(internalPath) [file dirname $fsBoxPath] + .fsBox.file.file delete 0 end + .fsBox.file.file insert 0 [file tail $fsBoxPath] + set fsBoxPath $fsBox(internalPath) + } { + while {"$fsBoxPath" != "" && "$fsBoxPath" != "/" && + ![file isdirectory $fsBoxPath]} { + set fsBox(internalPath) [file dirname $fsBoxPath] + set fsBoxPath $fsBox(internalPath) + } + } + } + if {"$fsBoxPath" == ""} { + set fsBoxPath "/" + set fsBox(internalPath) "/" + } + .fsBox.path.path delete 0 end + .fsBox.path.path insert 0 $fsBox(internalPath) + + if {[.fsBox.files.files size] > 0} { + .fsBox.files.files delete 0 end + } + if {$fsBoxAll} { + if {[catch "exec ls -F -a $fsBoxPath" fsBoxResult]} { + puts stderr "$fsBoxResult" + } + } { + if {[catch "exec ls -F $fsBoxPath" fsBoxResult]} { + puts stderr "$fsBoxResult" + } + } + set fsBoxElementList [lsort $fsBoxResult] + + foreach fsBoxCounter [winfo children .fsBox.pattern.patterns.patterns] { + if {[string length [info commands XFDestroy]] > 0} { + catch {XFDestroy $fsBoxCounter} + } { + catch {destroy $fsBoxCounter} + } + } + menu .fsBox.pattern.patterns.patterns.menu + catch ".fsBox.pattern.patterns.patterns.menu config $tmpButtonOpt" + + if {$fsBox(extensions)} { + .fsBox.pattern.patterns.patterns.menu add command \ + -label "*" \ + -command { + global fsBox + set fsBox(pattern) "*" + .fsBox.pattern.pattern delete 0 end + .fsBox.pattern.pattern insert 0 $fsBox(pattern) + FSBoxFSShow [.fsBox.path.path get] $fsBox(pattern) \ + $fsBox(all)} + } + + if {"$fsBoxPath" != "/"} { + .fsBox.files.files insert end "../" + } + foreach fsBoxCounter $fsBoxElementList { + if {[string match $fsBoxPattern $fsBoxCounter] || + [IsADir [string trimright $fsBoxPath/$fsBoxCounter "/@"]]} { + if {"$fsBoxCounter" != "../" && + "$fsBoxCounter" != "./"} { + .fsBox.files.files insert end $fsBoxCounter + } + } + + if {$fsBox(extensions)} { + catch "file rootname $fsBoxCounter" fsBoxRootName + catch "file extension $fsBoxCounter" fsBoxExtension + set fsBoxExtension [string trimright $fsBoxExtension "/*@"] + if {"$fsBoxExtension" != "" && "$fsBoxRootName" != ""} { + set fsBoxInsert 1 + set fsBoxLast [.fsBox.pattern.patterns.patterns.menu index last] + for {set fsBoxCounter1 0} {$fsBoxCounter1 <= $fsBoxLast} {incr fsBoxCounter1 1} { + if {"*$fsBoxExtension" == \ + "[lindex [.fsBox.pattern.patterns.patterns.menu entryconfigure \ + $fsBoxCounter1 -label] 4]"} { + set fsBoxInsert 0 + } + } + if {$fsBoxInsert} { + .fsBox.pattern.patterns.patterns.menu add command \ + -label "*$fsBoxExtension" \ + -command " + global fsBox + set fsBox(pattern) \"*$fsBoxExtension\" + .fsBox.pattern.pattern delete 0 end + .fsBox.pattern.pattern insert 0 \$fsBox(pattern) + FSBoxFSShow \[.fsBox.path.path get\] \$fsBox(pattern) \ + \$fsBox(all)" + } + } + } + } + if {$fsBox(extensions)} { + .fsBox.pattern.patterns.patterns.menu add separator + } + if {$fsBox(extensions) || + "[.fsBox.pattern.patterns.patterns.menu index last]" == "none"} { + .fsBox.pattern.patterns.patterns.menu add checkbutton \ + -label "Scan extensions" \ + -variable "fsBox(extensions)" \ + -command { + global fsBox + FSBoxFSShow [.fsBox.path.path get] \ + [.fsBox.pattern.pattern get] $fsBox(all)} + } +} + +########## +# Procedure: FSBoxBindSelectOne +# Description: action to select the current list item +# Arguments: fsBoxW - the widget +# fsBoxY - the y position in the listbox +# Returns: none +# Sideeffects: none +########## +proc FSBoxBindSelectOne {fsBoxW fsBoxY} {# xf ignore me 6 + + set fsBoxNearest [$fsBoxW nearest $fsBoxY] + if {$fsBoxNearest >= 0} { + $fsBoxW selection anchor $fsBoxNearest + $fsBoxW selection set anchor $fsBoxNearest + } +} + +proc IsADir {pathName} {# xf ignore me 5 +########## +# Procedure: IsADir +# Description: check if name is a directory (including symbolic links) +# Arguments: pathName - the path to check +# Returns: 1 if its a directory, otherwise 0 +# Sideeffects: none +########## + + if {[file isdirectory $pathName]} { + return 1 + } { + catch "file type $pathName" fileType + if {"$fileType" == "link"} { + if {[catch "file readlink $pathName" linkName]} { + return 0 + } + catch "file type $linkName" fileType + while {"$fileType" == "link"} { + if {[catch "file readlink $linkName" linkName]} { + return 0 + } + catch "file type $linkName" fileType + } + return [file isdirectory $linkName] + } + } + return 0 +} + +proc IsAFile {fileName} {# xf ignore me 5 +########## +# Procedure: IsAFile +# Description: check if filename is a file (including symbolic links) +# Arguments: fileName - the filename to check +# Returns: 1 if its a file, otherwise 0 +# Sideeffects: none +########## + + if {[file isfile $fileName]} { + return 1 + } { + catch "file type $fileName" fileType + if {"$fileType" == "link"} { + if {[catch "file readlink $fileName" linkName]} { + return 0 + } + catch "file type $linkName" fileType + while {"$fileType" == "link"} { + if {[catch "file readlink $linkName" linkName]} { + return 0 + } + catch "file type $linkName" fileType + } + return [file isfile $linkName] + } + } + return 0 +} + +proc IsASymlink {fileName} {# xf ignore me 5 +########## +# Procedure: IsASymlink +# Description: check if filename is a symbolic link +# Arguments: fileName - the path/filename to check +# Returns: none +# Sideeffects: none +########## + + catch "file type $fileName" fileType + if {"$fileType" == "link"} { + return 1 + } + return 0 +} + +# eof + diff --git a/soar-8.5.2/demos_soar7/FSBox/readme b/soar-8.5.2/demos_soar7/FSBox/readme new file mode 100644 index 0000000..50e9bb0 --- /dev/null +++ b/soar-8.5.2/demos_soar7/FSBox/readme @@ -0,0 +1,15 @@ + This directory contains a file selection GUI developed by Sven Delmas. +Below is his README to which this message was prepended. + +------------------------------------------------------------------------ + +Hi, + +this is a template from XF (an interface builder for Tcl/Tk). To use +this template in xf just move it to the template directory. To use it +in your own program just source it, and call it with: FSBox + +Have fun +Sven Delmas +--- +garfield@cs.tu-berlin.de diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/critter.tcl b/soar-8.5.2/demos_soar7/gui/critter_world/critter.tcl new file mode 100644 index 0000000..c8f92af --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/critter.tcl @@ -0,0 +1,211 @@ +# +# The Soar code for a critter. +# +# Input will come in on the top state (S1) and have the following form: +# +# S1 ^location *x.y* +# +# S1 ^north *?* +# S1 ^south *?* +# S1 ^east *?* +# S1 ^west *?* +# +# where *x.y* indicates the map coordinates of the current position. +# The *?* will be a single character indicating what is on the map at +# that location. For example, S1 ^east X would indicate that (relative +# to this agent), there is an object X one step to the east. For the +# possible map values, see the simulation code (in critter_world.tcl). +# +# Given the above input, the critter decides on a move to make using the +# normal Soar mechanisms of operator proposal and application. To help +# make this decision, the agent augments the top state with the attribute +# "last-dir" to record what the last direction of movement was. This is +# used to avoid moving back to the last spot visited. +# +# To move in one of the four directions, the agent issues a RHS call such +# as this: +# +# (tcl |selectDirection | ) +# +# This command, in turn, forwards the move request to the control +# agent to update the simulator. +# +# To reflect the current state of the inputs in the GUI, the agent +# invokes this RHS call: +# +# (tcl |updateCritterView .$interp_name || || || |) +# +# where the $interp_name will be taken from the current agent and +# embedded in the rule (the rule is defined using "" instead of {} so Tcl +# can do the variable expansion). This RHS action expands to +# {updateCritterView .foo # . # .} (assuming the agent is called "foo" and +# the squares have the indicated values) and is run in the agent's Tcl +# shell. +# +#------------------------------------------------------- + +# Make sure that we've got Soar around +#puts stdout "auto_path= $auto_path" ; flush stdout +puts stdout "critter.tcl: auto_path= $auto_path\n packages = [package names]\n" +package require Soar + +# Set up some basic stuff +watch 0 +output-strings-destination -push -channel stdout +source $default + + +sp {critter*create*space*critter + "Formulate the initial problem space" + (state ^superstate nil) + --> + ( ^name move-around ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name critter)} + +#------------------------------------------------------- + +sp {critter*create*state*initial-state + "Formulate the initial state" + (state ^name move-around ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name critter) + --> + ( ^last-dir unknown)} + +#------------------------------------------------------- +# +# Form operators based on input information +# +#------------------------------------------------------- +# +# Operator Proposal + +sp {critter*propose*operator*move + "Don't propose moving over anything but empty space" + (state ^problem-space.name critter ^superstate nil) + ( ^{<< north south east west >> } |.|) + ( ^location ) + --> + ( ^operator + =) + ( ^name move ^direction ^from-location )} + +#------------------------------------------------------- +# +# Operator Preferences + +sp {critter*compare*operator*move*north*worst + "Prefer not to move where we have just been" + (state ^problem-space.name critter + ^operator + + ^superstate nil) + ( ^name move ^direction north) + ( ^last-dir south) + --> + ( ^operator <)} + +sp {critter*compare*operator*move*south*worst + "Prefer not to move where we have just been" + (state ^problem-space.name critter + ^operator + + ^superstate nil) + ( ^name move ^direction south) + ( ^last-dir north) + --> + ( ^operator <)} + +sp {critter*compare*operator*move*east*worst + "Prefer not to move where we have just been" + (state ^problem-space.name critter + ^operator + + ^superstate nil) + ( ^name move ^direction east) + ( ^last-dir west) + --> + ( ^operator <)} + +sp {critter*compare*operator*move*west*worst + "Prefer not to move where we have just been" + (state ^problem-space.name critter + ^operator + + ^superstate nil) + ( ^name move ^direction west) + ( ^last-dir east) + --> + ( ^operator <)} + +sp {critter*compare*operator*move*same-direction*better + "Prefer to continue moving in the same direction" + (state ^problem-space.name critter + ^operator + ^operator { <> } + + ^superstate nil) + ( ^name move ^direction ) + ( ^last-dir ) + --> + ( ^operator > )} + +#------------------------------------------------------- +# +# Operator Application +# +# This tells the simulator that the agent wants to +# move in the indicated direction. As a side effect, +# the corresponding square on the agent's GUI is +# highlighted. + +sp {critter*apply*operator*move*same-direction + (state ^problem-space.name critter + ^operator + ^superstate nil) + ( ^name move ^direction ) + ( ^last-dir ) + --> + ( ^last-dir ) + (tcl |selectDirection | )} + +sp {critter*apply*operator*move*new-direction + (state ^problem-space.name critter + ^operator + ^superstate nil) + ( ^name move ^direction ) + ( ^last-dir { <> }) + --> + ( ^last-dir + -) + (tcl |selectDirection | )} + +#------------------------------------------------------- +# +# Operator Termination + +sp {critter*terminate*operator*move*location-changed + (state ^problem-space.name critter + ^operator + ^superstate nil) + ( ^name move ^direction ^from-location ) + ( ^location {<> }) + --> + ( ^operator @)} + +# If an operator fails, then highlight the corresponding +# square on the agent's GUI in red. + +sp "critter*terminate*operator*move*action-failed + (state ^problem-space.name critter + ^operator + ^superstate nil) + ( ^name move ^direction ^from-location ) + ( ^location ^move-made no) + --> + ( ^operator @) + (tcl |highlightCritterViewSquare .$interp_name | | red|)" + +#------------------------------------------------------- +# +# GUI update +# +# Update GUI when the location changes. + +sp "critter*gui*update + (state ^problem-space.name critter ^superstate nil) + ( ^location ) + ( ^north ^south ^east ^west ) + --> + (tcl |updateCritterView .$interp_name || || || |)" diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/critter_gui.tcl b/soar-8.5.2/demos_soar7/gui/critter_world/critter_gui.tcl new file mode 100644 index 0000000..3501044 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/critter_gui.tcl @@ -0,0 +1,106 @@ +# +# This file defines the GUI for a single critter agent. +# +# +# makeCritterView creates the top-level GUI for the critter. +# +# The created widget is named the same as the agent, but +# with a preceeding dot ("."). The widget contains a +# grid like a tic-tac-toe board showing the agent square in +# the middile and the eight surrounding squares. Since the +# map is considered four-connected rather than eight-connected, +# only the north south, east, and west squares are shown. The +# other squares are hidden in black. The normal button +# binding is disabled so that user is not led to believe that +# the button is active. + +# Global decls + +global soar_library auto_path +global critter_world_dir +global input_root wall_char space_char map_file stop_cw + +puts stdout "critter_gui: auto_path= $auto_path\n packages = [package names]" ; flush stdout +package require Tk 4.2 +wm withdraw . + + +proc makeCritterView {agent} { + set w .$agent + catch {destroy $w} + + toplevel $w + wm title $w "Agent $agent view" + wm iconname $w "$agent view" + + frame $w.view -width 200 -height 200 -relief ridge + + for {set i 0} {$i < 9} {incr i} { + set xpos [expr ($i%3)*.33] + set ypos [expr ($i/3)*.33] + button $w.view.$i + place $w.view.$i -relx $xpos -rely $ypos \ + -relwidth .33 -relheight .33 + bind $w.view.$i {doNothing} + if {($i%2) == 0} { + $w.view.$i configure -bg black -relief flat + } else { + $w.view.$i configure -relief raised + } + } + pack $w.view -padx 2m -pady 2m +} + +# This procedure is used to disable the button callback. +# If you try "bind widget {}" it doesn't work -- it +# simply uses the default binding. + +proc doNothing {} { +} + +# updateCritterView updates the squares that the critter can +# see. Positions 1, 3, 5, 7 correspond to north, west, east, +# south respectively. The background is set to Bisque in case +# it was highlighted earlier with another color. + +proc updateCritterView {w pos1 pos7 pos5 pos3} { + for {set i 1} {$i < 9} {incr i 2} { + $w.view.$i configure -text [set pos$i] -background Bisque + } + update +} + +# This procedure takes a selected direction and highlights +# the corresponding square with the given highlight color. + +proc highlightCritterViewSquare {w square highlight} { + if {$square == "north"} { + $w.view.1 configure -background $highlight + } elseif {$square == "south"} { + $w.view.7 configure -background $highlight + } elseif {$square == "east" } { + $w.view.5 configure -background $highlight + } elseif {$square == "west" } { + $w.view.3 configure -background $highlight + } +} + +# selectDirection is invoked from a Soar production RHS call. +# It sends the control agent the selected direction. The +# corresponding square is also highlighted. + +proc selectDirection {dir} { + global interp_name + + # Note that "sim" is aliased to the master interpreter + sim $interp_name $dir + + highlightCritterViewSquare .$interp_name $dir green +} + +# Now, create the GUI. + +global interp_name +makeCritterView $interp_name + + diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/critter_sim.tcl b/soar-8.5.2/demos_soar7/gui/critter_world/critter_sim.tcl new file mode 100644 index 0000000..9027a3c --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/critter_sim.tcl @@ -0,0 +1,430 @@ +# +# CRITTER SIMULATOR +# +# This demo illustrates how to create multiple agents and have +# them interact in a simulated world. This demo is intentionally +# implemented in a simple manner to clearly illustrate the +# concepts of agent interactions with a simulator. +# +#----------------------------------------------------------------------- + +# Global decls + +global soar_library auto_path +global critter_world_dir +global input_root wall_char space_char map_file stop_cw + +puts stdout "critter_sim: auto_path= $auto_path\n packages = [package names]\n" +flush stdout +package require Tk 4.2 +wm withdraw . + + +# +# Procedure to create the simulator GUI. This widget contains a +# map and a few buttons to control the simulator. +# + +proc makeCritterWorld {{w .cw}} { + global map_file + + catch {destroy $w} + + toplevel $w + wm title $w "Critter World" + wm iconname $w "Critter World" + + frame $w.frame -borderwidth 4 -relief ridge -bg Bisque3 + + makeMap $w.frame.map + loadMap $w.frame.map $map_file + + button $w.run -text Run -command "set stop_cw 0; simStep 1000" + button $w.stop -text Stop -command "set stop_cw 1" + button $w.step -text Step -command "set stop_cw 0; simStep 1" + +# Note that we need to tell some other agent (the original agent where +# this demo was started) to kill the current interpreter. We use the +# after command so the current agent will not appear in the evaluation +# stack when its destroyed. + + button $w.ok -text Dismiss -command "destroyCritters; destroy $w" + + pack $w.frame.map + pack $w.frame -side top -padx 2m -pady 2m + pack $w.run $w.stop $w.step -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m +} + +#----------------------------------------------------------------------- +# +# These procedures define the map loading operation. When a map is +# loaded, any existing map with the same widget name is destroyed. +# A single text widget is created to contain the map and the map is +# loaded into that widget. The map is found in the given text file +# and is copied into the widget verbatim. The map can have any width +# and height, but each line (row) of the map should be the same length. +# + +proc makeMap {w} { + catch {destroy $w} + text $w +} + +# +# This procedure reads a map file. The length of each line of the +# file is checked to find the max width line. This is used to size +# the window. The number of lines in the file is used to set the +# height of the text widget. We save the width and height in globals +# since we'll need those values later. +# + +proc loadMap {w file} { + global mapdata + + set max_width 0 + set max_height 0 + + set fileId [open $file r] + + while {[gets $fileId line] >= 0} { + set lineLength [string length $line] + if {$lineLength > $max_width} { + set max_width $lineLength + } + incr max_height + $w insert insert "$line\n" + } + + close $fileId + + $w configure -width $max_width -height $max_height + +# An odd quirk. Text widgets index lines from 1 but characters in +# the line starting from 0. Go figure. + + set mapdata(width) [expr $max_width - 1] + set mapdata(height) $max_height +} + +#----------------------------------------------------------------------- +# +# Critter creation and destruction... +# +# createCritters: This procedure creates a number of agents and +# initializes them properly. This initialization +# includes: +# - creating the agent +# - hiding its default top-level window +# - setting agent debugging output down to minimim +# - loading default and critter productions +# - loading critter GUI +# - running critter 2 dc's to ensure top-state S1 +# exists (ok, that's a bit of a hack) +# +# If you want to run more agents, just add to the sim_agents list +# below. +# +# In addition to agent initialization, globals are updated for each +# agent to +# - initialize the character used on the map display +# - initialize the movement request table +# - clear the list of input wmes that have been added +# + +proc createCritters {w} { + global sim_agents agent_char default request auto_path soar_library + global wmes + + set sim_agents [list alpha beta gamma] + + foreach agent $sim_agents { + interp create $agent + + $agent alias sim sim + $agent eval [list set auto_path "$auto_path"] + load {} Tk $agent + $agent eval "set interp_name $agent" + $agent eval "source critter.tcl" + $agent eval "source critter_gui.tcl" + + $agent eval {d 2} + + set agent_char($agent) [string toupper [string index $agent 0]] + set request($agent) center + set wmes($agent) {} + + randomlyPlaceAgent $w $agent + puts "created agent $agent" + } +} + +# This procedure destroys all critter agents and their windows. + +proc destroyCritters {} { + global sim_agents + + foreach agent $sim_agents { + interp delete $agent + } + +} + +#----------------------------------------------------------------------- +# +# simStep steps the simulator forward one step while calling all the +# agents to make a movement decision. If the stop_cw flag is set +# (most likely this happens from a GUI action) then the stepping +# loop halts. + +proc simStep {{n 1}} { + global sim_agents stop_cw + + for {set i 0} {$i < $n} {incr i} { + foreach agent $sim_agents { + $agent eval {d 1} + updateWorld $agent .cw.frame.map + } + if {$stop_cw == 1} {return} + } +} + +# +# updateWorld: This procedure is used to process the agent requests +# and move them in the world. If the request is invalid +# it is ignored. This may happen if the agent tries to +# move off the map, into another agent, or into a wall. +# The variable move_made is used to record whether the +# move suceeded or not. + +proc updateWorld {agent w} { + set move_made [processAgentRequest $agent $w] + updateAgentInputs $agent $w $move_made + update +} + +# +# processAgentRequest: This procedure moves the agent in the requested +# direction. If the request is invalid, the +# agent is not moved and a failure is recorded. + +proc processAgentRequest {agent w} { + global request pos_x pos_y mapdata agent_char space_char + +# Set x and y to current position and update with desired +# move direction. + + set x $pos_x($agent) + set y $pos_y($agent) + + if {[string compare $request($agent) north] == 0} { + set y [expr $pos_y($agent) - 1] + } elseif {[string compare $request($agent) south] == 0} { + set y [expr $pos_y($agent) + 1] + } elseif {[string compare $request($agent) east ] == 0} { + set x [expr $pos_x($agent) + 1] + } elseif {[string compare $request($agent) west ] == 0} { + set x [expr $pos_x($agent) - 1] + } + +# If the new position is off the map, then abort + + if {($x < 0) || ($x > $mapdata(width))} { + return fail + } + + if {($y < 1) || ($y > $mapdata(height))} { + return fail + } + +# If the current position contains an object that can't +# be moved over, then ignore the move as well. + + set pos_char [$w get $y.$x] + if {!( ($pos_char == $space_char) \ + || ($pos_char == $agent_char($agent)))} { + return fail + } + +# Update the map. Overwrite the agent position with +# a space character and insert the agent's char at +# the new position. + + $w delete $pos_y($agent).$pos_x($agent) + $w insert $pos_y($agent).$pos_x($agent) $space_char + $w delete $y.$x + $w insert $y.$x $agent_char($agent) + +# Set the updated position values + + set pos_x($agent) $x + set pos_y($agent) $y + + return succeed +} + +# +# updateAgentInputs: This procedure updates the state of the +# agent's input link with the local area +# it can see in the map. +# +# The agent's input is updated by sending it commands to +# do add-wme's with the given information. The add-wme +# command returns the timetag of the wme in the first +# field, so we scan that off and remember it. When we +# need to make a change to the inputs, we remove the old +# wmes and add new ones. +# + +proc updateAgentInputs {agent w move_made} { + global wmes input_root request pos_x pos_y + +# If the move failed, let the agent know. + + if {$move_made == "fail"} { + scan [$agent eval "add-wme $input_root move-made no"] \ + "%d" wme_added + lappend wmes($agent) $wme_added + set request($agent) pass + } + +# Pass is used to indicate that the agent will not be +# moved. Hence, no need to update the input wmes for +# the agent. + + if {$request($agent) == "pass"} {return} + +# Delete any existing wmes + + if {$wmes($agent) != ""} { + foreach wme $wmes($agent) { + $agent eval "remove-wme $wme" + } + set wmes($agent) {} + } + + # add new wmes and record their ids for later removal + + foreach dir {north south east west} { + set content [getMapContentRelative $agent $w $dir] + scan [$agent eval "add-wme $input_root $dir |$content|"] \ + "%d" wme_added + lappend wmes($agent) $wme_added + } + + scan [$agent eval \ + "add-wme $input_root location |$pos_x($agent).$pos_y($agent)|"] \ + "%d" wme_added + lappend wmes($agent) $wme_added + + set request($agent) pass +} + +# This procedure gets the contents of the map one step away from +# the agent in the given direction. + +proc getMapContentRelative {agent w dir} { + global mapdata pos_x pos_y wall_char + + set x $pos_x($agent) + set y $pos_y($agent) + + if {[string compare $dir north] == 0} { + set y [expr $pos_y($agent) - 1] + } elseif {[string compare $dir south] == 0} { + set y [expr $pos_y($agent) + 1] + } elseif {[string compare $dir east ] == 0} { + set x [expr $pos_x($agent) + 1] + } elseif {[string compare $dir west ] == 0} { + set x [expr $pos_x($agent) - 1] + } + +# If the new position is off the map, then return a wall + + if {($x < 0) || ($x > $mapdata(width))} { + return $wall_char + } + + if {($y < 1) || ($y > $mapdata(height))} { + return $wall_char + } + +# Otherwise, get the contents of the map at (x,y) + + return [$w get $y.$x] +} + +#----------------------------------------------------------------------- +# +# Include the code to generate random numbers. This is used to +# pick starting positions for agents. +# + +source random.tcl + +#----------------------------------------------------------------------- + +# +# This procedure randomly selects a position on the map which +# is open, so that the agent can be placed at the position. +# + +proc randomlyPlaceAgent {w agent} { + global mapdata agent_char space_char pos_x pos_y wall_char + + set pointFound $wall_char + + while {$pointFound != $space_char} { + set x [randomRange $mapdata(width)] + set y [expr [randomRange [expr $mapdata(height) - 1]] + 1] + + set pointFound [$w get $y.$x] + } + +# Remember the location for later use + + set pos_x($agent) $x + set pos_y($agent) $y + +# Update the map + + $w delete $y.$x + $w insert $y.$x $agent_char($agent) + + return $y.$x +} + +#----------------------------------------------------------------------- +# +# Sim: This procedure is called by the agents to submit their move +# requests. Their requests are recorded only, not processed. +# + +proc sim {agent move} { + global request + set request($agent) $move +} + +#----------------------------------------------------------------------- + +# +# Startup initializations ... +# + +set input_root S1 ;# Where to put input WMEs in the agents + +set wall_char "#" ;# Map character for a Wall +set space_char "." ;# Map character for an empty space + +set map_file "map.txt" ;# Map file + +set stop_cw 0 ;# Flag used to control stepping process + +randomInit [pid] ;# Initialize the random number generator + +#----------------------------------------------------------------------- +# +# Finally, create the GUI and the critters. + +makeCritterWorld .cw +createCritters .cw.frame.map diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/critter_world.tcl b/soar-8.5.2/demos_soar7/gui/critter_world/critter_world.tcl new file mode 100644 index 0000000..678d246 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/critter_world.tcl @@ -0,0 +1,12 @@ +# +# CRITTER WORLD +# +# This demo illustrates how to create multiple agents and have +# them interact in a simulated world. This demo is intentionally +# implemented in a simple manner to clearly illustrate the +# concepts of agent interactions with a simulator. +# +#----------------------------------------------------------------------- +puts stdout "critter_world: auto_path= $auto_path\n packages = [package names]" + +source "critter_sim.tcl" diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/map.txt b/soar-8.5.2/demos_soar7/gui/critter_world/map.txt new file mode 100644 index 0000000..1fce9b7 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/map.txt @@ -0,0 +1,16 @@ +.....#...#.....#................# +####.###......................... +##.....##..#.#......#######.....# +#...#......#.........######.##### +..#..#.....##..#............#...# +####.###..........####......#.#.. +##.....#...###............###.#.# +#...#......#......##.########.#.. +...........##..#...#........###.# +#.##.###.#######.....##.....#.#.. +#..#...#...#.............#..#.#.# +#.#.#......#.........###.##.#.#.. +.......#...##..#.....######.#.#.# +##.#.###.........#.#..........#.. +##.....#...#.....#.############.# +#..###.....#...#................. diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/random.tcl b/soar-8.5.2/demos_soar7/gui/critter_world/random.tcl new file mode 100644 index 0000000..af58b89 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/random.tcl @@ -0,0 +1,30 @@ +#----------------------------------------------------------------------- +# +# Random number generator. +# +# Taken from "Practical Programming in Tcl/Tk" by Brent Welch (pg 44). +# + +proc randomInit {seed} { + global rand + + set rand(ia) 9301 ;# Multiplier + set rand(ic) 49297 ;# Constant + set rand(im) 233280 ;# Divisor + set rand(seed) $seed ;# Last result +} + +proc random {} { + global rand + + set rand(seed) \ + [expr ($rand(seed)*$rand(ia) + $rand(ic)) % $rand(im)] + return [expr $rand(seed)/double($rand(im))] +} + +proc randomRange {range} { + expr int([random]*$range) +} + + +#----------------------------------------------------------------------- diff --git a/soar-8.5.2/demos_soar7/gui/critter_world/readme b/soar-8.5.2/demos_soar7/gui/critter_world/readme new file mode 100644 index 0000000..1a72ad3 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/critter_world/readme @@ -0,0 +1,19 @@ +This directory contains the code for the Critter World demo. This +demo shows several (3) agents moving around in a Rogue-like map world. + +This demo illustrates: + + - definition and control of multiple agents + - inter-agent communication via Tcl procedures + - embedding of Tcl data in Soar productions + - simple, reactive Soar agents + - a simple Tcl simulator to arbitrate agent actions in the world + - use of add-wme to communicate input data to Soar agents + - use of Tcl to communicate Soar actions to simulator + - file input to initialize map of world + - use of a random number generator + - no C coding needed to setup multi-agent interaction + - separate windows for each agent + +To run this demo, invoke "soartk", move to this directory and +"source critter_world.tcl" diff --git a/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl b/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl new file mode 100644 index 0000000..9e09332 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl @@ -0,0 +1,179 @@ +# +# Eight puzzle demo +# +#----------------------------------------------------------------------- +# +# Create top-level window for 8 puzzle demo. +# +# Any existing widget with the same name is destroyed. The window +# consists of a title at the top, a panel of three boards and some +# control buttons. The panel contains the starting state, current +# state, and goal state of the puzzle. +package require Soar + + +proc make8Puzzle {{w .8} + {start {2 8 3 1 6 4 7 0 5}} + {goal {1 2 3 8 0 4 7 6 5}}} { + global solveslow + + catch {destroy $w} + toplevel $w + wm title $w "8-Puzzle Demonstration" + wm iconname $w "8-Puzzle" + + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "8-Puzzle Demonstration" + + frame $w.frame -width 360 -height 120 -borderwidth 4 \ + -relief ridge -bg Grey70 + + make8Board "Starting \nState" $w.frame.ss $start + make8Board "Current \nState" $w.frame.cs $start + make8Board "Goal \nState" $w.frame.gs $goal + + button $w.solve -text Solve -command "run" + checkbutton $w.speed -text Slowly -variable solveslow + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" \ + -command "init-soar; puzzleSet $w.frame.cs \{$start\}" + button $w.reset -text Reset \ + -command "reset8Puzzle $w \{$start\}" + button $w.ok -text Dismiss -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame.ss $w.frame.cs $w.frame.gs -side left + pack $w.frame -side top -padx 20 + pack $w.solve $w.speed $w.stop $w.init $w.reset \ + -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m +} + +# Procedure to make a single 8-puzzle board. The name of +# the state is used as a title for the board. The board +# itself is simply nine titles in a square. + +proc make8Board {title w state} { + frame $w -width 160 -height 120 -borderwidth 0 + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 300 -text $title + frame $w.board -width 110 -height 110 -borderwidth 5 \ + -relief groove -bg Grey70 + + for {set i 0} {$i < 9} {incr i} { + set num [lindex $state $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + button $w.board.$num -relief raised -text $num + place $w.board.$num -relx $xpos($num) -rely $ypos($num) \ + -relwidth .33 -relheight .33 + } + } + + pack $w.msg $w.board -side top -pady 5 +} + +#----------------------------------------------------------------------- +# +# Procedure to reorder the puzzle entries. The buttons are +# moved to correspond to the given order. After the buttons +# are moved, the windows are updated to show the new positions +# (the Tk call "update" flushes pending updates to the X server). +# If the user has requested that the process move slowly, then +# sleep for a second. It actually takes a little longer to +# exec the process, but whatever. + +proc puzzleSet {w order} { + global solveslow + for {set i 0} {$i < 9} {incr i} { + set num [lindex $order $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + place $w.board.$num -relx $xpos($num) -rely $ypos($num) + } + } + + update + + if {$solveslow != 0} { + after 1000 + } +} + +# This procedure resets a puzzle to the initial state. It also +# removes all chunks and initializes Soar so that the puzzle can +# be run again. + +proc reset8Puzzle {w start} { + excise -chunks + init-soar + puzzleSet $w.frame.cs $start +} + +# This procedure dismisses the 8puzzle demo. It excises all +# productions (maybe not a good thing to do? +# and does an init-soar so other demos can be run from the gui. + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining eight puzzle solution method + +global soar_library +global interp_type + +excise -all +source $default +source ../../no-gui/eight_puzzle/eight_puzzle.soar + +set solveslow 0 + +make8Puzzle +reset8Puzzle .8 {2 8 3 1 6 4 7 0 5} + +# Redefine one rule to use a Tcl call to update GUI: + +sp {eight*monitor*state + (state ^problem-space

                                                                                                                        + ^binding + + ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) + --> + (tcl |puzzleSet .8.frame.cs {| + | | | | | | + | | | | | | + | | | | |}|) + (write (crlf) | -------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | -------------| | | (crlf) | | )} diff --git a/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl.soar8failed b/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl.soar8failed new file mode 100644 index 0000000..c0b4f95 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/eight_puzzle/eight_puzzle.tcl.soar8failed @@ -0,0 +1,179 @@ +# +# Eight puzzle demo +# +#----------------------------------------------------------------------- +# +# Create top-level window for 8 puzzle demo. +# +# Any existing widget with the same name is destroyed. The window +# consists of a title at the top, a panel of three boards and some +# control buttons. The panel contains the starting state, current +# state, and goal state of the puzzle. +package require Soar + + +proc make8Puzzle {{w .8} + {start {2 8 3 1 6 4 7 0 5}} + {goal {1 2 3 8 0 4 7 6 5}}} { + global solveslow + + catch {destroy $w} + toplevel $w + wm title $w "8-Puzzle Demonstration" + wm iconname $w "8-Puzzle" + + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 400 -text "8-Puzzle Demonstration" + + frame $w.frame -width 360 -height 120 -borderwidth 4 \ + -relief ridge -bg Grey70 + + make8Board "Starting \nState" $w.frame.ss $start + make8Board "Current \nState" $w.frame.cs $start + make8Board "Goal \nState" $w.frame.gs $goal + + button $w.solve -text Solve -command "run" + checkbutton $w.speed -text Slowly -variable solveslow + button $w.stop -text "Stop" -command "stop-soar" + button $w.init -text "Init Soar" \ + -command "init-soar; puzzleSet $w.frame.cs \{$start\}" + button $w.reset -text Reset \ + -command "reset8Puzzle $w \{$start\}" + button $w.ok -text Dismiss -command "dismiss $w" + + pack $w.msg -side top + pack $w.frame.ss $w.frame.cs $w.frame.gs -side left + pack $w.frame -side top -padx 20 + pack $w.solve $w.speed $w.stop $w.init $w.reset \ + -side left -padx 1m -pady 2m + pack $w.ok -side right -padx 1m -pady 2m +} + +# Procedure to make a single 8-puzzle board. The name of +# the state is used as a title for the board. The board +# itself is simply nine titles in a square. + +proc make8Board {title w state} { + frame $w -width 160 -height 120 -borderwidth 0 + message $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -aspect 300 -text $title + frame $w.board -width 110 -height 110 -borderwidth 5 \ + -relief groove -bg Grey70 + + for {set i 0} {$i < 9} {incr i} { + set num [lindex $state $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + button $w.board.$num -relief raised -text $num + place $w.board.$num -relx $xpos($num) -rely $ypos($num) \ + -relwidth .33 -relheight .33 + } + } + + pack $w.msg $w.board -side top -pady 5 +} + +#----------------------------------------------------------------------- +# +# Procedure to reorder the puzzle entries. The buttons are +# moved to correspond to the given order. After the buttons +# are moved, the windows are updated to show the new positions +# (the Tk call "update" flushes pending updates to the X server). +# If the user has requested that the process move slowly, then +# sleep for a second. It actually takes a little longer to +# exec the process, but whatever. + +proc puzzleSet {w order} { + global solveslow + for {set i 0} {$i < 9} {incr i} { + set num [lindex $order $i] + if {$num != 0} { + set xpos($num) [expr ($i%3)*.33] + set ypos($num) [expr ($i/3)*.33] + place $w.board.$num -relx $xpos($num) -rely $ypos($num) + } + } + + update + + if {$solveslow != 0} { + after 1000 + } +} + +# This procedure resets a puzzle to the initial state. It also +# removes all chunks and initializes Soar so that the puzzle can +# be run again. + +proc reset8Puzzle {w start} { + excise -chunks + init-soar + puzzleSet $w.frame.cs $start +} + +# This procedure dismisses the 8puzzle demo. It excises all +# productions (maybe not a good thing to do? +# and does an init-soar so other demos can be run from the gui. + +proc dismiss {w} { + excise -all + init-soar + destroy $w +} +#----------------------------------------------------------------------- +# +# Initialization and GUI creation + +# Load rules defining eight puzzle solution method + +global soar_library +global interp_type + +excise -all +#source $default +pushd ../../no-gui/eight_puzzle/eight_puzzle.soar +popd +set solveslow 0 + +make8Puzzle +reset8Puzzle .8 {2 8 3 1 6 4 7 0 5} + +# Redefine one rule to use a Tcl call to update GUI: + +sp {eight*monitor*state + (state ^problem-space

                                                                                                                        + ^binding + + ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) + --> + (tcl |puzzleSet .8.frame.cs {| + | | | | | | + | | | | | | + | | | | |}|) + (write (crlf) | -------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | -------------| | | (crlf) | | )} diff --git a/soar-8.5.2/demos_soar7/gui/eight_puzzle/readme b/soar-8.5.2/demos_soar7/gui/eight_puzzle/readme new file mode 100644 index 0000000..fd2a56a --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/eight_puzzle/readme @@ -0,0 +1,10 @@ +This directory contains the code for the eight_puzzle demo. +This demo adds a GUI to the eight puzzle example distributed +with non-Tcl Soar. This demo illustrates: + + - use of the Soar RHS function "tcl" to update a GUI + - connecting a simple but non-trivial GUI to a Soar appliation + - using Tcl procedures to break up script processing + +To run this demo, invoke "soartk", move to this directory and +"source eight_puzzle.tcl" \ No newline at end of file diff --git a/soar-8.5.2/demos_soar7/gui/graph_tool/farmer.soar b/soar-8.5.2/demos_soar7/gui/graph_tool/farmer.soar new file mode 100644 index 0000000..90b5ccb --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/graph_tool/farmer.soar @@ -0,0 +1,439 @@ +### +### FILE : farmer.s (NNPSCM) +### + +### +### AUTHOR(3) : Aladin.Akyurek [ Soar 6.0.7, 6.0.8 ] +### AUTHOR(2) : Brian.G.Milnes [ Soar 5.1 ] +### AUTHOR(1) : Jans.Aasman [ Soar 4.3 ] +### + +### +### CREATED(3) : Apr 26, 93 +### + +### +### MODIFIED(3) : Aug 21, 96 [ Soar 7.0.3 TCL TK ] Sayan Bhattacharyya +### MODIFIED(2) : Aug 9, 94 [ Soar 6.2.3 NNPSCM ] Aladin.Akyurek +### MODIFIED(1) : Jul 19, 94 [ Soar 6.2.3 NNPSCM ] Aladin.Akyurek +### + +### +### Jul 19, 94 : Removed copying down ^applied in the subgoals# +### Replaced "implement" in production names by "apply." +### Aug 9, 94 : Added a search-control production that is operative +### within the selection space. This effectively resolves +### the problem described in the comment accompanying +### the production farmer*better*operator*move-alone. +### Replaced the two productions for state failure +### by a set of three similar productions. +### Renamed the attribute ^directed-at as ^abject +### in operator structures. +### + +### +### ABSTRACT. This file provides a Soar system to solve the "farmer's +### dilemma" or problem. The problem consists of the farmer taking a wolf, +### a goat, and a cabbage across a river, one at a time, without leaving +### the goat alone with the cabbage or the wolf (i.e., PRESERVATION-GOAL). +### + +source $default + + +### +### TOP-LEVEL--ELABORATE STATE: +### TASK NAME AND DESIRED +### + +sp {top-level*elaborate*state*task*farmer + (state ^superstate nil) + --> + ( ^name farmer ^desired )} + +### +### TOP-LEVEL--ELABORATE STATE: +### TASK PROBLEM SPACE = FARMER +### + +# Commented out of RHS below (on Jul 19, 94) +# ^one-level-attributes applied + & + +sp {farmer*elaborate*state*space*farmer + (state ^superstate nil ^name farmer) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer + ^default-state-copy yes + ^two-level-attributes holds + & + + )} + +### +### TOP-LEVEL--ELABORATE STATE: +### INITIAL STATE +### + +sp {farmer*elaborate*state*initial-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name farmer) + --> + ( ^farmer + ^wolf + ^goat + ^cabbage + ^location + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^name FARMER) + ( ^name WOLF) + ( ^name GOAT) + ( ^name CABBAGE) + ( ^name LEFT-BANK ^opposite-of ) + ( ^name RIGHT-BANK ^opposite-of )} + +### +### FARMER PROBLEM SPACE OPERATORS: +### MOVE-ALONE AND MOVE-WITH +### + +sp {farmer*propose*operator*move-alone + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move-alone + ^object self + ^from + ^to )} + +sp {farmer*propose*operator*move-with + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move-with + ^object + ^from + ^to )} + +### +### FARMER PROBLEM SPACE: +### OPERATOR APPLICATION +### + +sp {apply*move-alone + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-alone + ^object self + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + --> + ( ^at - )} + +sp {apply*move-with + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-with + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + --> + (

                                                                                                                        ^at - ) + (

                                                                                                                        ^at - )} + +#These operator saving rules would fire also +#in subgoals for operator subgoaling. In this task +#operator subgoaling should not happen. Otherwise, +#add (state -^name operator-subgoal) to the condition +#parts of these rules. Jul 19, 94. + +sp {farmer*save*operator*applied*a + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state -^applied) + --> + ( ^applied )} + +sp {farmer*save*operator*applied*b + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^applied <> ) + --> + ( ^applied - )} + +### +### FARMER PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*move-alone + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-alone + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + --> + ( ^operator @ )} + +sp {terminate*move-with + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-with + ^object + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + --> + ( ^operator @ )} + +### +### FARMER PROBLEM SPACE: +### STATE EVALUATION +### + +### +### EVALUATION: STATE FAILURE +### + +sp {farmer*evaluate*state*failure*a + "Wolf will eat goat." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +sp {farmer*evaluate*state*failure*b + "Goat will eat cabbage." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +sp {farmer*evaluate*state*failure*c + "Goat will eat cabbage." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +### +### STATE EVALUATION: STATE SUCCESS/GOAL TEST +### + + ## This also defines implicitly the desired state + ## of the problem. + # + +sp {farmer*evaluate*state*success + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^name RIGHT-BANK) + --> + ( ^success )} + +### +### FARMER PROBLEM SPACE: +### SEARCH CONTROL +### + + ## Create "reject preference" for inverse operator. + ## Definition of Inverse Operator: + ## apply(a[i],s[i]) = s[j], + ## apply(a[j],S[j]) = s[i], + ## where a[i] and a[j] are different instantiations + ## of the operator A, and s stands for state. The + ## instantiation a[j] is the inverse of a[i]. + ## Example: a[i] = walk(x,y), a[j] = walk(y,x). + # + +sp {farmer*operator*inverse*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^applied ) + ( ^name + ^object + ^from + ^to ) + ( ^name + ^object + ^from + ^to ) + --> + ( ^operator - )} + + ## Without the production below Soar may get into a situation + ## in which the following holds: + ## AT(WOLF,LEFT-BANK) + ## AT(CABBAGE,LEFT-BANK) + ## AT(FARMER,RIGHT-BANK) + ## AT(GOAT,RIGHT-BANK) + ## From this situation it is possible for Soar to repeatedly + ## select a Move-With operator to move the wolf, the goat, or + ## the cabbage. In the process, it will produce the situation + ## in which the goat is at the left-bank, a configuration close + ## to the goal state. Since the goal-state is implicit in this + ## system, it will not be able to recognize this configuration + ## as such and to produce + ## Move-Alone(LEFT-BANK,RIGHT-BANK) + ## and then + ## Move-With(GOAT,LEFT-BANK,RIGHT-BANK) + ## to solve the puzzle. + ## The production below biases Soar to always consider + ## Move-Alone before any Move-With. + # + +sp {farmer*best*operator*move-alone + (state ^operator + ) + ( ^name evaluate-object + ^object ) + ( ^name move-alone) + --> + ( ^operator > )} + +### +### FARMER PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {farmer*monitor*predicate*holds + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^ ^{ <> at } ) + ( ^name ) + --> + (write (crlf) + | HOLDS | + |: at(| + |,| + |)|)} + +sp {farmer*monitor*tied-operator*move-alone + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-alone + ^object self + ^from + ^to ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-alone(self,| + |,| + |)|)} + +sp {farmer*monitor*tied-operator*move-with + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-with + ^object + ^from + ^to ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-with(| + |,| + |,| + |)|)} + +sp {farmer*monitor*operator-application*move-alone + (state ^operator ) + ( ^name move-alone + ^object self + ^from + ^to ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-alone(self,| + |,| + |)|)} + +sp {farmer*monitor*operator-application*move-with + (state ^operator ) + ( ^name + ^object + ^from + ^to ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-with(| + |,| + |,| + |)|)} + +### eof of farmer.s (Version Type: NNPSCM) diff --git a/soar-8.5.2/demos_soar7/gui/graph_tool/graph_tool.tcl b/soar-8.5.2/demos_soar7/gui/graph_tool/graph_tool.tcl new file mode 100644 index 0000000..0f8f151 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/graph_tool/graph_tool.tcl @@ -0,0 +1,136 @@ +# +# Graph demo +# + +global soar_library graphtool_dir graphtool graphtool_path blt_app + +set graphtool_dir $soar_library/../demos/gui/graph_tool +set graphtool soargraph +set graphtool_path $graphtool_dir/$graphtool +set blt_app $soar_library/../../blt-1.8/blt_wish + +proc test-shell {} { + global default graphtool_dir + excise -all + source $default + source $graphtool_dir/farmer.soar + init-soar + init-graph + monitor -add after-decision-cycle show-data + d +} + + +proc show-data {} { + global graphtool + set x [stats -system -dc-count] + set wme [stats -memory -pool wme -used] + set chunk [stats -system -chunk-count] + + send -async $graphtool "line_add wmes $x $wme ; line_add chunks $x $chunk" +} + + +proc init-graph {} { + global graphtool + send -async $graphtool "option add *graph.xTitle \"Decision Cycle\" + option add *graph.yTitle \"Y\" + option add *graph.title \"SoarGraph\" " + init-line wmes circle 1 + init-line chunks plus 3 +} + + +proc init-line {line symbol linewidth} { + global graphtool + set names [send $graphtool {$graph element names}] + if {[lsearch $names $line] >= 0} { + send -async $graphtool "\$graph element delete $line" + } + send -async $graphtool "set ${line}(x) {} + set ${line}(y) {} + \$graph element create $line \ + -xdata \$${line}(x) \ + -ydata \$${line}(y) \ + -symbol $symbol \ + -linewidth $linewidth " +} + +proc terminate-graphing-tool {} { + global graphtool + if {[lsearch [winfo interps] $graphtool] >= 0} { + echo "Terminating graphing tool ..." + send -async $graphtool exit + while (1) { + if {[lsearch [winfo interps] $graphtool] < 0} { + break + } + } + } +} + +proc fire-up-graphing-tool {} { + global graphtool graphtool_path blt_app + terminate-graphing-tool + + exec $blt_app -f $graphtool_path & + + echo "Starting up graphing tool ..." + while (1) { + set interps [winfo interps] + if {[lsearch $interps $graphtool] >= 0} { + break + } + } +} + + +proc mkGraphToolDemo {{w .graphtool}} { + global blt_app + if ![file exists $blt_app] { + tk_dialog .dlg "TkSoar Notification" \ + "Sorry, the Graph Tool Demo needs the BLT application which cannot be found." \ + error 0 {Dismiss} + return + } + catch {destroy $w} + toplevel $w + wm title $w "Graph Tool Demonstation" + wm iconname $w "Graph Tool" + + label $w.msg -font -Adobe-times-medium-r-normal--*-180* \ + -text "Graph Tool Demonstration" -padx 10 -pady 10 + + frame $w.frame -borderwidth 10 + + button $w.frame.run -text "Run Graph Demo" -command {test-shell} + button $w.frame.stop -text "Stop" -command "stop-soar" + button $w.frame.go -text "Continue" -command "d" + button $w.frame.restart -text "Restart Graphing Tool" \ + -command {fire-up-graphing-tool} + + button $w.ok -text Dismiss \ + -command "destroy $w; terminate-graphing-tool; monitor -clear" + + pack $w.frame.run $w.frame.stop $w.frame.go $w.frame.restart -side top + pack $w.msg $w.frame $w.ok -side top + + fire-up-graphing-tool + + monitor -clear + monitor -add after-decision-cycle update +} + +mkGraphToolDemo + + + + + + + + + + + + diff --git a/soar-8.5.2/demos_soar7/gui/graph_tool/readme b/soar-8.5.2/demos_soar7/gui/graph_tool/readme new file mode 100644 index 0000000..d884845 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/graph_tool/readme @@ -0,0 +1,23 @@ +This directory contains the code for the graph tool demo. +This demo shows the use of an external tool to graph Soar +data. Soar is run on a problem, data is extracted during the +run and sent to the graphing tool. This demo illustrates: + + - Ousterhout's hypertool idea + - creating a subprocess + - asynchronous interprocess communication using Tk's "send" + and "after" commands + - use of an independent tool + - extraction of statistics using the new Soar "stats" command + - using Soar callbacks + - attachment of scripts to Soar events using the "monitor" + command + - use of a monitor to extract statisical information and send + to the graphing tool + - use of a monitor to keep the GUI active + - connecting an application to a simple GUI interface + - using Tcl procedures to break up script processing + - use of gateway to previous Soar parser ("soar" command) + +To run this demo, invoke "soartk -useIPC", move to this directory and +"source graph_tool.tcl" \ No newline at end of file diff --git a/soar-8.5.2/demos_soar7/gui/graph_tool/soargraph b/soar-8.5.2/demos_soar7/gui/graph_tool/soargraph new file mode 100644 index 0000000..e2c6151 --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/graph_tool/soargraph @@ -0,0 +1,93 @@ +#!../../blt-1.8/blt_wish -f + +# This code is a slight modification of the script "graph" that +# came with the BLT distribution. + +source $env(SOAR_LIBRARY)/FSBox.tcl + +if [file exists ../library] { + set blt_library ../library +} +option add *Blt_htext.Font *Times-Bold-R*14* +option add *graph.xTitle "Go Step" +option add *graph.yTitle "Y" +option add *graph.title "SoarGraph" +option add *graph.elemBackground red + +set visual [winfo screenvisual .] +if { $visual != "staticgray" } { + option add *print.background yellow + option add *quit.background red +} + + +proc ConfigureGraph { interp graph } { + global env + exec $env(TCL_DIR)/blt-1.8/blt_wish -name GraphConfig \ + -f $env(TCL_DIR)/blt-1.8/demos/grconf.tcl $interp $graph & +} + +set remote {} +global graph +set graph .graph +blt_htext .header -text {%% +%%This is a demo of SoarGraph. It displays two-variable +data with assorted line attributes and symbols. The graph itself has +many components; x and y axis, legend, crosshairs, elements, etc. +You can configure any component by pressing this %% +button $blt_htext(widget).config -text button -bg green \ + -command [list ConfigureGraph [winfo name .] $graph] +$blt_htext(widget) append $blt_htext(widget).config +%%. + +You can zoom in on a section of the graph by using the left mouse +button to mark and drag out a rectangle. Mouse middle returns +you to overview mode. + +To create a postscript file, press the %% +button $blt_htext(widget).print -text print -command { + cd + set file [FSBox "Select File:" [pwd]] + .graph postscript $file -pagewidth 6.5i -pageheight 9i -landscape true +} +$blt_htext(widget) append $blt_htext(widget).print +%% button.} + +blt_graph $graph + +blt_htext .footer -text {Hit the %% +button $blt_htext(widget).quit -text quit -command { + catch "send GraphConfig after 1 exit" + destroy . +} +$blt_htext(widget) append $blt_htext(widget).quit +%% button when you've seen enough.%% +label $blt_htext(widget).logo -bitmap BLT +$blt_htext(widget) append $blt_htext(widget).logo -padx 20 +%%} + +proc line_add {line x y} { + global graph ${line} + lappend ${line}(x) $x + lappend ${line}(y) $y + eval "$graph element configure ${line} \ + -xdata \$${line}(x) -ydata \$${line}(y)" +} + +#$graph crosshairs set on + +pack append . \ + .header { padx 20 pady 10 } \ + .graph {} \ + .footer { padx 20 pady 10 } + +wm min . 0 0 + +source $env(SOAR_LIBRARY)/../../blt-1.8/demos/features.tcl +#SetCrosshairs $graph +SetActiveLegend $graph +SetClosestPoint $graph +SetZoom $graph + +wm min . 0 0 + diff --git a/soar-8.5.2/demos_soar7/gui/monitor_window.tcl b/soar-8.5.2/demos_soar7/gui/monitor_window.tcl new file mode 100644 index 0000000..25753db --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/monitor_window.tcl @@ -0,0 +1,40 @@ +# +# Monitor demo +# +# This demo shows the result of a command being shown in +# a window as Soar executes. This is a recreation of the +# functionality of the previous (pre-Tcl) multi-agent +# (with X) monitor command. +# + +proc mkMonitor {{w .mon} {c {print -stack -operator}}} { + catch {destroy $w} + + set monitor_name [monitor -add after-decision-cycle \ + [list ShowInMonitor $w $c]] + + toplevel $w + wm title $w "Monitor $monitor_name" + wm iconname $w "Monitor $monitor_name" + wm minsize $w 1 1 + + text $w.text -font -adobe-courier-bold-o-normal--14-*-*-*-*\ + -width 60 -height 10 -bd 2 -yscrollcommand "$w.scroll set" + scrollbar $w.scroll -command "$w.text yview" + button $w.ok -text Dismiss \ + -command "destroy $w; monitor -delete after-decision-cycle $monitor_name" + + pack $w.ok -side bottom -fill x + pack $w.scroll -side right -fill y + pack $w.text -side left -expand 1 -fill both +} + +proc ShowInMonitor {w command} { + output-strings-destination -push -append-to-result + $w.text delete 1.0 end + $w.text insert end [eval $command] + output-strings-destination -pop + update +} + +mkMonitor \ No newline at end of file diff --git a/soar-8.5.2/demos_soar7/gui/readme b/soar-8.5.2/demos_soar7/gui/readme new file mode 100644 index 0000000..9cf9dea --- /dev/null +++ b/soar-8.5.2/demos_soar7/gui/readme @@ -0,0 +1,22 @@ +This directory contains various demo programs for Soar 7. More detail +about the directories are: + + critter_world - The code for the Critter World demo + eight_puzzle - The code for the eight puzzle demo/example + graph_tool - The code for the Graph Tool example (uses farmer) + +The subdirectories contain README files that give more detail about +their demos. + +The files in this directory are: + +monitor_window.tcl + This script recreates the functionality of the monitor + command in the pre-Tcl version of Soar with multiple + agents and X windows. This demo illustrates: + + - manipulation of a text window + - use of a monitor to update a window + - monitor naming and deletion + - redirection of Soar prints + diff --git a/soar-8.5.2/demos_soar7/no-gui/analogy/analogy.soar b/soar-8.5.2/demos_soar7/no-gui/analogy/analogy.soar new file mode 100644 index 0000000..8bc576a --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/analogy/analogy.soar @@ -0,0 +1,539 @@ +### Program n-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 +### Version 20 Aug 96 changed to work with Soar 7.0.3 TCL TK -- Sayan Bhattacharyya + +### 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@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. + +package require Soar +source $default + +### ====================================================================== +### 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: + +# trace-format -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: | | | )} + + +### ====================================================================== +### ACTION-PROPOSAL SPACE +### ====================================================================== + +### This is where we drop down to when no action is proposed in the Perform +### space for a given task. The impasse shows up as a State-No-Change. + +### -- Initialise -- + +### Check that there's a task but no action ... Oh no!! That's going to +### give rise to self-undermining chunks. For now, check just that there's +### a task, we'll assume no action. + +sp {action-proposal*initialise + (state ^superstate ^impasse no-change ^attribute state) + ( ^problem-space.name perform) + ( ^task ) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^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*double-click-to-launch + (state ^problem-space.name action-proposal ^superstate ) + ( ^task ) + ( ^feature ) + ( ^fname effect ^fvalue launch) + ( ^fname arg1 ^fvalue ^fvalue << Word draw >>) + --> + ( ^action ) + ( ^movement double-click ^object )} + + +### -- Use analogy -- + +### The only "method" we have is to try using analogy. We'll do this by +### proposing the use-analogy operator, which will implement in its own space. + +sp {action-proposal*use-analogy*propose + (state ^problem-space.name action-proposal) + --> + ( ^name use-analogy) + ( ^operator )} + + +### ====================================================================== +### USE-ANALOGY SPACE +### ====================================================================== + +### This space arise from an Operator No-Change below the Use-analogy +### operator. The logic embodied in this space is as follows: +### +### (1) If the task involves some Effect on some Object Y +### (2) where the Object is of a known Class +### (3) and we can recall other members X of that Class +### (4) then we imagine the task of achieving that Effect on object X +### (5) we replace X by a *general descriptor* of Y +### (6) and return that as the recommended action. + + +### -- Initialise -- + +sp {use-analogy*initialise + (state ^superstate ^impasse no-change ^attribute operator) + ( ^operator.name use-analogy ^superstate ) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name use-analogy) + ( ^task-state )} + + +### -- The method -- + +### Recognise the applicability of the method (= step 1) + +sp {use-analogy*analogy-1*recognise + (state ^problem-space.name use-analogy) + ( ^task-state.task ) + ( ^feature ) + ( ^fname effect ^fvalue ) + ( ^fname arg1 ^fvalue ) + --> + ( ^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 ) + ( ^feature ) + ( ^fname arg1 ^fvalue << cg xl >>) + --> + ( ^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 Word + Word =, draw + draw =, xl + xl =)} + # 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 ^class-member -^imagined-action) + ( ^task-state.task ) + ( ^feature ) + ( ^fname effect ^fvalue ) + --> + ( ^name imagine-task ^task ) + ( ^feature + &, + &) + ( ^fname arg1 ^fvalue ) + ( ^operator )} + +### Monitor the imagine-task operator + +sp {use-analogy*imagine-task*monitor + (state ^problem-space.name use-analogy ^operator ) + ( ^name imagine-task ^task ) + ( ^feature ) + ( ^fname effect ^fvalue ) + ( ^fname arg1 ^fvalue ) + --> + (write | [| | | |]|)} + + +### The imagine-task operator is of course implemented in its own space +### (see below). When it "returns" it will *either* have an ^action marked +### on it, or else a ^fail. We terminate the operator in either case, with +### appropriate responses: + +### For a ^fail, reject the class-member and terminate the operator + +sp {use-analogy*analogy-1*imagine-task*fail*reject-member + (state ^problem-space.name use-analogy ^operator ) + ( ^analogy-method analogy-1) + ( ^name imagine-task ^task ^fail) + ( ^feature ) + ( ^fname arg1 ^fvalue ) + ( ^class-member ) + --> + ( ^class-member -)} + +sp {use-analogy*analogy-1*imagine-task*fail*terminate + (state ^problem-space.name use-analogy ^operator ) + ( ^analogy-method analogy-1) + ( ^name imagine-task ^fail) + --> + ( ^operator @)} + + +### For an ^action, copy it onto the state and terminate the operator + +sp {use-analogy*analogy-1*imagine-task*action*terminate + (state ^problem-space.name use-analogy ^operator ) + ( ^analogy-method analogy-1) + ( ^name imagine-task ^action ) + --> + ( ^imagined-action ) + ( ^operator @)} + + +### -- Making the substitution -- (step 5) + +### We now have an ^imagined-action on the state. We turn this into a +### ^analogised-action by substituting Y for X everywhere it occurs. It's +### a bit ad-hoc, but we'll do this by means of a second-level copy: + +### First, set up a blank analogised-action + +sp {use-analogy*analogy-1*substitute*analogised-action + (state ^problem-space.name use-analogy) + ( ^analogy-method analogy-1) + ( ^imagined-action ) + --> + ( ^analogised-action )} + + +### Then for each attribute, if the value is different to the ^class-member +### then simply copy it, but if it's the same then substitute the original +### object + +sp {use-analogy*analogy-1*substitute*copy + (state ^problem-space.name use-analogy) + ( ^analogy-method analogy-1) + ( ^imagined-action ^analogised-action ^class-member ) + ( ^ { <> }) + --> + ( ^ )} + +sp {use-analogy*analogy-1*substitute*substitute + (state ^problem-space.name use-analogy) + ( ^analogy-method analogy-1) + ( ^imagined-action ^analogised-action ^class-member ) + ( ^ ) + ( ^task-state.task ) + ( ^feature ) + ( ^fname arg1 ^fvalue ) + --> + ( ^ )} + + +### -- Finally, return the analogised-action to the super-state -- (step 6) + +### These rules acknowledge that there is a problem with the timing +### of chunking if we return the action before it is fully built. + +sp {use-analogy*analogy-1*recommend-analogised-action*ready + (state ^problem-space.name use-analogy) + ( ^analogy-method analogy-1) + ( ^analogised-action ) + ( ^ ) + --> + ( ^recommend ready)} + +sp {use-analogy*analogy-1*recommend-analogised-action*recommend + (state ^problem-space.name use-analogy) + ( ^analogy-method analogy-1) + ( ^task-state ^analogised-action ^recommend ready) + --> + ( ^action )} + + +### Now some monitoring rules to follow the progress of the analogy method + +sp {use-analogy*analogy-1*monitor*state*simple-attribute + (state ^problem-space.name use-analogy) + ( ^{ << analogy-method object-class class-member >> } ) + --> + (write (crlf) |Use-analogy state has | | = | )} + +sp {use-analogy*analogy-1*monitor*state*action + (state ^problem-space.name use-analogy) + ( ^{ << imagined-action analogised-action >> } ) + ( ^movement ^object ) + --> + (write (crlf) |Use-analogy state has | |: | | | )} + + +### ====================================================================== +### IMAGINE-TASK SPACE +### ====================================================================== + +### The implementation space for the imagine-task operator, which is of +### course triggered by the Operator No-Change, is made to look in crucial +### respects much like the top, Perform space, so that any immediate +### knowledge we have about doing the task can apply (in imagination). + + +### -- Initialise -- + +sp {imagine-task*initialise + (state ^superstate ^impasse no-change ^attribute operator) + ( ^operator ( ^name imagine-task)) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name perform ^type imaginary ^alias imagine-task) + ( ^superoperator )} + + +### Copy the task onto the state + +sp {imagine-task*initialise*state + (state ^problem-space.alias imagine-task) + ( ^superoperator.task ) + --> + ( ^task )} + + +### -- Imagine doing the task -- + +### At this point, any knowledge about how to do the task will apply. +### If we succeed, an ^action will appear on the state, so we simply copy +### it onto the operator as a way of returning the result. + +sp {imagine-task*return*action + (state ^problem-space.alias imagine-task) + ( ^action ^superoperator ) + --> + ( ^action )} + + +### ====================================================================== +### IMAGINE-TASK-FAIL SPACE +### ====================================================================== + + +### If we *fail* to imagine doing the task, then we will impasse out of +### the Imagine-Task space, through the Action-Proposal space, and into +### what would be a recursive call on Use-Analogy. We need to catch that +### and mark a ^fail on the (super-super-) superoperator. + +### It's a fine point as to whether or not the failure should be chunked. +### For now we don't, probably more interesting not to. + +### It would be cleaner Soar practice to set up an initial problem space and +### and state, at least, before passing back the ^fail. But this is the only +### think we ever do in this space, and what the heck, let's keep it simple! + +sp {imagine-task-fail*mark-fail + (state ^superstate ^impasse no-change ^attribute operator ^quiescence t) + ( ^operator.name use-analogy ^superstate ) + ( ^problem-space.alias imagine-task ^superoperator ) + --> + ( ^fail fail)} + +sp {imagine-task-fail*monitor + (state ^superstate ^impasse no-change ^attribute operator) + ( ^operator.name use-analogy ^superstate ) + ( ^problem-space.alias imagine-task) + --> + (write (crlf) |Fail: we don't know how to do the imagined task|)} + +### ====================================================================== +### EOF +### ====================================================================== diff --git a/soar-8.5.2/demos_soar7/no-gui/blocks-world/blocks-world.soar b/soar-8.5.2/demos_soar7/no-gui/blocks-world/blocks-world.soar new file mode 100644 index 0000000..7f5f380 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/blocks-world/blocks-world.soar @@ -0,0 +1,378 @@ +### +### FILE : blocks-world.s +### + +### +### AUTHOR(1) : John.E.Laird [ Soar 5.2 ] +### + +### +### CREATED(1) : Laird, et al. (1990). Soar User's Manual: Version 5.2 +### + +### +### MODIFIED(3) : Sep 05, 96 [ Soar 7.0.3 ] Sayan Bhattacharyya +### MODIFIED(2) : Apr 26, 93 [ Soar 6.0.7 ] Aladin.Akyurek +### MODIFIED(1) : Apr 24, 91 [ Soar 5.2.x ] Aladin.Akyurek +### + +### Sep 05, 96 : Updated to run in Soar 7.0.3 +### Apr 26, 93 : Updated to run in Soar 6.0.7, 6.0.8. +### Apr 24, 91 : Modified to run to completion in Soar 5.2. +### + +package require Soar +source $default +learn -except + +### +### TOP PROBLEM SPACE: +### ELABORATE TOP STATE +### + +sp {top-ps*elaborate*initial-state + (state ^name top-goal ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name top-ps) + ( ^name top-state) + --> + ( ^object-dynamic + &, + + &, + + &, + + & ) + ( ^object-static ^clear yes ^ontop ) + ( ^name A ^type block) + ( ^object-static ^clear no ^ontop

                                                                                                                        ) + ( ^name B ^type block) + ( ^object-static ^clear yes ^ontop
                                                                                                                        ) + ( ^name C ^type block) + ( ^clear yes ^object-static
                                                                                                                        ) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +sp {top-ps*elaborate*state*detect-tower + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name top-ps) + ( ^object-dynamic + { <> } + { <> <> }) + ( ^object-static ^ontop ) + ( ^object-static + ^ontop ) + ( ^object-static + ^ontop

                                                                                                                        ) + ( ^name A) + ( ^name B) + ( ^name C) + (
                                                                                                                        ^name table) + --> + ( ^object-dynamic + & ) + ( ^top-block + ^middle-block + ^bottom-block )} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name top-ps) + ( ^object-dynamic + + + ) + ( ^object-static ) + ( ^name A) + ( ^object-static ) + ( ^name B) + ( ^object-static ) + ( ^name C) + ( ^object-static

                                                                                                                        ) + (
                                                                                                                        ^name table) + -{ ( ^object-dynamic ) + ( ^top-block + ^middle-block + ^bottom-block ) } + --> + ( ^operator ) + ( ^name build-tower ^desired-state ) + ( ^object-dynamic + &, + + &, + + & + ^ontop-count 3) + ( ^object-static ^ontop ) + ( ^object-static ^ontop ) + ( ^object-static ^ontop
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### +### TOP PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {top-goal*terminate*operator*build-tower + (state ^problem-space

                                                                                                                        + ^operator ) + (

                                                                                                                        ^name top-ps) + ( ^object-dynamic ) + ( ^top-block + ^middle-block + ^bottom-block ) + ( ^name build-tower) + ( ^name A) + ( ^name B) + ( ^name C) + --> + ( ^operator @ )} + +### +### SUBGOAL BUILD-TOWER: +### DESIRED STATE +### + +sp {operator-no-chage*elaborate*goal*build-tower + (state ^superstate + ^impasse no-change + ^attribute operator) + (state ^operator ) + ( ^name build-tower ^desired-state ) + --> + ( ^desired ^name build-tower)} + +### +### SUBGOAL BUILD-TOWER: +### PROBLEM SPACE +### + +sp {build-tower*propose*space*blocks-world + (state ^name build-tower) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name blocks-world)} + +sp {build-tower*elaborate*space*blocks-world + (state ^name build-tower ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name blocks-world) + --> + (

                                                                                                                        ^default-state-copy yes + ^default-operator-copy no + ^two-level-attributes object-dynamic + & )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### INITIAL STATE +### + +#sp {blocks-world*propose*initial-state +# (state ^name build-tower ^problem-space

                                                                                                                        +# ^superstate ) +# (

                                                                                                                        ^name blocks-world) +# +# --> +# ) + + +### SB 9/5/96 +# Learning must be turned off for the blocks-world problem space +# as this is a chunk-free problem space + +sp {turn-learning-off + (state ^problem-space.name blocks-world) + --> + (dont-learn )} + +### SBH 7/8/94 +### New for NNPSCM: must copy down state attrs. to op subgoaling state. + +sp {blocks-world*operator-subgoaling*copy-operator-dynamics + (state ^problem-space.name blocks-world ^name build-tower + ^superstate.object-dynamic ) + --> + ( ^object-dynamic + &)} +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name blocks-world) + ( ^object-dynamic { <> }) + ( ^object-static ^clear yes -^ontop ) + ( ^type block) + ( ^object-static ^clear yes) + --> + ( ^operator + ) + ( ^name move-block + ^moving-block + ^destination )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator ) + ( ^object-dynamic ) + ( ^object-static + ^ontop { <> } + -^ontop ) + ( ^moving-block ^destination ) + --> + ( ^ontop - )} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator ) + ( ^object-dynamic ) + ( ^object-static ) + ( ^moving-block + ^destination ) + --> + ( ^ontop + )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator ) + ( ^object-dynamic ) + ( ^object-static ^clear yes) + ( ^type block) + ( ^destination ) + --> + ( ^clear yes - ^clear no)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator ) + ( ^object-dynamic { <> }) + ( ^object-static ^clear no) + ( ^object-static ^ontop { <> }) + ( ^moving-block ^destination ) + ( ^type block) + --> + ( ^clear no - ^clear yes)} + +sp {blocks-world*apply*operator*remember*moved-block*a + (state ^operator ) + ( -^last-moved-block) + ( ^moving-block ) + --> + ( ^last-moved-block + )} + +sp {blocks-world*apply*operator*remember*moved-block*b + (state ^operator ) + ( ^moving-block ) + --> + ( ^last-moved-block + )} + +sp {blocks-world*apply*operator*forget*last-moved-block + (state ^operator ) + ( ^last-moved-block ) + ( ^moving-block <> ) + --> + ( ^last-moved-block - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {blocks-world*terminate*operator*move-block + (state ^operator ) + ( ^object-dynamic ) + ( ^moving-block ^destination ) + ( ^object-static ^ontop ) + --> + ( ^operator @ )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {blocks-world*reject*move-block*twice + (state ^problem-space

                                                                                                                        + ^operator + ) + (

                                                                                                                        ^name blocks-world) + ( ^last-moved-block ) + ( ^moving-block ) + --> + ( ^operator - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### STATE EVALUATION/GOAL TEST +### + +sp {blocks-world*elaborate*goal*achieved + (state ^desired ) + ( ^object-dynamic ) + ( ^object-static ^ontop ) + ( ^object-dynamic ) + ( ^object-static ^ontop ) + --> + ( ^achieved & )} + +sp {blocks-world*elaborate*state*success + (state + ^desired + ^achieved + { <> } + { <> <> }) + ( ^ontop-count 3) + --> + ( ^success & )} + +sp {top-ps*default-operator*wait*halt + (state ^operator ) + ( ^name wait) + --> + (halt)} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*state*relation*ontop + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name blocks-world) + ( ^object-dynamic ) + ( ^object-static ^ontop ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*tied-operators*move-block + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-block(| + |,| + |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/blocks-opsub.soar b/soar-8.5.2/demos_soar7/no-gui/default/blocks-opsub.soar new file mode 100644 index 0000000..524344f --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/blocks-opsub.soar @@ -0,0 +1,211 @@ +### +### FILE : blocks-world.soar +### AUTHOR(1) : John.E.Laird [ Soar 8.1 ] +### CREATED(1) : December 12, 1998 +### + +source simple.soar + +sp {top-ps*elaborate*initial-state + (state ^name top-goal) + --> + ( ^world-state + ^ontop + ^clear

                                                                                                                        + ^object
                                                                                                                        ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^name top-state + ^object
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        )} + --> + ( ^operator ) + ( ^name build-tower + ^desired ) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^name << move-block build-tower >> + ^world-state ) + ( ^object + { <> }) + ( ^type block) +-{( ^ontop ) + ( ^top-block + ^bottom-block )} + --> + ( ^operator + =) + ( ^name move-block + ^moving-block + ^destination ) + } + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator + ^world-state ) + ( ^ontop + ^clear ) + ( ^top-block + -^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^ontop -)} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator + ^world-state ) + ( ^clear ) + ( ^moving-block + ^destination ) + --> + ( ^ontop ) + ( ^top-block + ^bottom-block )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator + ^world-state ) + ( ^clear ) + ( ^moving-block + ^destination ) + ( ^type block) + --> + ( ^clear -)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator + ^world-state ) + ( ^ontop ^clear ) + ( ^top-block + ^bottom-block { <> }) + ( ^type block) + ( ^moving-block + ^destination ) + --> + ( ^clear )} + +### +### SEARCH CONTROL +### + +sp {blocks-world*prefer*clear-block + (state ^operator + + ^desired.clear + ^world-state.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block ) + --> + ( ^operator >)} + +sp {blocks-world*prefer*ontop + (state ^operator + + ^desired.ontop + ^world-state ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^operator >)} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*world-state + (state ^world-state.ontop ) + ( ^top-block.name + ^bottom-block.name ) + --> + (write (crlf)| ontop(| |,| |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) |SELECT | |: move-block(| |,| |)|)} + +######### OPERATOR SUBGOALING + +sp {default*opsub*propose*space*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^moving-block + ^destination ) + --> + ( ^problem-space + ^name operator-subgoal + ^desired ) + ( ^clear )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal + ^superstate ) + ( ^ { <> problem-space + <> choices + <> impasse + <> object + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/default.soar b/soar-8.5.2/demos_soar7/no-gui/default/default.soar new file mode 100644 index 0000000..6c64bbe --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/default.soar @@ -0,0 +1,1434 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified By: John Laird +## Last Modified On: Friday December 11, 1998 +## +## Contents: Default productions for Soar 8.1 +## +############################################################################### + +## Significant Changes made to Convert to Soar 8.1 + +### +### iv. Possible Problems +### +### The default knowledge has a mind set that all evaluate-object operators +### will either be directly implemented, or will be implemented in a subspace +### that is performing look ahead style evaluation. This should be checked to +### see if it causes errors. +### +### There is still one opp-app declaration, due to a bug in support classification. +### +### Evaluate-rejected and evaluate-primary are still in this knowledge as +### operator names, but are not proposed by this knowledge. +### +### Operator subgoaling has known outstanding problems. +### + +### +### +### 7.1 Default knowledge for the top context +### + +## Elaborate the top goal with name top-goal and top-state. +## both are required for backward compatibility +## Make it worst so it will be overridden by all other names. + +sp {default*top-state*elaborate*state*name*top-state*top-goal + "Propose top-goal as name of top goal." + :default + (state ^superstate nil) + --> + ( ^name top-goal + ^name top-state)} + +## Elaborate state with io pointer. + +sp {default*elaborate*state*io + "Elaborate the initial state in the top problem space." + :default + (state ^impasse no-change + ^superstate ) + ( ^io ) + --> + ( ^io )} + +## Elaborate a state with the name of the superoperator + +sp {elaborate*state*operator*name + (state ^superstate.operator.name ) +--> + ( ^name )} + +### Propose wait for a state no-change + +sp {top-ps*propose*wait + (state ^attribute state + ^choices none + -^operator.name wait) +--> + ( ^operator +) + ( ^name wait)} + +### This avoids a operator no-change after wait is selected +### I've included it just to keep the trace simple + +sp {top-ps*apply*wait*random + (state ^operator ) + ( ^name wait) +--> + ( ^random elaboration)} + +sp {default*top-goal*halt*operator*failure + "Halt if no operator can be selected for the top goal." + :default + (state ^superstate nil) + (state ^impasse constraint-failure ^superstate ) + --> + (write (crlf) |No operator can be selected for top goal.| ) + (write (crlf) |Soar must halt.| ) + (halt)} + +### +### 7.2 Default knowledge for impasses +### +### +### 7.2.1 Multi-choice impasses +### +### /* SBH/mvp 7-8-94 */ +### If the problem space for handling the subgoal fails, signified by the +### choices none impasse below it, make an indifferent and worst-preference +### for each tied object. +### Only applies to operators in NNPSCM because operators are the only context slot +### that can tie. + +sp {default*select*indifferent-and-worst*tied + "Indifferent an object if it leads to a tie that can not be solved." + :default + (state ^problem-space.name selection + ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + (state ^operator +) + --> + ( ^operator =, < )} + +### If the problem space for handling the subgoal fails, signified by +### the choices none impasse below it, make a reject-preference for each +### conflicted object. + +sp {default*select*reject-and-reconsider*conflict + "Reject an object if it leads to a conflict that can not be solved." + :default + (state ^impasse conflict + ^attribute operator + ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + (state ^operator +) + --> + ( ^operator -)} + + +### +### 7.2.2 Operator no-change impasses +### +### See operator subgoaling, as this is the default action here. + +### +### 7.2.3 Other no-change impasses +### + +### If no objects are available for a slot, and there is no operator to +### find more, reject next higher object. + +sp {default*elaborate*operator*failed + "Mark an operator as failed if can not suggest operators in subgoal" + :default + :o-support ;# required so fail persists following operator rejection + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + (state ^attribute operator + ^choices none + ^superstate + ^quiescence t) + (state ^operator ) + --> + ( ^failed t)} + +sp {default*select*reject*failed*operator + "Reject an object if it leads to a no-change that cannot be solved." + :default + (state ^operator +) + ( ^failed t) + --> + ( ^operator - )} + + +### +### 7.2.4 Constraint-failure impasses +### + +### If there is a constraint-failure for a operator, below an object, +### reject that object. + +sp {default*elaborate*operator*failed*constraint-failure + :default + :o-support + (state ^impasse constraint-failure + ^superstate + ^quiescence t) + (state ^superstate + ^attribute operator + ^choices none) + (state ^operator ) + --> + ( ^failed t)} + +### +### 7.3 The selection space for multi-choice impasses +### + +### Use the selection problem space for all choice multiple, impasses +### - make it worst so that any other will dominate. + +sp {default*selection*propose*space*selection + :default + (state ^choices multiple) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name selection)} + +### Signal that a value other than novalue has been assigned. + +sp {default*selection*elaborate*state*found-value-true + :default + (state ^problem-space.name selection + ^choices multiple) + ( ^evaluation ) + ( ^ << numeric-value symbolic-value >> <> novalue) + --> + ( ^found-value true)} + + +### Signal that there are still objects to evaluate. + +sp {default*selection*elaborate*state*wait-true-not-all-objects-evaluated + :default + (state ^problem-space.name selection + ^operator + + ^choices multiple) + - {( ^type evaluation + ^evaluation ) + ( ^ << numeric-value symbolic-value >> )} + --> + ( ^wait true)} + +### +### 7.3.1 The evaluate-object operator +### + +### Create evaluate operator in selection problem space. + +sp {default*selection*propose*evaluate-object + :default + (state ^problem-space.name selection + ^item ) + -{(state ^evaluation ) ;#"state" added. AA/mvp 9-2-94 + ( ^object + ^value t)} + --> + ( ^state + ^name evaluate-object + ^object ) + ( ^operator +)} + + +### Make them indifferent if not ^operator-selection not-indifferent. + +sp {default*selection*select*evaluate-object*indifferent + :default + (state ^problem-space

                                                                                                                        + ^operator +) + (

                                                                                                                        ^name selection + - ^operator-selection not-indifferent) + ( ^name evaluate-object) + --> + ( ^operator =)} + +### Label all evaluation operators with ^type evaluation. + +sp {default*selection*elaborate*operator*evaluate-object*type-evaluation + :default + (state ^operator ) + ( ^name << evaluate-object evaluate-dominated evaluate-primary >> ) + --> + ( ^type evaluation)} + +### Create evaluation once the eval operator is selected. + +sp {default*selection*elaborate*state*evaluation + :default + (state ^operator ) + ( ^type evaluation) + --> + ( ^evaluation ) + ( ^state ^operator ) + ( ^evaluation )} + +sp {default*selection*elaborate*evaluate-object*desired + :default + (state ^operator + ^superstate.desired ) + ( ^type evaluation) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluate-object*superproblem-space + :default + (state ^problem-space.name selection + ^operator + ^superstate.problem-space ) + ( ^type evaluation) + --> + ( ^superproblem-space )} + +sp {default*selection*elaborate*evaluate-object*superstate + :default + (state ^problem-space.name selection + ^operator + ^superstate ) + ( ^type evaluation) + --> + ( ^superstate )} + +### If all objects have been evaluated, and all have value novalue, and +### there is a object being evaluated in a higher context, assign that +### object novalue. + +sp {default*selection*elaboare*evaluate-object*all-objects-novalue + :default + (state ^superstate.superstate + ^operator + - ^wait + - ^found-value + ^quiescence t + ^choices multiple) + (state ^problem-space.name selection + ^operator ) + ( ^type evaluation) + --> + ( ^numeric-value novalue ^evaluation-type final)} + + +### +### 7.3.1.1 Evaluation Objects +### + +sp {default*selection*elaborate*evaluation*value + :default + (state ^evaluation ) + ( ^ << numeric-value symbolic-value >>) + --> + ( ^value t)} + +sp {default*selection*elaborate*evaluation*desired + :default + (state ^superstate.desired + ^evaluation ) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluation*object + :default + (state ^operator + ^evaluation ) + ( ^object + ^evaluation + ^type evaluation) + --> + ( ^object )} + +sp {default*selection*elaborate*evaluation*type + :default + (state ^operator + ^evaluation ) + ( ^name + ^evaluation + ^type evaluation) + --> + ( ^type )} + + +### +### 7.3.1.2 Applying the evaluate-object operator +### +### Domain specific code may directly implement an evaluation, or an operator no-change may occur +### to do the job, see the next section. + + + +### +### 7.3.2 The evaluation subgoal +### + +### +### These productions which fire once an evaluation subgoal has been created +### have also been generalized. + +### SBH/mvp 9-2-94 +sp {default*evaluate-object*elaborate*state*desired + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( -^default-desired-copy yes ^type evaluation ^desired ) + --> + ( ^desired )} + + +sp {default*evaluate-object*elaborate*state*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator.name evaluate-object) + --> + ( ^name implement-evaluate-object)} + +sp {default*evaluate-object*elaborate*state*problem-space + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + --> + ( ^problem-space

                                                                                                                        )} + +## install a copy of the state, when ^default-state-copying and there +## is an operator tie. + +sp {default*evaluate-object*elaborate*state*duplicate-of + :default + (state ^problem-space

                                                                                                                        + ^superstate + ^default-state-copy yes) + (state ^operator ) + ( ^type evaluation + ^superstate ) + --> + ( ^duplicate-of* )} + +### Added test for superproblem-space. This restricts these productions +### to only fire in a lookahead. Previously, these productions made it +### impossible to use evaluation problem spaces other than lookahead. +### JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*look-ahead-operator*copy + :default + (state ^problem-space.name ^superstate.operator ) + ( ^type evaluation + ^default-operator-copy yes ^object ^superproblem-space.name ) + --> + ( ^look-ahead-operator ) + ( ^duplicate-of* )} + + +## Create pointer for uniform access even in no copy + +### Added test for superproblem-space. This restricts these productions +### to only fire in a lookahead. Previously, these productions made it +### impossible to use evaluation problem spaces other than lookahead. +### JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*look-ahead-operator*no-copy + :default + (state ^problem-space

                                                                                                                        ^superstate.operator ) + ( ^type evaluation + ^default-operator-copy no ^object ^superproblem-space

                                                                                                                        ) + --> + ( ^look-ahead-operator )} + +### install copy of operator in lookahead context. +###

                                                                                                                        / checks to correct bug from TJ +### Modified by JEL/mvp 07-Nov-93 + +sp {default*evaluate-object*propose*look-ahead + :default + (state ^problem-space.name ^look-ahead-operator ^superstate ) + (state ^superstate.problem-space.name ^operator.type evaluation) + -( ^tried-tied-operator ) + --> + ( ^operator ! +)} + + +### Detect that the operator has been tried when a duplicate is being used. + +sp {default*evaluate-object*elaborate*state*tried-tied-operator*copy + :default + (state ^problem-space

                                                                                                                        ^operator + ^superstate ^default-operator-copy yes) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ^object ) + ( ^duplicate-of* ) + --> + ( ^tried-tied-operator )} + +## Detect that the operator has been tried when a duplicate is not being used. + +sp {default*evaluate-object*elaborate*state*tried-tied-operator*no-copy + :o-support + :default + (state ^problem-space

                                                                                                                        ^operator + ^superstate ^default-operator-copy no) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ^object ) + --> + ( ^tried-tied-operator )} + + +### Give symbol-value failure when no operators are proposed in subgoals + +sp {default*evaluate-object*elaborate*evaluation*failure*no-operators + :default + (state ^operator ) + ( ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ^quiescence t) + (state ^superstate ^attribute state ^impasse no-change ^quiescence t) + (state ^superstate ^attribute state ^impasse no-change ^quiescence t) + --> + ( ^symbolic-value failure)} + + +sp {default*evaluate-object*elaborate*evaluation*failure*constraint-failure + :default + (state ^operator ) + ( ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ) + (state ^superstate ^attribute operator + ^impasse constraint-failure) + --> + ( ^symbolic-value failure)} + +sp {default*evaluate-object*elaborate*evaluation*from-subgoal + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator ^evaluation ) + ( ^type evaluation ^evaluation ^desired ) + --> + ( ^symbolic-value )} + + +## Added to handle duplicated desireds +sp {default*evaluate-object*elaborate*evaluation*from-subgoal*duplicate-desired + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator + ^evaluation ) + ( ^type evaluation ^evaluation ^desired ) + ( ^duplicate-of* ) + --> + ( ^symbolic-value )} + + +### +### 7.3.2.1. State Copying +### + +## If no signals on problem space, the default is to copy both state and operator + +sp {default*evaluate-object*elaborate*operator*type-evaluation*default-for-default-state-copy-is-yes + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-state-copy no) + --> + ( ^default-state-copy yes)} + +sp {default*evaluate-object*elaborate*operator*type-evaluation*default-state-copy-from-problem-space + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        ^default-state-copy ) + --> + ( ^default-state-copy )} + +### Default is that all-attributes-at-level are copied + +sp {default*evaluate-object*elaborate*state*default-state-copy-from-type-evaluation-operator + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation ^default-state-copy ) + --> + ( ^default-state-copy )} + +sp {default*evaluate-object*elaborate*state*default-copy-is-all-attributes-at-level-one + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        -^all-attributes-at-level two + -^one-level-attributes + -^two-level-attributes + -^dont-copy + -^dont-copy-anything) + --> + ( ^all-attributes-at-level one)} + +### We want ^all-attributes-at-level one to be on the goal, but if someone +### puts it on the space along with the other copying flags, we should allow +### that. So, copy it from the space to the goal. + +sp {default*evaluate-object*elaborate*state*copy-all-attributes-at-level-one-from-problem-space + :default + (state ^problem-space

                                                                                                                        ^default-state-copy yes) + (

                                                                                                                        ^all-attributes-at-level one) + --> + ( ^all-attributes-at-level one)} + +### Set up identifier mapping table for state duplication. + +sp {default*evaluate-object*elaborate*state*create-duplicates-table + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^default-state-copy yes) + --> + ( ^duplicates* )} + +### Copy one-level-attributes. + +### Replaced test for implement-evaluate-object with test for superproblem- +### space. Makes the productions more general and is consistent with other +### default productions for lookahead search. JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*add-one-level-attributes + :default + (state ^operator ) + ( ^superproblem-space

                                                                                                                        ) + (state ^problem-space

                                                                                                                        ^superstate + ^default-state-copy yes) + (

                                                                                                                        ^one-level-attributes ) + ( ^duplicate-of* ) + ( ^ ) + --> + ( ^ )} + +## Copy all attributes, when ^all-attributes-at-level one. + +### Replaced test for implement-evaluate-object with test for superproblem- +### space. Makes the productions more general and is consistent with other +### default productions for lookahead search. JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*add-all-attributes-at-level-one + :default + (state ^operator ) + ( ^superproblem-space

                                                                                                                        ) + (state ^problem-space

                                                                                                                        ^superstate + ^default-state-copy yes ^all-attributes-at-level one + ^duplicate-of* ) + (

                                                                                                                        - ^dont-copy-anything - ^dont-copy + - ^two-level-attributes ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +### If we copied a one-level-attribute, and it later turned +### out that its value happened to be something that was pointed to by a +### two-level-attribute, change its value to be the copied object. + +sp {default*evaluate-object*elaborate*state*change-one-level-attribute-to-duplicate + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^one-level-attributes ) + ( ^ ) + ( ^ ) + --> + ( ^ - )} + +### Fixes, when all-attributess-at-level one. + +sp {default*evaluate-object*elaborate*state*change-all-attributes-at-level-one-to-duplicate + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^all-attributes-at-level one + ^duplicate-of* ) + (

                                                                                                                        - ^dont-copy ) + ( ^{ <> tried-tied-operator } ) + ( ^ ) + --> + ( ^ - )} + +### Create new ids for two-level-attributes. + +sp {default*evaluate-object*elaborate*state*duplicate-id-for-attribute + :default + (state ^problem-space

                                                                                                                        + ^duplicates* ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^two-level-attributes ) + ( ^ ) + --> + ( ^ + =)} + +### Create new ids for all attributes, when ^all-attributes-at-level two. + +sp {default*evaluate-object*elaborate*state*duplicate-id-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        -^dont-copy-anything + -^dont-copy + ^all-attributes-at-level two + -^one-level-attributes ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +### Create a copy of the old object on the new link. First copy +### augmentations that don't point to objects that have been +### duplicated. + +set warnings off +sp {default*evaluate-object*elaborate*add-attribute-to-duplicate + :default + (state ^duplicates* + ^default-state-copy yes) + ( ^ + - ^) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Next copy augmentations that point to duplicated objects: + +set warnings off +sp {default*evaluate-object*elaborate*add-duplicated-attribute-to-duplicate + :default + (state + ^duplicates* ^default-state-copy yes) + ( ^ + ^ ) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Added ^two-level-attributes . Previously, it +### would copy any attribute that happened to point to the same value as +### one of the two-level-attributes. + +sp {default*evaluate-object*elaborate*state*add-duplicate-to-state + :default + (state ^problem-space

                                                                                                                        + ^duplicates* ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^two-level-attributes ) + ( ^ ) + ( ^ ) + --> + ( ^ )} + + +### moves the new links to the state when ^all-atts two. + +sp {default*evaluate-object*elaborate*state*add-duplicates-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^all-attributes-at-level two + - ^dont-copy-anything + - ^dont-copy + - ^one-level-attributes ) + ( ^{ <> tried-tied-operator } ) + ( ^ ) + --> + ( ^ )} + +## ------------------------------- +## Desired copying: +## ------------------------------- + +## Copy attributes to the duplicate desired state. We +## do this after the state is installed so that the duplicates table +## will already have been filled in. We just copy all attributes over +## from the original operator, except that attributes that pointed to +## objects that have been duplicated (on the state) are modified to point +## to the duplicate objects. + +sp {default*evaluate-object*elaborate*state*eval*desired + :default + (state ^superstate ) + (state ^operator ) + ( ^type evaluation ^desired ^default-desired-copy yes) + --> + ( ^desired ) + ( ^duplicate-of* )} + + +## Copy attributes whose values haven't been duplicated. + +### SBH/mvp 9-2-94 +### Added parallel preference to the copied attribute. +### Also, added the condition that the desired be attached to +### an evaluation superoperator. This is because if we use the same +### desired in a lower lookahead context, this production re-firing +### can cause stupid chunks. + +sp {default*duplicate-desired*copy-old-value + :default + (state ^superstate ^duplicates* ^desired ) + (state ^operator ) + ( ^type evaluation ^desired ) + ( ^duplicate-of* ) + ( ^{ <> duplicate-of* } -^dont-copy ) + - ( ^) + --> + ( ^ )} + +## Copy attributes whose values have been duplicated. + +sp {default*duplicate-desired*replace-old-value + :default + (state ^duplicates* ^desired ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^dont-copy ) + ( ^ ) + --> + ( ^ )} + + + +### 7.3.2.3 Operator copying +### +### Copy attributes to the duplicate operator. We +### do this after the state is installed so that the duplicates table +### will already have been filled in. We just copy all attributes over +### from the original operator, except that attributes that pointed to +### objects that have been duplicated (on the state) are modified to point +### to the duplicate objects. + + +sp {default*evaluate-object*elaborate*operator*default-operator-copy-is-yes + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-operator-copy no) + --> + ( ^default-operator-copy yes)} + + +sp {default*evaluate-object*elaborate*operator*copy-default-operator-copy-from-problem-space + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        ^default-operator-copy ) + --> + ( ^default-operator-copy )} + + +sp {default*evaluate-object*elaborate*state*copy-default-operator-copy-from-type-evaluation-operator + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation ^default-operator-copy ) + --> + ( ^default-operator-copy )} + +### Set up identifier mapping table for operator + +sp {default*evaluate-object*elaborate*state*create-duplicates-table-for-operator-only + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^default-operator-copy yes + - ^default-state-copy yes) + --> + ( ^duplicates* )} + +### Copy attributes whose values haven't been duplicated. +### + +sp {default*evaluate-object*elaborate*operator*add-attribute-to-duplicate-operator + :default + (state ^duplicates* ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^ dont-copy ) + ( - ^) + --> + ( ^ )} + +### Copy attributes whose values have been duplicated. + +sp {default*evaluate-object*elaborate*operator*add-duplicated-attribute-to-duplicate-operator + :default + (state ^duplicates* ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^dont-copy ) + ( ^ ) + --> + ( ^ )} + + +### +### 7.3.3 Computing evaluations +### +### +### 7.3.3.1 Computing numeric evaluations +### +### This is domain specific, so there are no default productions for this. + +### +### 7.3.3.2 Comparing numeric evaluations +### + +### If two objects have equal evaluations they are indifferent. + +sp {default*selection*compare*equal-evaluation-indifferent + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation { <> }) + ( ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + - ( ^equal not-indifferent) + --> + ( ^operator = )} ;# was ^ + + +### +### Generate operator preferences based on their evaluations and info +### as to whether higher or lower evaluations are better. + +sp {default*selection*compare*higher-evaluation-better + :default + (state ^problem-space.name selection + ^superstate + ^evaluation ^evaluation { <> }) + (state ^problem-space ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value < ^desired + ^type evaluate-object) + ( ^better higher) + --> + ( ^operator < )} + ;# was ^ + +sp {default*selection*compare*prefer-lower-evaluation + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation ^evaluation { <> }) + (state ^problem-space ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value > ^desired + ^type evaluate-object) + ( ^better lower) + --> + ( ^operator < )} + + +### +### 7.3.3.3 Computing symbolic evaluations +### + + +sp {default*selection*compare*same-symbolic-evaluations-are-indifferent + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + --> + ( ^operator = )} + +sp {default*selection*compare*success-evaluation-better-than-partial-success + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value success ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value partial-success + ^desired ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*compare*partial-failure-evaluation-better-than-failure + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value partial-failure ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value failure ^desired + ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*select*required-success-evaluation-becomes-required-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value required-success) + --> + ( ^operator !)} + +sp {default*selection*select*success-evaluation-becomes-best-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value << partial-success success >>) + --> + ( ^operator >)} + +sp {default*selection*select*indifferent-evaluation-becomes-indifferent-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value indifferent) + --> + ( ^operator =)} + +sp {default*selection*select*partial-failure-evaluation-becomes-worst-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired + ^object ) + ( ^symbolic-value partial-failure) + --> + ( ^operator <)} + +sp {default*selection*select*failure-evaluation-becomes-reject-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value << lose failure >>) + --> + ( ^operator -)} + +sp {default*selection*select*prohibit-failure-evaluation-becomes-prohibit-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value prohibit-failure) + --> + ( ^operator ~)} + + + +### +### 7.3.3.4 Default evaluations +### + +### A. default*pass-back-success +## if an operator leads to success and it is being +## tried out in a subgoal to evaluate another operator - +## give that second operator a success evaluation also + + +### AA/mvp 9-2-94 +sp {default*pass-back-success + :default + (state ^operator ^superstate ) ;# removed ^evaluation + ( ^name evaluate-object ^evaluation ) + ( ^symbolic-value << required-success success >>) + (state ^superstate ) + (state ^operator ) ;# removed ^evaluation + ( ^name evaluate-object ^evaluation ^object ) + ( ^name) + --> + ( ^symbolic-value partial-success)} + + + +### +### 7.3.3.5 Novalue evaluations +### + +### Make novalue worse than any other value. + +sp {default*selection*compare*novalue-evaluation-always-worse + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation ^evaluation { <> }) + (state ^desired ) + ( ^object ^numeric-value novalue ^desired + ^type evaluate-object) + ( ^object ^numeric-value <> novalue ^desired + ^type evaluate-object) + --> + ( ^operator > )} ;# was ^ + + +### +### 7.3.4 Halting Soar with success or failure +### + +### A. default*top-goal*halt*state*success +### Handle state augmentations dealing with goal termination for the top-level goal. + +sp {default*top-goal*halt*success + :default + (state ^name + ^desired + ^superstate nil + ^<< required-success success >> ) + --> + (write (crlf) | achieved |) + (halt)} + +### B. default*top-goal*halt*state*failure + +sp {default*top-goal*halt*failure + :default + (state ^superstate nil + ^desired + ^name + ^ << prohibit-failure failure >> ) + --> + (write (crlf) | failed|) + (halt)} + + +### +### 7.4 Operator Subgoaling (modified extensively by JEL/mvp 07-Nov-93) +####################################################################################### +### RESTRICTIONS ON USE: +### +### 1. The problem space used for operator implmentation can not be exactly +### the same problem space used for operator subgoaling (or the original +### task problem space). It can be a duplicate, but can not have the same +### identifier. This is because operator subgoaling is signalled by the +### selection of the task space as the problem space in the operator +### no-change subgoal. +### +### 2. For operator subgoaling and operator implementation to work +### together, there must be a production that tests when the preconditions +### of the operator have been achieved (operator subgoaling is successful) +### and whose action is to reconsider the problem space. This is necessary +### so that the switch can be made from the operator subgoaling problem +### space (the original task space) and the operator implementation problem +### space. +### +### sp {task*reconsider*problem-space*operator-subgoaling +### (state ^impasse no-change ^attribute operator ^object +### ^problem-space

                                                                                                                        ) +### (state ^problem-space

                                                                                                                        ^operator ) +### (state ^attributes that test operator instantiated) +### (operator ^name ...) +### --> +### (state ^problem-space @)} +### +### 3. All operators must be augmented with ^achieved when they have +### successfully applied. This helps avoid problems where chunks learned +### through operator subgoaling, can undo operator actions, and vice +### versa. +### +### 4. Operators must apply by changing existing structures on the state, +### not by creating new ones, or destroying existing ones. +### +##################################################################################### + +##################################################################################### +### OVERVIEW +### +### For look-ahead searches, always select the operator that subgoaling on +### after another operator has applied. If it then sucessfully applied, the +### look-ahead search was a success. +### +##################################################################################### + + +### make the super-problem space the default +### when there is a no-change for the operator +### make is worst so operator implementation will win out + +sp {default*generic*opsub*propose*space*generic + :default + (state ^impasse no-change ^attribute operator + ^superstate ) + (state ^problem-space ) + --> + ( ^problem-space )} + +###if the superproblem-space is selected as the +### current problem space then operator subgoaling +### is being used so select the superstate - +### the super-operator becomes the desired) +### +### The name gets a parallel preference because the state +### above (which is being copied down to this state) may +### also have a name. + +sp {default*generic*opsub*elaborate*state*name*operator-subgoal + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + (state ^problem-space

                                                                                                                        ) + --> + ( ^name operator-subgoal)} + +sp {default*generic*opsub*elaborate*state*desired + :default + (state ^problem-space

                                                                                                                        ^name operator-subgoal ^superstate ) + (state ^operator ) + --> + ( ^desired )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal ^superstate ) + ( ^ { <> problem-space <> impasse <> object <> name + <> superstate <> attribute <> operator <> desired } + ) + --> + ( ^ )} + +### The following is commented out; it would provide for keeping track +### of all levels of operator subgoaling, not just the most recent. +### Pass down all super operator subgoals as well. +# +# sp {default*generic*opsub*goal*elaborate*all-desireds +# :default +# (state ^problem-space

                                                                                                                        +# ^impasse no-change ^attribute operator ^superstate ) +# (state ^problem-space

                                                                                                                        ^desired ) +# --> +# (state ^desired )} +# +# +###don't select the operator for the operator that we are +### subgoaling on. + +sp {default*generic*select*reject-desired + :default + (state ^name operator-subgoal ^problem-space

                                                                                                                        ^desired ) + --> + ( ^operator -)} + +##if there is an evaluation subgoal within +### an operator subgoal and the operator being +### subgoaled on is applied - success + +sp {default*generic*opsub*detect*state*success + :default + (state ^problem-space

                                                                                                                        ^desired ^applied ) + ( ^achieved ) + --> + ( ^success )} + +sp {opsub*select-operator*subgoaling + :default + (state ^name implement-evaluate-object ^problem-space

                                                                                                                        + ^operator <> ^desired ) + ( ^name) + --> + ( ^operator !)} + +sp {default*generic*opsub*failure*no-operator + :default + (state ^superstate ^impasse no-change ^attribute state ^quiescence t) + ( ^name operator-subgoal ^desired ) + --> + ( ^failure )} + +sp {default*generic*evaluation*failure*no-operator + :default + (state ^superstate ^impasse no-change ^name operator-subgoal + ^attribute operator ^desired ^quiescence t + ^failure ) + ( ^operator ^desired ) + --> + ( ^failure )} + + +sp {default*generic*opsub*avoid*duplicate-operator + :default + (state ^impasse no-change ^name operator-subgoal + ^attribute operator ^operator + ^super-desired ) + ( ^name ) + ( ^name ) + --> + ( ^operator -)} + +#sp {default*generic*opsub*operator-subgoals +# :default +# (state ^name implement-evaluate-object ^problem-space

                                                                                                                        +# ^operator ^desired ) +# (state ^name operator-subgoal ^superstate ) +# --> +# ( ^operator @)} + +## These maintain the super-desireds + +sp {default*generic*opsub*subgoal-on-all-desired-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^desired ) + --> + ( ^super-desired &)} + +sp {default*generic*opsub*subgoal-on-all-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^super-desired ) + --> + ( ^super-desired &)} + +sp {default*apply*evaluate*augment*evaluation-operator-super-desired + :default + (state ^operator ^superstate ) + ( ^super-desired ) + ( ^evaluation ^type evaluation) + --> + ( ^super-desired &)} + +sp {default*elaborate*state*eval*super-desired + :default + (state ^impasse no-change ^attribute operator ^superstate ) + ( ^operator ) + ( ^type evaluation ^super-desired ) + --> + ( ^super-desired &)} + +### +### 7.5 Execution monitoring +### + +### If the state is marked with ^success , the goal succeeds. + +sp {default*monitor*goal*success + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-success required-success success >> ) + --> + (write (crlf) | Goal | | succeeded. |)} + +### If the state is marked with ^failure , the goal fails. + +sp {default*monitor*goal*failure + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-failure failure prohibit-failure >> ) + --> + (write (crlf) | Goal | | failed. |)} + +### Print the evaluation of any object that has a name (which doesn't +### get states). + +sp {default*monitor*operator*evaluation + :default + (state ^superstate nil -^verbose false) + (state ^operator ) + ( ^type evaluation ^object ^evaluation ) + ( ^ << numeric-value symbolic-value >> ) + ( ^name ) + --> + (write (crlf) | Evaluation of | | (| + |) is | )} + +sp {default*monitor*attribute-impasses + :default + (state ^superstate nil -^verbose false) + (impasse ^object ^attribute ^impasse ) + --> + (write (crlf) | Impasse for | | ^| + | type: | )} + + + + + + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/operator-subgoaling.soar b/soar-8.5.2/demos_soar7/no-gui/default/operator-subgoaling.soar new file mode 100644 index 0000000..e4e7ee1 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/operator-subgoaling.soar @@ -0,0 +1,207 @@ + +### +### 7.4 Operator Subgoaling (modified extensively by JEL/mvp 07-Nov-93) +####################################################################################### +### RESTRICTIONS ON USE: +### +### 1. The problem space used for operator implmentation can not be exactly +### the same problem space used for operator subgoaling (or the original +### task problem space). It can be a duplicate, but can not have the same +### identifier. This is because operator subgoaling is signalled by the +### selection of the task space as the problem space in the operator +### no-change subgoal. +### +### 2. For operator subgoaling and operator implementation to work +### together, there must be a production that tests when the preconditions +### of the operator have been achieved (operator subgoaling is successful) +### and whose action is to reconsider the problem space. This is necessary +### so that the switch can be made from the operator subgoaling problem +### space (the original task space) and the operator implementation problem +### space. +### +### sp {task*reconsider*problem-space*operator-subgoaling +### (state ^impasse no-change ^attribute operator ^object +### ^problem-space

                                                                                                                        ) +### (state ^problem-space

                                                                                                                        ^operator ) +### (state ^attributes that test operator instantiated) +### (operator ^name ...) +### --> +### (state ^problem-space @)} +### +### 3. All operators must be augmented with ^achieved when they have +### successfully applied. This helps avoid problems where chunks learned +### through operator subgoaling, can undo operator actions, and vice +### versa. +### +### 4. Operators must apply by changing existing structures on the state, +### not by creating new ones, or destroying existing ones. +### +##################################################################################### + +##################################################################################### +### OVERVIEW +### +### For look-ahead searches, always select the operator that subgoaling on +### after another operator has applied. If it then sucessfully applied, the +### look-ahead search was a success. +### +##################################################################################### + + +### make the super-problem space the default +### when there is a no-change for the operator +### make is worst so operator implementation will win out + +sp {default*generic*opsub*propose*space*generic + :default + (state ^impasse no-change ^attribute operator + ^superstate ) + (state ^problem-space ) + --> + ( ^problem-space )} + +###if the superproblem-space is selected as the +### current problem space then operator subgoaling +### is being used so select the superstate - +### the super-operator becomes the desired) +### +### The name gets a parallel preference because the state +### above (which is being copied down to this state) may +### also have a name. + +sp {default*generic*opsub*elaborate*state*name*operator-subgoal + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + (state ^problem-space

                                                                                                                        ) + --> + ( ^name operator-subgoal)} + +sp {default*generic*opsub*elaborate*state*desired + :default + (state ^problem-space

                                                                                                                        ^name operator-subgoal ^superstate ) + (state ^operator ) + --> + ( ^desired )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal ^superstate ) + ( ^ { <> problem-space <> impasse <> object <> name + <> superstate <> attribute <> operator <> desired } + ) + --> + ( ^ )} + +### The following is commented out; it would provide for keeping track +### of all levels of operator subgoaling, not just the most recent. +### Pass down all super operator subgoals as well. +# +# sp {default*generic*opsub*goal*elaborate*all-desireds +# :default +# (state ^problem-space

                                                                                                                        +# ^impasse no-change ^attribute operator ^superstate ) +# (state ^problem-space

                                                                                                                        ^desired ) +# --> +# (state ^desired )} +# +# +###don't select the operator for the operator that we are +### subgoaling on. + +sp {default*generic*select*reject-desired + :default + (state ^name operator-subgoal ^problem-space

                                                                                                                        ^desired ) + --> + ( ^operator -)} + +##if there is an evaluation subgoal within +### an operator subgoal and the operator being +### subgoaled on is applied - success + +sp {default*generic*opsub*detect*state*success + :default + (state ^problem-space

                                                                                                                        ^desired ^applied ) + ( ^achieved ) + --> + ( ^success )} + +sp {opsub*select-operator*subgoaling + :default + (state ^name implement-evaluate-object ^problem-space

                                                                                                                        + ^operator <> ^desired ) + ( ^name) + --> + ( ^operator !)} + +sp {default*generic*opsub*failure*no-operator + :default + (state ^superstate ^impasse no-change ^attribute state ^quiescence t) + ( ^name operator-subgoal ^desired ) + --> + ( ^failure )} + +sp {default*generic*evaluation*failure*no-operator + :default + (state ^superstate ^impasse no-change ^name operator-subgoal + ^attribute operator ^desired ^quiescence t + ^failure ) + ( ^operator ^desired ) + --> + ( ^failure )} + + +sp {default*generic*opsub*avoid*duplicate-operator + :default + (state ^impasse no-change ^name operator-subgoal + ^attribute operator ^operator + ^super-desired ) + ( ^name ) + ( ^name ) + --> + ( ^operator -)} + +#sp {default*generic*opsub*operator-subgoals +# :default +# (state ^name implement-evaluate-object ^problem-space

                                                                                                                        +# ^operator ^desired ) +# (state ^name operator-subgoal ^superstate ) +# --> +# ( ^operator @)} + +## These maintain the super-desireds + +sp {default*generic*opsub*subgoal-on-all-desired-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^desired ) + --> + ( ^super-desired &)} + +sp {default*generic*opsub*subgoal-on-all-super-desireds + :default + (state ^problem-space

                                                                                                                        + ^impasse no-change ^attribute operator ^superstate ) + ( ^problem-space

                                                                                                                        ^super-desired ) + --> + ( ^super-desired &)} + +sp {default*apply*evaluate*augment*evaluation-operator-super-desired + :default + (state ^operator ^superstate ) + ( ^super-desired ) + ( ^evaluation ^type evaluation) + --> + ( ^super-desired &)} + +sp {default*elaborate*state*eval*super-desired + :default + (state ^impasse no-change ^attribute operator ^superstate ) + ( ^operator ) + ( ^type evaluation ^super-desired ) + --> + ( ^super-desired &)} + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/selection.soar b/soar-8.5.2/demos_soar7/no-gui/default/selection.soar new file mode 100644 index 0000000..bb1a731 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/selection.soar @@ -0,0 +1,1044 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default/simple-selection.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified By: John Laird +## Last Modified On: Friday December 11, 1998 +## +## Contents: Default productions for simple-selection problem space for Soar 8.1 +## Only works for one level copies of internal states - copies +## every attribute on the top-level state unless the top-state +## has a world-state attribute, in which case it copies all of the +## world-state attributes. +## +############################################################################### + +## Significant Changes made to Convert to Soar 8.1 + +### +### iv. Possible Problems +### +### The default knowledge has a mind set that all evaluate-object operators +### will either be directly implemented, or will be implemented in a subspace +### that is performing look ahead style evaluation. This should be checked to +### see if it causes errors. +### +### There is still one opp-app declaration, due to a bug in support classification. +### +### Evaluate-rejected and evaluate-primary are still in this knowledge as +### operator names, but are not proposed by this knowledge. +### +### The selection space for multi-choice impasses +### + +### Use the selection problem space for all choice multiple, impasses +### - make it worst so that any other will dominate. + +sp {default*selection*propose*space*selection + :default + (state ^choices multiple) + --> + ( ^problem-space.name selection)} + +### Signal that a value other than novalue has been assigned. + +sp {default*selection*elaborate*state*found-value-true + :default + (state ^problem-space.name selection + ^choices multiple) + ( ^evaluation ) + ( ^ << numeric-value symbolic-value >> <> novalue) + --> + ( ^found-value true)} + + +### Signal that there are still objects to evaluate. + +sp {default*selection*elaborate*state*wait-true-not-all-objects-evaluated + :default + (state ^problem-space.name selection + ^operator + + ^choices multiple) + - {( ^type evaluation + ^evaluation ) + ( ^ << numeric-value symbolic-value >> )} + --> + ( ^wait true)} + +### +### 7.3.1 The evaluate-object operator +### + +### Create evaluate operator in selection problem space. + +sp {default*selection*propose*evaluate-object + :default + (state ^problem-space.name selection + ^item ) + -{(state ^evaluation ) ;#"state" added. AA/mvp 9-2-94 + ( ^object + ^value t)} + --> + ( ^state + ^name evaluate-object + ^object ) + ( ^operator +)} + + +### Make them indifferent if not ^operator-selection not-indifferent. + +sp {default*selection*select*evaluate-object*indifferent + :default + (state ^problem-space

                                                                                                                        + ^operator +) + (

                                                                                                                        ^name selection + - ^operator-selection not-indifferent) + ( ^name evaluate-object) + --> + ( ^operator =)} + +### Label all evaluation operators with ^type evaluation. + +sp {default*selection*elaborate*operator*evaluate-object*type-evaluation + :default + (state ^operator ) + ( ^name << evaluate-object evaluate-dominated evaluate-primary >> ) + --> + ( ^type evaluation)} + +### Create evaluation once the eval operator is selected. + +sp {default*selection*elaborate*state*evaluation + :default + (state ^operator ) + ( ^type evaluation) + --> + ( ^evaluation ) + ( ^state ^operator ) + ( ^evaluation )} + +sp {default*selection*elaborate*evaluate-object*desired + :default + (state ^operator + ^superstate.desired ) + ( ^type evaluation) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluate-object*superproblem-space + :default + (state ^problem-space.name selection + ^operator + ^superstate.problem-space ) + ( ^type evaluation) + --> + ( ^superproblem-space )} + +sp {default*selection*elaborate*evaluate-object*superstate + :default + (state ^problem-space.name selection + ^operator + ^superstate ) + ( ^type evaluation) + --> + ( ^superstate )} + +### If all objects have been evaluated, and all have value novalue, and +### there is a object being evaluated in a higher context, assign that +### object novalue. + +sp {default*selection*elaboare*evaluate-object*all-objects-novalue + :default + (state ^superstate.superstate + ^operator + - ^wait + - ^found-value + ^quiescence t + ^choices multiple) + (state ^problem-space.name selection + ^operator ) + ( ^type evaluation) + --> + ( ^numeric-value novalue ^evaluation-type final)} + + +### +### 7.3.1.1 Evaluation Objects +### + +sp {default*selection*elaborate*evaluation*value + :default + (state ^evaluation ) + ( ^ << numeric-value symbolic-value >>) + --> + ( ^value t)} + +sp {default*selection*elaborate*evaluation*desired + :default + (state ^superstate.desired + ^evaluation ) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluation*object + :default + (state ^operator + ^evaluation ) + ( ^object + ^evaluation + ^type evaluation) + --> + ( ^object )} + +sp {default*selection*elaborate*evaluation*type + :default + (state ^operator + ^evaluation ) + ( ^name + ^evaluation + ^type evaluation) + --> + ( ^type )} + + +### +### 7.3.1.2 Applying the evaluate-object operator +### +### Domain specific code may directly implement an evaluation, or an operator no-change may occur +### to do the job, see the next section. + + + +### +### 7.3.2 The evaluation subgoal +### + +### +### These productions which fire once an evaluation subgoal has been created +### have also been generalized. + +### SBH/mvp 9-2-94 +sp {default*evaluate-object*elaborate*state*desired + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( -^default-desired-copy yes ^type evaluation ^desired ) + --> + ( ^desired )} + + +sp {default*evaluate-object*elaborate*state*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator.name evaluate-object) + --> + ( ^name implement-evaluate-object)} + +sp {default*evaluate-object*elaborate*state*problem-space + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + --> + ( ^problem-space

                                                                                                                        )} + +## install a copy of the state, when ^default-state-copying and there +## is an operator tie. + +sp {default*evaluate-object*elaborate*state*duplicate-of + :default + (state ^problem-space

                                                                                                                        + ^superstate + ^default-state-copy yes) + (state ^operator ) + ( ^type evaluation + ^superstate ) + --> + ( ^duplicate-of* )} + +### Added test for superproblem-space. This restricts these productions +### to only fire in a lookahead. Previously, these productions made it +### impossible to use evaluation problem spaces other than lookahead. +### JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*look-ahead-operator*copy + :default + (state ^problem-space.name ^superstate.operator ) + ( ^type evaluation + ^default-operator-copy yes ^object ^superproblem-space.name ) + --> + ( ^look-ahead-operator ) + ( ^duplicate-of* )} + + +## Create pointer for uniform access even in no copy + +### Added test for superproblem-space. This restricts these productions +### to only fire in a lookahead. Previously, these productions made it +### impossible to use evaluation problem spaces other than lookahead. +### JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*look-ahead-operator*no-copy + :default + (state ^problem-space

                                                                                                                        ^superstate.operator ) + ( ^type evaluation + ^default-operator-copy no ^object ^superproblem-space

                                                                                                                        ) + --> + ( ^look-ahead-operator )} + +### install copy of operator in lookahead context. +###

                                                                                                                        / checks to correct bug from TJ +### Modified by JEL/mvp 07-Nov-93 + +sp {default*evaluate-object*propose*look-ahead + :default + (state ^problem-space.name ^look-ahead-operator ^superstate ) + (state ^superstate.problem-space.name ^operator.type evaluation) + -( ^tried-tied-operator ) + --> + ( ^operator ! +)} + + +### Detect that the operator has been tried when a duplicate is being used. + +sp {default*evaluate-object*elaborate*state*tried-tied-operator*copy + :default + (state ^problem-space

                                                                                                                        ^operator + ^superstate ^default-operator-copy yes) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ^object ) + ( ^duplicate-of* ) + --> + ( ^tried-tied-operator )} + +## Detect that the operator has been tried when a duplicate is not being used. + +sp {default*evaluate-object*elaborate*state*tried-tied-operator*no-copy + :o-support + :default + (state ^problem-space

                                                                                                                        ^operator + ^superstate ^default-operator-copy no) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ^object ) + --> + ( ^tried-tied-operator )} + + +### Give symbol-value failure when no operators are proposed in subgoals + +sp {default*evaluate-object*elaborate*evaluation*failure*no-operators + :default + (state ^operator ) + ( ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ^quiescence t) + (state ^superstate ^attribute state ^impasse no-change ^quiescence t) + (state ^superstate ^attribute state ^impasse no-change ^quiescence t) + --> + ( ^symbolic-value failure)} + + +sp {default*evaluate-object*elaborate*evaluation*failure*constraint-failure + :default + (state ^operator ) + ( ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ) + (state ^superstate ^attribute operator + ^impasse constraint-failure) + --> + ( ^symbolic-value failure)} + +sp {default*evaluate-object*elaborate*evaluation*from-subgoal + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator ^evaluation ) + ( ^type evaluation ^evaluation ^desired ) + --> + ( ^symbolic-value )} + + +## Added to handle duplicated desireds +sp {default*evaluate-object*elaborate*evaluation*from-subgoal*duplicate-desired + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator + ^evaluation ) + ( ^type evaluation ^evaluation ^desired ) + ( ^duplicate-of* ) + --> + ( ^symbolic-value )} + + +### +### 7.3.2.1. State Copying +### + +## If no signals on problem space, the default is to copy both state and operator + +sp {default*evaluate-object*elaborate*operator*type-evaluation*default-for-default-state-copy-is-yes + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-state-copy no) + --> + ( ^default-state-copy yes)} + +sp {default*evaluate-object*elaborate*operator*type-evaluation*default-state-copy-from-problem-space + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        ^default-state-copy ) + --> + ( ^default-state-copy )} + +### Default is that all-attributes-at-level are copied + +sp {default*evaluate-object*elaborate*state*default-state-copy-from-type-evaluation-operator + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation ^default-state-copy ) + --> + ( ^default-state-copy )} + +sp {default*evaluate-object*elaborate*state*default-copy-is-all-attributes-at-level-one + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        -^all-attributes-at-level two + -^one-level-attributes + -^two-level-attributes + -^dont-copy + -^dont-copy-anything) + --> + ( ^all-attributes-at-level one)} + +### We want ^all-attributes-at-level one to be on the goal, but if someone +### puts it on the space along with the other copying flags, we should allow +### that. So, copy it from the space to the goal. + +sp {default*evaluate-object*elaborate*state*copy-all-attributes-at-level-one-from-problem-space + :default + (state ^problem-space

                                                                                                                        ^default-state-copy yes) + (

                                                                                                                        ^all-attributes-at-level one) + --> + ( ^all-attributes-at-level one)} + +### Set up identifier mapping table for state duplication. + +sp {default*evaluate-object*elaborate*state*create-duplicates-table + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^default-state-copy yes) + --> + ( ^duplicates* )} + +### Copy one-level-attributes. + +### Replaced test for implement-evaluate-object with test for superproblem- +### space. Makes the productions more general and is consistent with other +### default productions for lookahead search. JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*add-one-level-attributes + :default + (state ^operator ) + ( ^superproblem-space

                                                                                                                        ) + (state ^problem-space

                                                                                                                        ^superstate + ^default-state-copy yes) + (

                                                                                                                        ^one-level-attributes ) + ( ^duplicate-of* ) + ( ^ ) + --> + ( ^ )} + +## Copy all attributes, when ^all-attributes-at-level one. + +### Replaced test for implement-evaluate-object with test for superproblem- +### space. Makes the productions more general and is consistent with other +### default productions for lookahead search. JEL 6/21/91 + +sp {default*evaluate-object*elaborate*state*add-all-attributes-at-level-one + :default + (state ^operator ) + ( ^superproblem-space

                                                                                                                        ) + (state ^problem-space

                                                                                                                        ^superstate + ^default-state-copy yes ^all-attributes-at-level one + ^duplicate-of* ) + (

                                                                                                                        - ^dont-copy-anything - ^dont-copy + - ^two-level-attributes ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +### If we copied a one-level-attribute, and it later turned +### out that its value happened to be something that was pointed to by a +### two-level-attribute, change its value to be the copied object. + +sp {default*evaluate-object*elaborate*state*change-one-level-attribute-to-duplicate + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^one-level-attributes ) + ( ^ ) + ( ^ ) + --> + ( ^ - )} + +### Fixes, when all-attributess-at-level one. + +sp {default*evaluate-object*elaborate*state*change-all-attributes-at-level-one-to-duplicate + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^all-attributes-at-level one + ^duplicate-of* ) + (

                                                                                                                        - ^dont-copy ) + ( ^{ <> tried-tied-operator } ) + ( ^ ) + --> + ( ^ - )} + +### Create new ids for two-level-attributes. + +sp {default*evaluate-object*elaborate*state*duplicate-id-for-attribute + :default + (state ^problem-space

                                                                                                                        + ^duplicates* ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^two-level-attributes ) + ( ^ ) + --> + ( ^ + =)} + +### Create new ids for all attributes, when ^all-attributes-at-level two. + +sp {default*evaluate-object*elaborate*state*duplicate-id-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        -^dont-copy-anything + -^dont-copy + ^all-attributes-at-level two + -^one-level-attributes ) + ( ^{ <> duplicate-of* <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +### Create a copy of the old object on the new link. First copy +### augmentations that don't point to objects that have been +### duplicated. + +set warnings off +sp {default*evaluate-object*elaborate*add-attribute-to-duplicate + :default + (state ^duplicates* + ^default-state-copy yes) + ( ^ + - ^) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Next copy augmentations that point to duplicated objects: + +set warnings off +sp {default*evaluate-object*elaborate*add-duplicated-attribute-to-duplicate + :default + (state + ^duplicates* ^default-state-copy yes) + ( ^ + ^ ) + ( ^ { <> tried-tied-operator } ) + --> + ( ^ )} +set warnings on + +### Added ^two-level-attributes . Previously, it +### would copy any attribute that happened to point to the same value as +### one of the two-level-attributes. + +sp {default*evaluate-object*elaborate*state*add-duplicate-to-state + :default + (state ^problem-space

                                                                                                                        + ^duplicates* ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^two-level-attributes ) + ( ^ ) + ( ^ ) + --> + ( ^ )} + + +### moves the new links to the state when ^all-atts two. + +sp {default*evaluate-object*elaborate*state*add-duplicates-for-all-attributes + :default + (state ^problem-space

                                                                                                                        + ^duplicates* + ^default-state-copy yes + ^duplicate-of* ) + (

                                                                                                                        ^all-attributes-at-level two + - ^dont-copy-anything + - ^dont-copy + - ^one-level-attributes ) + ( ^{ <> tried-tied-operator } ) + ( ^ ) + --> + ( ^ )} + +## ------------------------------- +## Desired copying: +## ------------------------------- + +## Copy attributes to the duplicate desired state. We +## do this after the state is installed so that the duplicates table +## will already have been filled in. We just copy all attributes over +## from the original operator, except that attributes that pointed to +## objects that have been duplicated (on the state) are modified to point +## to the duplicate objects. + +sp {default*evaluate-object*elaborate*state*eval*desired + :default + (state ^superstate ) + (state ^operator ) + ( ^type evaluation ^desired ^default-desired-copy yes) + --> + ( ^desired ) + ( ^duplicate-of* )} + + +## Copy attributes whose values haven't been duplicated. + +### SBH/mvp 9-2-94 +### Added parallel preference to the copied attribute. +### Also, added the condition that the desired be attached to +### an evaluation superoperator. This is because if we use the same +### desired in a lower lookahead context, this production re-firing +### can cause stupid chunks. + +sp {default*duplicate-desired*copy-old-value + :default + (state ^superstate ^duplicates* ^desired ) + (state ^operator ) + ( ^type evaluation ^desired ) + ( ^duplicate-of* ) + ( ^{ <> duplicate-of* } -^dont-copy ) + - ( ^) + --> + ( ^ )} + +## Copy attributes whose values have been duplicated. + +sp {default*duplicate-desired*replace-old-value + :default + (state ^duplicates* ^desired ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^dont-copy ) + ( ^ ) + --> + ( ^ )} + + + +### 7.3.2.3 Operator copying +### +### Copy attributes to the duplicate operator. We +### do this after the state is installed so that the duplicates table +### will already have been filled in. We just copy all attributes over +### from the original operator, except that attributes that pointed to +### objects that have been duplicated (on the state) are modified to point +### to the duplicate objects. + + +sp {default*evaluate-object*elaborate*operator*default-operator-copy-is-yes + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + -(

                                                                                                                        ^default-operator-copy no) + --> + ( ^default-operator-copy yes)} + + +sp {default*evaluate-object*elaborate*operator*copy-default-operator-copy-from-problem-space + :default + (state ^operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + (

                                                                                                                        ^default-operator-copy ) + --> + ( ^default-operator-copy )} + + +sp {default*evaluate-object*elaborate*state*copy-default-operator-copy-from-type-evaluation-operator + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation ^default-operator-copy ) + --> + ( ^default-operator-copy )} + +### Set up identifier mapping table for operator + +sp {default*evaluate-object*elaborate*state*create-duplicates-table-for-operator-only + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ) + ( ^type evaluation + ^default-operator-copy yes + - ^default-state-copy yes) + --> + ( ^duplicates* )} + +### Copy attributes whose values haven't been duplicated. +### + +sp {default*evaluate-object*elaborate*operator*add-attribute-to-duplicate-operator + :default + (state ^duplicates* ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^ dont-copy ) + ( - ^) + --> + ( ^ )} + +### Copy attributes whose values have been duplicated. + +sp {default*evaluate-object*elaborate*operator*add-duplicated-attribute-to-duplicate-operator + :default + (state ^duplicates* ^look-ahead-operator ) + ( ^duplicate-of* ) + ( ^ { <> duplicate-of* } + - ^dont-copy ) + ( ^ ) + --> + ( ^ )} + + +### +### 7.3.3 Computing evaluations +### +### +### 7.3.3.1 Computing numeric evaluations +### +### This is domain specific, so there are no default productions for this. + +### +### 7.3.3.2 Comparing numeric evaluations +### + +### If two objects have equal evaluations they are indifferent. + +sp {default*selection*compare*equal-evaluation-indifferent + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation { <> }) + ( ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + - ( ^equal not-indifferent) + --> + ( ^operator = )} ;# was ^ + + +### +### Generate operator preferences based on their evaluations and info +### as to whether higher or lower evaluations are better. + +sp {default*selection*compare*higher-evaluation-better + :default + (state ^problem-space.name selection + ^superstate + ^evaluation ^evaluation { <> }) + (state ^problem-space ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value < ^desired + ^type evaluate-object) + ( ^better higher) + --> + ( ^operator < )} + ;# was ^ + +sp {default*selection*compare*prefer-lower-evaluation + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation ^evaluation { <> }) + (state ^problem-space ^desired ) + ( ^object ^numeric-value ^desired + ^type evaluate-object) + ( ^object ^numeric-value > ^desired + ^type evaluate-object) + ( ^better lower) + --> + ( ^operator < )} + + +### +### 7.3.3.3 Computing symbolic evaluations +### + + +sp {default*selection*compare*same-symbolic-evaluations-are-indifferent + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + --> + ( ^operator = )} + +sp {default*selection*compare*success-evaluation-better-than-partial-success + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value success ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value partial-success + ^desired ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*compare*partial-failure-evaluation-better-than-failure + :default + (state ^problem-space.name selection ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value partial-failure ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value failure ^desired + ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*select*required-success-evaluation-becomes-required-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value required-success) + --> + ( ^operator !)} + +sp {default*selection*select*success-evaluation-becomes-best-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value << partial-success success >>) + --> + ( ^operator >)} + +sp {default*selection*select*indifferent-evaluation-becomes-indifferent-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value indifferent) + --> + ( ^operator =)} + +sp {default*selection*select*partial-failure-evaluation-becomes-worst-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation + ^desired + ^object ) + ( ^symbolic-value partial-failure) + --> + ( ^operator <)} + +sp {default*selection*select*failure-evaluation-becomes-reject-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value << lose failure >>) + --> + ( ^operator -)} + +sp {default*selection*select*prohibit-failure-evaluation-becomes-prohibit-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ^operator +) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value prohibit-failure) + --> + ( ^operator ~)} + + + +### +### 7.3.3.4 Default evaluations +### + +### A. default*pass-back-success +## if an operator leads to success and it is being +## tried out in a subgoal to evaluate another operator - +## give that second operator a success evaluation also + + +### AA/mvp 9-2-94 +sp {default*pass-back-success + :default + (state ^operator ^superstate ) ;# removed ^evaluation + ( ^name evaluate-object ^evaluation ) + ( ^symbolic-value << required-success success >>) + (state ^superstate ) + (state ^operator ) ;# removed ^evaluation + ( ^name evaluate-object ^evaluation ^object ) + ( ^name) + --> + ( ^symbolic-value partial-success)} + + + +### +### 7.3.3.5 Novalue evaluations +### + +### Make novalue worse than any other value. + +sp {default*selection*compare*novalue-evaluation-always-worse + :default + (state ^problem-space.name selection ;#^attribute ;#REMOVED. + ^superstate + ^evaluation ^evaluation { <> }) + (state ^desired ) + ( ^object ^numeric-value novalue ^desired + ^type evaluate-object) + ( ^object ^numeric-value <> novalue ^desired + ^type evaluate-object) + --> + ( ^operator > )} ;# was ^ + + +### +### 7.3.4 Halting Soar with success or failure +### + +### A. default*top-goal*halt*state*success +### Handle state augmentations dealing with goal termination for the top-level goal. + +sp {default*top-goal*halt*success + :default + (state ^name + ^desired + ^superstate nil + ^<< required-success success >> ) + --> + (write (crlf) | achieved |) + (halt)} + +### B. default*top-goal*halt*state*failure + +sp {default*top-goal*halt*failure + :default + (state ^superstate nil + ^desired + ^name + ^ << prohibit-failure failure >> ) + --> + (write (crlf) | failed|) + (halt)} + +### +### 7.5 Execution monitoring +### + +### If the state is marked with ^success , the goal succeeds. + +sp {default*monitor*goal*success + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-success required-success success >> ) + --> + (write (crlf) | Goal | | succeeded. |)} + +### If the state is marked with ^failure , the goal fails. + +sp {default*monitor*goal*failure + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-failure failure prohibit-failure >> ) + --> + (write (crlf) | Goal | | failed. |)} + +### Print the evaluation of any object that has a name (which doesn't +### get states). + +sp {default*monitor*operator*evaluation + :default + (state ^superstate nil -^verbose false) + (state ^operator ) + ( ^type evaluation ^object ^evaluation ) + ( ^ << numeric-value symbolic-value >> ) + ( ^name ) + --> + (write (crlf) | Evaluation of | | (| + |) is | )} + + + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/simple-opsub.txt b/soar-8.5.2/demos_soar7/no-gui/default/simple-opsub.txt new file mode 100644 index 0000000..e16900e --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/simple-opsub.txt @@ -0,0 +1,361 @@ +### +### FILE : blocks-world.soar +### + +### +### AUTHOR(1) : John.E.Laird [ Soar 8.1 ] +### + +### +### CREATED(1) : December 12, 1998 + +### + +source simple.soar + +### + +sp {top-ps*elaborate*initial-state + (state ^name top-goal) + --> + ( ^world-state + ^ontop + ^clear + ^objects

                                                                                                                        ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^object ) + ( ^object ) + ( ^object
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^problem-space.name top-ps + ^objects
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        )} + --> + ( ^operator ) + ( ^name build-tower + ^desired ) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### +### SUBGOAL BUILD-TOWER: +### DESIRED STATE +### + +sp {build-tower*elaborate*state*desired-state + (state ^worldstate + ^impasse no-change + ^attribute operator) + ( ^operator.desired ) + --> + ( ^desired + ^world-state )} + +### +### SUBGOAL BUILD-TOWER: +### PROBLEM SPACE +### + +sp {build-tower*propose*space*blocks-world + (state ^name build-tower) + --> + ( ^problem-space.name blocks-world)} + +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^problem-space.name blocks-world + ^world-state ) + ( ^object { <> }) + ( ^type block) + --> + ( ^operator + ) + ( ^name move-block + ^moving-block + ^destination + ^conditions + ^actions ) + ( ^clear ) + ( ^add + ^remove ) } + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator + ^world-state ) + ( ^ontop ) + ( ^top-block + -^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^ontop -)} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator + ^world-state ) + ( ^moving-block + ^destination ) + --> + ( ^ontop ) + ( ^top-block + ^bottom-block )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator.destination + ^world-state ) + ( ^clear ) + ( ^object ) + --> + ( ^clear -)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator + ^world-state ) + ( ^ontop ) + ( ^top-block + ^bottom-block { <> }) + -( ^type table) + ( ^moving-block + ^destination ) + --> + ( ^clear.object )} + +sp {blocks-world*apply*operator*remember*moved-block*a + (state ^operator.moving-block + ^world-state ) + ( -^last-moved-block) + --> + ( ^last-moved-block )} + +sp {blocks-world*apply*operator*forget*last-moved-block + (state ^operator.moving-block <> + ^world-state ) + ( ^last-moved-block ) + --> + ( ^last-moved-block - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {blocks-world*reject*move-block*twice + (state ^problem-space.name blocks-world + ^operator + + ^world-state.last-moved-block ) + ( ^moving-block ) + --> + ( ^operator - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### STATE EVALUATION/GOAL TEST +### + +sp {blocks-world*elaborate*state*success + (state ^desired + ^world-state ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + --> + ( ^success )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*world-state + (state ^world-state.ontop ) + ( ^top-block.name + ^bottom-block ) + --> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*tied-operators*move-block + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-block(| + |,| + |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} + + + +sp {top-ps*select*operator*impasse*tie*break + (state ^attribute operator + ^impasse tie + ^item + ^superstate ) +--> + (write (crlf) | Make tied operator indifferent.|) + ( ^operator =)} + +sp {default*opsub*propose*space*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate ) + ( ^operator + ^problem-space ) + ( ^conditions-unachieved *yes* + ^conditions ) + --> + ( ^problem-space + ^name operator-subgoal + ^desired )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal + ^superstate ) + ( ^ { <> problem-space + <> choices + <> impasse + <> object + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} + +sp {default*condition*achieved*property + :default + (state ^operator.conditions + ^condition-relations.property

                                                                                                                        + ^. ) + (

                                                                                                                        ^name + ^object ) + ( ^ ) + ( ^ ) + --> + ( ^achieved *yes*)} + +sp {default*condition*achieved*relation + :default + (state ^operator.conditions + ^condition-relations.relation + ^ (^ + ^ )) + ( ^name + ^object1 + ^object2 ) + ( ^ ) + ( ^ + ^ ) + --> + ( ^achieved *yes*)} + +sp (default*select*operator*mea + (state ^operator + + ^desired + ^condition-relations.relation.name ) + ( ^ + + + +### The following is commented out; it would provide for keeping track +### of all levels of operator subgoaling, not just the most recent. +### Pass down all super operator desireds as well. +# +# sp {default*generic*opsub*goal*elaborate*all-desireds +# :default +# (state ^problem-space

                                                                                                                        +# ^impasse no-change +# ^attribute operator +# ^superstate ) +# (state ^problem-space

                                                                                                                        +# ^desired ) +# --> +# (state ^desired )} +# +# + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/simple-os.soar.txt b/soar-8.5.2/demos_soar7/no-gui/default/simple-os.soar.txt new file mode 100644 index 0000000..e16900e --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/simple-os.soar.txt @@ -0,0 +1,361 @@ +### +### FILE : blocks-world.soar +### + +### +### AUTHOR(1) : John.E.Laird [ Soar 8.1 ] +### + +### +### CREATED(1) : December 12, 1998 + +### + +source simple.soar + +### + +sp {top-ps*elaborate*initial-state + (state ^name top-goal) + --> + ( ^world-state + ^ontop + ^clear + ^objects

                                                                                                                        ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^object ) + ( ^object ) + ( ^object
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^problem-space.name top-ps + ^objects
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        )} + --> + ( ^operator ) + ( ^name build-tower + ^desired ) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### +### SUBGOAL BUILD-TOWER: +### DESIRED STATE +### + +sp {build-tower*elaborate*state*desired-state + (state ^worldstate + ^impasse no-change + ^attribute operator) + ( ^operator.desired ) + --> + ( ^desired + ^world-state )} + +### +### SUBGOAL BUILD-TOWER: +### PROBLEM SPACE +### + +sp {build-tower*propose*space*blocks-world + (state ^name build-tower) + --> + ( ^problem-space.name blocks-world)} + +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^problem-space.name blocks-world + ^world-state ) + ( ^object { <> }) + ( ^type block) + --> + ( ^operator + ) + ( ^name move-block + ^moving-block + ^destination + ^conditions + ^actions ) + ( ^clear ) + ( ^add + ^remove ) } + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator + ^world-state ) + ( ^ontop ) + ( ^top-block + -^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^ontop -)} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator + ^world-state ) + ( ^moving-block + ^destination ) + --> + ( ^ontop ) + ( ^top-block + ^bottom-block )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator.destination + ^world-state ) + ( ^clear ) + ( ^object ) + --> + ( ^clear -)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator + ^world-state ) + ( ^ontop ) + ( ^top-block + ^bottom-block { <> }) + -( ^type table) + ( ^moving-block + ^destination ) + --> + ( ^clear.object )} + +sp {blocks-world*apply*operator*remember*moved-block*a + (state ^operator.moving-block + ^world-state ) + ( -^last-moved-block) + --> + ( ^last-moved-block )} + +sp {blocks-world*apply*operator*forget*last-moved-block + (state ^operator.moving-block <> + ^world-state ) + ( ^last-moved-block ) + --> + ( ^last-moved-block - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {blocks-world*reject*move-block*twice + (state ^problem-space.name blocks-world + ^operator + + ^world-state.last-moved-block ) + ( ^moving-block ) + --> + ( ^operator - )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### STATE EVALUATION/GOAL TEST +### + +sp {blocks-world*elaborate*state*success + (state ^desired + ^world-state ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^ontop + { <> } + { <> <> }) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + --> + ( ^success )} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*world-state + (state ^world-state.ontop ) + ( ^top-block.name + ^bottom-block ) + --> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*tied-operators*move-block + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-block(| + |,| + |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} + + + +sp {top-ps*select*operator*impasse*tie*break + (state ^attribute operator + ^impasse tie + ^item + ^superstate ) +--> + (write (crlf) | Make tied operator indifferent.|) + ( ^operator =)} + +sp {default*opsub*propose*space*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate ) + ( ^operator + ^problem-space ) + ( ^conditions-unachieved *yes* + ^conditions ) + --> + ( ^problem-space + ^name operator-subgoal + ^desired )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal + ^superstate ) + ( ^ { <> problem-space + <> choices + <> impasse + <> object + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} + +sp {default*condition*achieved*property + :default + (state ^operator.conditions + ^condition-relations.property

                                                                                                                        + ^. ) + (

                                                                                                                        ^name + ^object ) + ( ^ ) + ( ^ ) + --> + ( ^achieved *yes*)} + +sp {default*condition*achieved*relation + :default + (state ^operator.conditions + ^condition-relations.relation + ^ (^ + ^ )) + ( ^name + ^object1 + ^object2 ) + ( ^ ) + ( ^ + ^ ) + --> + ( ^achieved *yes*)} + +sp (default*select*operator*mea + (state ^operator + + ^desired + ^condition-relations.relation.name ) + ( ^ + + + +### The following is commented out; it would provide for keeping track +### of all levels of operator subgoaling, not just the most recent. +### Pass down all super operator desireds as well. +# +# sp {default*generic*opsub*goal*elaborate*all-desireds +# :default +# (state ^problem-space

                                                                                                                        +# ^impasse no-change +# ^attribute operator +# ^superstate ) +# (state ^problem-space

                                                                                                                        +# ^desired ) +# --> +# (state ^desired )} +# +# + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/simple-selection.soar b/soar-8.5.2/demos_soar7/no-gui/default/simple-selection.soar new file mode 100644 index 0000000..09f237c --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/simple-selection.soar @@ -0,0 +1,600 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default/simple-selection.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified By: John Laird +## Last Modified On: Friday December 11, 1998 +## +## Contents: Default productions for simple-selection problem space for Soar 8.1 +## Only works for one level copies of internal states - copies +## every attribute on the top-level state unless the top-state +## has a world-state attribute, in which case it copies all of the +## world-state attributes. +## +############################################################################### + +## Significant Changes made to Convert to Soar 8.1 + +### +################################################################################# +### The selection space for multi-choice impasses +### + +### Use the selection problem space for all choice multiple, impasses +### - make it worst so that any other will dominate. + +sp {default*selection*propose*space*selection + :default + (state ^choices multiple) + --> + ( ^problem-space.name selection)} + +### Signal that a value other than novalue has been assigned. + +sp {default*selection*elaborate*state*found-value-true + :default + (state ^problem-space.name selection + ^choices multiple + ^evaluation ) + ( ^ << numeric-value symbolic-value >> <> novalue) + --> + ( ^found-value true)} + +### +### The evaluate-object operator +### + +### Create evaluate operator in selection problem space. + +sp {default*selection*propose*evaluate-object + :default + (state ^problem-space.name selection + ^item ) + -{(state ^evaluation ) + ( ^object + ^value t)} + --> + ( ^operator + =) + ( ^name evaluate-object + ^object )} + +### Label all evaluation operators with ^type evaluation. + +sp {default*selection*elaborate*operator*evaluate-object*type-evaluation + :default + (state ^operator ) + ( ^name evaluate-object) + --> + ( ^type evaluation)} + +### Create evaluation once the eval operator is selected. + +sp {default*selection*elaborate*state*evaluation + :default + (state ^operator ) + ( ^type evaluation) + --> + ( ^evaluation ) + ( ^evaluation )} + +sp {default*selection*elaborate*evaluate-operator*desired + :default + (state ^operator + ^superstate.desired ) + ( ^type evaluation) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluation*desired + :default + (state ^superstate.desired + ^evaluation ) + --> + ( ^desired )} + +sp {default*selection*elaborate*evaluate-object*superproblem-space + :default + (state ^problem-space.name selection + ^operator + ^superstate.problem-space ) + ( ^type evaluation) + --> + ( ^superproblem-space )} + +sp {default*selection*elaborate*evaluate-object*superstate + :default + (state ^problem-space.name selection + ^operator + ^superstate ) + ( ^type evaluation) + --> + ( ^superstate )} + +### +### 7.3.1.1 Evaluation Objects +### + +sp {default*selection*elaborate*evaluation*value + :default + (state ^evaluation ) + ( ^ << numeric-value symbolic-value >>) + --> + ( ^value t)} + + +sp {default*selection*elaborate*evaluation*object + :default + (state ^operator + ^evaluation ) + ( ^object + ^evaluation + ^type evaluation) + --> + ( ^object )} + +sp {default*selection*elaborate*evaluation*type + :default + (state ^operator + ^evaluation ) + ( ^name + ^evaluation + ^type evaluation) + --> + ( ^type )} + +### +### Applying the evaluate-object operator +### +### Domain specific code may directly implement an evaluation, +### or an operator no-change may occur to do the job, see the next section. + +### +### The evaluation subgoal +### + +### +### These productions fire once an evaluation subgoal has been created +### have also been generalized. + +sp {default*evaluate-object*elaborate*state*desired + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^type evaluation ^desired ) + --> + ( ^desired )} + + +sp {default*evaluate-object*elaborate*state*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator.name evaluate-object) + --> + ( ^name implement-evaluate-object)} + +sp {default*evaluate-object*elaborate*state*problem-space + :default + (state ^impasse no-change + ^attribute operator + ^superstate.operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        ) + --> + ( ^problem-space

                                                                                                                        )} + +## install a copy of the state + +sp {default*evaluate-object*elaborate*state*copy + :default + (state ^superstate.operator ) + ( ^type evaluation + ^superstate ) + ( -^world-state + ^{ <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +sp {default*evaluate-object*elaborate*state*copy*world-state + :default + (state ^superstate.operator ) + ( ^type evaluation + ^superstate.world-state ) + --> + ( ^world-state )} + +sp {default*evaluate-object*elaborate*state*copy*world-state*copy + :default + (state ^superstate.operator ) + ( ^type evaluation + ^superstate.world-state ) + ( ^{ <> tried-tied-operator <> problem-space + <> impasse <> attribute <> choices <> quiescence + <> operator <> superstate + } ) + --> + ( ^ )} + +## Create pointer for uniform access even in no copy + +sp {default*evaluate-object*elaborate*state*look-ahead-operator*no-copy + :default + (state ^problem-space

                                                                                                                        + ^superstate.operator ) + ( ^type evaluation + ^object + ^superproblem-space

                                                                                                                        ) + --> + ( ^look-ahead-operator )} + +### install copy of operator in lookahead context. + +sp {default*evaluate-object*propose*look-ahead + :default + (state ^problem-space.name + ^look-ahead-operator + ^superstate ) + (state ^superstate.problem-space.name + ^operator.type evaluation) + -( ^tried-tied-operator ) + --> + ( ^operator + >)} + +### Detect that the operator has been tried when a duplicate is being used. + +sp {default*evaluate-object*elaborate*state*tried-tied-operator + :default + (state ^problem-space

                                                                                                                        + ^operator + ^superstate.operator ) + ( ^type evaluation + ^superproblem-space

                                                                                                                        + ^object ) + --> + ( ^tried-tied-operator )} + +### Give symbol-value failure when no operators are proposed in subgoals + +sp {default*evaluate-object*elaborate*evaluation*failure*no-operators + :default + (state ^operator + ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ^quiescence t) + (state ^superstate ^attribute state ^impasse no-change ^quiescence t) + --> + ( ^symbolic-value failure)} + +sp {default*evaluate-object*elaborate*evaluation*failure*constraint-failure + :default + (state ^operator ) + ( ^evaluation ) + ( ^type evaluation ^evaluation ) + (state ^superstate ) + (state ^superstate ^attribute operator ^impasse constraint-failure) + --> + ( ^symbolic-value failure)} + +sp {default*evaluate-object*elaborate*evaluation*from-subgoal + :default + (state ^superstate + ^ { << required-success success partial-success + indifferent partial-failure failure prohibit-failure + draw lose win >> } ) + (state ^operator ^evaluation ) + ( ^type evaluation ^evaluation ^desired ) + --> + ( ^symbolic-value )} + +### +### Computing evaluations +### +### +### Computing numeric evaluations +### +### This is domain specific, so there are no default productions for this. + +### +### Comparing numeric evaluations +### + +### If two objects have equal evaluations they are indifferent. + +sp {default*selection*compare*equal-evaluation-indifferent + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + ( ^desired ) + ( ^object + ^numeric-value + ^desired + ^type evaluate-object) + ( ^object + ^numeric-value + ^desired + ^type evaluate-object) + --> + ( ^operator = )} + + +### +### Generate operator preferences based on their evaluations and info +### as to whether higher or lower evaluations are better. + +sp {default*selection*compare*higher-evaluation-better + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object + ^numeric-value + ^desired + ^type evaluate-object) + ( ^object + ^numeric-value < + ^desired + ^type evaluate-object) + ( ^better higher) + --> + ( ^operator < )} + + +sp {default*selection*compare*prefer-lower-evaluation + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object + ^numeric-value + ^desired + ^type evaluate-object) + ( ^object + ^numeric-value > + ^desired + ^type evaluate-object) + ( ^better lower) + --> + ( ^operator < )} + +### +### 7.3.3.3 Computing symbolic evaluations +### + + +sp {default*selection*compare*same-symbolic-evaluations-are-indifferent + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + ( ^object ^symbolic-value ^desired + ^type evaluate-object) + --> + ( ^operator = )} + +sp {default*selection*compare*success-evaluation-better-than-partial-success + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value success ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value partial-success + ^desired ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*compare*partial-failure-evaluation-better-than-failure + :default + (state ^problem-space.name selection + ^superstate + ^evaluation { <> }) + (state ^desired ) + ( ^object ^symbolic-value partial-failure ^desired + ^type evaluate-object) + ( ^object { <> } ^symbolic-value failure ^desired + ^type evaluate-object) + --> + ( ^operator > )} + +sp {default*selection*select*required-success-evaluation-becomes-required-preference + :default + (state ^problem-space.name selection + ^operator + ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object + ^evaluation + ^desired + ^object ) + ( ^symbolic-value required-success) + --> + ( ^operator !)} + +sp {default*selection*select*success-evaluation-becomes-best-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value << partial-success success >>) + --> + ( ^operator >)} + +sp {default*selection*select*indifferent-evaluation-becomes-indifferent-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object ^evaluation + ^desired ^object ) + ( ^symbolic-value indifferent) + --> + ( ^operator =)} + +sp {default*selection*select*partial-failure-evaluation-becomes-worst-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object ^evaluation + ^desired + ^object ) + ( ^symbolic-value partial-failure) + --> + ( ^operator <)} + +sp {default*selection*select*failure-evaluation-becomes-reject-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value << lose failure >>) + --> + ( ^operator -)} + +sp {default*selection*select*prohibit-failure-evaluation-becomes-prohibit-preference + :default + (state ^problem-space.name selection ^operator ^superstate + ^evaluation ) + (state ^desired ) + ( ^name evaluate-object ^evaluation ^desired + ^object ) + ( ^symbolic-value prohibit-failure) + --> + ( ^operator ~)} + + + +### +### 7.3.3.4 Default evaluations +### + +### A. default*pass-back-success +## if an operator leads to success and it is being +## tried out in a subgoal to evaluate another operator - +## give that second operator a success evaluation also + +sp {default*pass-back-success + :default + (state ^operator + ^superstate.superstate.operator ) + ( ^name evaluate-object + ^evaluation.symbolic-value << required-success success >>) + ( ^name evaluate-object + ^evaluation + ^object.name) + --> + ( ^symbolic-value partial-success)} + + + +### +### 7.3.3.5 Novalue evaluations +### + +### Make novalue worse than any other value. + +sp {default*selection*compare*novalue-evaluation-always-worse + :default + (state ^problem-space.name selection + ^superstate + ^evaluation ^evaluation { <> }) + (state ^desired ) + ( ^object ^numeric-value novalue ^desired + ^type evaluate-object) + ( ^object ^numeric-value <> novalue ^desired + ^type evaluate-object) + --> + ( ^operator > )} + + +### +### 7.3.4 Halting Soar with success or failure +### + +### A. default*top-goal*halt*state*success +### Handle state augmentations dealing with goal termination for the top-level goal. + +sp {default*top-goal*halt*success + :default + (state ^name + ^desired + ^superstate nil + ^<< required-success success >> ) + --> + (write (crlf) | achieved |) + (halt)} + +### B. default*top-goal*halt*state*failure + +sp {default*top-goal*halt*failure + :default + (state ^superstate nil + ^desired + ^name + ^ << prohibit-failure failure >> ) + --> + (write (crlf) | failed|) + (halt)} + +### +### Execution monitoring +### + +### If the state is marked with ^success , the goal succeeds. + +sp {default*monitor*goal*success + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-success required-success success >> ) + --> + (write (crlf) | Goal | | succeeded. |)} + +### If the state is marked with ^failure , the goal fails. + +sp {default*monitor*goal*failure + :default + (state ^superstate nil - ^verbose false) + (state ^name ^desired + ^<< partial-failure failure prohibit-failure >> ) + --> + (write (crlf) | Goal | | failed. |)} + +### Print the evaluation of any object that has a name. + +sp {default*monitor*operator*evaluation + :default + (state ^superstate nil -^verbose false) + (state ^operator ) + ( ^type evaluation ^object ^evaluation ) + ( ^ << numeric-value symbolic-value >> ) + ( ^name ) + --> + (write (crlf) | Evaluation of | | (| + |) is | )} + + + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/simple.soar b/soar-8.5.2/demos_soar7/no-gui/default/simple.soar new file mode 100644 index 0000000..579eba3 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/simple.soar @@ -0,0 +1,145 @@ +## -*- Mode: sde -*- +## +############################# -*- Mode: Soar -*- ############################# +## +## File : default/simple.soar +## Author : John Laird +## Created on : Mon Feb 27 16:15:34 1989 +## Last Modified By: John Laird +## Last Modified On: Friday December 11, 1998 +## +## Contents: Simple Default productions for Soar 8.1 +## +############################################################################### +## +## Significant Changes made to Convert to Soar 8.1 +## +### +### +### 7.1 Default knowledge for the top context +### + +## Elaborate the top goal with name top-goal and top-state. +## both are required for backward compatibility +## Make it worst so it will be overridden by all other names. + +sp {default*top-state*elaborate*state*name*top-state*top-goal + "Propose top-goal as name of top goal." + :default + (state ^superstate nil) + --> + ( ^name top-goal + ^name top-state)} + +## Elaborate every substate with io pointer. + +sp {default*elaborate*state*io + "Elaborate each substate with io pointer." + :default + (state ^impasse no-change + ^superstate.io ) + --> + ( ^io )} + +## Elaborate every substate with world-state pointer if it exists on the top state + +sp {default*elaborate*state*world-state + "Elaborate substates with world-state." + :default + (state ^impasse no-change + ^superstate.world-state ) + --> + ( ^world-state )} + +sp {default*copy*world*state + :default + (state ^world-state + ^impasse no-change + ^attribute operator) + --> + ( ^world-state )} + + +## Elaborate a state with the name of the superoperator + +sp {elaborate*state*operator*name + "Elaborate substates with name of operator." + :default + (state ^superstate.operator.name ) +--> + ( ^name )} + +### Propose wait for a state no-change + +sp {top-ps*propose*wait + "Propose wait if there is a state no-change." + :default + (state ^attribute state + ^choices none + -^operator.name wait) +--> + ( ^operator + <) + ( ^name wait)} + +### This avoids a operator no-change after wait is selected +### I've included it just to keep the trace simple - it never fires + +sp {top-ps*apply*wait*random + "Fake production just to avoid extra operator no-change." + :default + (state ^operator ) + ( ^name wait) +--> + ( ^random elaboration)} + +sp {default*top-goal*halt*operator*failure + "Halt if no operator can be selected for the top goal." + :default + (state ^superstate nil) + (state ^impasse constraint-failure ^superstate ) + --> + (write (crlf) |No operator can be selected for top goal.| ) + (write (crlf) |Soar must halt.| ) + (halt)} + +sp {default*select*indifferent-and-worst*tied + "Indifferent an object if it leads to a tie that can not be solved." + :default + (state ^operator +) + (state ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + --> + ( ^operator =, < )} + +### If the problem space for handling the subgoal fails, signified by +### the choices none impasse below it, make a reject-preference for each +### conflicted object. + +sp {default*select*reject-and-reconsider*conflict + "Reject an object if it leads to a conflict that can not be solved." + :default + (state ^operator +) + (state ^impasse conflict + ^attribute operator + ^superstate + ^item + ^quiescence t) + (state ^attribute state + ^choices none + ^superstate + ^quiescence t) + --> + ( ^operator -)} + + + + + + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/default/simpleb-opsub.txt b/soar-8.5.2/demos_soar7/no-gui/default/simpleb-opsub.txt new file mode 100644 index 0000000..646fea8 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/default/simpleb-opsub.txt @@ -0,0 +1,224 @@ +### +### FILE : blocks-world.soar +### AUTHOR(1) : John.E.Laird [ Soar 8.1 ] +### CREATED(1) : December 12, 1998 +### + +source simple.soar + +sp {top-ps*elaborate*initial-state + (state ^name top-goal) + --> + ( ^world-state + ^ontop + ^clear

                                                                                                                        + ^objects
                                                                                                                        ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + (write (crlf) |Initial state has A on B and B and C on the table.|)} + +### +### TOP PROBLEM SPACE OPERATOR: +### BUILD-TOWER +### + +sp {top-ps*propose*operator*build-tower + (state ^problem-space.name top-ps + ^objects
                                                                                                                        ) + ( ^name A ^type block) + ( ^name B ^type block) + ( ^name C ^type block) + (
                                                                                                                        ^name table ^type table) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        )} + --> + ( ^operator ) + ( ^name build-tower + ^desired ) + ( ^ontop ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block ) + ( ^top-block + ^bottom-block
                                                                                                                        ) + (write (crlf) |The goal is to get A on B on C on the table.|)} + +### + +sp {default*copy*world*state + (state ^world-state + ^impasse no-change + ^attribute operator) + --> + ( ^world-state )} + +### +### BLOCKS-WORLD PROBLEM SPACE OPERATOR: +### MOVE-BLOCK +### + +sp {blocks-world*propose*operator*move-block + (state ^name build-tower + ^world-state ) + ( ^object + { <> }) + ( ^type block) + --> + ( ^operator + =) + ( ^name move-block + ^moving-block + ^destination ) + } + +### +### BLOCKS-WORLD PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {blocks-world*apply*operator*move-block*remove-ontop + (state ^operator + ^world-state ) + ( ^ontop + ^clear ) + ( ^top-block + -^bottom-block ) + ( ^moving-block + ^destination ) + --> + ( ^ontop -)} + +sp {blocks-world*apply*operator*move-block*create-ontop + (state ^operator + ^world-state ) + ( ^clear ) + ( ^moving-block + ^destination ) + --> + ( ^ontop ) + ( ^top-block + ^bottom-block )} + +sp {blocks-world*apply*operator*move-block*remove-clear + (state ^operator.destination + ^world-state ) + ( ^clear ) + --> + ( ^clear -)} + +sp {blocks-world*apply*operator*move-block*create-clear + (state ^operator + ^world-state ) + ( ^ontop ^clear ) + ( ^top-block + ^bottom-block { <> }) + -( ^type table) + ( ^moving-block + ^destination ) + --> + ( ^clear )} + +### +### SEARCH CONTROL +### + +sp {blocks-world*prefer*clear-block + (state ^operator + + ^desired.clear + ^world-state.ontop ) + ( ^top-block + ^bottom-block ) + ( ^moving-block ) + --> + ( ^operator >)} + +sp {blocks-world*prefer*ontop + (state ^operator + + ^desired.ontop + ^world-state ) + ( ^top-block + ^bottom-block ) + ( ^moving-block + ^destination ) + -{( ^ontop ) + ( ^top-block + ^bottom-block ) + --> + ( ^operator >)} + +### +### BLOCKS-WORLD PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {blocks-world*monitor*world-state + (state ^world-state.ontop ) + ( ^top-block.name + ^bottom-block.name ) + --> + (write (crlf) + | ontop(| + |,| |)|)} + +sp {blocks-world*monitor*operator-application*move-block + (state ^operator ) + ( ^name move-block + ^moving-block + ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-block(| + |,| + |)|)} + +######### OPERATOR SUBGOALING + +sp {default*opsub*propose*space*name + :default + (state ^impasse no-change + ^attribute operator + ^superstate ) + ( ^operator + ^problem-space ) + ( ^moving-block + ^destination ) + --> + ( ^problem-space + ^name operator-subgoal + ^desired ) + ( ^clear )} + +sp {default*generic*opsub*copy*superstate + :default + (state ^name operator-subgoal + ^superstate ) + ( ^ { <> problem-space + <> choices + <> impasse + <> object + <> name + <> quiescence + <> superstate + <> attribute + <> operator + <> desired } + ) + --> + ( ^ )} + diff --git a/soar-8.5.2/demos_soar7/no-gui/eight_puzzle/eight_puzzle.soar b/soar-8.5.2/demos_soar7/no-gui/eight_puzzle/eight_puzzle.soar new file mode 100644 index 0000000..35a268b --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/eight_puzzle/eight_puzzle.soar @@ -0,0 +1,403 @@ +### +### FILE : eight-puzzle.s +### + +### +### AUTHOR(1) : John.E.Laird [ Soar 5.x ] +### + +### +### CREATED(1) : Oct 11, 89 +### + +### +### MODIFIED(8) : Aug 25, 96 [ Soar 7.0.3 ] Sayan Bhattacharyya +### MODIFIED(7) : Nov 18, 94 [ Soar 6.2.3 ] John.E.Laird +### MODIFIED(6) : May 10, 93 [ Soar 6.0.9 ] JT.Traub +### MODIFIED(5) : Apr 29, 93 [ Soar 6.0.7 ] John.E.Laird +### MODIFIED(4) : ? [ Soar 6.x.x ] ? +### MODIFIED(3) : Apr 17, 91 [ Soar 5.2.x ] Brian.G.Milnes +### MODIFIED(2) : May 17, 90 [ Soar 5.1.0 ] Thomas.F.McGinnis +### MODIFIED(1) : Oct 11, 89 [ Soar 5.1.0 ] John.E.Laird +### + +### +### Aug 25, 96 : default rules now loaded automatically +### Nov 18, 94 : Clean up NNPSCM and improve generality of chunks by changing calculation of tile-cell on state +### May 10, 93 : Added in Multiattribute statements +### Apr 29, 93 : Removed testing cell names from state evaluation +### productions, and applied test from the production for +### operator termination. +### Apr 17, 91 : Changed for new notify. +### May 17, 90 : Added ^default-operator-copy no, in prep for Soar +### 5.1.2. +### Oct 11, 89 : Changed evaluation productions to Soar 5.1. +### + +### +### Originally //hawk/users/soar/dsm/tasks/eight2.dsm (University of Michigan). +### Eight puzzle for DSM. Modifies the bindings, but does not create new +### bindings. +### State Structure: + ## Each state contains nine bindings. + ## The bindings connect together a cell, one of the nine positions on + ## the board and a tile, one of the movable pieces. + ## The cells have pointers, ^cell, to each of their adjacent cells. + ## The state also has a pointer to the blank-cell and the cell + ## that the last moved tile is in -- this improves efficiency and + ## simplify computations that depend on the previous operator. +### Operator Staructure: + ## Each operator contains a pointer to the cell with the blank + ## and the cell with the tile to be moved. +### + +package require Soar +source $default +multi-attributes binding 10 + + ## Name the first subgoal eight-puzzle and create the + ## problem space and operators + +### +### TOP GOAL: +### SOLVE-EIGHT-PUZZLE +### + +### +### TOP GOAL PROBLEM SPACE: +### EIGHT-PUZZLE +### + +sp {eight*create*space*eight-puzzle + (state ^superstate nil) + --> + ( ^name solve-eight-puzzle ^desired ^problem-space

                                                                                                                        + ) + (

                                                                                                                        ^name eight-puzzle ^default-state-copy yes + ^default-operator-copy no + ^one-level-attributes blank-cell blank-cell & + ^one-level-attributes tile-cell tile-cell & + ^two-level-attributes binding binding & )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### INITIAL STATE AND DESIRED STATE +### + + ## Define the initial state and the impasse state: + ## each state is a set of bindings# + ## each binding points to a cell and a tile# + ## each cell points to its neighboring cells. + +sp {eight*create*state*initial-and-desired-states + (state ^name solve-eight-puzzle ^problem-space

                                                                                                                        + ^desired ) + (

                                                                                                                        ^name eight-puzzle) + --> + ( ^name 0) ( ^name 1) ( ^name 2) + ( ^name 3) ( ^name 4) ( ^name 5) + ( ^name 6) ( ^name 7) ( ^name 8) + ( ^name c11 ^cell + &, ^cell + & ) + ( ^name c12 ^cell + &, ^cell + &, ^cell + & ) + ( ^name c13 ^cell + &, ^cell + &,) + ( ^name c21 ^cell + &, ^cell + &, ^cell + & ) + ( ^name c22 ^cell + &, ^cell + &, + ^cell + &, ^cell + & ) + ( ^name c23 ^cell + &, ^cell + &, ^cell + & ) + ( ^name c31 ^cell + &, ^cell + & ) + ( ^name c32 ^cell + &, ^cell + &, ^cell + & ) + ( ^name c33 ^cell + &, ^cell + & ) + ( ^blank-cell ^tile-cell nil + ^binding + &, + &, + &, + &, + &, + + &, + &, + &, + & ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^better higher + ^binding + &, + &, + &, + &, + &, + &, + + &, + &, + & ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^cell ^tile )} + +### +### EIGHT-PUZZLE PROBLEM SPACE OPERATOR: +### MOVE-TILE +### + +sp {eight*create*operator*move-tile + (state ^problem-space

                                                                                                                        + ^blank-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell ) + --> + ( ^name move-tile ^tile-cell ^blank-cell ) + ( ^operator + )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {eight*apply*operator*move-tile + (state ^problem-space

                                                                                                                        + ^operator + ^binding { <> } + ^blank-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^tile-cell ^blank-cell ^name move-tile) + ( ^tile ^cell ) + ( ^tile ^cell ) + --> + ( ^blank-cell - ) + ( ^tile - ) + ( ^tile - )} + +sp {eight*apply*operator*remove-tile-cell + (state ^problem-space

                                                                                                                        + ^operator + ^tile-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^blank-cell <> ^name move-tile) + --> + ( ^tile-cell -)} + +sp {eight*apply*operator*add-tile-cell + (state ^problem-space

                                                                                                                        + ^operator + ^blank-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^blank-cell ^name move-tile) + --> + ( ^tile-cell )} + +sp {eight*save*operator*applied*a + (state ^problem-space

                                                                                                                        + ^operator + ^tile-cell + ^blank-cell + -^applied) + (

                                                                                                                        ^name eight-puzzle) + ( ^tile-cell ^blank-cell ) + --> + ( ^applied + )} + +sp {eight*save*operator*applied*b + (state ^problem-space

                                                                                                                        + ^operator + ^tile-cell + ^blank-cell + ^applied { <> }) + (

                                                                                                                        ^name eight-puzzle) + ( ^tile-cell ^blank-cell ) + --> + ( ^applied - + )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {eight*reconsider*operator*move-tile + (state ^problem-space

                                                                                                                        + ^operator + ^tile-cell + ^blank-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^tile-cell ^blank-cell ) + --> + ( ^operator @ )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### STATE EVALUATION +### + + ## A numeric evaluation function, + ## based on changes by operators, is used + ## to evaluate state. + +### +### EVALUATION: STATE POSITIVE +### + + ## 1 point for moving tile into its impasse cell + # +sp {eight*elaborate*state*evaluation*positive*one + (state ^problem-space

                                                                                                                        + ^superstate + ^tile-cell + ^binding + ^applied ) + (

                                                                                                                        ^name eight-puzzle) + ( ^binding ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^operator + ^evaluation ) + ( ^name evaluate-object ^evaluation + ^object + ^desired ) + --> + ( ^numeric-value 1)} + +### +### EVALUATION: STATE NEUTRAL +### + + ## 0 points for not moving tile in or out of its impasse cell + # +sp {eight*elaborate*state*evaluation*neutral*zero + (state ^problem-space

                                                                                                                        + ^superstate + ^tile-cell + ^blank-cell + ^binding { <> } { <> <> } + ^applied ) + (

                                                                                                                        ^name eight-puzzle) + ( ^binding { <> }) + ( ^cell ^tile ) + ( ^tile ) + ( ^tile ) + ( ^cell ^tile { <> }) + ( ^cell ^tile { <> }) + ( ^operator + ^evaluation ) + ( ^name evaluate-object ^evaluation + ^object + ^desired ) + --> + ( ^numeric-value 0)} + +### +### EVALUATION: STATE NEGATIVE +### + + ## -1 points for moving tile out of its impasse cell + # +sp {eight*elaborate*state*evaluation*negative*one + (state ^problem-space

                                                                                                                        + ^superstate + ^tile-cell + ^binding + ^blank-cell + ^applied ) + (

                                                                                                                        ^name eight-puzzle) + ( ^binding ) + ( ^cell ^tile ) + ( ^cell ^tile ) + ( ^operator + ^evaluation ) + ( ^name evaluate-object ^evaluation + ^object + ^desired ) + --> + ( ^numeric-value -1)} + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + +sp {eight*detect*state*success + (state ^problem-space

                                                                                                                        + ^desired + ^binding + + ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) + ( ^binding + + ) + ( ^cell.name c11 ^tile ) + ( ^cell.name c12 ^tile ) + ( ^cell.name c13 ^tile ) + ( ^cell.name c21 ^tile ) + ( ^cell.name c22 ^tile ) + ( ^cell.name c23 ^tile ) + ( ^cell.name c31 ^tile ) + ( ^cell.name c32 ^tile ) + ( ^cell.name c33 ^tile ) + --> + ( ^success )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### SEARCH CONTROL +### + +sp {eight*operator*move-tile*inverse*reject + "Reject the operator that was applied to create this state." + (state ^problem-space

                                                                                                                        + ^operator + + ^tile-cell ) + (

                                                                                                                        ^name eight-puzzle) + ( ^tile-cell ) + --> + ( ^operator - )} + +### +### EIGHT-PUZZLE PROBLEM SPACE: +### MONITOR STATE +### + + ## Want this to fire whenever an op is installed or + ## whenever op is applied (bindings change) but NOT both. + ## Try requiring that operator be finished. + # + +sp {eight*monitor*state + (state ^problem-space

                                                                                                                        + ^binding + + ) + (

                                                                                                                        ^name eight-puzzle) + ( ^cell.name c11 ^tile ) + ( ^name ) + ( ^cell.name c12 ^tile ) + ( ^name ) + ( ^cell.name c13 ^tile ) + ( ^name ) + ( ^cell.name c21 ^tile ) + ( ^name ) + ( ^cell.name c22 ^tile ) + ( ^name ) + ( ^cell.name c23 ^tile ) + ( ^name ) + ( ^cell.name c31 ^tile ) + ( ^name ) + ( ^cell.name c32 ^tile ) + ( ^name ) + ( ^cell.name c33 ^tile ) + ( ^name ) + --> + (write (crlf) | -------------| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | \|---\|---\|---\|| | | (crlf) | | ) + (write | \|| | | | | |\|| | | | | |\|| | | | | |\|| | | (crlf) | | ) + (write | -------------| | | (crlf) | | )} + +### eof of eight-puzzle.s + + diff --git a/soar-8.5.2/demos_soar7/no-gui/farmer/farmer.soar b/soar-8.5.2/demos_soar7/no-gui/farmer/farmer.soar new file mode 100644 index 0000000..1bba5e9 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/farmer/farmer.soar @@ -0,0 +1,440 @@ +### +### FILE : farmer.s (NNPSCM) +### + +### +### AUTHOR(3) : Aladin.Akyurek [ Soar 6.0.7, 6.0.8 ] +### AUTHOR(2) : Brian.G.Milnes [ Soar 5.1 ] +### AUTHOR(1) : Jans.Aasman [ Soar 4.3 ] +### + +### +### CREATED(3) : Apr 26, 93 +### + +### +### MODIFIED(3) : Aug 21, 96 [ Soar 7.0.3 TCL TK ] Sayan Bhattacharyya +### MODIFIED(2) : Aug 9, 94 [ Soar 6.2.3 NNPSCM ] Aladin.Akyurek +### MODIFIED(1) : Jul 19, 94 [ Soar 6.2.3 NNPSCM ] Aladin.Akyurek +### + +### +### Jul 19, 94 : Removed copying down ^applied in the subgoals# +### Replaced "implement" in production names by "apply." +### Aug 9, 94 : Added a search-control production that is operative +### within the selection space. This effectively resolves +### the problem described in the comment accompanying +### the production farmer*better*operator*move-alone. +### Replaced the two productions for state failure +### by a set of three similar productions. +### Renamed the attribute ^directed-at as ^abject +### in operator structures. +### + +### +### ABSTRACT. This file provides a Soar system to solve the "farmer's +### dilemma" or problem. The problem consists of the farmer taking a wolf, +### a goat, and a cabbage across a river, one at a time, without leaving +### the goat alone with the cabbage or the wolf (i.e., PRESERVATION-GOAL). +### + +package require Soar +source $default + + +### +### TOP-LEVEL--ELABORATE STATE: +### TASK NAME AND DESIRED +### + +sp {top-level*elaborate*state*task*farmer + (state ^superstate nil) + --> + ( ^name farmer ^desired )} + +### +### TOP-LEVEL--ELABORATE STATE: +### TASK PROBLEM SPACE = FARMER +### + +# Commented out of RHS below (on Jul 19, 94) +# ^one-level-attributes applied + & + +sp {farmer*elaborate*state*space*farmer + (state ^superstate nil ^name farmer) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer + ^default-state-copy yes + ^two-level-attributes holds + & + + )} + +### +### TOP-LEVEL--ELABORATE STATE: +### INITIAL STATE +### + +sp {farmer*elaborate*state*initial-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name farmer) + --> + ( ^farmer + ^wolf + ^goat + ^cabbage + ^location + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^name FARMER) + ( ^name WOLF) + ( ^name GOAT) + ( ^name CABBAGE) + ( ^name LEFT-BANK ^opposite-of ) + ( ^name RIGHT-BANK ^opposite-of )} + +### +### FARMER PROBLEM SPACE OPERATORS: +### MOVE-ALONE AND MOVE-WITH +### + +sp {farmer*propose*operator*move-alone + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move-alone + ^object self + ^from + ^to )} + +sp {farmer*propose*operator*move-with + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move-with + ^object + ^from + ^to )} + +### +### FARMER PROBLEM SPACE: +### OPERATOR APPLICATION +### + +sp {apply*move-alone + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-alone + ^object self + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + --> + ( ^at - )} + +sp {apply*move-with + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-with + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + --> + (

                                                                                                                        ^at - ) + (

                                                                                                                        ^at - )} + +#These operator saving rules would fire also +#in subgoals for operator subgoaling. In this task +#operator subgoaling should not happen. Otherwise, +#add (state -^name operator-subgoal) to the condition +#parts of these rules. Jul 19, 94. + +sp {farmer*save*operator*applied*a + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state -^applied) + --> + ( ^applied )} + +sp {farmer*save*operator*applied*b + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name + ^object + ^from + ^to ) + (

                                                                                                                        ^name farmer) + (state ^applied <> ) + --> + ( ^applied - )} + +### +### FARMER PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*move-alone + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-alone + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^farmer ^at ) + --> + ( ^operator @ )} + +sp {terminate*move-with + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move-with + ^object + ^to ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^<< wolf goat cabbage >> ^at ) + --> + ( ^operator @ )} + +### +### FARMER PROBLEM SPACE: +### STATE EVALUATION +### + +### +### EVALUATION: STATE FAILURE +### + +sp {farmer*evaluate*state*failure*a + "Wolf will eat goat." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +sp {farmer*evaluate*state*failure*b + "Goat will eat cabbage." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +sp {farmer*evaluate*state*failure*c + "Goat will eat cabbage." + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^opposite-of ) + --> + ( ^failure )} + +### +### STATE EVALUATION: STATE SUCCESS/GOAL TEST +### + + ## This also defines implicitly the desired state + ## of the problem. + # + +sp {farmer*evaluate*state*success + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^farmer ^at ) + (

                                                                                                                        ^wolf ^at ) + (

                                                                                                                        ^goat ^at ) + (

                                                                                                                        ^cabbage ^at ) + ( ^name RIGHT-BANK) + --> + ( ^success )} + +### +### FARMER PROBLEM SPACE: +### SEARCH CONTROL +### + + ## Create "reject preference" for inverse operator. + ## Definition of Inverse Operator: + ## apply(a[i],s[i]) = s[j], + ## apply(a[j],S[j]) = s[i], + ## where a[i] and a[j] are different instantiations + ## of the operator A, and s stands for state. The + ## instantiation a[j] is the inverse of a[i]. + ## Example: a[i] = walk(x,y), a[j] = walk(y,x). + # + +sp {farmer*operator*inverse*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^applied ) + ( ^name + ^object + ^from + ^to ) + ( ^name + ^object + ^from + ^to ) + --> + ( ^operator - )} + + ## Without the production below Soar may get into a situation + ## in which the following holds: + ## AT(WOLF,LEFT-BANK) + ## AT(CABBAGE,LEFT-BANK) + ## AT(FARMER,RIGHT-BANK) + ## AT(GOAT,RIGHT-BANK) + ## From this situation it is possible for Soar to repeatedly + ## select a Move-With operator to move the wolf, the goat, or + ## the cabbage. In the process, it will produce the situation + ## in which the goat is at the left-bank, a configuration close + ## to the goal state. Since the goal-state is implicit in this + ## system, it will not be able to recognize this configuration + ## as such and to produce + ## Move-Alone(LEFT-BANK,RIGHT-BANK) + ## and then + ## Move-With(GOAT,LEFT-BANK,RIGHT-BANK) + ## to solve the puzzle. + ## The production below biases Soar to always consider + ## Move-Alone before any Move-With. + # + +sp {farmer*best*operator*move-alone + (state ^operator + ) + ( ^name evaluate-object + ^object ) + ( ^name move-alone) + --> + ( ^operator > )} + +### +### FARMER PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {farmer*monitor*predicate*holds + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name farmer) + (state ^holds ) + ( ^ ^{ <> at } ) + ( ^name ) + --> + (write (crlf) + | HOLDS | + |: at(| + |,| + |)|)} + +sp {farmer*monitor*tied-operator*move-alone + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-alone + ^object self + ^from + ^to ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-alone(self,| + |,| + |)|)} + +sp {farmer*monitor*tied-operator*move-with + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name move-with + ^object + ^from + ^to ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: move-with(| + |,| + |,| + |)|)} + +sp {farmer*monitor*operator-application*move-alone + (state ^operator ) + ( ^name move-alone + ^object self + ^from + ^to ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-alone(self,| + |,| + |)|)} + +sp {farmer*monitor*operator-application*move-with + (state ^operator ) + ( ^name + ^object + ^from + ^to ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move-with(| + |,| + |,| + |)|)} + +### eof of farmer.s (Version Type: NNPSCM) diff --git a/soar-8.5.2/demos_soar7/no-gui/kab/kab.soar b/soar-8.5.2/demos_soar7/no-gui/kab/kab.soar new file mode 100644 index 0000000..3274ce7 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/kab/kab.soar @@ -0,0 +1,1276 @@ +### +### FILE : keys-and-boxes.s, alias: kab.s (NNPSCM) +### + +### +### AUTHOR(2) : Sayan Bhattacharyya [ Soar 7.0.3 ] +### AUTHOR(1) : Aladin.Akyurek [ Soar 6.2.3 ] +### + +### +### CREATED(1) : Sep 11, 94 +### + +### +### MODIFIED(1) : Aug 22, 96 by Sayan Bhattacharyya +### + +### +### Copyright (C) Aladin Akyurek (NISCALE, Leiden, The Netherlands). +### + +### +### ABSTRACT. This file provides a Soar system to solve the Keys +### and Boxes problem which "has been proposed by Michie +### /.../ as a "benchmark" problem for problem solving programs. +### The problem is as follows: +### In a room there is a robot with no sensory ability +### whatsoever. Four places are defined in the room: BOX1, BOX2, +### TABLE, and DOOR. Outside the room there is one place: OUTSIDE. +### At DOOR there is a non-empty pile of red objects. +### At BOX1 or BOX2 (we don't know which) there is a +### non-empty pile of keys, all of which fit the door. We don't know +### what is at the other box. +### TABLE is empty. +### The robot has three possible actions: +### 1. Pick up -- If the robot is holding something, this action has +### no effect. Otherwise, some object at the location will be in the +### robot's hand when this action is completed. +### 2. Put down -- If the robot is not holding anything, this action +### has no effect. Otherwise, the object in the robot's hand is added +### to the pile at the current location of the robot. +### 3. Go to X -- The robot's location becomes X. If X is OUTSIDE, there +### must be a key in the pile at DOOR or this action has no effect. +### The robot has no way to tell if any action had an effect or not. +### Initially the robot is at an undetermined place in the +### room, and it is unknown if anything is in its hand. /.../ The problem +### is to develop a set of actions that will ensure that a red object is +### OUTSIDE" [1, pp. 55-56]. +### +### As specified by Sacerdoti (1977), the problem contains a crucial +### contradiction which makes it unsolvable/intractable for most human +### subjects. A robot "with no sensory ability whatsoever" is indeed +### difficult to imagine as capable of "Go to X", that is, going to a +### specified object. Sacerdoti and his system Noah ignored this, +### apparently without knowing that they did so. In fact, even without +### this restrictive statement, it is an interesting, "pure" planning +### problem that requires one to deal "with a partially specified initial +### state, and with actions whose effects are only partially specified." +### The problem that we solve here does not contain the statement in +### question. As said, this modification of the problem specification +### does not change its nature. +### +### John E. Laird (1986) ever wrote the following: "This is a complex +### problem with many steps that was unsolvable without the use of +### *hierarchical kernels* in Noah. The argument implicit in Noah is +### that this problem would be intractable in a system like Soar without +### deliberate planning." The Soar system here is an attempt to meet +### that challenge. +### + +### +### The system is comprised of two problem spaces, three task-operators +### (T-Ops), and seven generic operators (G-Ops): +### +### Problem Space Associated Operators +### -------------- ------------------------------------------------ +### Keys-And-Boxes { Create-Focus, Change-Focus, Pick-Up, Put-Down, +### GoTo, Pop, Add, Del, Replace, Goal-Test } +### Set-Focus { Set-Focus } +### -------------- ------------------------------------------------ +### +### The keys-and-boxes space (i.e., the task space) looks for an *action*, +### and if it can, it proposes one or more T-ops for that *action*. +### Otherwise, G-ops attempt to bring in a different *action* in focus for +### which T-ops can be created. An *action* is computed from within +### a subspace by means of the set-focus operator that proposes other G-ops +### to create or change a focus in the task space (cf. the system for +### tower-of-hanoi, also in the "examples" directory). The table below +### shows the mapping between an *action* and T-ops. +### +### Action T-Ops +### -------------- ------------------------------------------------ +### Acquire(X) GoTo(I), Pick-Up(X,I) where Loc(X,I) +### Transfer(X) GoTo(I), Put-Down(X,I) where I = any location +### Transfer(X,I) GoTo(I), Put-Down(X,I) where I = destination +### -------------- ------------------------------------------------ +### +### Note that Soar solves the problem by "abstraction planning" (see +### Tenenberg [2]) as did Noah, and by look-ahead. +### +### REFERENCES. [1] Sacerdoti, E. D. (1977). A structure for plans and +### behavior. New York: Elsevier. +### [2] Tenenberg, J. D. (1991). Abstraction in planning. In +### J. F. Allen, H. A. Kautz, R. N. Pelavin, and J. D. Tenenberg, Reasoning +### about plans (Chap. 4). San Mateo, CA: Morgan Kaufmann. +### + +package require Soar +source $default + + +### +### TASK NAME: +### KEYS-AND-BOXES +### + +sp {top-level*elaborate*state*task*keys-and-boxes + (state ^superstate nil) + --> + ( ^name keys-and-boxes)} + +### +### TASK PROBLEM SPACE: +### KEYS-AND-BOXES +### + +sp {keys-and-boxes*elaborate*state*space*keys-and-boxes + (state ^name keys-and-boxes ^superstate nil) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name keys-and-boxes + ^default-state-copy yes + ^one-level-attributes + room + &, + box + &, + table + &, + door + &, + outside + &, + robot + &, + object + &, + location + & + ^two-level-attributes + holds + &, + action + & )} + +### +### TASK SPACE: +### INITIAL STATE AND +### DESIRED STATE +### + +sp {keys-and-boxes*elaborate*state*initial-and-desired-states + (state ^name keys-and-boxes ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name keys-and-boxes) + --> + ( ^room + ^box + &, + & + ^table

                                                                                                                        + ^door + ^outside + ^robot + ^pile + &, + &, + & + ^location + &, + &, + &,
                                                                                                                        + &, + & + ^object + &, + &, + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,
                                                                                                                        + & ) + ( ^in ^name box-1) + ( ^in ^name box-2) + (
                                                                                                                        ^in ^name table) + ( ^links ^to ^in ^name door) + ( ^name outside) + ( ^name robot) + ( ^base-type red-object + & ^loc ) + ( ^base-type key + &, non-key + & ^loc ) + ( ^base-type key + &, non-key + & ^loc ) + (

                                                                                                                        ^robot ^holding ^loc ) + ( ^in ^name |_|) + (

                                                                                                                        ^object ^loc ) + ( ^type unknown ^name object-1) + (

                                                                                                                        ^door ^status locked) + (

                                                                                                                        ^object ^loc ) + ( ^type key + &, non-key + & ^name object-2) + (
                                                                                                                        ^object ^loc ) + ( ^type key + &, non-key + & ^name object-3) + (
                                                                                                                        ^object ^loc ) + ( ^type red-object ^name object-4) + ( ^desired + & ) + ( ^object ^loc )} + +### +### TASK SPACE OPERATORS: +### T-Ops = GOTO, PICK-UP, AND PUT-DOWN +### G-Ops = CREATE-FOCUS, CHANGE-FOCUS, +### POP, ADD, DEL, REPLACE, +### AND GOAL-TEST +### For the generic operator Goal-Test, +### see the section on goal-test. +### + +# +#GoTo + Pick-Up <-- Acquire +# + +sp {keys-and-boxes*propose*goto->pick-up*object*object-loc + "Acquire ==> GoTo, Pick-Up." + (state ^problem-space

                                                                                                                        + ^holds

                                                                                                                        + ^action ) + (

                                                                                                                        ^name keys-and-boxes) + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding nothing) + ( ^isa acquire ^object ) + --> + ( ^operator ) + ( ^name goto + ^reference-action + ^loc + ^done? no) + ( ^name pick-up + ^reference-action + ^object + ^loc + ^done? no)} + +# +#GoTo + Put-Down <-- Transfer +# + +sp {keys-and-boxes*propose*goto->put-down*object*destination + "Transfer ==> GoTo, Put-Down: destination is given." + (state ^problem-space

                                                                                                                        + ^holds

                                                                                                                        + ^action ) + (

                                                                                                                        ^name keys-and-boxes) + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding ) + ( ^isa transfer ^object ^destination ) + --> + ( ^operator ) + ( ^name goto + ^reference-action + ^loc + ^done? no) + ( ^name put-down + ^reference-action + ^object + ^loc + ^done? no)} + +sp {keys-and-boxes*propose*goto->put-down*object*no-destination + "Transfer ==> GoTo, Put-Down: destination is not given." + (state ^problem-space

                                                                                                                        + ^location + ^holds

                                                                                                                        + ^action ) + (

                                                                                                                        ^name keys-and-boxes) + #the expression ^location is crucial here. + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding ) + ( ^isa transfer ^object -^destination) + --> + ( ^operator ) + ( ^name goto + ^reference-action + ^loc + ^done? no) + ( ^name put-down + ^reference-action + ^object + ^loc + ^done? no)} + +# +#Create-Focus, Change-Focus +#are proposed from within the subspace +#set-focus, or by chunks. +# + +# +#Pop +# + +sp {keys-and-boxes*object*action*propose*pop*transfer + (state ^problem-space

                                                                                                                        + ^action + ^location + ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa transfer ^object -^destination) + ( ^object ^loc ) + --> + ( ^operator + = ) + ( ^name pop + ^action + ^done? no)} + +sp {keys-and-boxes*object*action*propose*pop*transfer*destination + (state ^problem-space

                                                                                                                        + ^action + ^location + ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa transfer ^object ^destination ) + ( ^object ^loc ) + --> + ( ^operator + = ) + ( ^name pop + ^action + ^done? no)} + +sp {keys-and-boxes*object*action*propose*pop*acquire + (state ^problem-space

                                                                                                                        + ^action + ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa acquire ^object ) + ( ^robot ^holding ) + --> + ( ^operator + = ) + ( ^name pop + ^action + ^done? no)} + +# +#Add, Del. None proposed in this task. +# + +# +#Replace +# + +sp {object*action*propose*replace*door*value*locked + (state ^problem-space

                                                                                                                        + ^location + ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^door ^status locked) + -{ (state ^holds ) + ( ^object ^loc <> ) + ( ^type key) } + --> + ( ^operator + = ) + ( ^name replace + ^level two + ^structure + ^pattern-value locked + ^by open + ^done? no)} + +### +### TASK SPACE: +### OPERATOR APPLICATION +### + +sp {apply*pick-up + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^holds

                                                                                                                        ) + ( ^name pick-up + ^object + ^loc + ^done? no) + (

                                                                                                                        ^name ) + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding nothing ^loc ) + --> + (

                                                                                                                        ^loc - ) + (

                                                                                                                        ^holding nothing - ) + ( ^done? yes no - )} + +sp {apply*put-down + (state ^operator ) + (state ^problem-space

                                                                                                                        + #^location added. + ^location + ^holds

                                                                                                                        ) + ( ^name put-down + ^object + ^loc + ^done? no) + (

                                                                                                                        ^name ) + #Object(X) & Loc(X,R) & Robot(R) = Robot R has X. + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding ^loc ) + --> + (

                                                                                                                        ^loc - ) + (

                                                                                                                        ^holding nothing - ) + ( ^done? yes no - )} + +sp {apply*goto + "Locations inside/outside are handled within goto proposals." + (state ^operator ) + (state ^problem-space

                                                                                                                        ^holds ) + ( ^name goto + ^loc + ^done? no) + (

                                                                                                                        ^name ) + ( ^robot ^loc { <> }) + --> + ( ^loc - ) + ( ^done? yes no - )} + +# +#Save the task operator that is applied. +# + +sp {keys-and-boxes*save*operator*applied*first-time + (state ^operator ) + (state ^problem-space

                                                                                                                        + -^applied) + ( ^name ^loc ) + (

                                                                                                                        ^name keys-and-boxes) + --> + ( ^applied )} + +sp {keys-and-boxes*save*operator*applied*later-times + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^applied <> ) + ( ^name ^loc ) + (

                                                                                                                        ^name keys-and-boxes) + --> + ( ^applied - )} + +sp {apply*create-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        + -^action ) + (

                                                                                                                        ^name ) + ( ^name create-focus ^action ^done? no) + ( ^isa ^super-action none) + --> + ( ^action + & ) + ( ^done? yes no - )} + +sp {apply*change-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^action + -^action ) + (

                                                                                                                        ^name ) + ( ^name change-focus ^action ^done? no) + ( ^isa ^super-action ) + --> + ( ^action + &, - ) + ( ^done? yes no - )} + +# +#Apply Pop, Add, Del, Replace. +# + +sp {apply*pop*a + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^action ) + ( ^name pop ^action ^done? no) + ( ^super-action none) + (

                                                                                                                        ^name ) + --> + ( ^action - ) + ( ^done? yes no - )} + +sp {apply*pop*b + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^action + ^action { <> }) + ( ^name pop ^action ^done? no) + (

                                                                                                                        ^name ) + ( ^super-action { <> none }) + --> + ( ^action - ) + ( ^done? yes no - )} + +sp {apply*pop*c + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^action + -^action ) + ( ^name pop ^action ^done? no) + (

                                                                                                                        ^name ) + ( ^super-action { <> none }) + --> + ( ^action + &, - ) + ( ^done? yes no - )} + +sp {apply*add*level-one + (state ^operator ) + (state ^problem-space

                                                                                                                        + -^ ) + ( ^name add + ^level one + ^pattern + ^done? no) + ( ^ ) + (

                                                                                                                        ^name ) + --> + ( ^ + & ) + ( ^done? yes no - )} + +sp {apply*add*level-two + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^ ) + ( ^name add + ^level two + ^structure + ^pattern + ^done? no) + ( ^ ) + (

                                                                                                                        ^name ) + ( -^ ) + --> + ( ^ + & ) + ( ^done? yes no - )} + +sp {apply*del*level-one + (state ^operator ) + (state ^problem-space

                                                                                                                        ^ ) + ( ^name del + ^level one + ^pattern + ^done? no) + ( ^ ) + (

                                                                                                                        ^name ) + --> + ( ^ - ) + ( ^done? yes no - )} + +sp {apply*del*level-two + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^ ) + ( ^name del + ^level two + ^structure + ^pattern + ^done? no) + ( ^ ) + (

                                                                                                                        ^name ) + ( ^ ) + --> + ( ^ - ) + ( ^done? yes no - )} + +sp {apply*replace*level-one + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^ ) + ( ^name replace + ^level one + ^pattern-value + ^by + ^done? no) + (

                                                                                                                        ^name ) + --> + ( ^ - ) + ( ^done? yes no - )} + +sp {apply*replace*level-two + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^ ) + ( ^name replace + ^level two + ^structure + ^pattern-value + ^by + ^done? no) + (

                                                                                                                        ^name ) + ( ^ ) + --> + ( ^ - ) + ( ^done? yes no - )} + +### +### TASK SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*put-down + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name put-down ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*pick-up + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name pick-up ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*goto + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name goto ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*create-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name create-focus ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*change-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name change-focus ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*pop + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name pop ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*add + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name add ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*del + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name del ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*replace + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name replace ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### SEARCH CONTROL: +### TASK SPACE AND +### SELECTION SPACE +### + +sp {keys-and-boxes*reject*goto*not-table + "Tranfer(X,-) & GoTo(I) & Not(Table(I)), Reject(GoTo(I))." + (state ^operator + ) + (state ^problem-space

                                                                                                                        + ^action + -^table ) + ( ^name goto ^reference-action ^loc ) + ( ^isa transfer -^destination) + (

                                                                                                                        ^name ) + --> + ( ^operator - )} + +sp {keys-and-boxes*reject*put-down*not-table + "Tranfer(X,-) & Put-Down(X,I) & Not(Table(I)), Reject(Put-Down(X,I))." + (state ^operator + ) + (state ^problem-space

                                                                                                                        + ^action + -^table ) + ( ^name put-down ^reference-action ^loc ) + ( ^isa transfer -^destination) + (

                                                                                                                        ^name ) + --> + ( ^operator - )} + +sp {keys-and-boxes*reject*goto*current-loc + "Loc(R,I) & GoTo(I), Reject(GoTo(I))." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^holds ) + ( ^name goto ^loc ) + (

                                                                                                                        ^name ) + ( ^robot ^loc ) + --> + ( ^operator - )} + +sp {keys-and-boxes*best*operator*doable + "Loc(R,I) & Op(X,I), Best(Op(X,I))." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^holds ) + ( ^name << pick-up put-down >> ^loc ) + (

                                                                                                                        ^name ) + ( ^robot ^loc ) + --> + ( ^operator > )} + +sp {keys-and-boxes*reject*operator*door-locked*to-outside + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^holds

                                                                                                                        ) + ( ^name ^loc ^done? no) + (

                                                                                                                        ^name ) + (

                                                                                                                        ^robot ^loc ) + (

                                                                                                                        ^door ^status locked) + ( -^in ) + ( ^in ) + --> + ( ^operator - )} + +sp {keys-and-boxes*reject*operator*door-locked*to-inside + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^holds

                                                                                                                        ) + ( ^name ^loc ^done? no) + (

                                                                                                                        ^name ) + (

                                                                                                                        ^robot ^loc ) + (

                                                                                                                        ^door ^status locked) + ( ^in ) + ( -^in ) + --> + ( ^operator - )} + +# sp {keys-and-boxes*compare*goto*better +# "Loc(R,Not(I)) & GoTo(I) & Op(X,I), Better(GoTo(I),Op(X,I))." +# (state ^operator + + ) +# (state ^problem-space

                                                                                                                        ^holds ) +# (

                                                                                                                        ^name ) +# ( ^name goto ^loc ) +# ( ^name << pick-up put-down >> ^object ^loc ) +# ( ^robot ^loc <> ) +# --> +# ( ^operator > )} + +sp {selection*compare*evaluate-goto*better + "Loc(R,Not(I)) & GoTo(I) & Op(X,I), Better(GoTo(I),Op(X,I))." + (state ^operator + + ) + (state ^problem-space ^superstate ) + ( ^name selection) + ( ^name evaluate-object ^object ) + ( ^name evaluate-object ^object ) + ( ^name goto ^loc ) + ( ^name << pick-up put-down >> ^object ^loc ) + (state ^holds

                                                                                                                        ) + (

                                                                                                                        ^robot ^loc <> ) + --> + ( ^operator > )} + +# +#Search Control for Create-Focus, Change-Focus. +# + +sp {keys-and-boxes*reject*create-focus + "Prefer changing an existing focus to creating another." + (state ^operator + + ) + ( ^name create-focus ^done? no) + ( ^name change-focus ^done? no) + --> + ( ^operator - )} + +sp {keys-and-boxes*reject*focus-operator*done*yes + "Bar re-selecting a focus operator." + (state ^operator + ) + ( ^name << create-focus change-focus >> + ^done? yes) + --> + ( ^operator - )} + +sp {keys-and-boxes*reject*focus-operator*same-action-and-object + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^action ) + ( ^name << create-focus change-focus >> + ^action + ^done? no) + ( ^isa ^object ) + ( ^isa ^object ) + --> + ( ^operator - )} + +# +#Search Control for Pop, Add, Del, Replace. +# + +sp {task-space*compare*pop*indifferent + (state ^operator + + ) + (state ^problem-space

                                                                                                                        ) + ( ^name pop ^done? no) + ( ^name pop ^done? no) + (

                                                                                                                        ^name ) + --> + ( ^operator = )} + +sp {task-space*compare*pop*better + (state ^operator + + ) + (state ^problem-space

                                                                                                                        ) + ( ^name pop ^done? no) + ( -^name << pop add del replace >>) + (

                                                                                                                        ^name ) + --> + ( ^operator > )} + +# sp {task-space*compare*add-del-replace*indifferent +# (state ^operator + { <> } + ) +# (state ^problem-space

                                                                                                                        ) +# ( ^name { << add del replace >> }) +# ( ^name ) +# (

                                                                                                                        ^name ) +# --> +# ( ^operator = )} + +sp {task-space*compare*add-del-replace*better + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        ) + ( ^name << add del replace >> ) + ( -^name << add del replace >>) + (

                                                                                                                        ^name ) + --> + ( ^operator > )} + +### +### SUBSPACE SET-FOCUS: +### INITIAL STATE +### + +# +#Initial state of the subspace +#is a duplicate of superstate. +# + +sp {impasse-no-change*create*context + (state ^impasse no-change ^superstate ) + (state ^problem-space ) + ( ^name keys-and-boxes) + --> + ( ^problem-space + ^duplicates* + ^duplicate-of* ) + ( ^name set-focus + ^default-state-copy yes + ^default-operator-copy yes + #attributes to copy or duplicate should be + #in a separate, task production. + ^one-level-attributes + room + &, + box + &, + table + &, + door + &, + outside + &, + robot + &, + object + &, + location + &, + pursue + &, + action + & + ^two-level-attributes + holds + & )} + +sp {impasse-no-change*elaborate*state*duplicate*one-level-attributes + :default + (state ^problem-space

                                                                                                                        ^duplicate-of* ) + (

                                                                                                                        ^name ^default-state-copy yes ^one-level-attributes ) + ( ^ ) + --> + ( ^ + & )} + +sp {impasse-no-change*elaborate*state*duplicate*id-for-attribute + :default + (state ^problem-space

                                                                                                                        ^duplicate-of* ^duplicates* ) + (

                                                                                                                        ^name ^default-state-copy yes ^two-level-attributes ) + ( ^ ) + --> + ( ^ + = )} + +set warnings off +sp {impasse-no-change*elaborate*state*add-attribute-to-duplicate + :default + (state ^problem-space

                                                                                                                        ^duplicates* ) + (

                                                                                                                        ^name ^default-state-copy yes) + ( ^ ) + ( ^ ) + ( -^) + --> + ( ^ + & )} +set warnings on + +set warnings off +sp {impasse-no-change*elaborate*state*add-duplicated-attribute-to-duplicate + :default + (state ^problem-space

                                                                                                                        ^duplicates* ) + (

                                                                                                                        ^name ^default-state-copy yes) + ( ^ ) + ( ^ ) + ( ^ ) + --> + ( ^ + & )} +set warnings on + +sp {impasse-no-change*elaborate*state*add-duplicate-to-state + :default + (state ^problem-space

                                                                                                                        ^duplicate-of* ^duplicates* ) + (

                                                                                                                        ^default-state-copy yes ^two-level-attributes ) + ( ^ ) + ( ^ ) + --> + ( ^ + & )} + +### +### SUBSPACE OPERATOR: +### SET-FOCUS +### + +sp {set-focus*propose*set-focus + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name set-focus) + --> + ( ^operator ) + ( ^name set-focus)} + +sp {set-focus*elaborate*set-focus*action*none + (state ^operator + ) + (state ^problem-space

                                                                                                                        -^action) + (

                                                                                                                        ^name set-focus) + --> + ( ^action none)} + +sp {set-focus*elaborate*set-focus*action + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^action ) + (

                                                                                                                        ^name set-focus) + --> + ( ^action + & )} + +### +### SET-FOCUS SUBSPACE: +### OPERATOR APPLICATION +### + +sp {apply*set-focus*action*transfer*object*destination + (state ^operator ) + (state ^problem-space + ^pursue + ^superstate ) + ( ^name set-focus ^action none) + ( ^name ) + ( ^object ^loc ) + --> + ( ^operator + <, = ) + ( ^name create-focus ^action ^done? no) + ( ^isa transfer + ^super-action none + ^object + ^destination )} + +sp {apply*set-focus*acquire*object + (state ^operator ) + (state ^problem-space + ^holds + ^action + ^superstate ) + ( ^name set-focus ^action ) + ( ^robot ^holding <> ) + ( ^isa transfer ^object ^destination ) + --> + ( ^operator + <, = ) + ( ^name change-focus ^action ^done? no) + ( ^isa acquire + ^super-action + ^object )} + +sp {apply*set-focus*transfer*object*type*key + (state ^operator ) + (state ^problem-space + ^location + ^holds + ^action + ^superstate ) + ( ^name set-focus ^action ) + ( ^door ^status locked) + ( ^links ^to ) + ( ^object ^loc <> ) + ( ^object ^loc <> ) + ( ^type key) + ( ^isa transfer ^object ^destination ) + --> + #no worst preference here. + ( ^operator + = ) + ( ^name change-focus ^action ^done? no) + ( ^isa transfer + ^super-action + ^object + ^destination )} + +sp {apply*set-focus*transfer*object*hand-free + (state ^operator ) + (state ^problem-space + ^holds + ^action + ^superstate ) + ( ^name set-focus ^action ) + ( ^object ^loc ) + ( ^robot ^holding ) + ( ^isa acquire ^object { <> }) + --> + ( ^operator + <, = ) + ( ^name change-focus ^action ^done? no) + ( ^isa transfer + ^super-action + ^object )} + +### +### TASK SPACE: +### GOAL TEST +### + +sp {keys-and-boxes*elaborate*state*desired-of-object*satisfied + (state ^desired ) + (state ^problem-space

                                                                                                                        ^holds ) + ( ^object ^loc ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^object ^loc ) + --> + ( ^satisfied + & )} + +sp {task-space*elaborate*state*pursue + (state ^desired -^satisfied ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name ) + --> + ( ^pursue + & )} + +sp {task-space*propose*goal-test*top-level + (state ^superstate nil) + (state ^problem-space

                                                                                                                        + -^pursue + -^success) + (

                                                                                                                        ^name ) + --> + ( ^operator =, + ) + ( ^name goal-test ^result-type success)} + +sp {task-space*propose*goal-test*look-ahead + (state ^name implement-evaluate-object) + (state ^problem-space

                                                                                                                        + -^pursue + -^success) + (

                                                                                                                        ^name ) + --> + ( ^operator =, + ) + ( ^name goal-test ^result-type success)} + +sp {task-space*select*goal-test*better + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        -^pursue) + ( ^name goal-test) + ( -^name << pop add del replace >>) + (

                                                                                                                        ^name ) + --> + ( ^operator > )} + +sp {apply*goal-test*top-level + (state ^operator ) + (state ^problem-space

                                                                                                                        + ^desired + ^satisfied + -^pursue + -^ + ^superstate nil) + ( ^name goal-test ^result-type ) + --> + ( ^ + & )} + +sp {apply*goal-test*look-ahead + (state ^operator ) + (state ^name implement-evaluate-object + ^problem-space

                                                                                                                        + ^desired + ^satisfied + -^pursue + -^ + ^applied ) + ( ^name goal-test ^result-type ) + --> + ( ^ + & )} + +sp {terminate*goal-test + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name goal-test) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TASK SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {keys-and-boxes*monitor*state*holds*object*loc + (state ^problem-space

                                                                                                                        ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^object ^loc ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | loc(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*state*holds*robot*loc*holding*no + (state ^problem-space

                                                                                                                        ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^robot ^holding nothing ^loc ) + ( ^name ) + --> + (write (crlf) + | loc(robot,| + |), holding nothing.|)} + +sp {keys-and-boxes*monitor*state*holds*robot*loc*holding*yes + (state ^problem-space

                                                                                                                        ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^robot ^holding ^loc ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | loc(robot,| + |), holding(| + |).|)} + +sp {keys-and-boxes*monitor*state*holds*door*status + (state ^problem-space

                                                                                                                        ^holds ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^door ^status ) + --> + (write (crlf) + | | + |(door).|)} + +sp {keys-and-boxes*desired-state*object*destination + (state ^desired ^superstate nil) + ( ^object ^loc ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | desired[loc(| + |,| + |)].|)} + +sp {keys-and-boxes*monitor*action*acquire + (state ^problem-space

                                                                                                                        ^action ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa acquire ^object ) + ( ^name ) + --> + (write (crlf) + | | + |: acquire(| + |).|)} + +sp {keys-and-boxes*monitor*action*transfer + (state ^problem-space

                                                                                                                        ^action ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa transfer ^object -^destination) + ( ^name ) + --> + (write (crlf) + | | + |: transfer(| + |).|)} + +sp {keys-and-boxes*monitor*action*transfer*destination + (state ^problem-space

                                                                                                                        ^action ) + (

                                                                                                                        ^name keys-and-boxes) + ( ^isa transfer ^object ^destination ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: transfer(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*tied-operator*pick-up + (state ^impasse tie ^item ) + ( ^name pick-up ^object ^loc ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: pick-up(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*tied-operator*put-down + (state ^impasse tie ^item ) + ( ^name put-down ^object ^loc ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | | + |: put-down(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*tied-operator*goto + (state ^impasse tie ^item ) + ( ^name goto ^loc ) + ( ^name ) + --> + (write (crlf) + | | + |: goto(| + |).|)} + +sp {keys-and-boxes*monitor*operator-application*pick-up + (state ^operator ) + (state ^holds

                                                                                                                        ) + ( ^name pick-up ^object ^loc ) + ( ^name ) + ( ^name ) + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding ^loc ) + --> + (write (crlf) + | pick-up(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*operator-application*put-down + (state ^operator ) + (state ^holds

                                                                                                                        ) + ( ^name put-down ^object ^loc ) + ( ^name ) + ( ^name ) + (

                                                                                                                        ^object ^loc ) + (

                                                                                                                        ^robot ^holding nothing ^loc ) + --> + (write (crlf) + | put-down(| + |,| + |).|)} + +sp {keys-and-boxes*monitor*operator-application*goto*holding*no + (state ^operator ) + (state ^holds ) + ( ^name goto ^loc ) + ( ^name ) + ( ^robot ^holding nothing ^loc ) + --> + (write (crlf) + | goto(| + |), while holding nothing.|)} + +sp {keys-and-boxes*monitor*operator-application*goto*holding*yes + (state ^operator ) + (state ^holds ) + ( ^name goto ^loc ) + ( ^name ) + ( ^robot ^holding ^loc ) + ( ^name ) + --> + (write (crlf) + | goto(| + |), while holding(| + |).|)} + +### eof of kab.s (Version: NNPSCM) + + diff --git a/soar-8.5.2/demos_soar7/no-gui/missionaries/missionaries.soar b/soar-8.5.2/demos_soar7/no-gui/missionaries/missionaries.soar new file mode 100644 index 0000000..923574a --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/missionaries/missionaries.soar @@ -0,0 +1,509 @@ +### +### FILE : missionaries.soar +### + +### +### AUTHOR(2) : Sayan Bhattacharyya [ Soar 7.0.3 ] +### AUTHOR(1) : Aladin.Akyurek [ Soar 5.1.1 ] +### + +### +### CREATED(3) : Aug 22, 96 +### CREATED(2) : May 10, 93 +### CREATED(1) : May 21, 91 +### + +### +### ABSTRACT. This file provides a Soar system to solve +### the missionaries and cannibals problem. Three missionaries and +### three cannibals come to a river. There is a a boat on their side of +### the river that can be used by either one or two persons at a time. +### This boat must be used to cross the river in such a way that cannibals +### never outnumber missionaries on either side of the river. +### + +### +### TOP GOAL: +### MISSIONARIES-AND-CANNIBALS +### + +package require Soar +source $default + +sp {top-goal*elaborate*goal*missionaries-and-cannibals + (state ^superstate nil) + --> + ( ^name missionaries-and-cannibals + ^desired )} + +### +### TOP GOAL PROBLEM SPACE: +### MISSIONARIES-AND-CANNIBALS/MAC +### + +sp {mac*propose*space*mac + (state ^name missionaries-and-cannibals + ^superstate nil) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals + ^default-state-copy yes + ^one-level-attributes boat + &, + location + & + ^two-level-attributes mlist + &, + clist + &, + next + &, + holds + & )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### INITIAL-STATE +### + +sp {mac*propose*state*initial-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name missionaries-and-cannibals) + --> + + ( ^mlist + &, + & + ^clist + &, + & + ^boat ^location + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &, +

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + (
                                                                                                                        ^boat ^location ) + ( ^next ) + ( ^value missionary ^next ) + ( ^value missionary ^next ) + ( ^value missionary ^next none) + ( ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next none) + ( ^next none) + ( ^next none) + ( ^name left ^opposite-of ) + ( ^name right ^opposite-of )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE OPERATORS: +### MOVE1, MOVE2, AND MOVE11 +### + +sp {mac*propose*operator*move1 + "Moves either a missionary or a cannibal." + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^boat ^location ) + ( ^next <> none) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move1 + ^done? no + ^inst + ^from + ^to )} + +sp {mac*propose*operator*move2 + "Moves either two missionaries or two cannibals." + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^boat ^location ) + ( ^next ) + ( ^next <> none) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move2 + ^done? no + ^inst + ^with + ^from + ^to )} + +sp {mac*propose*operator*move11 + "Moves one missionary and one cannibal." + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + (

                                                                                                                        ^boat ^location ) + ( ^next <> none) + ( ^next <> none) + ( ^opposite-of ) + --> + ( ^operator ) + ( ^name move11 + ^done? no + ^inst + ^with + ^from + ^to )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*move1 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move1 + ^done? no + ^inst + ^from + ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^boat ^location ) + ( ^next ) + ( ^next ) + ( ^value ^next ) + ( ^opposite-of ) + --> + ( ^next - ) + ( ^next - ) + ( ^value ^next ) + (

                                                                                                                        ^location - ) + ( ^done? yes no - )} + +sp {implement*move2 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move2 + ^done? no + ^inst + ^with + ^from + ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^ ^location ) + (

                                                                                                                        ^boat ^location ) + ( ^next ) + ( ^next ) + ( ^value ^next ) + ( ^value ^next ) + ( ^opposite-of ) + --> + ( ^next - ) + ( ^next - ) + ( ^value ^next ) + ( ^value ^next ) + (

                                                                                                                        ^location - ) + ( ^done? yes no - )} + +sp {implement*move11 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move11 ^inst ^with ^from ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + (
                                                                                                                        ^boat ^location ) + ( ^next ) + ( ^next ) + ( ^next ) + ( ^next ) + ( ^value ^next ) + ( ^value ^next ) + ( ^opposite-of ) + --> + ( ^next - ) + ( ^next - ) + ( ^next - ) + ( ^next - ) + ( ^value ^next ) + ( ^value ^next ) + (
                                                                                                                        ^location - ) + ( ^done? yes no - )} + +sp {mac*save*operator*applied*a + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( -^applied) + --> + ( ^applied )} + +sp {mac*save*operator*applied*b + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^applied <> ) + --> + ( ^applied - )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*move1 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move1 ^done? yes) + (

                                                                                                                        ^name missionaries-and-cannibals) + --> + ( ^operator @ )} + +sp {terminate*move2 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move2 ^done? yes) + (

                                                                                                                        ^name missionaries-and-cannibals) + --> + ( ^operator @ )} + +sp {terminate*move11 + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name move11 ^done? yes) + (

                                                                                                                        ^name missionaries-and-cannibals) + --> + ( ^operator @ )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### STATE EVALUATION +### + +### +### EVALUATION: STATE FAILURE +### + +sp {mac*evaluate*state*failure*one-against-more + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + ( ^next ) + ( ^value missionary ^next none) + ( ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next ) + --> + ( ^failure )} + +sp {mac*evaluate*state*failure*two-against-more + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + ( ^next ) + ( ^value missionary ^next ) + ( ^value missionary ^next none) + ( ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next none) + --> + ( ^failure )} + +sp {mac*evaluate*state*failure*detect-state-duplicate + (state ^problem-space + ^superstate ) + ( ^name ) + ( ^holds ) + ( ^mlist ^location ) + ( ^clist ^location ) + ( ^next none) + ( ^next none) + ( ^name right) + (state ^problem-space + ^superstate ) + ( ^name <> ) + (state ^problem-space

                                                                                                                        + ^desired ) + (

                                                                                                                        ^name ) + ( ^holds ^applied ) + ( ^mlist ^location ) + ( ^clist ^location ) + ( ^next none) + ( ^next none) + ( ^name right) + --> + ( ^failure )} + + ## Comment out the following excise statement if you want + ## the problem solved without long detours under conditions + ## of (user-select random). That is, without this production + ## excised and user-select set to random mac.s will sometimes return + ## to the initial state of the problem at some point, a state + ## of affairs that does not thwart finding the right string + ## of steps that solves the problem. + # + +# excise mac*evaluate*state*failure*detect-state-duplicate + +### +### EVALUATION: STATE SUCCESS/GOAL TEST +### + + ## This also defines implicitly the desired state + ## of the problem. + # + +sp {mac*detect*state*success + (state ^desired ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^mlist ^location ) + (

                                                                                                                        ^clist ^location ) + ( ^next ) + ( ^value missionary ^next ) + ( ^value missionary ^next ) + ( ^value missionary ^next none) + ( ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next ) + ( ^value cannibal ^next none) + ( ^name right) + --> + ( ^success )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### SEARCH CONTROL +### + + ## Create "reject preference" for inverse operator. + ## Definition of Inverse Operator: + ## apply(a[i],s[i]) = s[j], + ## apply(a[j],S[j]) = s[i], + ## where a[i] and a[j] are different instantiations + ## of the operator A, and s stands for state. The + ## instantiation a[j] is the inverse of a[i]. + ## Example: a[i] = walk(x,y), a[j] = walk(y,x). + # + +sp {mac*operator*inverse*move1*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ) + ( ^name move1 ^inst ^from ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^applied ) + ( ^name move1 ^inst ^from ^to ) + ( ^value ) + ( ^value ) + --> + ( ^operator - )} + +sp {mac*operator*inverse*move2*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ) + ( ^name move2 ^inst ^with ^from ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^applied ) + ( ^name move2 ^inst ^with ^from ^to ) + ( ^value ) + ( ^value ) + ( ^value ) + ( ^value ) + --> + ( ^operator - )} + +sp {mac*operator*inverse*move11*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ) + ( ^name move11 ^inst ^with ^from ^to ) + (

                                                                                                                        ^name missionaries-and-cannibals) + ( ^applied ) + ( ^name move11 ^inst ^with ^from ^to ) + ( ^value ) + ( ^value ) + ( ^value ) + ( ^value ) + --> + ( ^operator - )} + +### +### MISSIONARIES-AND-CANNIBALS PROBLEM SPACE: +### MONITOR OPERATORS +### + +sp {mac*monitor*operator-application*move1 + (state ^operator ) + ( ^name move1 + ^inst + ^from + ^to ) + ( ^value ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move1(| + |,| + |,| + |)|)} + +sp {mac*monitor*operator-application*move2 + (state ^operator ) + ( ^name move2 + ^inst + ^with + ^from + ^to ) + ( ^value ) + ( ^value ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move2(| + |,| + |,| + |,| + |)|)} + +sp {mac*monitor*operator-application*move11 + (state ^operator ) + ( ^name move11 + ^inst + ^with + ^from + ^to ) + ( ^value ) + ( ^value ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | APPLIED | + |: move11(| + |,| + |,| + |,| + |)|)} + +### eof of mac.s + + diff --git a/soar-8.5.2/demos_soar7/no-gui/readme b/soar-8.5.2/demos_soar7/no-gui/readme new file mode 100644 index 0000000..e427f82 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/readme @@ -0,0 +1,12 @@ +This directory contains various demo programs for Soar 7. More detail +about the directories are: + + analogy - The code for the deliberate analogy example + blocks-world - The code for the Blocks world example + eight_puzzle - The code for the eight puzzle demo/example + farmer - The code for the farmer puzzle example + kab - The code for the Keys and Boxes example + missionaries - The code for the Missionaries and Cannibals example + safe-stack - The code for the Safe Stack examples + towers-of-hanoi - The code for the Towers of Hanoi examples + waterjug - The code for the Water Jug example diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.1 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.1 new file mode 100644 index 0000000..1f29ede --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.1 @@ -0,0 +1,25 @@ + +# prob.1 +# An EBG problem the safe-to-stack system starts with. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^volume ^density ) + ( ^color ^weight ) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.1) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.2 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.2 new file mode 100644 index 0000000..a73dbb0 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.2 @@ -0,0 +1,26 @@ + +# prob.2 +# An EBG problem for the safe-to-stack system, +# in which VOLUME(BOX) is unknown. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^density ) ;# volume unknown + ( ^color ^weight ) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.1) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.3 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.3 new file mode 100644 index 0000000..8e05a1f --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.3 @@ -0,0 +1,26 @@ + +# prob.3 +# An EBG problem for the safe-to-stack system, +# in which LIGHTER(BOX,ENDTABLE) is given. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^volume ^density ^lighter ) + ( ^color ^weight ) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.1) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.4 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.4 new file mode 100644 index 0000000..df856c1 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.4 @@ -0,0 +1,32 @@ + +# prob.4 +# An EBG problem for the safe-to-stack system, +# in which LIGHTER(BOX,ENDTABLE) and +# WEIGHT(BOX)=0.1 are both given. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + &, + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color + ^volume + ^density + ^weight + ^lighter ) + ( ^color ^weight ) + ( ^value 0.1) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.1) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.5 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.5 new file mode 100644 index 0000000..e1fc367 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.5 @@ -0,0 +1,27 @@ + +# prob.5 +# An EBG problem for the safe-to-stack system, +# which differs from prob.1 with respect to the +# numbers involved. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^volume ^density ) + ( ^color ^weight ) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.2) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.6 b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.6 new file mode 100644 index 0000000..f037503 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/probs/prob.6 @@ -0,0 +1,27 @@ + +# prob.6 +# An EBG problem for the safe-to-stack system, +# in which FRAGILE(ENDTABLE)=NO and LIGHTER(BOX,ENDTABLE) +# are both given. + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^volume ^density ) + ( ^color ^weight ^fragile no) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.2) + ( ^value red) + ( ^value blue) + ( ^box ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/readme b/soar-8.5.2/demos_soar7/no-gui/safe-stack/readme new file mode 100644 index 0000000..93145c3 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/readme @@ -0,0 +1,19 @@ + +ReadMe +of the Safe-To-Stack Soar System +Jan 3, 94 + + +This directory contains: + + -- (a) README, this file; + -- (b) safe-to-stack.soar, the Soar system which runs with Soar 7.0.3; and + -- (c) probs, a directory of various problems to solve from the domain of (b). + +For the task domain, see the header of the file (b). + +When first loaded, (b) attempts to solve prob.1 (see the directory probs). + +To try another problem, just source a prob file from the directory probs and +do init-soar. + diff --git a/soar-8.5.2/demos_soar7/no-gui/safe-stack/safe-stack.soar b/soar-8.5.2/demos_soar7/no-gui/safe-stack/safe-stack.soar new file mode 100644 index 0000000..cb20f65 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/safe-stack/safe-stack.soar @@ -0,0 +1,495 @@ +### +### FILE : safe-to-stack.s +### + +### MODIFIED(1) : Sayan Bhattacharyya [ 7.0.3 TCL TK] +### +### AUTHOR(2) : Aladin.Akyurek [ Soar 6.1.0 ] +### AUTHOR(1) : Paul.S.Rosenbloom [ Soar 4.2.x ] +### + +### MODIFIED(1) : August 22, 96 +### +### CREATED(2) : Jun 18, 93 +### CREATED(1) : Mar 23, 86 +### + +### +### ABSTRACT. This file provides a Soar system to solve the SAFE-TO-STACK +### example for Explanation-Based Generalization (EBG), a unified approach +### to Explanation-Based Learning (EBL) that is forwarded in Mitchell, +### Keller, and Kedar-Cabelli (1986). The Soar 4.2.x system for this +### example underlies the paper by Rosenbloom and Laird (1986). +### + +### +### REFERENCES. [1] Minton, S., Carbonell, J. G., Knoblock, C. A., +### Kuokka, D. R., Etzioni, O., & Gil, Y. (1989). Explanation-based +### learning: A problem-solving perspective. Artificial Intelligence, +### 40, 63-118. +### [2] Mitchell, T., Keller, R., & Kedar-Cabelli, S. (1986). +### Explanation-based generalization: A unifying view. Machine Learning, +### 1, 47-80. +### [3] Rosenbloom, P. S., & Laird, J. E. (1986). Mapping +### explanation-based generalization onto Soar. In Proceedings of the +### Fifth National Conference on Artificial Intelligence (pp. 561-567). +### San Mateo, CA: Morgan Kaufmann. +### + +# +# The SAFE-TO-STACK example for EBG (see Minton, et al., 1989, p. 69) +# ------------------------------------------------------------------- +# Target concept definition: +# SAFE-TO-STACK(x,y) iff NOT(FRAGILE(y)) or LIGHTER(x,y) +# +# Training example: +# ON(OBJ1,OBJ2) +# ISA(OBJ1,BOX) +# ISA(OBJ2,ENDTABLE) +# COLOR(OBJ1,RED) +# COLOR(OBJ2,BLUE) +# VOLUME(OBJ1,1) +# DENSITY((OBJ1,0.1) +# +# Domain theory: +# VOLUME(p[1],v[1]) and DENSITY(p[1],d[1]) +# --> WEIGHT(p[1],v[1]*d[1]) +# WEIGHT(p[1],w[1]) and WEIGHT(p[2],w[2]) and LESS(w[1],w[2]) +# --> LIGHTER(p[1],p[2]) +# ISA(p[1],ENDTABLE) --> WEIGHT(p[1],5) [default] +# LESS(0.1,5) +# +# Operationality criterion: +# The learned concept description must be expressed in terms +# of the predicates used to describe examples (e.g., VOLUME, +# COLOR, DENSITY) or other selected, easily evaluated +# predicates from the domain theory (e.g., LESS). +# ------------------------------------------------------------------- + +package require Soar +source $default + +### +### TOP-PS: +### CURRENT STATE +### + +sp {top-ps*current-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name top-ps) + --> + ( ^real-state ) + ( ^object + &, + & + ^box + ^endtable + ^weight + & + ^volume + & + ^density + & + ^color + &, + & + ^holds + & ) + ( ^color ^volume ^density ) + ( ^color ^weight ) + ( ^value 5 ^is default) + ( ^value 1) + ( ^value 0.1) + ( ^value red) + ( ^value blue) + ( ^box ^on )} + +### +### TOP-PS OPERATOR: +### EVALUATE-QUERY +### + +sp {top-ps*propose*operator*evaluate-query + (state ^superstate nil ^real-state ) + (state ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name top-ps) + ( ^box ^endtable ) + --> + ( ^operator + = ) + ( ^name evaluate-query ^query ) + ( ^object ^safe-to-stack )} + +### +### TOP-PS: +### OPERATOR IMPLEMENTATION +### + +#None. + +### +### TOP-PS: +### OPERATOR TERMINATION +### + +sp {terminate*evaluate-query + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name evaluate-query ^query ) + ( ^object ^safe-to-stack ) + ( ^object ) + ( ^safe-to-stack ) + --> + ( ^operator @ - )} + +### +### TOP-PS PROBLEM-SPACE SUBGOAL: +### GOAL.NAME = QUERY-GOAL +### PROBLEM SPACE = QUERY-SPACE +### INITIAL STATE = SUPERSTATE +### + +sp {top-ps*operator-no-change*propose*space*query-space + (state ^superoperator + ^impasse no-change + ^attribute operator) + ( ^name evaluate-query ^query ) + --> + ( ^name query-goal) + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name query-space)} + +### sp {query-space*propose*state*superstate +### (state ^name query-goal +### ^problem-space +### ^object ) +### ( ^name query-space) +### +### --> +### ( ^state )} + + +sp {query-space*copy*real-state*from-superstate + (state ^name query-goal + ^problem-space + ^superstate.real-state ) + ( ^name query-space) + --> + ( ^real-state )} + + +### +### QUERY-SPACE: +### ELABORATE GOAL +### + +sp {query-space*elaborate*goal*top-space-query + (state ^name query-goal + ^superoperator + ^problem-space

                                                                                                                        + ) + ( ^name evaluate-query ^query ) + --> + ( ^query + & )} + +### +### QUERY-SPACE: +### SUBQUERIES +### + +sp {query*safe-to-stack*subquery*lighter + (state ^query -^succeeded ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^safe-to-stack ) + (

                                                                                                                        ^name query-space) + --> + ( ^query + & ) + ( ^object ^lighter )} + +sp {query*lighter*subquery*weight*source-object + (state ^query -^succeeded ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^lighter ) + (

                                                                                                                        ^name query-space) + --> + ( ^query + & ) + ( ^weightof )} + +sp {query*lighter*subquery*weight*target-object + (state ^query -^succeeded ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^lighter ) + (

                                                                                                                        ^name query-space) + --> + ( ^query + & ) + ( ^weightof )} + +sp {query*lighter*subquery*less + (state ^query -^succeeded ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^lighter ) + ( ^weight ) + ( ^weight ) + (

                                                                                                                        ^name query-space) + --> + ( ^query + & ) + ( ^weight ^less )} + +### +### QUERY-SPACE OPERATORS/DOMAIN THEORY: +### SAFE-TO-STACK, LIGHTER, WEIGHT, AND LESS +### + +sp {query-space*propose*operator*safe-to-stack*fragile + (state ^query -^succeeded ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^safe-to-stack ) + ( ^object ) + ( ^fragile no) + --> + ( ^operator + = ) + ( ^name safe-to-stack + ^object + ^reference-object )} + +sp {query-space*propose*operator*safe-to-stack*lighter + (state ^query -^succeeded ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^safe-to-stack ) + ( ^object ) + ( ^lighter ) + ( -^fragile no) + --> + ( ^operator + = ) + ( ^name safe-to-stack + ^object + ^reference-object )} + +sp {query-space*propose*operator*lighter + (state ^query -^succeeded ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^lighter ) + ( ^object ) + ( ^weight ) + ( ^weight ) + ( ^less ) + --> + ( ^operator + = ) + ( ^name lighter + ^object + ^reference-object )} + +sp {query-space*propose*operator*less + (state ^query -^succeeded ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^weight ^less ) + ( ^object ) + ( ^weight ) + ( ^weight ) + --> + ( ^operator + = ) + ( ^name less + ^number + ^reference-number )} + +sp {query-space*propose*operator*weight + (state ^query -^succeeded ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^weightof ) + ( ^object ) + ( ^volume ^density ) + --> + ( ^operator + = ) + ( ^name weight + ^object )} + +### +### QUERY-SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*safe-to-stack*relation*fragile*value*no + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name safe-to-stack + ^object + ^reference-object ) + ( ^object ) + ( ^fragile no) + --> + ( ^safe-to-stack )} + +sp {implement*safe-to-stack*relation*lighter + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name safe-to-stack + ^object + ^reference-object ) + ( ^object ) + ( ^lighter ) + --> + ( ^safe-to-stack )} + +sp {implement*lighter + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name lighter + ^object + ^reference-object ) + ( ^object ) + ( ^weight ) + ( ^weight ) + ( ^less ) + --> + ( ^lighter )} + +sp {implement*less + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name less + ^number + ^reference-number ) + ( ^object ) + ( ^weight ) + ( ^weight ) + ( ^value ) + ( ^value < ) + --> + ( ^less )} + +sp {implement*weight*volume-times-density + (state ^operator ^real-state ^problem-space

                                                                                                                        ) + ( ^name weight + ^object ) + ( ^object ) + ( ^volume ^density ) + ( ^value ) + ( ^value ) + ( -^weight) + --> + ( ^weight + & ) + ( ^weight ) + ( ^value (* ))} + +### +### QUERY-SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*safe-to-stack + (state ^operator ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^name safe-to-stack ^object ^reference-object ) + ( ^object ) + ( ^safe-to-stack ) + --> + ( ^operator @ )} + +sp {terminate*lighter + (state ^operator ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^name lighter ^object ^reference-object ) + ( ^object ) + ( ^lighter ) + --> + ( ^operator @ )} + +sp {terminate*less + (state ^operator ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^name less ^number ^reference-number ) + ( ^object ) + ( ^weight ) + ( ^weight ) + ( ^less ) + --> + ( ^operator @ )} + +sp {terminate*weight + (state ^operator ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^name weight ^object ) + ( ^object ) + ( ^weight ) + --> + ( ^operator @ )} + +### +### QUERY SATISFACTION +### + +sp {query*safe-to-stack*succeeded + (state ^query ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^safe-to-stack ) + (

                                                                                                                        ^name query-space) + ( ^object ) + ( ^safe-to-stack ) + --> + ( ^succeeded + & )} + +sp {query*lighter*succeeded + (state ^query ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^object ^lighter ) + (

                                                                                                                        ^name query-space) + ( ^object ) + ( ^lighter ) + --> + ( ^succeeded + & )} + +sp {query*weight*succeeded + (state ^query ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^weightof ) + (

                                                                                                                        ^name query-space) + ( ^object ^weight ) + ( ^weight ) + --> + ( ^succeeded + & )} + +sp {query*less*succeeded + (state ^query ^real-state ) + (state ^problem-space

                                                                                                                        ) + ( ^weight ^less ) + (

                                                                                                                        ^name query-space) + ( ^object ) + ( ^weight ) + ( ^weight ) + ( ^less ) + --> + ( ^succeeded + & )} + +### +### TERMINATE TASK +### + +sp {top-ps*object*operator*wait*halt + (state ^operator ) + ( ^name wait) + --> + (write (crlf) + | Type "print -full -chunks" for the result.|) + (halt)} + +sp {query-space*failure*halt + (state ^impasse no-change + ^attribute state + ^superstate ) + (state ^quiescence t + ^impasse no-change + ^attribute operator + ^name query-goal + ^superoperator + ^superstate ) + --> + (write (crlf) + | Query goal failed.|) + (halt)} + +### +### DEFAULT PRODUCTION +### + +#New Default Production For The Operator-No-Change Impasse + +sp {default*operator-no-change*elaborate*goal*superoperator + :default + (state ^impasse no-change + ^attribute operator + ^superstate ) + (state ^operator ) + (state ^problem-space ) + --> + ( ^superoperator )} + +### eof of safe-to-stack.s + + + diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.1 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.1 new file mode 100644 index 0000000..90ed723 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.1 @@ -0,0 +1,35 @@ + +#prob.3d.1 +#A 3-disk problem the tower-of-hanoi system starts with. + +# 1 1 +# 2 2 +# 3 3 +# --- --- --- --- --- --- +# A B C A B C +# +# Initial State Desired State + + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + &, + & + ^peg + &, + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + &, + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.2 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.2 new file mode 100644 index 0000000..1d7649d --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.3d.2 @@ -0,0 +1,35 @@ + +#prob.3d.2 +#A 3-disk problem for the tower-of-hanoi system. + +# 1 +# 2 2 +# 1 3 3 +# --- --- --- --- --- --- +# A B C A B C +# +# Initial State Desired State + + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + &, + & + ^peg + &, + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above none ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + &, + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.4d.1 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.4d.1 new file mode 100644 index 0000000..b0009fa --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.4d.1 @@ -0,0 +1,39 @@ + +#prob.4d.1 +#A 4-disk problem for the tower-of-hanoi system. + +# 1 1 +# 2 2 +# 3 3 +# 4 4 +# --- --- --- --- --- --- +# A B C A B C +# +# Initial State Desired State + + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 4-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + &, + &, + & + ^peg + &, + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + &, + &, + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.1 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.1 new file mode 100644 index 0000000..ea9fc9e --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.1 @@ -0,0 +1,57 @@ + +#prob.5d.1 +#A 5-disk problem for the tower-of-hanoi system. + +# 1 1 +# 2 2 +# 3 3 +# 4 4 +# 5 5 +# --- --- --- --- --- --- +# A B C A B C +# +# Initial State Desired State + + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 5-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + + &, + + &, + + &, + + & + ^peg + &, + + &, + + & + ^holds

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + + &, + + &, + + &, + + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.2 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.2 new file mode 100644 index 0000000..5f3f804 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/probs/prob.5d.2 @@ -0,0 +1,57 @@ + +#prob.5d.2 +#A 5-disk problem for the tower-of-hanoi system. + +# 1 +# 2 +# 3 1 +# 4 2 4 +# 5 3 5 +# --- --- --- --- --- --- +# A B C A B C +# +# Initial State Desired State + + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 5-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + + &, + + &, + + &, + + & + ^peg + &, + + &, + + & + ^holds

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + + &, + + &, + + &, + + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/readme b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/readme new file mode 100644 index 0000000..7241a00 --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/readme @@ -0,0 +1,22 @@ +ReadMe +of the Tower-Of-Hanoi Soar System +Feb 20, 94 + + +This directory contains: + + -- (a) README, this file; + -- (b) tower-of-hanoi.soar, the Soar system; and + -- (c) probs, a directory of various problems to solve from the domain of (b). + +For the task domain, see the header of the file (b). + +When first loaded, (b) attempts to solve prob.3d.1 (see the directory probs). + +To try another problem, just source a prob file from the directory probs and +do init-soar. + +Note. This Soar system implements what Herbert A. Simon calls "a sophisticated +perceptual strategy" for the tower-of-hanoi task, but it does not produce or +acquire that strategy. + diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/tn-toh.s7 b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/tn-toh.s7 new file mode 100644 index 0000000..a1bd66a --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/tn-toh.s7 @@ -0,0 +1,879 @@ +### +### FILE : tower-of-hanoi7.soar +### + +### +### AUTHOR(1) : Aladin.Akyurek [ Soar 6.1.0 ] +### AUTHOR(2) : Tim Chapman [ Soar 7.0.4 ] +### tidied Frank Ritter 10 Dec 97 + +### +### CREATED(1) : Aug 15, 93 +### + +### +### MODIFIED(3) : May 27, 97 [ soar 7.0.4 ] Tim Chapman +### MODIFIED(2) : Feb 18, 94 [ soar 6.1.x ] Aladin.Akyurek +### MODIFIED(1) : Jan 11, 94 [ soar 6.1.x ] Aladin.Akyurek +### + +### May 27, 97 : Added Blocksworld problem space for Tower +### Noticing Strategy. +### Feb 18, 94 : Added the Pop operator, removed the Infer space. +### Jan 11, 94 : Collapsed two problem spaces into one from +### the version which was presented at the 7th EuroSoar Workshop +### (Nov 93, Nottingham, UK). +### +### Copyright (C) Aladin Akyurek (NISCALE, Leiden, The Netherlands). + +### +### TOP GOAL: +### TOWER-OF-HANOI +### + +watch learning -print +watch -chunks -print +learn -on + +sp {top-goal*elaborate*goal*toh + "Create the top goal state" + (state ^superstate nil) + --> + ( ^name tower-of-hanoi)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### TOWER-OF-HANOI +### + +sp {toh*propose*space*tower-of-hanoi + "Propose the tower-of-hanoi problem space" + (state ^name tower-of-hanoi) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### INITIAL-STATE AND DESIRED-STATE +### + +#prob.5d.1 +#A 5-disk problem for the tower-of-hanoi system. + +# 1 +# 2 +# 3 +# 4 +# 5 +# --- --- --- +# A B C +# +# Initial State Desired State + +# This can be modified to create larger or smaller towers +sp {toh*propose*state*initial-and-desired-states + "A 5-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^taskstate ) + ( ^disk + &, + + &, + + &, + + &, + + & + ^peg + &, + + &, + + & + ^holds

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + &, +

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (
                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name 4 ^size 4) + ( ^name 5 ^size 5) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + + &, + + &, + + &, + + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND +### CLEAR +### + +sp {toh*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^superstate nil + ^problem-space.name tower-of-hanoi ^taskstate ) + ( ^disk { <> }) + ( ^size ) + ( ^size > ) + --> + ( ^larger + & )} + +sp {toh*object*disk*elaborate*state*upper-disk + "If not(above(x,disk)), then upper-disk(disk)." + (state ^problem-space.name tower-of-hanoi ^taskstate ) + ( ^disk ) + -{ ( ^holds ) + ( ^above ) } + --> + ( ^upper-disk + & )} + +sp {toh*object*peg*elaborate*state*clear + "If not(on(x,peg)), then clear(peg)." + (state ^problem-space.name tower-of-hanoi ^taskstate ) + ( ^peg ) + -{ ( ^holds ) + ( ^on ) } + --> + ( ^clear + & )} + +### +### TOWER-OF-HANOI PROBLEM SPACE OPERATORS: +### SET-FOCUS AND MOVE-DISK +### For POP and GOAL-TEST, see below. +### + +sp {toh*propose*operator*set-focus*disk-to-move + "If no focus [i.e., no disk-to-move], then create one." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( -^disk-to-move) + --> + ( ^operator + <, = ) + ( ^name set-focus ^previous-focus none ^done? no)} + +## -fer moveable? +sp {toh*propose*operator*set-focus*disk-to-move*alternative + "If the disk in focus is not movable, change the focus." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move ) + # ( ^disk ) + # ( -^moveable yes) + --> + ( ^operator + <, = ) + ( ^name set-focus ^previous-focus ^done? no)} + +sp {toh*propose*operator*move-disk*disk-to-move*onto + "Move disk when target peg is clear." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move ^upper-disk + ^peg + ^clear + ^holds ) + ( ^disk + ^from { <> } + ^to ) + ( ^disk ^on ) + --> + ( ^operator ) + ( ^name move-disk ^disk + ^from + ^to + ^done? no)} + +sp {toh*propose*operator*move-disk*disk-to-move*above + "Move disk where upper disk on the target peg is larger." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move + ^upper-disk + ^peg + -^clear + ^holds ) + ( ^disk + ^from { <> } + ^to ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^operator ) + ( ^name move-disk ^disk + ^from + ^to + ^done? no)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*move-disk*from-above*nodisk*target-peg*is-clear + "Carry out the move when target peg is clear" + (state ^operator ) + (state ^problem-space

                                                                                                                        ^taskstate ) + ( ^name move-disk ^disk + ^from + ^to + ^done? no) + (

                                                                                                                        ^name ) + ( ^upper-disk ^clear ^disk-to-move + ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^above none ^on ) + --> + ( ^on - ) + ( ^done? yes no - )} + +sp {implement*move-disk*from-above*adisk*target-peg*is-clear + "Carry out the move from above a disk when target is clear" + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name move-disk ^disk ^done? no + ^from ^to ) + (

                                                                                                                        ^name ) + ( ^upper-disk ^clear + ^disk-to-move ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^above { <> none } ^on ) + --> + ( ^above none - ) + ( ^on - ) + ( ^done? yes + no - )} + +sp {implement*move-disk*from-above*adisk-or-nodisk*target-peg*is-not-clear + "Carry out the move to a non-clear target peg" + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name move-disk ^disk ^done? no + ^from ^to ) + (

                                                                                                                        ^name ) + ( ^upper-disk { <> } + -^clear + ^disk-to-move ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^above ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^above - ) + ( ^on - ) + ( ^done? yes no - )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*set-focus + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name set-focus ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*move-disk + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name move-disk ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: POP FOCUS +### + +sp {toh*propose*operator*pop*object*disk-to-move + "Propose pop operator to choose disk to focus on" + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^holds ^disk-to-move ) + ( ^disk ^to ) + ( ^disk ^on ) + --> + ( ^operator + =, < ) + ( ^name pop ^focus ^done? no) + ( ^pop? yes)} + +sp {task-space*compare*pop*better + "Check that pop is the best operator" + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        ^taskstate ) + ( ^name pop) + ( -^name { << pop add del >> }) + (

                                                                                                                        ^name ) + --> + ( ^operator > )} + +sp {implement*pop + "Pop the focus to the most suitable disk" + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name pop ^focus ^done? no) + (

                                                                                                                        ^name ) + ( ^ ) + ( ^pop? yes) + --> + ( ^ - ) + ( ^done? yes no - )} + +sp {terminate*pop + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name pop ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: GOAL-TEST +### + +sp {toh*desired-of-disk*satisfied + "Check if conditions are satisfied" + (state ^desired ^problem-space

                                                                                                                        ^taskstate ) + ( ^disk ^above ^on ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^holds ) + ( ^disk ^above ^on ) + --> + ( ^satisfied + & )} + +sp {task-space*mark*state*pursue + "Mark goals to pursue" + (state ^desired -^satisfied ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name ) + --> + ( ^pursue + & )} + +sp {task-space*propose*operator*goal-test*top-goal + "Propose operator for if top-goal is reached" + (state ^superstate nil ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name ) + ( -^pursue -^success) + --> + ( ^operator =, + ) + ( ^name goal-test ^result-type success)} + +sp {task-space*select*operator*goal-test*better + "Check if goal test is best operator" + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        ^taskstate ) + ( ^name goal-test) + ( -^name << pop add del >>) + (

                                                                                                                        ^name ) + ( -^pursue) + --> + ( ^operator > )} + +sp {implement*goal-test*top-goal + "Implement the goal reached operator" + (state ^operator ^problem-space

                                                                                                                        ^taskstate + ^desired ^satisfied ^superstate nil) + ( ^name goal-test ^result-type ) + ( -^pursue -^ ) + --> + (write (crlf) | ********** Goal State Achieved ********* | ) + ( ^ + & ) + ( ^ + & ) + (halt)} + +sp {terminate*goal-test + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + ( ^name goal-test) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM-SPACE SUBGOAL: +### PROBLEM SPACE = SET-FOCUS +### INITIAL STATE = SUPERSTATE +### + +sp {toh*operator-no-change*create*goal-context*set-focus + "Propose the set-focus problem space on impasse" + (state ^superstate.operator ^impasse no-change + ^attribute operator ^superstate ) + ( ^name set-focus) + ( ^problem-space ^taskstate ) + --> + ( ^problem-space ) + ( ^name set-focus) + ( ^taskstate )} + +### +### SET-FOCUS PROBLEM SPACE: +### STATE ELABORATION: +### IS-BLOCKED-BY AND +### LARGEST-BLOCKING-DISK +### + +sp {set-focus*elaborate*state*disk-to-move*blocking-disks*source + "Record blocking disks on source peg" + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^is-blocked-by + & )} + +sp {set-focus*elaborate*state*disk-to-move*blocking-disks*target + "Record blocking disks on target peg" + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ^holds ) + ( ^disk ^from + ^to { <> }) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^is-blocked-by + & )} + +sp {set-focus*elaborate*state*disk-to-move*largest-blocking-disk + "Record the largest blocking disk" + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ) + ( ^is-blocked-by ) + -{ ( ^disk-to-move ) + ( ^is-blocked-by ) + ( ^larger ) } + --> + ( ^largest-blocking-disk )} + +### +### SET-FOCUS PROBLEM SPACE OPERATORS: +### CREATE-FOCUS AND CHANGE-FOCUS +### + +sp {set-focus*propose*operator*create-focus + "Propose to create a focus if none exists" + (state ^problem-space

                                                                                                                        ^taskstate + ^superoperator ) + (

                                                                                                                        ^name set-focus) + ( ^previous-focus none) + --> + ( ^operator + = ) + ( ^name create-focus ^previous-focus none)} + +sp {set-focus*propose*operator*change-focus + "Propose to change existing focus" + (state ^problem-space

                                                                                                                        ^taskstate + ^superoperator ) + (

                                                                                                                        ^name set-focus) + ( ^previous-focus { <> none }) + --> + ( ^operator + = ) + ( ^name change-focus ^previous-focus )} + +### +### SET-FOCUS PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*create-focus*disk-to-move*largest + "Set focus to largest blocking disk" + (state ^operator ^problem-space

                                                                                                                        ^taskstate + ^superoperator ) + (

                                                                                                                        ^name ) + ( ^name create-focus) + ( ^holds ^pursue ) + ( ^disk ^on ) + ( ^disk ^on ) + -{ ( ^pursue ) + ( ^disk ) + ( ^larger ) } + --> + ( ^disk-to-move + & ) + ( ^disk ^from ^to ) + ( ^done? yes no - )} + +sp {implement*change-focus*disk-to-move*largest-blocker + "Set focus to largest blocking disk" + (state ^operator ^problem-space

                                                                                                                        ^taskstate + ^superoperator ) + (

                                                                                                                        ^name ) + ( ^name change-focus ^previous-focus ) + ( ^peg ^holds ^disk-to-move ) + ( ^disk ^largest-blocking-disk + ^from { <> } + ^to { <> }) + ( ^disk ^on { <> }) + ( ^larger ) + --> + ( ^disk-to-move + &, - ) + ( ^disk ^from ^to ) + ( ^done? yes no - )} + +### +### SET-FOCUS PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*create-focus + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name ) + ( ^name create-focus) + --> + ( ^operator @ )} + +sp {terminate*change-focus + (state ^operator ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name ) + ( ^name change-focus) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### Various productions to provide informative output to user + +sp {toh*monitor*state*holds*above*disk + (state ^superstate nil ^taskstate ) + ( ^holds ) + ( ^disk ^above ^on ) + ( ^size ) + ( ^size ) + ( ^name ) + --> + (write (crlf) | On(| |,| |),Above(| + |,| |).|)} + +sp {toh*monitor*state*holds*above*none + (state ^superstate nil ^taskstate ) + ( ^holds ) + ( ^disk ^above none ^on ) + ( ^size ) + ( ^name ) + --> + (write (crlf) | On(| |,| |),Above(| |,-).|)} + +sp {toh*monitor*state*upper-disk + (state ^superstate nil ^taskstate ) + ( ^upper-disk ) + ( ^size ) + --> + (write (crlf) | Upper-Disk(| |).|)} + +sp {toh*monitor*state*clear + (state ^superstate nil ^taskstate ) + ( ^clear ) + ( ^name ) + --> + (write (crlf) | Clear(Peg(| |)).|)} + +sp {toh*monitor*state*disk-to-move + (state ^superstate nil ^taskstate ) + ( ^disk-to-move ) + ( ^disk ) + ( ^size ) + --> + (write (crlf) | Focus(Disk(| |)).|)} + +sp {toh*desired-state*above*disk + (state ^desired ^superstate nil) + ( ^disk ^above ^on ) + ( ^size ) + ( ^size ) + ( ^name ) + --> + (write (crlf) | Desired[On(| |,| |),Above(| + |,| |)].|)} + +sp {toh*desired-state*above*none + (state ^desired ^superstate nil) + ( ^disk ^above none ^on ) + ( ^size ) + ( ^name ) + --> + (write (crlf) | Desired[On(| |,| |),Above(| + |,-)].|)} + +sp {toh*monitor*operator-execution*move-disk + (state ^operator ^taskstate ) + ( ^name move-disk ^disk ^done? yes + ^from ^to ) + ( ^holds ) + ( ^disk ^on ) + ( ^size ) + ( ^name ) + ( ^name ) + --> + (write (crlf) | Executing(Move-Disk(| |,| + |,| |)).|)} + +### NEW PRODUCTION ****************************************** +### Give an output on state of the world when it changes +### by Tim Chapman May 1997 + +sp {toh*display*operator-execution*move-disk + (state ^operator ^taskstate ) + ( ^name move-disk ^disk ^done? yes + ^from ^to ) + ( ^holds

                                                                                                                        ^holds

                                                                                                                        ^holds

                                                                                                                        ^holds

                                                                                                                        ^holds

                                                                                                                        ) + (

                                                                                                                        ^disk.size 1 ^on ) + (

                                                                                                                        ^disk.size 2 ^on ) + (

                                                                                                                        ^disk.size 3 ^on ) + (

                                                                                                                        ^disk.size 4 ^on ) + (
                                                                                                                        ^disk.size 5 ^on ) + ( ^name ) + ( ^name ) + ( ^name ) + ( ^name ) + ( ^name ) + --> + (write (crlf) | Disk 1 on | + |, Disk 2 on | + |, Disk 3 on | + |, Disk 4 on | + |, Disk 5 on | )} + + +### TOWER NOTICING PRODUCTIONS **************************** +### by Tim Chapman +### A set of rules to notice towers of size 2 to 4 + +sp {toh*notice*stack-size-two + (state ^taskstate ) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^above none ^disk ^on ) + ( ^size 2) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 1) + ( ^name ) + --> + ( ^tower yes ^moveable yes) + (write (crlf) | *** NOTICED TOWER SIZE TWO ON PEG (| |).|)} + +sp {toh*notice*stack-size-three + (state ^taskstate ) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^above none ^disk ^on ) + ( ^size 3) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 2) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 1) + ( ^name ) + --> + ( ^tower yes ^moveable yes) + (write (crlf) | *** NOTICED TOWER SIZE THREE ON PEG (| |).|)} + +sp {toh*notice*stack-size-four + (state ^taskstate ) + ( ^holds

                                                                                                                        ) + (

                                                                                                                        ^above none ^disk ^on ) + ( ^size 4) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 3) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 2) + (

                                                                                                                        ^above ^disk ^on ) + ( ^size 1) + ( ^name ) + --> + ( ^tower yes ^moveable yes) + (write (crlf) | NOTICED TOWER SIZE FOUR ON PEG (| |).|)} + + +### +### DEFAULT PRODUCTION +### + +#New Default Production For The Operator-No-Change Impasse + +sp {default*operator-no-change*elaborate*goal*superoperator + :default + (state ^impasse no-change ^attribute operator ^superstate ) + (state ^operator ^problem-space ^taskstate ) + --> + ( ^superoperator )} + +### eof of tower-of-hanoi.s + +### NEW RULES FOR TOWER NOTICING ********************************** +### by Tim Chapman May 1997 + +# Propose to move disks in towers disk rules: + +sp {toh*propose*operator*move-tower-disk*onto + "Move where target peg is clear." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move ^peg ^clear ^holds ) + ( ^disk ^from { <> } + ^to ) + ( ^moveable yes) + ( ^disk ^on ) + --> + ( ^operator + >) + ( ^name move-disk ^disk ^done? no + ^from ^to )} + +sp {toh*propose*operator*move-tower-disk*above + "Move where upper disk on the target peg is larger." + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move ^upper-disk + ^peg -^clear + ^holds ) + ( ^disk ^from { <> } + ^to ) + ( ^moveable yes) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^operator + >) + ( ^name move-disk ^disk ^done? no + ^from ^to )} + + +### TOWER-OF-HANOI PROBLEM-SPACE SUBGOAL: +### PROBLEM SPACE = BLOCKSWORLD +### INITIAL STATE = SUPERSTATE or BLOCKSWORLD +### + +sp {toh*operator-no-change*create*goal-context*blocksworld + "Create blocksworld state on impasse" + (state ^superstate.operator ^impasse no-change + ^attribute operator ^superstate ) + ( ^name move-disk ^done? no) + ( ^problem-space ^taskstate ) + --> + ( ^problem-space ) + ( ^name blocksworld) + ( ^taskstate )} + +sp {blocksworld*elaborate*state*disk-to-move*blocking-disks*source + "Elaborate the blocksworld state to mark blocking disk" + (state ^problem-space

                                                                                                                        ^taskstate ^superstate.operator ) + (

                                                                                                                        ^name blocksworld) + ( ^holds ) + ( ^name move-disk ^disk ^from ^to ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^disk-blocked-by + & )} + +sp {blocksworld*elaborate*state*disk-to-move*blocking-disks*target + "Elaborate the blocksworld state to mark blocking disk" + (state ^problem-space

                                                                                                                        ^taskstate ^superstate.operator ) + (

                                                                                                                        ^name blocksworld) + ( ^holds ) + ( ^name move-disk ^disk + ^from ^to { <> }) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^disk-blocked-by + & )} + +sp {blocksworld*elaborate*state*disk-to-move*largest-blocking-disk + "Select largest blocking disk" + (state ^problem-space

                                                                                                                        ^taskstate ) + (

                                                                                                                        ^name blocksworld) + ( ^disk-blocked-by ) + -{ ( ^disk-blocked-by ) + ( ^larger ) } + --> + ( ^largest-blocking-disk )} + +sp {blocksworld*elaborate*state*disk-to-move*mark-other-peg + "Select the peg that moves the blocking disk out of the way" + (state ^problem-space.name blocksworld ^superstate.operator + ^taskstate ) + ( ^peg ) + ( ^name move-disk ^disk + ^from { <> } + ^to { <> }) + --> + ( ^other-peg )} + + +# propose an operator to move blocking disk. + +sp {blocksworld*propose*operator*try-to-clear + "Propose move-disk operator for blocking disk" + (state ^problem-space.name blocksworld + ^superstate.operator ^taskstate ) + ( ^holds ^peg ) + ( ^disk ) + ( ^largest-blocking-disk ^other-peg ) + ( ^disk ^on { <> }) + ( ^larger ) + --> + ( ^operator + = ) + ( ^name move-disk ^disk ^done? no + ^from ^to )} + +# implement move disk op. + +sp {blocksworld*implement*operator*try-to-clear*from-nodisk-to-clear + "Implement the move-disk operator on the blocking disk" + (state ^operator ^problem-space.name blocksworld ^taskstate ) + ( ^name move-disk ^disk ^done? no + ^from ^to ) + ( ^upper-disk ^clear ^holds ) + ( ^disk ^above none ^on ) + --> + ( ^on - ) + ( ^done? yes no - )} + + +sp {blocksworld*implement*operator*try-to-clear*from-adisk-to-clear + "Implement the move-disk operator on the blocking disk" + (state ^operator ^problem-space.name blocksworld ^taskstate ) + ( ^name move-disk ^disk ^done? no + ^from ^to ) + ( ^upper-disk ^clear ^holds ) + ( ^disk ^above { <> none } ^on ) + --> + ( ^above none - ) + ( ^on - ) + ( ^done? yes no - )} + +sp {blocksworld*implement*operator*try-to-clear*from-any-to-not-clear + "Implement the move-disk operator on the blocking disk" + (state ^operator ^problem-space.name blocksworld ^taskstate ) + ( ^name move-disk ^disk ^done? no + ^from ^to ) + ( ^upper-disk { <> } + -^clear ^holds ) + ( ^disk ^above ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^above - ) + ( ^on - ) + ( ^done? yes no - )} + +# terminate move-disk operator. + +sp {terminate*try-to-clear + (state ^operator ^problem-space.name blocksworld ^taskstate ) + ( ^name move-disk ^done? yes) + --> + ( ^operator @ ) } + +### eof: Tower of Hanoi + \ No newline at end of file diff --git a/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/towers-of-hanoi.soar b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/towers-of-hanoi.soar new file mode 100644 index 0000000..00e1dec --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/towers-of-hanoi/towers-of-hanoi.soar @@ -0,0 +1,750 @@ + +### +### FILE : tower-of-hanoi.s +### + +### +### AUTHOR(1) : Aladin.Akyurek [ Soar 6.1.0 ] +### + +### +### CREATED(1) : Aug 15, 93 +### + +### +### MODIFIED(3) : Aug 22, 96 [ soar 7.0.3 ] Sayan Bhattacharyya +### MODIFIED(2) : Feb 18, 94 [ soar 6.1.x ] Aladin.Akyurek +### MODIFIED(1) : Jan 11, 94 [ soar 6.1.x ] Aladin.Akyurek +### + +### +### Aug 22, 96 : Minor syntactic change to make this run with Soar 7.0.3 +### Feb 18, 94 : Added the Pop operator, removed the Infer space. +### Jan 11, 94 : Collapsed two problem spaces into one from +### the version which was presented at the 7th EuroSoar Workshop +### (Nov 93, Nottingham, UK). +### +### Copyright (C) Aladin Akyurek (NISCALE, Leiden, The Netherlands). +### + +### +### ABSTRACT. This file provides a Soar system to solve the Tower +### of Hanoi problems. This puzzle "involves three vertical pegs or +### posts and a number of doughnut-like disks of graduated sizes that +### fit on the pegs. At the outset, all the disks are arranged pyrami- +### dally on one of the pegs, say A, with the largest disk on the bottom. +### The task is to move all of the disks to another peg, C, say, under +### the constraints that (1) only one disk may be moved at a time, and +### (2) a disk may never be placed on top of another smaller than itself. +### Any number of disks may be used; the minimum number of moves for +### a solution is (2**n - 1), where n is the number of disks" (Simon, +### 1975/1979, pp. 230-231). +### + +### +### This Soar system implements the production system given in Simon +### [6, pp. 238-239]. See, in particular, Anzai & Simon [3, p. 121]. +### The system is comprised of three problem spaces and six operators: +### +### Problem Space Associated Operators +### -------------- ---------------------------------------- +### Tower-Of-Hanoi { Set-Focus, Move-Disk, Pop, Goal-Test } +### Set-Focus { Create-Focus, Change-Focus } +### -------------- ---------------------------------------- +### +### The tower-of-hanoi space (i.e., the task space) looks for a *disk-to-move*, +### and if it can, moves the *disk-to-move* to its destination; otherwise +### it attempts, by means of the set-focus operator, to establish one that can +### be moved. The associated set-focus space either creates *disk-to-move* +### or changes the existing one(s). +### +### The system "will solve the Tower of Hanoi problem for any number of +### disks starting from any situation". No proof is provided for this +### conclusion (see for examples such as 3-disk, 4-disk, etc., the associated +### "probs" directory). The following should help in comparing the system +### to the descriptions given in [3] and [6]. +### +### (in 6) State = Can <---> (state ^operator ) and +### ( ^disk-to-move ) and +### ( ^disk ) and +### ( ^name move-disk +### ^disk ) +### (in 3) (LEGAL X P Q) <---> same as above +### (in 6) State = Can't(J) <---> (state ^operator ) and +### ( ^disk-to-move ) and +### ( ^name set-focus +### ^previous-focus ) +### (in 6) Goal = Move(k,P(k),Q) <---> ( ^disk-to-move ) +### ( ^disk +### ^from +### ^to ) +### (in 3) (STATE X P Q) <---> same as above +### (in 3) NEXTSMALLER (of disk X) <---> largest of the disks that block +### the disk specified in the structure +### disk-to-move +### + +### +### REFERENCES. [1] Amarel, S. (1984). Expert behaviour and problem +### representations. In A. Elithorn & R. Banerji (Eds.), Artificial +### and human intelligence (pp. 1-41). Amsterdam: Elsevier. +### [2] Anderson, J. R., Kushmerick, N., & Lebiere, C. (1993). +### The Tower of Hanoi and goal structures. In J. R. Anderson (1993), Rules +### of the mind (pp. 121-142). Hillsdale, NJ: Erlbaum. +### [3] Anzai, Y., & Simon, H. A. (1979). The theory of learning +### by doing. Psychological Review, 86, 124-140 (Reprinted in Simon, H. A. +### (1979), Models of thought (Vol. 2, pp. 116-133). New Haven, CT: Yale +### University Press.). +### [4] Newell, A. (1992). Unified theories of cognition and +### the role of Soar. In J. A. Michon & A. Akyurek (Eds.), Soar: A cognitive +### architecture in perspective (pp. 25-79). +### [5] Ruiz, D., & Newell, A. (1989). Tower-noticing triggers +### strategy-change in the Tower of Hanoi: A Soar model. In Proceedings of the +### Eleventh Annual Conference of the Cognitive Science Society (pp. 522-529). +### [6] Simon, H. A. (1975). The functional equivalence of problem +### solving skills. Cognitive Psychology, 7, 268-288 (Reprinted in Simon, H. +### A. (1979), Models of thought (Vol. 1, pp. 230-244). New Haven, CT: Yale +### University Press.). +### + +package require Soar +source $default + +### +### TOP GOAL: +### TOWER-OF-HANOI +### + +sp {top-goal*elaborate*goal*tower-of-hanoi + (state ^superstate nil) + --> + ( ^name tower-of-hanoi)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### TOWER-OF-HANOI +### + +sp {tower-of-hanoi*propose*space*tower-of-hanoi + (state ^name tower-of-hanoi) + --> + ( ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### INITIAL-STATE AND DESIRED-STATE +### + +sp {tower-of-hanoi*propose*state*initial-and-desired-states + "A 3-Disk Tower of Hanoi Problem." + (state ^name tower-of-hanoi ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name tower-of-hanoi) + --> + ( ^state ) + ( ^disk + &, + &, + & + ^peg + &, + &, + & + ^holds

                                                                                                                        + &,

                                                                                                                        + &,

                                                                                                                        + & ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above ^on ) + (

                                                                                                                        ^disk ^above none ^on ) + ( ^name 1 ^size 1) + ( ^name 2 ^size 2) + ( ^name 3 ^size 3) + ( ^name |A|) + ( ^name |B|) + ( ^name |C|) + ( ^desired + &, + &, + & ) + ( ^disk ^above ^on ) + ( ^disk ^above ^on ) + ( ^disk ^above none ^on )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### STATE ELABORATION/INFERENCES: +### LARGER, UPPER-DISK, AND +### CLEAR +### + +sp {tower-of-hanoi*object*disk*elaborate*state*larger + "If size-of(i) > size-of(j), then larger(i,j)." + (state ^superstate nil) + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk { <> }) + ( ^size ) + ( ^size > ) + --> + ( ^larger + & )} + +sp {tower-of-hanoi*object*disk*elaborate*state*upper-disk + "If not(above(x,disk)), then upper-disk(disk)." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk ) + -{ ( ^holds ) + ( ^above ) } + --> + ( ^upper-disk + & )} + +sp {tower-of-hanoi*object*peg*elaborate*state*clear + "If not(on(x,peg)), then clear(peg)." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^peg ) + -{ ( ^holds ) + ( ^on ) } + --> + ( ^clear + & )} + +### +### TOWER-OF-HANOI PROBLEM SPACE OPERATORS: +### SET-FOCUS AND MOVE-DISK +### For POP and GOAL-TEST, see below. +### + +sp {tower-of-hanoi*propose*operator*set-focus*disk-to-move + "If no focus [i.e., no disk-to-move], then create one." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( -^disk-to-move) + --> + ( ^operator + <, = ) + ( ^name set-focus + ^previous-focus none + ^done? no)} + +sp {tower-of-hanoi*propose*operator*set-focus*disk-to-move*alternative + "If the disk in focus is not movable, change the focus." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move ) + --> + ( ^operator + <, = ) + ( ^name set-focus + ^previous-focus + ^done? no)} + +sp {tower-of-hanoi*propose*operator*move-disk*disk-to-move*onto + "Target peg is clear." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move + ^upper-disk + ^peg + ^clear + ^holds ) + ( ^disk + ^from { <> } + ^to ) + ( ^disk ^on ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? no)} + +sp {tower-of-hanoi*propose*operator*move-disk*disk-to-move*above + "Upper disk on the target peg is larger." + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^disk-to-move + ^upper-disk + ^peg + -^clear + ^holds ) + ( ^disk + ^from { <> } + ^to ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^operator ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? no)} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*move-disk*from-above*nodisk*target-peg*is-clear + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? no) + (

                                                                                                                        ^name ) + ( ^upper-disk + ^clear + ^disk-to-move + ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^above none ^on ) + --> + ( ^on - ) + ( ^done? yes no - )} + +sp {implement*move-disk*from-above*adisk*target-peg*is-clear + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? no) + (

                                                                                                                        ^name ) + ( ^upper-disk + ^clear + ^disk-to-move + ^holds ) + ( ^disk ^from ^to ) + ( ^disk ^above { <> none } ^on ) + --> + ( ^above none - ) + ( ^on - ) + ( ^done? yes no - )} + +sp {implement*move-disk*from-above*adisk-or-nodisk*target-peg*is-not-clear + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? no) + (

                                                                                                                        ^name ) + ( ^upper-disk { <> } + -^clear + ^disk-to-move + ^holds ) + ( ^disk + ^from + ^to ) + ( ^disk ^above ^on ) + ( ^disk ^on ) + --> + ( ^above - ) + ( ^on - ) + ( ^done? yes no - )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*set-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name set-focus ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*move-disk + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name move-disk ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: POP FOCUS +### + +sp {tower-of-hanoi*propose*operator*pop*object*disk-to-move + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^holds ^disk-to-move ) + ( ^disk ^to ) + ( ^disk ^on ) + --> + ( ^operator + =, < ) + ( ^name pop + ^focus + ^done? no) + ( ^pop? yes)} + +sp {task-space*compare*pop*better + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name pop) + ( -^name { << pop add del >> }) + (

                                                                                                                        ^name ) + --> + ( ^operator > )} + +sp {implement*pop + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name pop + ^focus + ^done? no) + (

                                                                                                                        ^name ) + ( ^ ) + ( ^pop? yes) + --> + ( ^ - ) + ( ^done? yes no - )} + +sp {terminate*pop + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name pop ^done? yes) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: GOAL-TEST +### + +sp {tower-of-hanoi*desired-of-disk*satisfied + (state ^desired ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^disk ^above ^on ) + (

                                                                                                                        ^name tower-of-hanoi) + ( ^holds ) + ( ^disk ^above ^on ) + --> + ( ^satisfied + & )} + +sp {task-space*mark*state*pursue + (state ^desired -^satisfied ) + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name ) + --> + ( ^pursue + & )} + +sp {task-space*propose*operator*goal-test*top-goal + (state ^superstate nil) + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name ) + ( -^pursue -^success) + --> + ( ^operator =, + ) + ( ^name goal-test ^result-type success)} + +sp {task-space*select*operator*goal-test*better + (state ^operator + { <> } + ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name goal-test) + ( -^name << pop add del >>) + (

                                                                                                                        ^name ) + ( -^pursue) + --> + ( ^operator > )} + +sp {implement*goal-test*top-goal + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state + ^desired + ^satisfied + ^superstate nil) + ( ^name goal-test ^result-type ) + ( -^pursue -^ ) + --> + ( ^ + & ) + ( ^ + & )} + +sp {terminate*goal-test + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name goal-test) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM-SPACE SUBGOAL: +### PROBLEM SPACE = SET-FOCUS +### INITIAL STATE = SUPERSTATE +### + +sp {tower-of-hanoi*operator-no-change*create*goal-context*set-focus + (state ^superstate.operator + ^impasse no-change + ^attribute operator + ^superstate ) + ( ^name set-focus) ## ^done? no + ( ^problem-space ^state ) + --> + ( ^problem-space ) + ( ^name set-focus) + ( ^state )} + +### +### SET-FOCUS PROBLEM SPACE: +### STATE ELABORATION: +### IS-BLOCKED-BY AND +### LARGEST-BLOCKING-DISK +### + +sp {set-focus*elaborate*state*disk-to-move*blocking-disks*source + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ^holds ) + ( ^disk + ^from + ^to ) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^is-blocked-by + & )} + +sp {set-focus*elaborate*state*disk-to-move*blocking-disks*target + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ^holds ) + ( ^disk + ^from + ^to { <> }) + ( ^disk ^on ) + ( ^disk ^on ) + ( ^larger ) + --> + ( ^is-blocked-by + & )} + +sp {set-focus*elaborate*state*disk-to-move*largest-blocking-disk + (state ^problem-space

                                                                                                                        ^state ) + (

                                                                                                                        ^name set-focus) + ( ^disk-to-move ) + ( ^is-blocked-by ) + -{ ( ^disk-to-move ) + ( ^is-blocked-by ) + ( ^larger ) } + --> + ( ^largest-blocking-disk )} + +### +### SET-FOCUS PROBLEM SPACE OPERATORS: +### CREATE-FOCUS AND CHANGE-FOCUS +### + +sp {set-focus*propose*operator*create-focus + (state ^problem-space

                                                                                                                        + ^state + ^superoperator ) + (

                                                                                                                        ^name set-focus) + ( ^previous-focus none) + --> + ( ^operator + = ) + ( ^name create-focus ^previous-focus none)} + +sp {set-focus*propose*operator*change-focus + (state ^problem-space

                                                                                                                        + ^state + ^superoperator ) + (

                                                                                                                        ^name set-focus) + ( ^previous-focus { <> none }) + --> + ( ^operator + = ) + ( ^name change-focus ^previous-focus )} + +### +### SET-FOCUS PROBLEM SPACE: +### OPERATOR IMPLEMENTATION +### + +sp {implement*create-focus*disk-to-move*largest + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state + ^superoperator ) + ( ^name create-focus) + (

                                                                                                                        ^name ) + ( ^holds ^pursue ) + ( ^disk ^on ) + ( ^disk ^on ) + -{ ( ^pursue ) + ( ^disk ) + ( ^larger ) } + --> + ( ^disk-to-move + & ) + ( ^disk + ^from + ^to ) + ( ^done? yes no - )} + +sp {implement*change-focus*disk-to-move*largest-blocker + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state + ^superoperator ) + ( ^name change-focus ^previous-focus ) + (

                                                                                                                        ^name ) + ( ^peg + ^holds + ^disk-to-move ) + ( ^disk + ^from { <> } + ^to { <> } + ^largest-blocking-disk ) + ( ^disk ^on { <> }) + ( ^larger ) + --> + ( ^disk-to-move + &, - ) + ( ^disk + ^from + ^to ) + ( ^done? yes no - )} + +### +### SET-FOCUS PROBLEM SPACE: +### OPERATOR TERMINATION +### + +sp {terminate*create-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name create-focus) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +sp {terminate*change-focus + (state ^operator ) + (state ^problem-space

                                                                                                                        ^state ) + ( ^name change-focus) + (

                                                                                                                        ^name ) + --> + ( ^operator @ )} + +### +### TOWER-OF-HANOI PROBLEM SPACE: +### MONITOR STATE AND OPERATORS +### + +sp {tower-of-hanoi*monitor*state*holds*above*disk + (state ^superstate nil) + (state ^state ) + ( ^holds ) + ( ^disk ^above ^on ) + ( ^size ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | On(| + |,| + |),Above(| + |,| + |).|)} + +sp {tower-of-hanoi*monitor*state*holds*above*none + (state ^superstate nil) + (state ^state ) + ( ^holds ) + ( ^disk ^above none ^on ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | On(| + |,| + |),Above(| + |,-).|)} + +sp {tower-of-hanoi*monitor*state*upper-disk + (state ^superstate nil) + (state ^state ) + ( ^upper-disk ) + ( ^size ) + --> + (write (crlf) + | Upper-Disk(| + |).|)} + +sp {tower-of-hanoi*monitor*state*clear + (state ^superstate nil) + (state ^state ) + ( ^clear ) + ( ^name ) + --> + (write (crlf) + | Clear(Peg(| + |)).|)} + +sp {tower-of-hanoi*monitor*state*disk-to-move + (state ^superstate nil) + (state ^state ) + ( ^disk-to-move ) + ( ^disk ) + ( ^size ) + --> + (write (crlf) + | Focus(Disk(| + |)).|)} + +sp {tower-of-hanoi*desired-state*above*disk + (state ^desired ^superstate nil) + ( ^disk ^above ^on ) + ( ^size ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | Desired[On(| + |,| + |),Above(| + |,| + |)].|)} + +sp {tower-of-hanoi*desired-state*above*none + (state ^desired ^superstate nil) + ( ^disk ^above none ^on ) + ( ^size ) + ( ^name ) + --> + (write (crlf) + | Desired[On(| + |,| + |),Above(| + |,-)].|)} + +sp {tower-of-hanoi*monitor*operator-execution*move-disk + (state ^operator ) + (state ^state ) + ( ^name move-disk + ^disk + ^from + ^to + ^done? yes) + ( ^holds ) + ( ^disk ^on ) + ( ^size ) + ( ^name ) + ( ^name ) + --> + (write (crlf) + | Executing(Move-Disk(| + |,| + |,| + |)).|)} + +### +### DEFAULT PRODUCTION +### + +#New Default Production For The Operator-No-Change Impasse + +sp {default*operator-no-change*elaborate*goal*superoperator + :default + (state ^impasse no-change + ^attribute operator + ^superstate ) + (state ^operator ) + (state ^problem-space ^state ) + --> + ( ^superoperator )} + +### eof of tower-of-hanoi.s + diff --git a/soar-8.5.2/demos_soar7/no-gui/waterjug/waterjug.soar b/soar-8.5.2/demos_soar7/no-gui/waterjug/waterjug.soar new file mode 100644 index 0000000..b1c627f --- /dev/null +++ b/soar-8.5.2/demos_soar7/no-gui/waterjug/waterjug.soar @@ -0,0 +1,505 @@ +### +### FILE : waterjug.s (NNPSCM) +### + +### +### AUTHOR(1) : Brian.G.Milnes [ Soar 5.1.x ] +### + +### +### CREATED(1) : Nov 6, 89 +### + +### +### MODIFIED(7) : Aug 22, 96 [ Soar 7.0.3 ] Sayan Bhattacharyya +### MODIFIED(7) : Nov 28, 94 [ Soar 6.2.4 ] Aladin.Akyurek +### MODIFIED(6) : Sep 28, 94 [ Soar 6.2.4 ] Aladin.Akyurek +### MODIFIED(5) : Aug 25, 94 [ Soar 6.2.3 ] Aladin.Akyurek +### MODIFIED(4) : Aug 4, 94 [ Soar 6.2.3 ] Aladin.Akyurek +### MODIFIED(3) : Aug 3, 94 [ Soar 6.2.3 ] Aladin.Akyurek +### MODIFIED(2) : May 15, 93 [ Soar 6.0.7 ] Aladin.Akyurek +### MODIFIED(1) : Dec 9, 89 [ ? ] Bob.Doorenbos +### + +### +### May 15, 93 : Modernized both style and code# simplified +### computations needed for proposing and +### applying the pour operator# replaced +### productions for tracing state and operator +### applications/selections; changed the mechanism +### to save the last operator applied. +### Aug 3, 94 : The operator pour(3:3,5:2) could not apply, +### now it does. Simplified the proposal of the +### pour operator. Added productions to trace +### the tied operators plus some other minor changes. +### Added also a psych note with references. +### Aug 4, 94 : Converted to Soar 6.2.3/NNPSCM. +### Aug 25, 94 : Added the statement (excise default*pass-back-success) +### to remove the production in question from the default set. +### The reason for this is that the task could not run +### to completion with certain, rare sequences of +### evaluations during lookahead, because this +### production causes wrong learning. +### Sep 28, 94 : The rule default*pass-back-success in the default set +### has been modified in the version that supersedes 6.2.3# +### therefore the excise statement has been removed. +### Nov 28, 94 : Added 2 controle rules: One for the top level which +### makes Emptying a not completely full jug worst; +### The other biases Soar in the selection space +### to evaluate Pour before Empty or Fill. +### + +### +### ABSTRACT. These Soar productions implement the waterjug task. +### The task is to find the sequence of steps that fill the three gallon +### jug with one gallon of water. There are a well that has an infinite +### amount of water, a five gallon jug, and a three gallon jug. +### + +### +### A PSYCHOLOGICAL NOTE. The present set of productions could be used as a +### starting point to study models of and issues associated with (variant) +### water jug tasks. Relevant references are listed below. +### + +### +### REFERENCES. [1] Atwood, M. E., & Polson, P. G. (1976). A process +### model for water jug problems. Cognitive Psychology, 8, 191-216. +### [2] Ernst, G. W., & Newell, A. (1969). GPS: A case study in +### generality and problem solving. New York: Academic Press. +### [3] Mortensen, U. (1973). Models for some elementary +### problem solving processes. In A. Elithorn & D. Jones (Eds.), Artificial +### and human thinking. San Francisco, CA: Jossey-Bass. +### + +### +### DESCRIPTION. The task problem space has three operators: empty, +### fill, and pour. Empty empties a jug into the well. Fill fills up +### a jug from the well. Pour pours some or all of the contents +### from one jug into the other jug. Pour can only pour out the contents +### of the jug until the source is empty or the destination is full. +### State Structure: Each jug has slots to record its capacity [volume], +### the amount of water it contains [contents], and the capacity +### available [free] which is the volume minus the contents. +### (state s1 ^jug j1) +### (jug j1 ^volume v1 ^contents c1 ^free f1), +### where v1, c1, and f1 are numbers. +### + +package require Soar +source $default + + +### +### TASK NAME AND +### PROBLEM SPACE +### + +sp {top-level*elaborate*state*task*waterjug + (state ^superstate nil) + --> + ( ^name waterjug ^problem-space

                                                                                                                        ) + (

                                                                                                                        ^name waterjug ^default-state-copy yes) + (

                                                                                                                        ^two-level-attributes jug + & )} + +### +### WATERJUG: +### DESIRED STATE +### + +sp {waterjug*elaborate*state*desired-state + (state ^problem-space

                                                                                                                        ^superstate nil) + (

                                                                                                                        ^name waterjug) + --> + ( ^desired ) + ( ^jug ^contents 1) + ( ^volume 3)} + +### +### WATERJUG: +### INITIAL STATE +### + +sp {waterjug*elaborate*state*initial-state + (state ^name waterjug + ^problem-space

                                                                                                                        + ^desired ) + (

                                                                                                                        ^name waterjug) + ( ^jug ^contents 1) + ( ^volume 3) + --> + ( ^jug + &, + &) + ( ^name three-gallon + ^volume 3 + ^contents 0 + ^free 3) + ( ^name five-gallon + ^volume 5 + ^contents 0 + ^free 5)} + +### +### WATERJUG TASK OPERATORS: +### EMPTY, FILL, AND POUR +### + +sp {waterjug*propose*empty + "contents(i) > 0 --> empty(i)." + (state ^problem-space

                                                                                                                        ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^contents > 0) + --> + ( ^operator ) + ( ^name empty + ^done? no + ^jug )} + +sp {waterjug*propose*fill + "contents(i) = 0 --> fill(i)." + (state ^problem-space

                                                                                                                        ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^contents 0) + --> + ( ^operator ) + ( ^name fill + ^done? no + ^jug )} + +sp {waterjug*propose*pour + "contents(i) > 0 & free(j) > 0 --> pour(i,j)." + (state ^problem-space

                                                                                                                        ^jug { <> }) + (

                                                                                                                        ^name waterjug) + ( ^contents > 0) + ( ^free > 0) + --> + ( ^operator ) + ( ^name pour + ^done? no + ^jug + ^into )} + +### +### WATERJUG: +### OPERATOR APPLICATION +### + +sp {apply*empty + (state ^operator ) + (state ^problem-space

                                                                                                                        ^jug ) + ( ^name empty + ^done? no + ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^volume + ^contents + ^free ) + --> + ( ^contents 0 - ) + ( ^free - ) + ( ^done? yes no - )} + +sp {apply*fill + (state ^operator ) + (state ^problem-space

                                                                                                                        ^jug ) + ( ^name fill + ^done? no + ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^volume + ^contents 0 + ^free ) + --> + ( ^contents 0 - ) + ( ^free 0 - ) + ( ^done? yes no - )} + + ## Apply pour when contents of source jug i is less than + ## or equal to the capacity available of the destination jug j. + # + +sp {apply*pour*source*contents*less-or-equal + (state ^operator ) + (state ^problem-space

                                                                                                                        ^jug ) + ( ^name pour + ^done? no + ^jug + ^into ) + (

                                                                                                                        ^name waterjug) + ( ^volume + ^contents + ^free ) + ( ^volume + ^contents <= + ^free ) + --> + ( ^contents 0 - ) + ( ^free - ) + ( ^contents (+ ) - ) + ( ^free (- ) - ) + ( ^done? yes no - )} + + ## Implement pour when contents of source jug i is more + ## than the capacity available of the destination jug j. + # + +sp {apply*pour*source*contents*more + (state ^operator ) + (state ^problem-space

                                                                                                                        ^jug ) + ( ^name pour + ^done? no + ^jug + ^into ) + (

                                                                                                                        ^name waterjug) + ( ^volume + ^contents + ^free ) + ( ^volume + ^contents > + ^free ) + --> + ( ^contents (- ) - ) + ( ^free (+ ) - ) + ( ^contents - ) + ( ^free 0 - ) + ( ^done? yes no - )} + +sp {waterjug*save*operator*applied*first-time + (state ^operator ) + (state ^problem-space

                                                                                                                        -^applied) + ( ^name ) + (

                                                                                                                        ^name waterjug) + --> + ( ^applied )} + +sp {waterjug*save*operator*applied*later-times + (state ^operator ) + (state ^problem-space

                                                                                                                        ^applied <> ) + ( ^name ) + (

                                                                                                                        ^name waterjug) + --> + ( ^applied - )} + +### +### WATERJUG: +### OPERATOR TERMINATION +### + +sp {terminate*empty + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name empty ^done? yes) + (

                                                                                                                        ^name waterjug) + --> + ( ^operator @ )} + +sp {terminate*fill + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name fill ^done? yes) + (

                                                                                                                        ^name waterjug) + --> + ( ^operator @ )} + +sp {terminate*pour + (state ^operator ) + (state ^problem-space

                                                                                                                        ) + ( ^name pour ^done? yes) + (

                                                                                                                        ^name waterjug) + --> + ( ^operator @ )} + +### +### WATERJUG: +### STATE EVALUATION +### + +### +### EVALUATION: +### STATE FAILURE +### + +sp {waterjug*evaluate*state*failure*state-duplicate + # is the current context, i.e., last context, + #in which is applied. + (state ^desired + ^problem-space + ^jug + ^applied ) + -(state ^superstate ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + # is a parent context of . + (state { <> } ^problem-space + ^jug ) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + ( ^failure ) + (write (crlf) + | Current state | + | is a duplicate of the state | + |.|)} + +### +### EVALUATION: +### STATE SUCCESS/GOAL TEST +### + +sp {waterjug*evaluate*state*success + (state ^desired ) + (state ^problem-space

                                                                                                                        ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^volume 3 ^contents 1) + --> + ( ^success )} + +### +### WATERJUG: +### SEARCH CONTROL +### + + ## There are two cases of inverse operators: + ## fill(jug[i]) followed by empty(jug[i]) or + ## pour(jug[i],jug[j]) followed by pour(jug[j],jug[i]). + # + +sp {waterjug*inverse*empty*reject + "Reject empty, inverse of fill." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^applied ) + ( ^name empty ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^name fill ^jug ) + --> + ( ^operator - )} + +sp {waterjug*inverse*pour*reject + "Reject inverse operator." + (state ^operator + ) + (state ^problem-space

                                                                                                                        ^applied ) + ( ^name pour ^jug ^into ) + (

                                                                                                                        ^name waterjug) + ( ^name pour ^jug ^into ) + --> + ( ^operator - )} + +sp {waterjug*empty*jug-not-full*worst + (state ^operator + ) + (state ^jug ) + ( ^name empty ^jug ) + ( ^volume ^contents < ) + --> + ( ^operator < )} + + ## The production that follows biases Soar to + ## consider evaluating Pour before Fill or Empty. + # + +sp {waterjug*evaluate-object*pour*better + (state ^operator + ) + ( ^name evaluate-object + ^object ) + ( ^name pour) + --> + ( ^operator > )} + +### +### WATERJUG: +### MONITOR STATE AND +### OPERATORS +### + +sp {waterjug*monitor*state + (state ^problem-space

                                                                                                                        ^jug ) + (

                                                                                                                        ^name waterjug) + ( ^volume 3 ^contents ) + ( ^volume 5 ^contents ) + --> + (write (crlf) + | 3:| + | 5:| )} + +sp {waterjug*monitor*operator-application*empty + (state ^operator ) + ( ^name empty + ^done? no + ^jug ) + ( ^volume ^contents ) + --> + (write (crlf) + | EMPTY(| + |:| + |)|)} + +sp {waterjug*monitor*operator-application*fill + (state ^operator ) + ( ^name fill + ^done? no + ^jug ) + ( ^volume ^contents ) + --> + (write (crlf) + | FILL(| + |:| + |)|)} + +sp {waterjug*monitor*operator-application*pour + (state ^operator ) + ( ^name pour + ^done? no + ^jug + ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) + --> + (write (crlf) + | POUR(| + |:| + |,| + |:| + |)|)} + +sp {waterjug*monitor*tied-operator*empty + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name empty ^jug ) + ( ^volume ^contents ) + --> + (write (crlf) + | | + |: empty(| + |:| + |)|)} + +sp {waterjug*monitor*tied-operator*fill + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name fill ^jug ) + ( ^volume ^contents ) + --> + (write (crlf) + | | + |: fill(| + |:| + |)|)} + +sp {waterjug*monitor*tied-operator*pour + (state ^impasse tie + ^attribute operator + ^item ) + ( ^name pour ^jug ^into ) + ( ^volume ^contents ) + ( ^volume ^contents ) + --> + (write (crlf) + | | + |: pour(| + |:| + |,| + |:| + |)|)} + +### eof of waterjug.s (Version Type: NNPSCM) + diff --git a/soar-8.5.2/demos_soar7/readme b/soar-8.5.2/demos_soar7/readme new file mode 100644 index 0000000..00c467f --- /dev/null +++ b/soar-8.5.2/demos_soar7/readme @@ -0,0 +1,26 @@ +This directory contains various demo programs for Soar 7. More detail +about the directories are: + + C_extension - An example of adding user C code to Soar 7. + FSBox - Tcl code for defining and using a file selection dialog + gui - Soar code examples with a Tk GUI interface + no-gui - Soar code examples that are runnable via stdio + +The subdirectories contain README files that give more detail about +their demos. + +The Soar group welcomes additions to this demo directory. +Some possible ideas for other demos include the following: + + - Agents playing tic_tac_toe with other agents or users + - A Status window with agent information: #agents, stats, control buttons + - Drag and drop: e.g. drag file icons into Soar window --> initiates a load + - Use TclDP to communicate with remote Soars + - 1 GUI display controlling remote Soar agents + - Add an icon bar to gui.tcl + - Add a MIME type of text/x-soar to .mailcap to show program sharing + via email. Could use for co-operative work, bug reports, etc. + - Show multi-agent timing info, e.g., msec/dc for all agents. + - Show use with SDE, e.g. operator name brings up WWW document on operator + - A dialog that enables users to select which commands to add to the + Quick Action keys at the bottom of the top-level GUI diff --git a/soar-8.5.2/demos_soar7/soar-io-using-tcl.tcl b/soar-8.5.2/demos_soar7/soar-io-using-tcl.tcl new file mode 100644 index 0000000..b645f25 --- /dev/null +++ b/soar-8.5.2/demos_soar7/soar-io-using-tcl.tcl @@ -0,0 +1,283 @@ +# This file contains an example of defining Soar I/O functions entirely +# using Tcl. This example computes the Fibonnaci sequence. Karl Schwamb +# (schwamb@isi.edu) wrote the original version and +# Robert Wray (robert.wray@umich.edu) modified the example to include +# Soar operators and deliberate output-link clean up. +# +### This example is consistent with the way I (robert.wray@umich.edu) think +### Soar-6-syle IO was generally used. It is based on the following +### observations: +### +### +### In Soar 6: +### 1) The top state (identifiable by the ^superstate nil) and the +### ^io augmentation on the top state are created by the architecture +### at decision cycle 0. +### 2) The ^input-link augmentation on ^io is created by the IO subsystem. +### In Soar 6, this was normally a C function, in Soar 7, it will +### (probably) most often be done with tcl scripts. +### 3) The ^output-link augmentation on ^io is created by production firings +### from the Soar agent. +### 4) Once created, the input-link and output-link identifiers are not deleted +### or changed unless there is an init-soar issued. +### +### +### The total program (Soar + IO routines) computes the Fibonnaci sequence. This +### occurs through the action of the add-two-inputs Soar operator which simply +### takes the values of two numbers on its input-link, adds them, and directs +### the output routine to print the added number by issuing an output command. +### Also notice that the removal of output commands is a deliberate process in +### this example (ie, done by an operator). That is the way this is done in most +### Soar implementations. +### +### The second of the Fibonnaci computations occurs on the IO process side. The +### print-add-result command not only prints the result but also updates the +### variables fib_n and fib_n_1. These two variables are then updated on the Soar +### input-link by the input-routine, resulting in a new proposal of +### add-two-numbers. So the result +### is the addition of a new number to the Fibonnaci sequence every decision. + +### To run: +### source this file in a Soar 7 window ==> source soar-io-using-tcl.tcl +### type step by decisions to see the behavior ==> go 1 d +### Note: Since the Fibonnaci values increase quickly, you will see errors +### as soon as 40 decisions, depending on the size of integers on your machine. +### (Fib(40) = 165580141) + +package require Soar + +proc my-input-procedure {mode} { + global io_header counter past_count number_1_wme \ + number_2_wme number_1_id number_2_id fib_n fib_n_1 + + # Show inputs: prints out this message each time the input procedure is called + puts "my-input-procedure: <$mode>" + + switch $mode { + top-state-just-created { + + set counter 2 ;# Initialize counter + set past_count $counter ;# Past Count is used to decide when to update input + set fib_n 1 ;# Bootstrap the Fibonnaci sequence for this example + set fib_n_1 1 + + # Find the identifier for the root of I/O activity. On the + # top-state this identifier is the value of the "io" attribute. + # We use the command "output-strings-destination" to return the + # results of the wmes command rather than printing the information + # to the screen. + + # First, find the top state id: + + output-strings-destination -push -append-to-result + scan [print -internal {(* ^superstate nil)}] "(%d: %s" timetag top_state_id + set top_wmes [print -internal $top_state_id] + output-strings-destination -pop + + # Now find the io header id within the top state wmes. We + # cannot use "wmes" here because although the addition of the + # "io" link has just been made in the agent, the WME additions + # are buffered until all the input functions have been processed. + + set io_header_part [lindex $top_wmes \ + [expr [lsearch $top_wmes "^io"] \ + + 1]] + set io_header [string trimright $io_header_part ")"] + + # Now add the three wmes defining the input structure. We save the + # timetag of the last number wmes so we can update during normal input + # cycles. + + set link_id [add-wme-and-get-id $io_header input-link] + set number_1_id [add-wme-and-get-id $link_id number-1] + set number_2_id [add-wme-and-get-id $link_id number-2] + scan [add-wme $number_1_id value $fib_n] "%d" number_1_wme + scan [add-wme $number_2_id value $fib_n_1] "%d" number_2_wme + } + normal-input-cycle { + + # For a normal input, check to see if the counter (which is + # incremented for valid output) is different from the + # past count. If so, then remove the wme's for the + # previous values of number-1 and number-2 and then + # place the new values (fib_n and fib_n_1) on the input-link. + + if { $past_count != $counter } { + remove-wme $number_1_wme + remove-wme $number_2_wme + scan [add-wme $number_1_id value $fib_n] "%d" number_1_wme + scan [add-wme $number_2_id value $fib_n_1] "%d" number_2_wme + set past_count $counter + } + } + top-state-just-removed { + # The lack of non-commented code here implies that no special processing + # is necessary when the top state is just removed (ie, an init-soar has just + # been issued). This may not always be the case. + } + } +} + +# The following procedure adds a wme with a specified object and +# attribute. The value is an identifier which is returned after +# being generated automatically by Soar. + +proc add-wme-and-get-id {obj attr} { + scan [add-wme $obj $attr *] "%d: %s %s %s" \ + timetag object attribute id + return $id +} + +# The following output procedure examines the example output link +# structure and prints the added result data, if present. Note +# that io_header is computed in my_input_procedure before this +# procedure is called. + +proc my-output-procedure {mode outputs} { + global io_header output_link_id counter fib_n fib_n_1 + +# output_link_id is global because one need only compute it once, when +# the output-link augmentation is created. In general, this should only +# happen once between init-soar's (mode: added-output-command). +# Then, the id is used in the changed-output-command calls to do the +# processing directed by the Soar agent. + + # Show inputs + + puts "my-output-procedure: <$mode> <$outputs>" + foreach out $outputs { + puts "==> $out" + } + + switch $mode { + added-output-command { + + set output_link_id \ + [get-output-value $outputs $io_header "output-link"] + } + modified-output-command { + if [string match $output_link_id ""] {return} + set command_name \ + [get-output-value $outputs $output_link_id command] + if [string match $command_name ""] {return} + if [string match $command_name print-add-result] { + set value \ + [get-output-value $outputs $output_link_id \ + add-result] + if [string match $value ""] {return} + echo "IO: New Value Fib($counter) = $value = $fib_n + $fib_n_1" + incr counter + set fib_n_1 $fib_n + set fib_n $value + } else { + +# In this case, there is only a single command. In other systems, there +# will be a number of elseif's here (or perhaps a switch on $command_name) +# to parse the command from the Soar agent. + + echo "I don't know the command: $command_name" + } + } + removed-output-command { +# The same comment applies here as it did in the input routine. + } + } +} + +# The utility get-output-value is defined as follows: + +# Given an id or an attribute, return the value of that WME. +proc get-output-value {outputs id attr} { + foreach wme $outputs { +# the 0'th element in a wme list is the id + if { [string match $id ""] + || [string match $id [lindex $wme 0]]} { +# and the second (1'th) element is the attribute + if { [string match $attr ""] + || [string match $attr [lindex $wme 1]]} { +# and the third (2'th) element is the value + return [lindex $wme 2] + } + } + } +} + +# Now tell the agent about which I/O procedures to use + + +# You can't add the same input-function twice without first deleting it. so, to +# avoid this problem (when re-source-ing, for example) the io functions are added +# only when the added_montors variable has not yet been created. +if {[info exists added_monitors]==0} { + io -add -input my-input-procedure input-test + io -add -output my-output-procedure output-link + set added_monitors 1 +} + + + +######################### Soar Productions ####################################### + +# this production creates the output-link augmentation under ^io + +sp { top-state*elaborate*output-link + (state ^io ) + --> + (write (crlf) |Soar: Creating the output-link augmentation| (crlf) ) + ( ^output-link

                                                                                                                          )} + + +# if there are two numbers on the input-link, then propose this operator to add them. + +sp { propose*operator*add-two-numbers + (state ^io ) + ( ^input-link ) + ( ^number-1 ^number-2 ) + ( ^value ) + ( ^value ) + --> + ( ^operator +) + ( ^name add-two-numbers + ^number-1 + ^number-2 )} + +# Once the operator has been selected, this application production does the addition +# and sends the result as a command to the output function through the output-link. + +sp { add-two-numbers*apply*add-and-output + (state ^operator ^io ) + ( ^output-link
                                                                                                                            ) + ( ^name add-two-numbers + ^number-1 + ^number-2 + -^done) + --> + ( ^done *yes*) + (write (crlf) |Soar: | | + | | = | (+ ) (crlf)) + (
                                                                                                                              ^command print-add-result + ^add-result (+ )) + } + +# The test of the output-link guarantees that the +# there has been an output phase between the application/elaboration +# that placed the output command on the link and the firing of +# this one. +sp { add-two-numbers*apply*remove-output-command + (state ^operator ^io ) + ( ^name add-two-numbers) + ( ^output-link
                                                                                                                                ) + (
                                                                                                                                  ^command ^add-result ) + --> + (write (crlf) |Soar: Removing TCL command | | add-result | (crlf) ) + (
                                                                                                                                    ^command - + ^add-result -)} + +# terminate the operator when ^done. +sp { add-two-numbers*terminate + (state ^operator ) + ( ^name add-two-numbers + ^done *yes*) + --> + ( ^operator @)} + + diff --git a/soar-8.5.2/demos_soar7/user-contrib/command-tee-file.soar b/soar-8.5.2/demos_soar7/user-contrib/command-tee-file.soar new file mode 100644 index 0000000..e378d37 --- /dev/null +++ b/soar-8.5.2/demos_soar7/user-contrib/command-tee-file.soar @@ -0,0 +1,41 @@ +# +# Author: Thomas Head +# +# Description: This procedure is similar to the soar procedure +# "command-to-file", except that output is directed both to a +# file and the console. +# + +proc command-tee-file {command arg1 {arg2 ""}} { + if {[string match $arg2 "" ]} { + set file $arg1 + set mode w + } elseif {[string match $arg1 "-new"]} { + set file $arg2 + set mode w + } elseif {[string match $arg2 "-new"]} { + set file $arg1 + set mode w + } elseif {[string match $arg1 "-existing"]} { + set file $arg2 + set mode a + } elseif {[string match $arg2 "-existing"]} { + set file $arg1 + set mode a + } else { + error "command-to-file: Unrecognized arguments: $arg1 $arg2" + } + + set f [open $file $mode] + + output-strings-destination -push -append-to-result + set output [uplevel $command] + output-strings-destination -pop + echo $output + + output-strings-destination -push -file-id $f + echo $output + output-strings-destination -pop + + close $f +} diff --git a/soar-8.5.2/demos_soar7/user-contrib/soar-menu.tcl b/soar-8.5.2/demos_soar7/user-contrib/soar-menu.tcl new file mode 100644 index 0000000..8623799 --- /dev/null +++ b/soar-8.5.2/demos_soar7/user-contrib/soar-menu.tcl @@ -0,0 +1,41 @@ +########################################################################## +# File : soar-menu.tcl +# Author : Frank E. Ritter (with help from GDB) +# Date : 30-Oct-96 +# Last Update : 01-Apr-97 by Thomas Head +# Description : +# +# Takes two real arguments, window title and list of items to choose. +########################################################################## +# + +proc soar-menu {{title "Soar-menu"} {menuitems {1 2 3}} \ + {w .soarmenu} {maxw 0}} { + global soarmenuResult + set soarmenuResult "" + catch {destroy $w} + + toplevel $w + wm title $w $title + wm iconname $w $title + set maxw [string length $title] + incr maxw 2 + foreach item $menuitems { + if {[string length $item] > $maxw} { + set maxw [string length $item]}} + + frame $w.frame -borderwidth 4 + foreach item $menuitems { + eval "\ + button .soarmenu.$item -text $item -width $maxw \ + -command {destroy .soarmenu; set soarmenuResult $item}" + pack .soarmenu.$item -side top} + + if {"$soarmenuResult" == ""} { + # wait for the box to be destroyed + update idletask + grab .soarmenu + tkwait window .soarmenu} + ## echo ">>" $soarmenuResult "<<" + return $soarmenuResult} + diff --git a/soar-8.5.2/demos_soar7/user-contrib/soar-trap.soar b/soar-8.5.2/demos_soar7/user-contrib/soar-trap.soar new file mode 100644 index 0000000..fbc9664 --- /dev/null +++ b/soar-8.5.2/demos_soar7/user-contrib/soar-trap.soar @@ -0,0 +1,25 @@ +# +# Author: Thomas Head +# Last Update: Jan 6 1997, modified rename message +# +# Description: This file alleviates the annoying problem that occurs when +# typing the command soar while in soar. Because of the auto-exec feature +# of Tcl, this command normally causes a new soar image to be invoked while +# still in soar. If you dont want that to happen, source this file! +# + +proc soar args { + + echo You have attempted to invoke soar from within soar. + echo Type \"rename soar {}\" to allow soar in Soar. + echo Command ignored. + +} + +proc soartk args { + + echo You have attempted to invoke soartk from within soar. + echo Type \"rename soartk {}\" to allow soartk in Soar. + echo Command ignored. + +} diff --git a/soar-8.5.2/doc/ChangeLog.Soar6 b/soar-8.5.2/doc/ChangeLog.Soar6 new file mode 100644 index 0000000..c8e3968 --- /dev/null +++ b/soar-8.5.2/doc/ChangeLog.Soar6 @@ -0,0 +1,1009 @@ +Version 6.0.0: + -- 2 coredumps + -- infinite loop in excise-chunks. + -- provided tilde expansion in file names. + -- Fixed cntrl C on ibm rs/6000 causing unwanted exits. + -- WME supported by a justification that got removed was hanging around. + No longer. + -- Fix for a type of chunk being built that couldn't be reordered. + -- Fix to atof to allow it to compile on a NeXT. + -- Added warnings for things that look like they might be mistyped variables + or mistyped disjunctions while parsing. + +Version 6.0.1: + -- added a 'version' command to give full version information from the + interface level. + -- rearranged the makefile slightly to prevent it recompiling executables + whenever no object files had changed. + -- removed the beta test notice from the startup routine. Why this routine + duplicates the text in 'soarnews' I'll never understand. + +Version 6.0.2: + -- Made some simple changes to make the code compile on HP Apollos. I don't + know if these will work on all HP machines. Time will tell. + -- Made a few small fixes to lexer.c and to convert.c so that the program + would compile under straight ultrix cc as well as gcc. + -- Added a bugfix provided by bob that fixed a problem with a rete + optimization. This fixes two outstanding core dumps. + +Version 6.0.3: + -- Made some changes to "recmem.c" to overcome problems with chunk-free + problem spaces. This was in reference to bug report #400. + +Version 6.0.4: + -- Missed a use of alloca last time around. Removed it. + -- In interface.c a stray use of "printf" was replaced with "print" + so that output would go to soar managed streams rather than + standard output. + -- HP fixes for ISI: + -- Commented out "struct timeval;" and added include of sys/time.h + in soar.h + -- Added "const" decl to predicate function "compare_firing_counts" + formal parameters in file interface.c to match ANSI spec. + -- Added "rm = NIL" in function "remove_wme_from_alpha_mem" in + rete.c to placate the native HP compiler which thinks rm needs + to be initialized. + -- Added a cast to (int *) in the call to select in file io.c + -- In tilde.c added a switch before the include of pwd.h to + correct a struct decl problem. + -- Changed makefile so that objects and binaries for multiple machines + can be maintained in the soar directory to avoid duplicating sources. + The is achieved by selecting the appropriate make.header.* file + in the makefile. Also changed makefile for multi-agent processing. + -- Added multi-agent capability. A number of changes were made: + -- Moved globals to a header file (global_vars.h contains the extern + decls and global_vars.c the memory-allocating decls). This also + forced the move of associated typedefs and constants -- so the + tail end of soar.h looks rather messy. Soar.h really needs to + be broken into smaller pieces! If DFLAGS is empty (the default + setting in the makefile). Then the global vars are decl'ed as in + earlier versions (before 6.0.4). If MULTI_AGENT_ENABLED is set + then the globals are placed into a record (see the end of soar.h) + and the record is allocated once per agent. Note that multi-agent + processing is not fully activated unless a .init.soar.multi file + is present when soar is run. + -- To select the proper agent as well as accomodating backward + compatibility, the macro "current_agent" is introduced to define + the access path to the proper agent's global data. This change + alone affected ~1900 lines of source. + -- Added commands "create-agents", "select-agent", "agent-go", + and "schedule" for multi-agent processing. + -- Added a new file "scheduler.c" which handles the scheduling of + agents in multi-agent mode. + -- Added a file "x_interface.c" which defines the X interface to + multi-agent soar. The implementation uses only Xlib calls so + no dependence on a widget set (e.g., Motif) is present. + -- Added a new file "queue.c" and its header "queue.h". This is + a generic queue abstract data type. It is used in the + X display processing of text-io. Since text-io is occuring in + separate windows (instead of standard input as in single-agent + mode) we must queue up the text-io strings until they can be + processed by an agent. + -- Stripped all code out of main.c and moved it to init_soar.c + EXCEPT for the top-level function "main". This was done to + facilitate integration with systems which want to control + Soar (rather than having soar control external systems). By + linking with the other object files and redefining main.c + this is easily accomplished with the stripped down version of + main.c. + -- Added a directory under tests: multi/multi. This directory + uses the same format as the other test directories but is pushed + down one level so that it is not processed when "run-all-tests" + is invoked. This is because it only works if MULTI_AGENT_ENABLED + is defined and USE_X_DISPLAY is NOT. This causes all multi-agent + I/O to occur in standard I/O. To run the test, compile soar + with the above switch setting for DFLAGS in the make.body file. + Then cd to tests/multi/multi and execute "run-multi-test". + This directory also serves as an example of how to setup multi- + agent processing. + +Version 6.0.5: + -- Added an "obj" directory to hold object files. + -- Added machine-dependent directories sun4, IRIX, hp700 to the + bin and obj directories. + +Version 6.0.6: + -- Fixed bug in makefile that missed where convert.o should be + located. + -- Corrected another bug in makefile that handles machine-dependent + processing of convert. + +Version 6.0.7: + -- Added missing directories lib/{sun4,IRIX,hp700,pmax_mach} + -- Fixed a text-io bug in x_interface.c which caused commands + to be ignored after issuing an explicit go/run command. + -- Added Gary's better duplicate chunk detection algorithm. + -- Fixed a bug generated by the combination of USE_X_DISPLAY + and running soar without a .init.soar.multi file. The + command processor would not read commands from the window + in this state. + -- Fixed a bug generated by use of MULTI_AGENT_ENABLED. When + running with only the global agent, control-c was not + stopping the soar process. + -- Another HP fix. Added more switches to the including of the + file. Without these, nothing gets included. + Fixes use of X windows on HP. + -- Moved -lX11 in library loading sequence to the end to allow + redirecting of search for X11 library. This is also proper + because X11 doesn't depend on other libs. See make.body. + -- Added comment to make.header.hp to show how include and lib + files can be found on HPs. This is needed for the X11 + stuff to be compiled correctly. + -- Made a fix so that make_blank_growable_string no longer + assumes that sizeof(int) == sizeof(int *) + +Version 6.0.8: + -- Removed the redundancy between the two files global_vars.c + and global_vars.h by using the macro GLOBAL. In global_vars.h + the GLOBAL is set to "extern" so that the global vars are + defined as external in header files. In global_vars.c the + GLOBAL macro is set to the empty string so the variables can + be declared as fields in a record or as global variables with + memory allocation. + -- Reordered the include of stddef.h in soar.h to after the include + for stdio.h. The inclusion order was breaking on some Suns. + The doc in GNU's stddef.h clearly states that this should be + after any includes of sys/types.h for Suns. But there was also + problems with stdio.h. + -- When users entered an unterminated string in a command, Soar + was hanging in the X interface. Culprit routine was + "command_is_complete" which didn't check for matching double + quotes. + -- Improved use of queues by replacing queue_init with queue_create + which includes the malloc step. + -- Added "help all" in the interface which is equivalent to + list-help-topics per bug enhancement #428. + -- Double checked convert.c code against submitted bug report containing + compilation changes necessary for compiling convert.c under THINK_C + (bug #431) + -- Added 2 hqx files in the directory mac_support. These contain project + files and source code needed to compile Soar under ThinkC on a Mac. + -- Changed soar from using rand to using random thus giving better selection + for user select. + -- Fixed memory leak that was caused by impasse id's not being GC'd + correctly. + -- Renamed symbol construct to Symbol to allow for Mac compilation. + +Version 6.1.0: + -- Went to version 6.1. + -- Added new command multi-attribute. This command is used similar to the + way multi-attributes was in soar5. However, you cannot specify a list + of attribute value pairs. Only one multi-attribute may be given with + each multi-attributes line. Syntax of the command is + (multi-attribute symbol value). This removes the slowdown that Gary's + reordering change introduced. + -- Added RCS headers to all source code files. + -- Split some of the larger source code files into more manageable peices. + Decide.c -> decide.c, prefmem.c, wmem.c, tempmem.c + Production.c -> production.c, reorder.c, osupport.c + Recmem.c -> recmem.c, osupport.c, chunk.c, backtrace.c + -- Added the examples directory of example tasks as per Aladin's request. + -- Reorganized the task suite tests to use the tasks from the examples dir. + -- init-soar will now reset the arguments to the 'go' command. + -- removeing a stack-trace-format will now no longer cause a blank line + to be printed to the display. + -- Soar now maintains seperate working directory pointers for each of the + agents. + -- select-agent can now be used to return control to the global agent in + the non-X version of the multi-agent code. + -- A bug in agent-go has been fixed so that agent-go commands take effect + correctly regardless of which agent they were listed in. + +Version 6.1.1: + -- Default Rules added and modified for operator subgoaling. + -- X-Window and Multiple Agent code changes for additional compatability + between Soar and IFOR/ModSAF. + -- User Interface Enhancements. + -- New RHS Functions. + -- Simple makefile enhancements - use of -ansi switch to allow for ansii + check. + -- Addition of New "doc" and "pc_support" directories. + +Version 6.2.1: + -- removed pc_support, mac_support, convert, taql_conversion directories + -- added NNPSCM as a compile-time option + - made nnpscm and non-nnpscm directories under bin, lib, obj + - made NNPSCM versions of default rules, example pgms, and tests + -- added pscm_convert directory - an SDE (emacs) program to convert + between old PSCM and NNPSCM + -- added conditional command-line options: setvar, unsetvar, if, if-not + -- added commands: alias, unalias, pushd, popd, dirs, memories + -- added general shell escape (UNIX only) + -- fixed commands: select-agent, destroy-agent, preferences, explain, cd + -- fixed load-errors facility + -- fixed erroneous printing out of prompts + -- fixed pathname string length overflow problem + -- modified pathnames so they can be entered w/o quotation marks + -- modified the print and p commands + -- added RHS functions: ifeq, strlen, user-select + -- modified Soar to allow backtracing through prohibit preferences + -- added 2 new example problems, safe-stack and tower-of-hanoi + +Version 6.2.2: + -- updated "conversion.el" file in pscm-convert directory. + -- added "convert-prods.soar" to pscm-convert directory. + -- modified "memories" command. + -- fixed uninitialized variable "max_chunks_reached". + -- fixed uninitialized queue element. + -- fix for NNPSCM in reorderer, trace-format code, and o-support + calculations. + -- fix for "print" command - previous functionality. + -- fixed "interrupt" RHS function. + -- modified make.body to correctly process "make clobber" command. + -- modified "dispatch_command" to correctly compile under SGI IRIX. + -- added new "pf" (production finding) user command. + + See "User.Notes" and "Release.Notes" for more detailed information. + +Version 6.2.3 + -- fix for NNPSCM Default Rules. + -- fix for NNPSCM trace-format. + -- removal and addition of several gold-standard tests and examples for + NNPSCM. + +Version 6.2.5 (and 6.2.4 beta versions) + -- fix for NNPSCM and non-NNPSCM Default Rules. + -- fix argument list for control_c_handler. + -- de-linting Soar. + -- apply patches for MS-Windows Soar. + -- apply patches for MacSoar. + -- made the "print" command list attributes alphabetically. + -- fixes for o-support on nnpscm. + -- modified and added several example problems for nnpscm and non-nnpscm. + -- cleaned up a garbage pointer in decide.c which was causing core dumps. + -- fixed nnpscm o-support problem for operator preferences. + -- cleaned up output concerning "Firing", "Retracting", and "Building". + -- added print-alias command. + -- made it so that chunks get printed out in ascending order. + -- added "last" and 'stop asking' options to user-select command. + -- modified destroy_soar_agent() to handle destroying current agent. + -- added "and" feature to "if" and "if-not" commands. + -- modified "memories" command to make it more useful. + -- fixed core dump problem in load-errors facility. + -- added input-period command. + -- modified "pf" command to make it more useful. + -- added chunky-problem-spaces command. + -- made the numbering of production types consistent. + -- Soar will now compile with gcc -ansi on pmax_mach. + -- added file of aliases to the default directory. + -- each agent now has its own default print depth. + -- fixed problem where destroy_soar_agent tries to delete an empty queue. + -- added default limits of 20 to memories and firing-counts commands. + -- properly initialized cond->bt.prohibits + -- moved the DEBUG_INSTANTIATIONS compiler flag from rete.c to recmem.c + +Version 6.2.6 + -- New version indicating start of TclSoar integration. + -- subsequent interim versions will be identified by greek letters. + -- Note that the ChangeLog entries below for all greek versions through + 7.0.0.beta are reconstructions since the merge process was not developed + using the CMU version tracking. Hence, there are likely to be gaps + in the following record. + +Version 6.2.6.alpha + -- Added Tcl, Tk, and BLT to distribution. This is primarily for folks + who don't already have Tcl and Tk. BLT is used to support one of the + demo programs, but is not essential. The version of Tcl included + is a modified version of Tcl 7.3. The modifications are to support + various Soar requirements. Likewise, the distribution also includes + a modified version of Tk 3.6. BLT 1.7 included a small script + modification for the graphing tool demonstration. + -- Added a "make-soar" Bourne shell script which builds Tcl, Tk, Soar, + and BLT for the user as an added convenience. + -- Restructured directories by moving original directory down a level. + -- Added new documentation files: DEMOS, DIFFERENCES, DOCUMENTATION, + FAQ, FEATURES, ISSUES, PHILOSOPHY, PORTING, README, TODO. + -- Added use of configure scripts to automate Makefile tailoring on + installed platforms. The configure scripts are generated from the + configure.in files using GNU autoconf (version 2.0). The Makefile + is created by the configure program by using the Makefile.in + template. The configure script also generates the Makefile in the + subdirectory soar (a.k.a, 6.2.6). The previous Makefile was renamed + to non-tcl-makefile, for users who want to build the old Soar 6 user + interface. The configure process also has supporting files starting + with the name "config". + -- Files added to support the Soar/Tcl connection: command_utils.[ch], + commands.[ch], ma_commands.[ch]. These files implement new versions + of the Soar 6 user interface commands. These new versions use the + standard Tcl C API for commands. + -- Created a demos subdirectory to hold Tcl-specific demos. + -- Created a doc subdirectory to contain documentation on new Soar + commands added to the base Tcl interpreter. The sources are in + man troff format. Scripts are used to translate these to "cat" and + "html" forms. This form is more closely aligned with the Tcl + documentation and is intended to replace the on-line Soar help in + Soar 6. + -- Created a library subdirectory to contain Tcl initialization code + for a Soar agent. + -- Added a script "mosaic-bg" used to run a mosaic process under + the remote control of Tcl. This is used in the gui.tcl example + in the demos directory to show the new documentation form. + -- Added tclAppInit.c and tkAppInit.c which are used to initialize (in + C code) the Tcl+Soar executable and the Tcl+Tk+Soar executable. + -- Various modifications to the original Soar source code to interface + Tcl. The changes are marked with "#ifdef USE_TCL" and "#ifdef + USE_TK": + - callback.[ch]: Added a callback system intended to replace the + use of hook functions. This allows dynamic alteration of + functionality during various events in Soar. + - global_vars.h: Added Tcl-related variables "interpreter", to + indicate the interpreter associated with an agent; "window", to + indicate the Tk window associated with an agent; and + "tcl_output_buffer", used to manage I/O with the Soar 6 parser. + - init_soar.c: Added an include for the Tcl-related "commands.h" + header. Modified the QUIESCENCE_PHASE processing in + do_one_top_level_phase to unconditionally print a carriage return + for Tcl. Added a default callback function for printing on + stdout. Added agent initialization which creates a Tcl interpreter + and Tk main window for each agent. Added code to delete Tcl + interpreter when agent destroyed. Added function Soar_Init to + be used to initialize Soar from Tcl. + - interface.c: Added a header include for Tcl support + (command_utils.h). Commented out several utility functions that + are now found in command_utils.c. Since commands in interface.c + are replaced by code in commands.c, the supporting utility + functions need to be moved out of interface.c as well. Interface.c + defines the Soar 6 user interface and will be removed, eventually. + - lexer.c: Added code to examine the "alternate_input_string" buffer + for input to the Soar parser under Tcl. The + "alternate_input_suffix" is examined after the buffer is exhausted + for trailing characters. This makes is a little more efficient + since a new string doesn't have to be formed at the Tcl level. + Changed default token classification to QUOTED_STRING_LEXEME for + Tcl, to avoid quirky quoting issues with Tcl to Soar input. + Removed prompt printing nonsense for Tcl -- all prompts are printed + from Tcl. + - main.c: Eliminated main function under Tcl since Tcl has its own + main. + - print.c: Added Tcl header. Redirected prints to new function + Tcl_LogAndPrint which uses the callback system instead of printing + to stdout. Added a function to print WMEs differently for Tcl + (print_wme_for_tcl). + - rhsfun.c: Added Tcl RHS function call. Allows Soar productions to + run commands in the agent's Tcl interpreter. + - scheduler.c: Added commands.h header. Added call to switch agent + context before running an agent -- this ensures that all critical + global variables are updated so that an agent is run as the + "current" agent. + - soar.h: Added decls of Tcl related functions: + print_wme_for_tcl, print_all_trace_formats_tcl, Soar_Init. + Added Tcl and Tk header files. + - trace.c: Changed output of print_tracing_rule to eliminate parens + since Tcl doesn't use them. Added alternative function + print_tracing_rule_tcl that uses Tcl syntax. Added alternative + function print_all_trace_formats_tcl which uses the function + print_tracing_rule_tcl to print the formats. + +Version 6.2.6.beta + -- Added "else : ;" to for loop in dirs target in + tcl/ts/soar/Makefile.in to work around problem with Bourne shell at CMU. + -- Replaced use of "-x" with "-f" in tcl/make-soar (some sites don't + have this option in the "test" command). + -- Removed config.cache (a site dependent file) from tcl/ts in + distribution. + +Version 6.2.6.gamma + -- In tcl/ts/command_utils.h, changed decl. of count_memory_use_for_node + to: extern unsigned long count_rete_tokens_for_production + (production *prod); + -- In tcl/ts/command_utils.c, Changed print_memories() stuff to call + count_rete_tokens_for_production() ; Deleted + count_memory_use_for_node() and associated routines; Commented out + rete-stats command stuff (for now, need to go back and fix this later + -- BUGBUG) + -- In tcl/ts/commands.c, Changed call to count_memory_use_for_node() + into call to count_rete_tokens_for_production(). + -- Chunk.c: Minor changes for revised rhs_value and action formats. + -- Decide.c: Changed all occurrences of "common.decider_wme" to + "common.a.decider_wme". + -- Glob_vars.h: + - Removed ncc_subconditions_bottom_dense_nvn + - Removed ncc_subconditions_bottom_sparse_nvn + - Removed ncc_subconditions_bottom_node + - Removed neg_token_pool + - Removed dummy_matches_node_tokens + - Changed type of ms_assertions, ms_retractions, left_ht, right_ht, + dummy_top_node, dummy_matches_node, dummy_matches_token + - Added decl. of dummy_top_token + - Added decl's of max_rhs_unbound_variables, rhs_variable_bindings + - Removed production_addition_result, production_being_added_now, + refracted_inst_for_production_being_added_now, + warn_on_duplicate_production + - Added rete_node_counts_if_no_sharing[] array + - BUGBUG what to do about token_additions, token_deletions? + -- Init_soar.c: Removed initialization of dummy_matches_node_tokens. + -- Interface.c: + - Changed calling sequence for p_node_to_conditions_and_nots(). + - Made "memories" command use count_rete_tokens_for_production(). + - Fixed "pf" command stuff to use new RHS format stuff. + - Added "fastload-productions" and "fastsave-productions" commands. + -- Mem.c: Changed it so memory blocks now have to start on a 4-byte + boundary (i.e., low-order *two* bits have to be zero) instead of a + 2-byte boundary. This is needed because we now use the low-order + two bits of rhs_value's as type specifier bits. + - #defined DEFAULT_BLOCK_SIZE constant to replace hard-coded number. + - BUGBUG why does it keep using sizeof(int *) rather than sizeof(int) + on growable strings? + -- Osupport.c: + - Minor changes for revised rhs_value and action formats. + - BUGBUG extern decl's of calculate_compile_time_o_support(). + -- Parser.c: Removed first_letter_from_test() -- it's now in + production.c because it's now used not only by the parser but also by + the Rete (for gensymming chunk variable names). + - Minor changes for revised rhs_value and action formats. + -- Print.c: Minor changes for revised rhs_value and action formats. + Changed print_production() so it gets the RHS by calling + p_node_to_conditions_and_nots() -- need this to re-gensym chunk variable + names. + -- Production.c: + - Added first_letter_of_xxx() routines. + - Minor changes for revised rhs_value and action formats. + - Changed make_production() -- the Rete now fills in + p->rhs_unbound_variables. + -- Recmem.c: Minor changes for revised rhs_value and action formats. + - Changes to firer for revised rhs unbound variable handling. + -- Reorder.c: Minor changes for revised rhs_value and action formats. + -- Rete.c: Changed whole file. + - Adds left unlinking. + - Adds dynamic split/merge of beta memories with single child join nodes + (previously always merged, even when more than one child -- caused + more tokens to be created) + - Adds tree-based removal (previously used rematch-based removal) + - Adds "fastload-productions" and "fastsave-productions" commands. + - Discards names of variables in chunks (re-gensyms them when you + print the chunk). This can be disabled (i.e., make Soar save the + variable names) by setting discard_chunk_varnames = FALSE. + - Added count_rete_tokens_for_production(). + -- Soar.h: + - Removed a bunch of Rete-related declarations + - Removed detailed declaration of node_varnames structure + - Removed detailed declaration of ms_change structure + - Added common field to all symbols (unioned with decider_wme, so it + doesn't take up any extra space) for use in fastsave/load + - Added rete_binding_locations field to variables + - Added fields to wmes for tree-based removal in the Rete + - Revised declarations for rhs_values and actions + - Added declarations for first_letter_from_xxx() routines + - Revised decl. of p_node_to_conditions_and_nots(), added decl. of + get_symbol_from_rete_loc(). + - Added decl. of count_rete_tokens_for_production(). + - Added decl. of fast_remove_from_dll() -- a slightly faster version + of the remove_from_dll() macro. + - Added some new Rete-related declarations + -- Symtab.c: Added initialization of rete_binding_locations field on + new variables. + -- Added rete-net command to access Bob's binary rete save/load feature. + Added a matching man page. Added command to demos/gui.tcl menu bar. + -- changes for ports to DEC pmax Mach and Apple Quadra MachTen platforms + -- Added check in config.guess to consider MachTen OS on Macs. + -- Added fix to config.sub for MachTen OS on Macs. + -- Added check for "fmod" to Tcl configure enabling Tcl to build under + CMU Mach OS. Other Mach OS changes needed: use gcc and gmake since + native versions busted. + -- Removed used ot "mkdir -p" since switch not universally recognized. + -- Added "#ifdef" checks to tilde.c for dirent.h. + -- Cleaned up and added more documentation to demos/gui.tcl file. + -- Changed demos/graph_tool.tcl to use chunk count rather than pos nodes + in rete since rete stats has changed. + -- Based on rete changes, revised code which extracts individual stats + and updated man page correspondingly. + -- Fix to wmem command where successive invocations led to parse error. + (Problem with buffer handling in wmem command.) + -- Fixed GUI prompting so always occurs on a newline + -- Fixed several GUI logging bugs + -- Fixed problem with typed "select-agent" command failing in GUI + -- Fixed bug in create-agents command that would switch the "current" + interpreter to the newly created one. + -- Intercept "help" commands entered in GUI text window so output + corresponds to that obtained from menus. + -- Renamed help files to match commands + -- GUI intercepts typed in "help" commands and displays like the menu action + -- Help proc checks for several pagers if env var PAGER not set + -- Added list-help-topics command and help -all + -- All 4 modules now use gcc and gmake if available (so take these out + of your path for the SGI build there at UMich) + -- All 4 modules cache results of configure + -- Merged ma_commands.c file into commands.c file + +Version 6.2.6.delta + -- Reorder initializations in init_soar.c to a more rational order. + -- Added before/after schedule-cycle events to support the running + of simulators. + -- Fixed loading of init files so that a "cd" is performed first to + properly handle relative path names. + -- Reorganizing code so Tcl, Tk, and BLT are as originally distributed + from the Tcl Archive site. TclSoar is now a fairly standard Tcl + extension and all code changes are contained in the TclSoar + subdirectory. + -- Moved soargraph demo file from tcl/blt-1.7/demos to tcl/ts/demos + restoring BLT-1.7 to its original distributed state. + -- Moved changed files in tk3.6 (tkMain.c tkText.c tk.h) to tcl/ts + restoring Tk 3.6 to its original distributed state. + -- Moved callback system out of Tcl 7.3 into tcl/ts/kernel restoring + Tcl 7.3 to its original distributed state. + -- Fixed seg fault upon exit -- needed to destroy top level window + before destroying Tcl interpreter. + -- Corrected "r" and "run" so that they run "forever" without any arguments + -- Fixed bug so that Soar can be compiled without Tcl (uses Soar 6 user + interface). + -- Cleaned up order of functions in file commands.c + -- Added "pf" command. + -- Fixed bug in printing conjunctive negations -- the -{} chars were + being dropped. Change to function Tk_print_to_text_widget now makes + text widget string insertions faster by avoided nested calls to Tcl. + -- Enhanced build so that Soar can be built without Tk. + +Version 6.2.6.epsilon + -- fixes for build on HP. Includes addtion of _INCLUDE_POSIX_SOURCE + flag during compilations. + -- fix for prompt error under Tk (for Doug Pearson) + -- creation of libraries libtclsoar.a and libtksoar.a for linking + by user programs + -- Split agent related code out of init_soar.c into agent.c in soar/src + -- Renamed files in tcl/ts to conform to Tcl conventions + -- Removed all calls from tcl/ts/soar/src into tcl/ts to avoid + unresolved symbols during library links. Previous functions in + interface.c that were calling into tcl/ts were prefixed with "old_" + and no longer excluded by #ifdef USE_TCL switches. + -- Added files soarAgent.c and soarScheduler.c in tcl/ts to override + definitions in libsoar.a. + -- Added numerous fixes and cleanups from Bob (see + tcl/ts/soar/doc/bobschangelog2) + -- Rete fastsave file format changed -- incompatible with earlier + versions + -- Backtrace.c: Removed some unnecessary extern declarations. + -- Chunk.c: Minor changes for gcc -Wall, removed some unnecessary + extern declarations. + -- Explain.c: Minor changes for gcc -Wall + -- Glob_vars.h: + - Added 4 decl's: num_[null_]{left,right}_activations + - Added decl. of token_additions_without_sharing + - Removed decl. of token_deletions + - Added comments, rearranged stuff to neaten it up + - Removed decl. of placeholder_counter[] -- moved it to parser.c. + - Removed decl. of found_undefined -- moved it to trace.c. + - Removed decl. of format -- moved it to trace.c. + - Removed decl. of format_string_error_message -- moved it to trace.c. + - Removed decl. of collected_nots -- moved it to rete.c. + - Removed index_num. + - Removed dummy_matches_node. + -- Init_soar.c: + - Added initializations for token & activation count variables. + - Moved initialization of match_cpu_time inside #ifdef + DETAILED_TIMING_STATS. + - Minor changes for gcc -Wall + - Removed useless comments for global variables no longer there + - Removed initial assignment to index_num. + -- Interface.c: + - In print_memories(), removed "curr_prod" variable from print_memories(). + - Minor changes for gcc -Wall + - Commented out old version of "$" command + -- Io.c: Moved typedef's of some I/O structures here from soar.h + -- Osupport.c: Removed some unnecessary extern declarations. + -- Parser.c: Minor changes for making placeholder_counter[] not a + per-agent thing. + -- Prefmem.c: Eliminated unintentional use of trigraph in comment. + -- Production.c: Minor changes for gcc -Wall + -- Recmem.c: + - Eliminated unintentional use of trigraph in comment. + - Minor changes for gcc -Wall + - Removed some unnecessary extern declarations. + -- Rete.c: + - Added more comments, etc. + - Added decl. of MS_trace (moved from soar.h) + - Changed gensymmed variables to look like instead of . + - Renamed current_agent(collected_nots) as nots_found_in_production. + - Added dummy_matches_node as a not-per-agent global variable. + - Revised format of fastsave/load files -- now on version 3. + -- Rhsfun.c: + - Added "#ifdef USE_TCL" around installation of "tcl" rhs function. + - Added alternate "#ifdef __ultrix" clause to avoid warning message on + call to localtime(). + -- Rhsfun_math.c: Removed unused variable "arg_value" in + abs_rhs_function_code(). + -- Scheduler.c: Fixed up execute_go_selection() call for non-Tcl version. + -- Soar.h: + - Removed decl. of MS_trace (moved to rete.c) + - Added note about rhs_value's + - Added comments + - Added many declarations for stuff that was being used in one file + but defined in another, hence needed an extern declaration. + - Moved typedef's of some I/O structures to io.c + -- Trace.c: + - Minor changes for gcc -Wall + - Minor changes for making found_undefined not a per-agent thing. + - Minor changes for making format not a per-agent thing. + - Minor changes for making format_string_error_message not a per-agent + thing. + -- make.body: + - Added stuff to compile and link callback.c + - Added callback.h to list of header files + +Version 6.2.6.zeta + -- removed text I/O stuff + -- removed non-NNPSCM option + -- fixed several memory leaks + -- modified RHS grammar so it allows extra commas + -- modified RHS grammar so attributes can be numbers or function calls + -- fixed Gary's "multi-attribue" (with very large number) bug + -- Removed files queue.c, queue.h; updated Makefile.in, make.body accordingly + -- soarAgent.c: + - Removed text I/O stuff. + - Removed NNPSCM #ifdef stuff. + -- soarCommandUtils.c: Removed NNPSCM #ifdef stuff. + -- soarCommands.c: Removed NNPSCM #ifdef stuff. + -- Agent.c: + - Removed text I/O stuff. + - Removed NNPSCM #ifdef stuff. + -- Chunk.c: Removed NNPSCM #ifdef stuff. + -- Decide.c: Removed NNPSCM #ifdef stuff. + -- Glob_vars.h: + - Removed text I/O stuff. + - Removed NNPSCM #ifdef stuff. + -- Init_soar.c: + - Removed NNPSCM #ifdef stuff. + - Removed "NNPSCM" from startup banner printout (there's no other + version now). + - Added "TCL" to startup banner printout (in Tcl version only). + -- Interface.c: + - Removed NNPSCM #ifdef stuff. + - Minor changes in old_actions_are_equal_with_bindings() to allow RHS + attributes to be general rhs_value's. + -- Io.c: + - Reset io_header and io_header_link to NIL when top state is removed. + - Removed text I/O stuff. + - Removed NNPSCM #ifdef stuff. + -- Osupport.c: + - Removed NNPSCM #ifdef stuff. + - Minor changes in various places to allow RHS attributes to be general + rhs_value's. + -- Parser.c: + - Added call to deallocate_test() in parse_head_of_conds_for_one_id(), to + fix memory leak (variables didn't get deallocated). + - Changed 'g' (for goal) to 's' (for state). + - Removed NNPSCM #ifdef stuff. + - Modified RHS grammar so attributes can be arbitrary rhs_value's, + not just variables or symbolic constants. + - Modified RHS grammar to allow extra commas. + -- Print.c: + - Removed NNPSCM #ifdef stuff. + - Minor change to print_action_list() to allow RHS attributes to be + general rhs_value's. + -- Production.c: + - In deallocate_production(), changed free_list(rhs_unbound_vars) to + deallocate_symbol_list_removing_references() to fix memory leak. + - Changed 'g' (for goal) to 's' (for state). + - Minor change to add_all_variables_in_action() to allow RHS attributes to + be general rhs_value's. + -- Recmem.c: Changed 'g' (for goal) to 's' (for state). + -- Reorder.c: + - Fixed MAX_COST and reorder_simplified_conditions() to avoid core dumps + with very large multi-attribute values. This fixes Gary Pelton's bug + report of 3/15/95. + - Fixed memory leak in remove_isa_state_tests_for_non_roots(). + - Removed NNPSCM #ifdef stuff. + -- Rete.c: Changed 'g' (for goal) to 's' (for state). + -- Soar.h: + - Removed text I/O stuff. + - Removed NNPSCM #ifdef stuff. + -- Symtab.c: Removed NNPSCM #ifdef stuff. + -- Tempmem.c: Removed NNPSCM #ifdef stuff. + -- Trace.c: Removed NNPSCM #ifdef stuff. + -- x_interface.c: Removed text I/O stuff. + -- Fixed bug in load command where previous "cd"s did not affect the + Soar kernel's directory stack. + -- Fixed bug in Makefile.in that was leaving off TclSoar scheduler + in soarScheduler.c + -- Added a new function Soar_AgentInit as a hook function so that + users can copy tkAppInit.c (or tclAppInit.c) and add their own + C extensions. A demo is in demos/C_extension. + -- Finished C extension example in tcl/ts/demos/C_extension + -- Added documention to demos directories (README files) and + reorganized directory to make more modular. Removed non-nnpscm + stuff in anticipation of Bob's changes. + -- Fixed bug in "preferences" command noticed by John Laird. + -- Fixed a bug in soar callback initialization (after-init-agent) was + called before soar_init_callbacks). + -- Reorganized initialization. Sequence is now 1) init internal + Soar structures 2) source tclsoar.tcl 3) call Soar_AgentInit + 4) eval "init-agent" 5) call after-init-agent callback + -- Added check to Graph Tool Demo to make sure that BLT exists. This + fix prevents the GUI from hanging when BLT can't be found. + -- Fixed a scheduler problem for Mike v. and John related to tag-soar + running global agent callbacks > once when stopping. + -- Fixed bug in help -- env. var PAGER was being ignored. + -- Added info. about default setting to man page for user-select. + -- Fixed a bug in pf command -- system would hang if pattern not + escaped with {} or "". + -- Merged Tcl exit and Soar quit commands. + -- Defined "?" to print message about Soar-only commands. + -- Added numeric arguments back for wme details in matches, preferences, + and ms commands. + -- Added a "help-syntax" command to list syntax from man pages. + -- Corrected alias facility so that only defined aliases can be + unaliased. Also, added switch to "print-alias" to list all aliases. + -- Added warning to alias definition when replacing an exising command. + -- Added TCL and/or TK to version string for SDE. + -- Changed tcl/ts/soar/Makefile.in to compile objects if makefile changes + -- Updated documentation on sp command for NNPSCM + -- Addition of SHELL macro to tcl/ts/Makefile.in to force Bourne shell + usage in make on SGI. + -- queue.{c,h} files were only needed for text-io so they have been deleted. + +Version 6.2.6.eta + -- Updated trace format stuff for NNPSCM --- *** User-visible changes: *** + - Can no longer specify special trace formats for goals & problem spaces + - %cg (print current goal) and %cp (print current problem space) no + longer supported as trace format string escapes + -- Fix for Gary's core dump bug + -- Added Doug Pearson's o-support calculation scheme (3-way option) + -- Updated "go" command for NNPSCM --- *** User-visible changes: *** + - Can no longer specifiy "g" and "ps" options on "go" command. + -- Reorderer now checks for RHS function calls with unbound variables as + arguments -- will not accept these. + -- soarAgent.c: + - Changed FOR_GOALS_TF to FOR_STATES_TF. + - Added initialization of current_agent(o_support_calculation_type). + -- soarCommands.c: + - Minor changes for updated (NNPSCM) trace format stuff. + - Changed comments for "go" command -- "g" and "ps" args no longer allowed. + - Added "o-support-mode" command. + -- soarCommandUtils.c: + - In execute_go_selection(), removed cases for GO_GOAL and + GO_PROBLEM_SPACE. + - In parse_go_command(), removed cases for GO_GOAL and GO_PROBLEM_SPACE. + - Minor changes to actions_are_equal_with_bindings() to allow RHS + attr's to be arbitrary rhs_value's. (I fixed this in interface.c + earlier but forgot to fix it here.) + -- go.n: Updated for NNPSCM "go" command stuff. + -- trace-format.n: Updated for NNPSCM trace format stuff. + -- agent.c: + - Changed FOR_GOALS_TF to FOR_STATES_TF. + - Added initialization of current_agent(o_support_calculation_type). + -- Chunk.c: Minor changes to chunk_instantiation() for Gary's core dump bug. + -- Decide.c: Changed FOR_GOALS_TF to FOR_STATES_TF. + -- Explain.c: Minor changes to explain_add_temp_to_chunk_list() for + Gary's core dump bug. + -- Glob_vars.h: + - Removed context variables for goals & problem spaces (useless with + NNPSCM) + - Changed trace format arrays to have 3 entries instead of 5 (gets rid of + special entries for goals and problem spaces). + - Added decl. of o_support_calculation_type. + -- Init_soar.c: Updated comments for run_for_n_selections_of_slot() for + NNPSCM. + -- Interface.c: + - Changed FOR_GOALS_TF to FOR_STATES_TF. + - Updated help screens for (1) trace formats and (2) trace format escapes. + - Updated "go" command stuff to no longer accept "go for n selections + of goals" and "go for n selections of problem spaces". + - Added "o-support-mode" command. + -- Osupport.c: Added routine to do Doug Pearson's scheme for o-support + calculations. + -- Recmem.c: Added code to fill_in_new_instantiation_stuff() to do + (optionally) Doug Pearson's scheme for o-support calculations. 3 + modes, controlled by value of global variable o_support_calculation_type + (0=normal, 1=warn on differences, 2=Doug's). + -- Reorder.c: In legal_to_execute_action(), added checks to make sure + RHS function calls have all their arguments bound (i.e., no unbound + variables as args). + -- Soar.h: + - Change to parameters for explain_add_temp_to_chunk_list(), for + Gary's core dump bug. + - Minor changes for updated (NNPSCM) trace format stuff. + - Updated comments for run_for_n_selections_of_slot() for NNPSCM. + - Removed GO_GOAL and GO_PROBLEM_SPACE from "enum go_type_enum". + - Removed isa_state and isa_problem_space fields from identifiers. + -- Symtab.c: + - Removed context variables for goals & problem spaces (useless with + NNPSCM) + - Removed initialization of isa_state and isa_problem_space on + identifiers. + -- Trace.c: Revisions for updated (NNPSCM) trace format stuff. + -- Wmem.c: Removed update of isa_state and isa_problem_space on identifiers. + -- Added code to catch errors from all Tcl_Eval calls. + -- Added a procedure to demos/gui.tcl to beautify cat pages by + converting term control sequences to Tk text tags. + -- Added cast functions "int" and "float" to Soar kernel. + -- Changed RHS function "tcl" to return a value so it can be used + in RHS functional compositions. + -- Some man page corrections based on Clare's email messages + -- Changed all man pages to use SEE ALSO instead of KEYWORDS. + -- "soar" command renamed "soar6". + -- Per Karen Coulter's request, changed "make-soar" to write a + file summarizing build settings. + -- Removed MULTI_AGENT_ENABLED switch. Removed multi_agent_mode + variable. Removed processing of ".init.soar.multi" file. + Folded global var decls back in soar.h -- and removed global_vars.c + and global_vars.h. + -- Added dependency on soar.h into tcl/ts/Makefile.in + -- Added SHELL env. var setting in tcl/ts/Makefile.in for SGI + +Version 6.2.6.theta + -- Fixed decider bug where it preferred already-in-WM values among + indifferent items. + -- Added experimental "attribute-preferences-mode" command. This is a + test of John's proposal for disallowing most attribute preferences. + There are three modes available: + 0: Just like Soar 6 now. + 1: Just like Soar 6 now, except prints a warning whenever a + preference other than + or - is created for a non-context slot. + 2: Whenever a preference other than + or - is created for a + non-context slot, it prints an error message and ignores (discards) + that preference. For non-context slots, the set of values + installed in working memory is always equal to the set of + acceptable values minus the set of rejected values. + -- soarAgent.c: Added initialization of + current_agent(attribute_preferences_mode). + -- soarCommands.c: Added attribute-preferences-mode command. + -- agent.c: Added initialization of + current_agent(attribute_preferences_mode). + -- decide.c: + - In run_preference_semantics(), removed code to prefer already-installed + value among mutually indifferent candidates. + - In run_preference_semantics(), added handling for when + attribute_preferences_mode=2. + -- interface.c: Added attribute-preferences-mode command. + -- recmem.c: In execute_action(), added handling of + attribute_preferences_modes 1 and 2. + -- soar.h: Added decl. of attribute_preferences_mode as a per-agent + variable. + -- Removed global agent from Soar kernel and Tcl interface + -- Added several command line options. Available options are now: + agent, path, display, file, geometry, help, noTk, sync, tclsh, + verbose, wish + -- New man page describing command line options and Soar startup + (listed first in Soar HTML directory of man pages -- see + http://www.isi.edu/soar/tclsoar/soar_man.html) + -- Made "soar" the default startup agent + -- Removed Soar 6 gateway (and hence, the "load" command) since + these depended on a global Soar agent. + -- Converted default.soar file to TclSoar syntax. It is contained + in .../tcl/ts/library/default.soar + -- Converted all examples to TclSoar syntax and added them to the + "demos" subdirectory. There are now 4 GUI demos and 8 non-GUI demos. + -- Tk's "send" command has been extended to work with local non-Tk + interpreters. Bug fix to send so remote sends to local agents + works properly. "send" now subsumes the old "send-agent" command + which has been removed. + -- Changed agent init procedure to look for files with names + .soar instead of subdirectories. + -- Added ability to create agent, wish, or tclsh interpreter + shells from command line or via create-interp command + -- Replaced {create,list,select,destroy}-agent with + {create,list,select,destroy}-interp commands and added the original + commands as new aliases. + -- Added Clare's help message to help command + -- tksoar binary now works without X. This can be controlled + via a command line switch (-noTk) or the absence of a DISPLAY + environment variable setting. + -- Replaced "help-syntax" with "help -usage". + -- Replaced Tcl global var "agentname" with the new globals + "interp_name" and "interp_type". + -- Added these commands to normal tclsh/wish interpreters: + create-interp, list-interps, select-interp, schedule-interp, + destroy-interp, send (generalized) + -- Added schedule-interp command to process interpreter(s) in the + Soar scheduling process + -- Tclsh and wish interpreters initialized using the "path" setting + and .soar files. + -- "agentpath" command-line switch changed to simply "path" since it + applies to all types of interpreters. + -- TCLSOAR_OPTIONS env. var no longer processed. Command line option + tailoring more flexibly handled by Unix shell aliases. + -- non-Tcl version (using the Soar 6 UI) now has a default startup + agent called "soar" with a simpler prompt. + -- Added ability to compile Soar when Tcl and Tk are pre-installed + elsewhere. To support this, renamed .../tcl/make-soar to + .../tcl/make-all and added .../tcl/ts/make-soar. + -- Streamlined user extension hook to a single file (soarAppInit.c) + and a single function (Soar_InterpInit). + -- Added files tclBasic.c, tkConfig.h, soarArgv.c, soarInterp.c, soarMain.c + -- Improved modularity by removing files tcl.h, tk.h, tclMain.c, tkMain.c + -- Removed hook functions in Soar kernel -- code now uses callback system + -- Added man2thml converter to tcl/ts/doc subdir so users can do their + own HTML conversions + -- Fixed numerous gcc -Wall warnings + +Version 7.0.0.beta + -- Rewrote test suite to work with Tcl and under Bourne shell + -- Fixed problem where error not reported for "d hi". + -- Fixed seg fault when DISPLAY set to a bogus value. + -- Fixed seg fault when starting two tksoar's. Added code to notice + when interp name changed due to registration with X server. + -- Fixed a bug where -noTk and empty DISPLAY still gave a warning + -- Fixed a typo: watch command arg firings-wme was missing last "s". + -- Fixed error in soarCommands.c for watch command. In test for on/off + base should be TRACE_FIRINGS_OF_USER_PRODS_SYSPARAM. + -- Upgraded Soar to Tcl 7.4 and Tk 4.0. + -- Did a major overhaul on the configure.in script and the Makefile.in + file to more closely match Tcl's approach. This should make the + software more robust and able to be installed in system areas. + -- Took new versions of tclBasic.c, tkText.c, and tkSend.c from the new + Tcl/Tk distributions and added Soar mods. + -- Updated Tcl_SendCmd.c in soarInterp.c to match send process in + tkSend.c + -- Updated demos/gui.tcl file (and other Tk demo files) with Tk 4.0 + changes. This included changing "geometry" switch to "width" and + "height" switches; adding -tearoff option to agent list menu; adding + "postcommand" switch for dynamically generated menus; updating + bindings to account for new hierarchical composition approach; + removing explicit references to Bisque color scheme. + -- soarInterp.c: Removed call to "destroy ." when removing an + interpreter. Bug apparently fixed in Tk 4.0. + -- Makefile.in: Renamed executables: tclsoar -> soar, tksoar -> soartk. + Ditto for library names. + -- Dropped directory link "soar", and renamed "6.2.6" to "kernel". + -- Renamed kernel/src/soar.h to kernel/src/soarkernel.h and updated all + files including this header file. + -- Renamed tclsoar.h to soar.h + -- Added $default variable to enable "source $default" to read in + default rules (Clare's #32) + -- Made ? synonym of "help" (Clare's #4b) + -- Changed pager order in "help" command from "less, more, page" to + "more, page, less" (Clare's #5) + -- Changed "default-print-depth" to "default-wme-depth" (Clare #9) + -- Changed "quiescence phase" to "decision phase" + -- Changed reference in rhsfun_math.c from "strtod" to "my_strtod" + to increase portability and consistency. + -- Fixed "cd" when issued with no arguments + -- Changed "ptrace" to "pwatch" (Clare #34) + -- Changed "no-o-support" and "NO_O_SUPPORT" and "DECLARED_NO_O_SUPPORT" + to "i-support", "I_SUPPORT", and "DECLARED_I_SUPPORT" per Clare #14. + -- Changed "trace-format" to "format-watch" (Clare #26) + -- In tcl/ts/kernel: Renamed README to INSTALL and added a new README + file. + -- Subdivided demos directory into gui and no-gui portions. Clare #20. + -- Renamed "print-all-symbols" to "internal-symbols" (Clare #23) + -- Renamed "print-destination" to "output-strings-destination" (Clare #24) + -- Added function "reset_production_firing_counts" to function + "reset_statistics" in file tcl/ts/kernel/src/init_soar.c. Also + update corresponding man page for command init-soar. (Clare #12) + -- Changed arguments to "command-to-file" Tcl proc to be "-new" and + "-existing" (was "w" and "a"). Clare #38. + -- Merged the "pgs" command into "print" as the option "-stack". + Updated the "print" man page and eliminated the "pgs" man page. + Clare #30. + -- Enhanced "help" to consider Tcl, Tk, and Unix man pages. "-all" + option now includes all Tcl, Tk, and Soar commands. All help is + now generated via nroff (was using cat pages) and man (for Unix + pages). (Clare #4) + -- Merged all alias man pages into one called "aliases". + -- Enhanced "help" to catch aliases defined on "aliases" man page + so that cummary page can be used rather than individual man + pages on each alias. + -- Moved Soar 6 related aliases to tcl/ts/library/alias-soar6.tcl + (was in tcl/ts/library/tclsoar.tcl) + -- Renamed "tclsoar.tcl" file to "soar.tcl" + -- Changed GUI "step" button to "step 1 dc" to clarify step size + -- Changed GUI "Save/Load Rete" to "Save/Load Production Memory" + to make more generic for naive users and to accomodate possible + production network change (e.g., to TREAT vice RETE) + -- Changed "log" command to use "-new" and "-existing" rather than + "a" and "w" access modes. Removed use of "-open". Made switch + order of "-new" and "-existing" more flexible to match related + command "command-to-file". (Clare #37) + -- Moved these agent-only commands to soarInterp.c so they could be + used by all interps: soarnews, version. + -- Renamed "init-interp" to "init-interpreter" + -- Renamed "eval-in-interps" (or send-to-interps) to "send-to-interpreters" + -- Merged "matches" and "ms" commands. Updated matches man page + and removed "ms" man page. (Clare #8). + -- Removed all "#if 0" code in soarCommands.c + -- Completed changes to explain command for Soar 7. Removed on/off + switch, removed sole -trace switch, removed side-effect of + remembering last chunk/justification used. (Clare #25) + -- Updated man page for explain to match above change. + -- Added Tcl I/O routines to match proposal. Now functions much + like C I/O code. C I/O changed to use callback system to + accomodate adding and removing (new) I/O functions. + -- Updated demos/C_extension/soarAppInit.c to use new I/O scheme. + -- Added demos/soar-io-using-tcl.tcl to illustrate how to use Soar + I/O facilities using only Tcl. + -- Upgraded BLT to 1.8 to match use of Tcl 7.4/Tk 4.0. Upgraded + graph tool demo to use this new version. + -- Fixed a bug in the send command that incorrectly acted as if + Tk interpreters did not have send capability. + -- Updated make-all script for new versions of Tcl/Tk/Soar/BLT. + -- Changed all internal references to "tclsoar" to be "soar". + -- Changed "ts" dir name to "soar-7.0.0.beta" diff --git a/soar-8.5.2/doc/cat/add-wme.n b/soar-8.5.2/doc/cat/add-wme.n new file mode 100644 index 0000000..c45d2c2 --- /dev/null +++ b/soar-8.5.2/doc/cat/add-wme.n @@ -0,0 +1,65 @@ + + + +add-wme(n) Soar Commands add-wme(n) + + + +_________________________________________________________________ + +NAME + add-wme - Add a working memory element + +SYNOPSIS + add-wme _i_d [^]_a_t_t_r_i_b_u_t_e _v_a_l_u_e [+] +_________________________________________________________________ + + +DESCRIPTION + This command adds an element to working memory and returns + the timetag of the wme. In effect, Soar's working memory is + surgically altered by this command. add-wme adds a new wme + with the given _i_d, _a_t_t_r_i_b_u_t_e, _v_a_l_u_e, and optional _p_r_e_f_e_r_- + _e_n_c_e. The given _i_d must be an existing identifier. The + _a_t_t_r_i_b_u_t_e and _v_a_l_u_e fields can be any Soar symbol. If * is + given in the _a_t_t_r_i_b_u_t_e or _v_a_l_u_e field, Soar creates a new + identifier (symbol) for that field. If the _p_r_e_f_e_r_e_n_c_e is + given, it can only have the value + to indicate that an + acceptable preference should be created for this wme. + + add-wme is often used by an input function to update Soar's + information about the state of the external world. + + +EXAMPLES + This example adds the attribute/value pair "message-status + received" to the identifier (symbol) S1: + + add-wme S1 ^message-status received +9 + This example adds an attribute/value pair with an acceptable + preference to the identifier (symbol) Z2. The attribute is + "message" and the value is a unique identifier generated by + Soar. Note that since the ^ is optional, it has been left + off in this case. + + add-wme Z2 message * + +9 +WARNINGS + _T_h_i_s _c_o_m_m_a_n_d _i_s _i_n_h_e_r_e_n_t_l_y _u_n_s_t_a_b_l_e _a_n_d _m_a_y _h_a_v_e _w_e_i_r_d _s_i_d_e + _e_f_f_e_c_t_s (_p_o_s_s_i_b_l_y _e_v_e_n _i_n_c_l_u_d_i_n_g _s_y_s_t_e_m _c_r_a_s_h_e_s). For exam- + ple, the chunker can't backtrace through wmes created via + add-wme. Removing input wmes or context/impasse wmes may + have unexpected side effects. _Y_o_u'_v_e _b_e_e_n _w_a_r_n_e_d. + + +SEE ALSO + remove-wme + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/alias.n b/soar-8.5.2/doc/cat/alias.n new file mode 100644 index 0000000..dc8bb68 --- /dev/null +++ b/soar-8.5.2/doc/cat/alias.n @@ -0,0 +1,130 @@ + + + +alias(n) Soar Commands alias(n) + + + +_________________________________________________________________ + +NAME + alias - Define a new Soar alias + +SYNOPSIS + alias [_n_a_m_e [_d_e_f_i_n_i_t_i_o_n | -_o_f_f]] +_________________________________________________________________ + + +DESCRIPTION + This command defines new aliases by creating Tcl procedures + with the given _n_a_m_e. The new procedure can then take an + arbitrary number of arguments which are post-pended to the + given _d_e_f_i_n_i_t_i_o_n and then that entire string is executed as + a command. When invoked, the command is executed at the + global level as if typed in from the interactive command + line interpreter. The _d_e_f_i_n_i_t_i_o_n must be a single command, + ';' for multiple commands is not allowed. If more complex + aliases are desired, then the Tcl proc command can be used + to define a new procedure. The alias procedure checks to + see if the _n_a_m_e already exists, and does not destroy exist- + ing procedures or aliases by the same name. + + Existing aliases can be removed by using the command + unalias, or by specifying alias _n_a_m_e -_o_f_f. + + With no arguments, alias returns the list of defined + aliases. + + With only the _n_a_m_e given, alias returns the current defini- + tion. + + + +EXAMPLES + The command wmes is an alias which is defined as follows: + + alias wmes print -depth 0 -internal +9 + If the user executes a command such as: + + wmes {(* ^superstate nil)} +9 + it is as if the user had typed this command: + + print -depth 0 -internal {(* ^superstate nil)} +9 +WARNINGS + +9 + + +Soar Last change: 1 + + + + + + +alias(n) Soar Commands alias(n) + + + + Alias is also a Tcl command that is used when creating + slave interps. In Tcl, it is used to allow slave interps to + call procs that are defined in the master interp. See the + Tcl help file in your system. + + + +FILES + soar.tcl and soar7.2km-aliases.tcl + + The aliases for Soar provided upon startup are defined + in these files. The files are located in the + $soar_library directory (folder). + + +SEE ALSO + unalias, rename, proc, predefined-aliases, and Tcl Help for + the interp and alias commands + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/attention-lapse.n b/soar-8.5.2/doc/cat/attention-lapse.n new file mode 100644 index 0000000..327573b --- /dev/null +++ b/soar-8.5.2/doc/cat/attention-lapse.n @@ -0,0 +1,66 @@ + + + +attention-lapse(n) Soar Commands attention-lapse(n) + + + +_________________________________________________________________ + +NAME + attention-lapse - Enable/Disable attentional lapsing + +SYNOPSIS + attention-lapse [-on | -off] +_________________________________________________________________ + + +DESCRIPTION + The attention-lapse command is used to enable/disable the + attentional lapsing capabilities of Soar. The default value + is -off. If no argument is given, then the current atten- + tional lapsing status is printed. The actual behaviors for + lapsing are controlled thru the start-attention-lapse and + wake-from-attention-lapse commands. + + +OPTIONS + -on Attentional lapsing will occur according to the _s_t_a_r_t- + _a_t_t_e_n_t_i_o_n-_l_a_p_s_e and _w_a_k_e-_f_r_o_m-_a_t_t_e_n_t_i_o_n-_l_a_p_s_e commands. + + -off Attentional lapsing will not occur. + + +WARNINGS + This functionality must be enabled at compile time be defin- + ing the compiler options ATTENTION_LAPSE and + REAL_TIME_BEHAVIOR in soarkernel.h. This option is not + defined in the distribution version of Soar. + + + +SEE ALSO + start-attention-lapse wake-from-attention-lapse + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/attribute-preferences-mode.n b/soar-8.5.2/doc/cat/attribute-preferences-mode.n new file mode 100644 index 0000000..5945b27 --- /dev/null +++ b/soar-8.5.2/doc/cat/attribute-preferences-mode.n @@ -0,0 +1,130 @@ + + + +attribute-preferences-mode(n)Soar Commandsattribute-preferences-mode(n) + + + +_________________________________________________________________ + +NAME + attribute-preferences-mode - Set or list the attribute + preferences mode + +SYNOPSIS + attribute-preferences-mode [_m_o_d_e] +_________________________________________________________________ + + +DESCRIPTION + This command is obsolete for Soar 8. In Soar 8, the code + automatically operates as if attribute-preferences-mode = 2. + + For Soar 7, this command sets and prints the attributes + preferences mode. If _m_o_d_e is not given, this command prints + the current attribute preferences mode. If _m_o_d_e is given, + it must be one of the positive integers 0, 1, or 2 and is + used to reset the attribute preferences modes. + + The "attribute-preferences-mode" parameter is used to con- + trol the handling of preferences (other than acceptable and + reject preferences) for non-context slots. The _m_o_d_e set- + tings have the following interpretations: + + 0 Handle them the normal (Soar 6) way. + + 1 Handle them the normal (Soar 6) way, but print a warn- + ing message whenever a preference other than + or - is + created for a non-context slot. + + 2 Whenever a preferences other than + or - is created for + a non-context slot, print an error message and ignore + (discard) that preference. For non-context slots, the + set of values installed in working memory is always + equal to the set of acceptable values minus the set of + rejected values. + + The default initial setting of the "attribute-preferences- + mode" parameter is 0. + + +EXAMPLES + The command issued with no arguments, returns the current + mode: + + attribute-preferences-mode +9 + The next example makes use of Tcl command abbreviation while + setting the mode to 1: +9 + + +Soar Last change: 1 + + + + + + +attribute-preferences-mode(n)Soar Commandsattribute-preferences-mode(n) + + + + attr 1 +9 + +VARIABLE + Note that the commandname uses dashes to separate the words. + There is also a Soar variable "attribute_preferences_mode" + (with underscores) that can be used to set the mode through + the the Tcl _s_e_t command. If the _m_o_d_e is not given, the Tcl + _s_e_t command prints the current attribute preferences mode. + If _m_o_d_e is given, it must be one of the positive integers 0, + 1, or 2 and is used to reset the attribute preferences + modes. + + set attribute_preferences_mode returns the current mode + + set attribute_preferences_mode 1 sets the mode to 1 + + Soar variables cannot be abbreviated in the same manner as + commandnames. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + + + + +9 + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/attribute_preferences_mode.n b/soar-8.5.2/doc/cat/attribute_preferences_mode.n new file mode 100644 index 0000000..ead5135 --- /dev/null +++ b/soar-8.5.2/doc/cat/attribute_preferences_mode.n @@ -0,0 +1,66 @@ + + + +attribute_preferences_mode(n)Soar Commandsattribute_preferences_mode(n) + + + +_________________________________________________________________ + +NAME + attribute_preferences_mode - Set or list the attribute + preferences mode + +SYNOPSIS + set attribute_preferences_mode [_m_o_d_e] +_________________________________________________________________ + + +DESCRIPTION + attribute_preferences_mode is a Soar variable which sets and + prints the attributes preferences mode through the the Tcl + _s_e_t command. If the _m_o_d_e is not given, the Tcl _s_e_t command + prints the current attribute preferences mode. If _m_o_d_e is + given, it must be one of the positive integers 0, 1, or 2 + and is used to reset the attribute preferences modes. + + The "attribute_preferences_mode" parameter is used to con- + trol the handling of preferences (other than acceptable and + reject preferences) for non-context slots. The _m_o_d_e set- + tings have the following interpretations: + + 0 Handle them the normal (Soar 6) way. + + 1 Handle them the normal (Soar 6) way, but print a warn- + ing message whenever a preference other than + or - is + created for a non-context slot. + + 2 Whenever a preferences other than + or - is created for + a non-context slot, print an error message and ignore + (discard) that preference. For non-context slots, the + set of values installed in working memory is always + equal to the set of acceptable values minus the set of + rejected values. + + The default initial setting of the + "attribute_preferences_mode" variable is 0. + +SEE ALSO + variables + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/capture-input.n b/soar-8.5.2/doc/cat/capture-input.n new file mode 100644 index 0000000..32f4839 --- /dev/null +++ b/soar-8.5.2/doc/cat/capture-input.n @@ -0,0 +1,65 @@ + + + +capture-input(n) Soar Commands capture-input(n) + + + +_________________________________________________________________ + +NAME + capture-input - Save agent commands issued from the input + function + +SYNOPSIS + capture-input _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command may be used to start and stop the recording of + input function commands as created by an external simula- + tion. commands are recorded decision cycle by decision + cycle. Use the command replay-input to replay the sequence. + The _a_c_t_i_o_n must be one of the following: + + -open _p_a_t_h_n_a_m_e + A log file named _p_a_t_h_n_a_m_e is created and input captur- + ing is initiated. + + -query + Returns open if capturing is active or closed if cap- + turing is not active. + + -off Close the captured input file. + + +EXAMPLES + This initiates input capturing and places the commands in + foo.in: + + capture-input -new foo.in +9 + This terminates capturing and closes the open log file: + + capture-input -off +9 + +WARNING +SEE ALSO + replay-input + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/chunk-name-format.n b/soar-8.5.2/doc/cat/chunk-name-format.n new file mode 100644 index 0000000..69857a4 --- /dev/null +++ b/soar-8.5.2/doc/cat/chunk-name-format.n @@ -0,0 +1,131 @@ + + + +chunk-name-format(n) Soar Commands chunk-name-format(n) + + + +_________________________________________________________________ + +NAME + chunk-name-format - Specify format of names of newly created + chunks + +SYNOPSIS + chunk-name-format [-short | -long] [-prefix [<_p_r_e_f_i_x>]] [- + count [<_c_h_u_n_k-_n_u_m>]] +_________________________________________________________________ + + +DESCRIPTION + The chunk-name-format command specifies the format to be + used when naming newly created chunks. The short format is: + + <_p_r_e_f_i_x>-<_c_h_u_n_k-_n_u_m> +9 + The long format is: + + <_p_r_e_f_i_x>-<_c_h_u_n_k-_n_u_m>*d<_d_c>*<_i_m_p_a_s_s_e-_t_y_p_e>*<_d_c-_c_h_u_n_k-_n_u_m> +9 + where: + + <_p_r_e_f_i_x> + is a user-definable prefix string; <_p_r_e_f_i_x> defaults to + "chunk" when unspecified by the user; + + <_c_h_u_n_k-_n_u_m> + is 1 for the first chunk created, 2 for the second + chunk created, and so on. + + <_d_c> is the number of the decision cycle in which the chunk + was formed; + + <_i_m_p_a_s_s_e-_t_y_p_e> + is [tie | conflict | cfailure | snochange | opnochange] + + <_d_c-_c_h_u_n_k-_n_u_m> + is the number of the chunk within that specific deci- + sion cycle. + + Notes: + + 1 The <_p_r_e_f_i_x> string may not contain the '*' character. + (The chunk-name-format command enforces this con- + straint.) The '*' character marks the ending of the + number of the chunk, and chunk numbers are examined + during production loading to allow a starting chunk + number to be identified automatically. + + + + +Soar Last change: 1 + + + + + + +chunk-name-format(n) Soar Commands chunk-name-format(n) + + + + 2 <_i_m_p_a_s_s_e-_t_y_p_e> is the impasse of the lowest goal that + has a result generated by this chunk. + + +OPTIONS + -short + When generating chunk names, use the short format. + (See the DESCRIPTION section for details.) + + -long + When generating chunk names, use the long format. (See + the DESCRIPTION section for details.) This is the + default format for Soar. + + -prefix [<_p_r_e_f_i_x>] + When generating chunk names, use the string <_p_r_e_f_i_x>. + <_p_r_e_f_i_x> is initially "chunk". When <_p_r_e_f_i_x> is + unspecified, return the current <_p_r_e_f_i_x>. + + -count [<_c_h_u_n_k-_n_u_m>] + Set chunk counter to <_c_h_u_n_k-_n_u_m>. <_c_h_u_n_k-_n_u_m> cannot + be reset to a number lower than the smallest chunk + number of any loaded chunk. When <_c_h_u_n_k-_n_u_m> is + unspecified, return the current <_c_h_u_n_k-_n_u_m>. + + +EXAMPLES + chunk-name-format -short -prefix "chunk" -count 0 + To cause chunks to be named according to the "old" + scheme. + + chunk-name-format -prefix "new-chunk" + To begin naming a new sequence of chunks. + + chunk-name-format -count 1000 + To begin numbering a new sequence of chunks at 1000. + + chunk-name-format -count + To retrieve the next <_c_h_u_n_k-_n_u_m> that will be used to + form a chunk name. + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/command-to-file.n b/soar-8.5.2/doc/cat/command-to-file.n new file mode 100644 index 0000000..0e3b3c9 --- /dev/null +++ b/soar-8.5.2/doc/cat/command-to-file.n @@ -0,0 +1,65 @@ + + + +command-to-file(n) Soar Commands command-to-file(n) + + + +_________________________________________________________________ + +NAME + command-to-file - Evaluate the command and print result to + file + +SYNOPSIS + command-to-file _c_o_m_m_a_n_d _f_i_l_e [_m_o_d_e] +_________________________________________________________________ + + +DESCRIPTION + This evaluates a _c_o_m_m_a_n_d in the current interpreter. The + prints issued by the command and its result (both of which + are normally printed to stdout) are redirected to the given + _f_i_l_e. The _m_o_d_e determines whether the file is initially + opened in write (-new) or append (-existing) mode. If no + _m_o_d_e is given, then -new is assumed. + + +EXAMPLES + The command writes all productions to the file my-file: + + command-to-file list-productions my-file +9 + This command appends the memory statistics to the already + existing file my-stats-file: + + command-to-file {stats -memory} my-stats-file -existing +9 + +SEE ALSO + output-strings-destination + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/d.n b/soar-8.5.2/doc/cat/d.n new file mode 100644 index 0000000..4ea77cc --- /dev/null +++ b/soar-8.5.2/doc/cat/d.n @@ -0,0 +1,66 @@ + + + +d(n) Soar Commands d(n) + + + +_________________________________________________________________ + +NAME + d - Run Soar by decision cycles + +SYNOPSIS + d [_c_y_c_l_e_s] +_________________________________________________________________ + + +DESCRIPTION + d is actually a predefined alias for 'run [n] d' which runs + the Soar agent for the given number of decision _c_y_c_l_e_s. If + no cycles are given, then the agent is run for one decision + cycle. 'd -1' or 'd forever' runs the agent until the + task terminates or a user interrupt is given. + + +SEE ALSO + run + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/default-wme-depth.n b/soar-8.5.2/doc/cat/default-wme-depth.n new file mode 100644 index 0000000..e1bd4d8 --- /dev/null +++ b/soar-8.5.2/doc/cat/default-wme-depth.n @@ -0,0 +1,131 @@ + + + +default-wme-depth(n) Soar Commands default-wme-depth(n) + + + +_________________________________________________________________ + +NAME + default-wme-depth - Set or list the default print depth + +SYNOPSIS + default-wme-depth [_d_e_p_t_h] +_________________________________________________________________ + + +DESCRIPTION + This command sets and prints the default printing depth. If + _d_e_p_t_h is not given, this command prints the default printing + depth. If _d_e_p_t_h is given, it must be a positive integer and + is used to reset the default printing depth. + + The "default-wme-depth" parameter is used to control the + default printing depth of the print command. The default + initial setting of the "default-wme-depth" parameter is 1. + + +EXAMPLES + The command issued with no arguments, returns the print + depth: + + default-wme-depth +9 + The next example makes use of Tcl command abbreviation while + setting the depth to 3: + + def 3 +9 + + +VARIABLE + Note that the commandname uses dashes to separate the words. + There is also a Soar variable "default_wme_depth" (with + underscores) that can be used to set the print depth through + the the Tcl _s_e_t command. If _d_e_p_t_h is not given, the Tcl _s_e_t + commands prints the default printing depth. If _d_e_p_t_h is + given, it must be a positive integer and is used to reset + the default printing depth. + + set default_wme_depth returns the current depth + + set default_wme_depth 3 sets the depth to 3 + + Soar variables cannot be abbreviated in the same manner as + commandnames. + + + + + +Soar Last change: 1 + + + + + + +default-wme-depth(n) Soar Commands default-wme-depth(n) + + + +WARNINGS + This parameter can be overridden in any invocation of the + print command by using the -depth option. + + +SEE ALSO + print, variables + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/default_wme_depth.n b/soar-8.5.2/doc/cat/default_wme_depth.n new file mode 100644 index 0000000..99dab0b --- /dev/null +++ b/soar-8.5.2/doc/cat/default_wme_depth.n @@ -0,0 +1,66 @@ + + + +default_wme_depth(n) Soar Commands default_wme_depth(n) + + + +_________________________________________________________________ + +NAME + default_wme_depth - Set or list the default print depth + +SYNOPSIS + set default_wme_depth [_d_e_p_t_h] +_________________________________________________________________ + + +DESCRIPTION + default_wme_depth is a Soar variable which sets and prints + the default printing depth through the Tcl _s_e_t command. If + _d_e_p_t_h is not given, the Tcl _s_e_t commands prints the default + printing depth. If _d_e_p_t_h is given, it must be a positive + integer and is used to reset the default printing depth. + + The "default_wme_depth" parameter is used to control the + default printing depth of the print command. The default + initial setting of the "default_wme_depth" parameter is 1. + + +WARNINGS + This parameter can be overridden in any invocation of the + print command by using the -depth option. + + +SEE ALSO + print variables + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/dirs.n b/soar-8.5.2/doc/cat/dirs.n new file mode 100644 index 0000000..a8d66ea --- /dev/null +++ b/soar-8.5.2/doc/cat/dirs.n @@ -0,0 +1,66 @@ + + + +dirs(n) Soar Commands dirs(n) + + + +_________________________________________________________________ + +NAME + dirs - List the directory stack + +SYNOPSIS + dirs +_________________________________________________________________ + + +DESCRIPTION + This command lists the directory stack. Agents can move + through a directory structure by pushing and popping direc- + tory names. The dirs command returns the stack. + + The command pushd places a new "agent current directory" on + top of the directory stack and cds to it. The command popd + removes the directory at the top of the directory stack and + cds to the previous directory which now appears at the top + of the stack. + + +SEE ALSO + pushd, popd, topd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/e.n b/soar-8.5.2/doc/cat/e.n new file mode 100644 index 0000000..eb6e5fb --- /dev/null +++ b/soar-8.5.2/doc/cat/e.n @@ -0,0 +1,66 @@ + + + +e(n) Soar Commands e(n) + + + +_________________________________________________________________ + +NAME + e - Run Soar by elaboration cycles + +SYNOPSIS + e [_c_y_c_l_e_s | forever] +_________________________________________________________________ + + +DESCRIPTION + e is actually a predefined alias for 'run [n] e' which runs + the Soar agent for the given number of elaboration _c_y_c_l_e_s. + If no cycles are given, then the agent is run for one ela- + boration cycle. 'e -1' or 'e forever' runs the agent until + the task terminates or a user interrupt is given. + + +SEE ALSO + SO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/echo.n b/soar-8.5.2/doc/cat/echo.n new file mode 100644 index 0000000..7a19be2 --- /dev/null +++ b/soar-8.5.2/doc/cat/echo.n @@ -0,0 +1,66 @@ + + + +echo(n) Soar Commands echo(n) + + + +_________________________________________________________________ + +NAME + echo - Echo message + +SYNOPSIS + echo [-_n_o_n_e_w_l_i_n_e] _a_r_g_s +_________________________________________________________________ + + +DESCRIPTION + This command echos the _a_r_g_s to the current output stream. + This is normally stdout but can be set to a variety of chan- + nels. If an _a_r_g is -nonewline then no newline is printed at + the end of the printed strings. Otherwise a newline is + printed after printing all the given _a_r_g_s. For the full + details of the redirection, see the command output-strings- + destination. + + Users wanting to print variables and data to the screen, + should use echo rather than the Tcl command "puts." The + echo command gets redirected to the appropriate channel + according to output-strings-destination; the "puts" command + does not. + + +SEE ALSO + output-strings-destination + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/excise.n b/soar-8.5.2/doc/cat/excise.n new file mode 100644 index 0000000..2d02f39 --- /dev/null +++ b/soar-8.5.2/doc/cat/excise.n @@ -0,0 +1,131 @@ + + + +excise(n) Soar Commands excise(n) + + + +_________________________________________________________________ + +NAME + excise - Remove productions from Soar's memory + +SYNOPSIS + excise _p_r_o_d_u_c_t_i_o_n-_n_a_m_e | -chunks | -default | -task | -user + | -all +_________________________________________________________________ + + +DESCRIPTION + This command removes productions from Soar's memory. Each + option given on the command line may be either a production + name or the type of the standard set of productions (indi- + cated by a keyword). + + +OPTIONS + _p_r_o_d_u_c_t_i_o_n-_n_a_m_e + Remove the production named _p_r_o_d_u_c_t_i_o_n-_n_a_m_e from memory + + -chunks + Remove all chunks (learned productions) and justifica- + tions from memory + + -default + Remove all default rules (:default) from memory + + -task + Remove all non-default productions from memory and per- + form an init-soar command + + -user + Remove all user productions (but not chunks or default + rules) from memory. + + -all Remove all productions from memory and perform an + init-soar command + + +EXAMPLES + This removes the production my*first*production and all + chunks: + + excise my*first*production -chunks +9 + This removes all productions and does an init-soar: + + excise -all +9 + + + +Soar Last change: 1 + + + + + + +excise(n) Soar Commands excise(n) + + + +SEE ALSO + init-soar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/explain-backtraces.n b/soar-8.5.2/doc/cat/explain-backtraces.n new file mode 100644 index 0000000..d839b00 --- /dev/null +++ b/soar-8.5.2/doc/cat/explain-backtraces.n @@ -0,0 +1,132 @@ + + + +explain-backtraces(n) Soar Commands explain-backtraces(n) + + + +_________________________________________________________________ + +NAME + explain-backtraces - Interpret chunking backtraces + +SYNOPSIS + explain-backtraces [_p_r_o_d_n_a_m_e_n_a_m_e [_n | -full] ] +_________________________________________________________________ + + +DESCRIPTION + This command provides some interpretation of backtraces gen- + erated during chunking. If no option is given, then a list + of all chunks and justifications is printed. + + The two most useful variants are explain-backtraces _p_r_o_d_n_a_m_e + and explain-backtraces _n_a_m_e _n. The first variant lists all + of the conditions for the named chunk or justification, and + the _g_r_o_u_n_d which resulted in inclusion in the + chunk/justification. A _g_r_o_u_n_d is a working memory element + (WME) which was tested in the supergoal. Just knowing which + WME was tested may be enough to explain why the + chunk/justification exists. If not, the conditions can be + listed with an integer value. This value can be used in + explain-backtraces _n_a_m_e _n to obtain a list of the produc- + tions which fired to obtain this condition in the + chunk/justification (and the crucial WMEs tested along the + way). Why use an integer value to specify the condition? + To save a big parsing job. + + +OPTIONS + If an option is given, it must match one of the following + forms: + + _n_a_m_e list all conditions and grounds for the chunk or jus- + tification named _n_a_m_e + + _n_a_m_e -full + provide a backtrace for the chunk or justification + named _n_a_m_e + + _n_a_m_e _n + explain why condition number _n is in the chunk or jus- + tification + + +WARNINGS + save_backtraces mode must be on when a chunk or justifica- + tion is created or no explanation will be available. + Explain-backtraces mode is toggled using the save_backtraces + boolean variable. save_backtraces is off by default. When + + + +Soar Last change: 1 + + + + + + +explain-backtraces(n) Soar Commands explain-backtraces(n) + + + + explain mode is on, more memory is used, and building chunks + and justifications will be slower. + + +SEE ALSO + _s_a_v_e__b_a_c_k_t_r_a_c_e_s, _v_a_r_i_a_b_l_e_s + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/firing-counts.n b/soar-8.5.2/doc/cat/firing-counts.n new file mode 100644 index 0000000..6e63adc --- /dev/null +++ b/soar-8.5.2/doc/cat/firing-counts.n @@ -0,0 +1,65 @@ + + + +firing-counts(n) Soar Commands firing-counts(n) + + + +_________________________________________________________________ + +NAME + firing-counts - Print production firing counts + +SYNOPSIS + firing-counts [_i_n_t_e_g_e_r | _p_r_o_d_u_c_t_i_o_n-_n_a_m_e_s] +_________________________________________________________________ + + +DESCRIPTION + This command prints information about production firings. + If an option is not given, then all productions are printed + in a sorted list according to how many times they have + fired. + + +OPTIONS + If given, an option can take one of two forms -- an integer + or a list of production names: + + _i_n_t_e_g_e_r + List the top _i_n_t_e_g_e_r productions. If _i_n_t_e_g_e_r is 0, + only the productions which haven't fired are listed. + + _p_r_o_d_u_c_t_i_o_n-_n_a_m_e_s + For each production in _p_r_o_d_u_c_t_i_o_n-_n_a_m_e_s, print how many + times the production has fired. + + +EXAMPLES + This example prints the 10 productions which have fired the + most times along with their firing counts: + + firing-counts 10 +9 + This example prints the firing counts of productions + my*first*production and my*second*production: + + firing-counts my*first*production my*second*production +9 + +WARNINGS + firing-counts are reset to zero after an init-soar + + NB: This command is slow, because the sorting takes time + O(n*log n) + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/format-watch.n b/soar-8.5.2/doc/cat/format-watch.n new file mode 100644 index 0000000..14940ef --- /dev/null +++ b/soar-8.5.2/doc/cat/format-watch.n @@ -0,0 +1,261 @@ + + + +format-watch(n) Soar Commands format-watch(n) + + + +_________________________________________________________________ + +NAME + format-watch - Control the format of printed objects + +SYNOPSIS + format-watch [-_s_t_a_c_k | -_o_b_j_e_c_t] [_o_p_e_r_a_t_i_o_n _c_l_a_s_s [_n_a_m_e] _f_o_r_- + _m_a_t] + operation ::= -add | -remove + class ::= s | o | * + format ::= {sequence of format masks} +_________________________________________________________________ + +DESCRIPTION + The format-watch command defines the format to use when + printing Soar objects and the Soar goal stack. The optional + _t_y_p_e, if present, must be the switch -object or -stack and + indicates which format to manipulate. Object trace formats + control how Soar prints an object--e.g., a certain operator, + problem-space, etc. Stack trace formats control how Soar + prints its context stack selections in watch 0 and print + -stack printouts. If no _t_y_p_e is given, then -stack is + assumed. + + The second portion of the format-watch command is the _a_c_t_i_o_n + to apply to the selected trace format. An action consists + of adding or removing formats to selected classes of + objects. An _a_c_t_i_o_n has the following form: + + _o_p_e_r_a_t_i_o_n _c_l_a_s_s [_n_a_m_e] _f_o_r_m_a_t +9 + The _o_p_e_r_a_t_i_o_n must be either -add or -remove. An -add + operation adds new trace formats replacing any existing ones + with identical applicability conditions. A -remove opera- + tion removes trace formats with the given applicability con- + ditions. The combination of _c_l_a_s_s and _n_a_m_e define the appli- + cability conditions of the _f_o_r_m_a_t (i.e., which classes of + objects the _f_o_r_m_a_t applies to). The _c_l_a_s_s must be either s + or o and indicates that the operation applies to states or + operators, respectively. The wildcard symbol * may also be + used to indicate that the _f_o_r_m_a_t applies to all objects. If + an -object trace is being manipulated, then an optional _n_a_m_e + may be given indicating the format applies only to objects + with that name. If a -stack trace is being manipulated, + then an optional _n_a_m_e may be given indicating the format + applies only within problem spaces of that name. + + The _f_o_r_m_a_t string can be any sequence of characters sur- + rounded by curly braces. Note that double quotes are not + sufficient because the square brackets in the format string + will be interpreted as a command to be evaluated by Tcl. + Certain formatting controls can be used within the string-- + + + +Soar Last change: 1 + + +9 + + +format-watch(n) Soar Commands format-watch(n) + + + + see the section FORMAT CONTROLS below for more information. + + + If no arguments are given, then format-watch prints the + current format settings. + + +FORMAT CONTROLS + The following control sequences can be used within trace + format strings. The _S indicates the sequence is ONLY usable + in stack traces: + + %cs print the current state using the appropriate object + trace format (_S) + + %co print the current operator using the appropriate object + trace format (_S) + + %dc print the current decision cycle number (_S). Not mean- + ingful and therefore ignored in stack traces produced + by the print -stack command. + + %ec print the current elaboration cycle number (_S). Not + meaningful and therefore ignored in stack traces pro- + duced by the print -stack command. + + %sd print the current subgoal depth (_S). This uses 0 as + the top level. + + %rsd[_p_a_t_t_e_r_n] + repeat (subgoal depth) times: print the given _p_a_t_t_e_r_n + (_S). + + %left[_n_u_m,_p_a_t_t_e_r_n] + print the _p_a_t_t_e_r_n left justified in a field of _n_u_m + spaces. + + %right[_n_u_m,_p_a_t_t_e_r_n] + print the _p_a_t_t_e_r_n right justified in a field of _n_u_m + spaces. + + %id print the identifier of the current object. + + %v[_a_t_t_r] + print the value(s) of attribute ^_a_t_t_r on the current + object. If there is no ^_a_t_t_r on the current object, + nothing is printed. + + %v[_p_a_t_h] + same as the above, only follow the given attribute _p_a_t_h + to get the value(s). A _p_a_t_h is a sequence of attribute + names separated by periods, such as foo.bar.baz. + + + +Soar Last change: 2 + + + + + + +format-watch(n) Soar Commands format-watch(n) + + + + %v[*] + print all values of all attributes on the current + object. + + %o[args] + same as %v, except that if the value is an identifier, + it is printed using the appropriate object trace for- + mat. + + %av[args] + same as %v, except the printed value is preceeded with + "^attr " to indicate the attribute name. + + %ao[args] + a combination of the above two. + + %ifdef[_p_a_t_t_e_r_n] + print the given _p_a_t_t_e_r_n if and only if all escape + sequences inside it are "meaningful" or "well-defined." + For example, the format string %ifdef[foo has value: + %v[foo]] will print nothing if there is no ^foo on the + current object. + + %nl print a newline + + %% print a percent sign + + %[ print a left bracket + + %] print a right bracket + + +EXAMPLES + In the following examples, the phrase "the command prints X" + is simply an abbreviation for the more accurate phrase "the + command defines a trace format string which when used for + printing will print X". + + These commands are equivalent to the default settings for + stack traces: + + format-watch -stack -add s {%right[6,%dc]: %rsd[ ]==>S: %cs} + format-watch -stack -add o {%right[6,%dc]: %rsd[ ] O: %co} +9 + The above format strings print the decision cycle number + right justified in a field 6 characters wide. After that, a + colon and space are printed. Then, three spaces are printed + as many times as the subgoal is deep. Finally, a few more + characters are printed to indicate the item type and then + the item itself is printed. + +9 + + +Soar Last change: 3 + + + + + + +format-watch(n) Soar Commands format-watch(n) + + + + The following commands are equivalent to the default set- + tings for object traces: + + format-watch -object -add * {%id %ifdef[(%v[name])]} + format-watch -object -add s {%id %ifdef[(%v[attribute] %v[impasse])]} + format-watch -object -add o evaluate-object {%id (evaluate-object %o[object])} +9 + The first command prints an identifier followed by its name + in parentheses (if a name is defined) for all objects. This + will hold unless overridden by more specific applicability + conditions. This first format might print something like: + O37 (my-operator-name). The last two commands define (over- + riding) formats for states and operators. The second com- + mand, for states, prints the state identifier followed, in + parentheses, by its ^attribute and ^impasse attributes, if + they are defined. For example, this might print G5 (opera- + tor no-change). Finally, the third command handles + evaluate-object operators in the selection space. These + operators will be printed as an id followed, in parentheses, + by the string "evaluate-object " and the printed representa- + tion of the object being printed. + + The following stack trace format causes both the current + state and current operator to be printed whenever an opera- + tor is selected. (There is a linefeed in the middle of the + format string.) + + format-watch -stack -add o {%right[6,%dc]: %rsd[ ] S: %cs + %rsd[ ] O: %co} +9 + The above format is useful for watching the effects of + operator applications. + + +SEE ALSO + watch, print + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/gds-print.n b/soar-8.5.2/doc/cat/gds-print.n new file mode 100644 index 0000000..81da823 --- /dev/null +++ b/soar-8.5.2/doc/cat/gds-print.n @@ -0,0 +1,66 @@ + + + +init-soar(n) Soar Commands init-soar(n) + + + +_________________________________________________________________ + +NAME + init-soar - Initialize Soar + +SYNOPSIS + init-soar +_________________________________________________________________ + + +DESCRIPTION + This command initializes or re-initializes Soar. Initiali- + zation removes all elements from working memory, wipes out + the goal stack, and resets all statistics. It does not + excise chunks. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/gds_print.n b/soar-8.5.2/doc/cat/gds_print.n new file mode 100644 index 0000000..0be06ab --- /dev/null +++ b/soar-8.5.2/doc/cat/gds_print.n @@ -0,0 +1,66 @@ + + + +gds_print(n) Soar Commands gds_print(n) + + + +_________________________________________________________________ + +NAME + gds_print - Examine the goal dependency set. + +SYNOPSIS + gds_print +_________________________________________________________________ + + +DESCRIPTION + A debugging command for examing the GDS when necessary. It + is horribly inefficient and should not generally be used + except when something is going wrong and you want to take a + peak at the Goal Dependency Set. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/help.n b/soar-8.5.2/doc/cat/help.n new file mode 100644 index 0000000..b114975 --- /dev/null +++ b/soar-8.5.2/doc/cat/help.n @@ -0,0 +1,132 @@ + + + +help(n) Soar Commands help(n) + + + +_________________________________________________________________ + +NAME + help - Print man pages for Soar commands + +SYNOPSIS + help [-all | _c_o_m_m_a_n_d_n_a_m_e [-usage]] +_________________________________________________________________ + + +DESCRIPTION + This command prints the formatted manual page for the given + _c_o_m_m_a_n_d_n_a_m_e. Soar's help facility is able to do command + completion, so as long as a unique substring of the command- + name is specified, Soar will find and display the help page. + + Under the TSI (Tcl-Soar Interface, a graphical interface to + Soar), the help will pop up a separate window to display the + text. + + Under Unix with no TSI running, the help command attempts to + locate a pager program to use to display help pages page- + by-page since some are longer than a typical screen. The + command first examines the environment variable PAGER to see + if the user has defined a preference there. If that is not + present, the help system checks to see if one of the com- + monly used pagers "less", "more", or "page" is available (in + that order). If no pager is available, then an error mes- + sage is given. If no pagers exist on your system, then you + can set the environment variable PAGER to "cat" and the help + pages will simply be cat'ed to the screen. Since some pages + are long, this will make it difficult to read an entire + page. + + +OPTIONS + -all List all commands for which help is available + + -usage + List only the SYNOPSIS section of the man page. This + includes the abbreviated syntax for the command. - + usage may not work properly on some windows and mac + systems. + + +FILES + The nroff sources for the manual pages are stored in the + subdirectory .../doc/man. These files are used to generate + the "cat" and "HTML" versions which are stored in + .../doc/cat and .../doc/html, respectively. + + + + + +Soar Last change: 1 + + + + + + +help(n) Soar Commands help(n) + + + +ENVIRONMENT + PAGER + + This variable contains the user's preferred paging pro- + gram which shows text page by page rather than spewing + all text at once to standard output. Typical pagers + are more, less, and page. + + +WARNINGS + Some pages, such as less clear the screen upon exit, remov- + ing the help page from view. If you wish to retain the help + page, use a pager such as more. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/indifferent-selection.n b/soar-8.5.2/doc/cat/indifferent-selection.n new file mode 100644 index 0000000..4e169b6 --- /dev/null +++ b/soar-8.5.2/doc/cat/indifferent-selection.n @@ -0,0 +1,66 @@ + + + +indifferent-selection(n) Soar Commands indifferent-selection(n) + + + +_________________________________________________________________ + +NAME + indifferent-selection - Control indifferent preference arbi- + tration + +SYNOPSIS + indifferent-selection [-first | -last | -ask | -random] +_________________________________________________________________ + + +DESCRIPTION + This command controls indifferent preference arbitration. + When an indifferent preference tie is created among two or + more items, then the "indifferent-selection" parameter is + used by the Soar decision procedure to control the selection + of one item to resolve the tie and avoid an impasse. + + If no option is given, this command prints the current set- + ting of the "indifferent-selection" parameter. If an option + is given, it is used to guide the resolution of indifferent + preference ties. At startup, the default setting of the + "indifferent-selection" parameter is -random. + + +OPTIONS + If given, the option must match one of the following: + + -first + Choose the first object found (deterministically) + + -last + Choose the last object found (deterministically) + + -ask Ask the user to choose one of the items + + -random + Choose an object randomly. This is the default set- + ting. + +WARNINGS + -ask currently only works under Unix, when Soar is run from + the console window (not the TSI). This is because + indifferent-selection is handled deep in the kernel, and the + kernel has no knowledge of Tcl, and therefore no information + on how to read data from anywhere except stdin. + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/init-soar.n b/soar-8.5.2/doc/cat/init-soar.n new file mode 100644 index 0000000..81da823 --- /dev/null +++ b/soar-8.5.2/doc/cat/init-soar.n @@ -0,0 +1,66 @@ + + + +init-soar(n) Soar Commands init-soar(n) + + + +_________________________________________________________________ + +NAME + init-soar - Initialize Soar + +SYNOPSIS + init-soar +_________________________________________________________________ + + +DESCRIPTION + This command initializes or re-initializes Soar. Initiali- + zation removes all elements from working memory, wipes out + the goal stack, and resets all statistics. It does not + excise chunks. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/input-period.n b/soar-8.5.2/doc/cat/input-period.n new file mode 100644 index 0000000..3138dec --- /dev/null +++ b/soar-8.5.2/doc/cat/input-period.n @@ -0,0 +1,66 @@ + + + +input-period(n) Soar Commands input-period(n) + + + +_________________________________________________________________ + +NAME + input-period - Set or list the input period + +SYNOPSIS + input-period [_p_e_r_i_o_d] +_________________________________________________________________ + + +DESCRIPTION + This command is obsolete for Soar8. In Soar8, input is done + at the start of every decision cycle. + + This command controls the rate of input to the Soar agent. + If _p_e_r_i_o_d is not specified, this command prints the current + input period. If _p_e_r_i_o_d is specified, it must be a non- + negative integer and is used to reset the input period. A + _p_e_r_i_o_d of 0 sets input to occur every elaboration cycle. A + positive value for _p_e_r_i_o_d sets Soar to accept input only + every nth _p_e_r_i_o_d decision cycles. The default initial set- + ting of the "input-period" parameter is 0. + + +EXAMPLES + input-period 5 + Input is accepted only every 5th decision cycle by the + Soar agent. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/internal-symbols.n b/soar-8.5.2/doc/cat/internal-symbols.n new file mode 100644 index 0000000..5a6fb68 --- /dev/null +++ b/soar-8.5.2/doc/cat/internal-symbols.n @@ -0,0 +1,66 @@ + + + +internal-symbols(n) Soar Commands internal-symbols(n) + + + +_________________________________________________________________ + +NAME + internal-symbols - Print contents of the Soar symbol table + +SYNOPSIS + internal-symbols +_________________________________________________________________ + + +DESCRIPTION + This command prints information about the Soar symbol table. + Such information is typically only useful for users attempt- + ing to debug Soar by locating memory leaks. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/io.n b/soar-8.5.2/doc/cat/io.n new file mode 100644 index 0000000..c4f2c9a --- /dev/null +++ b/soar-8.5.2/doc/cat/io.n @@ -0,0 +1,66 @@ + + + +io(n) Soar Commands io(n) + + + +_________________________________________________________________ + +NAME + io - Manage attachment of scripts to Soar I/O + +SYNOPSIS + io _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command manages the attachment of scripts to Soar I/O. + Soar has an event defined for input and another for output. + Scripts can be attached to these Soar events so that they + are invoked every time the Soar event occurs. These scripts + can later be removed using the io command. The status of + attachments can be listed also. If a new attachment is + created, its identifier is returned as the result of this + command. + + The specified _a_c_t_i_o_n must have one of the following forms: + + -add [-input | -output] _s_c_r_i_p_t [_i_d] + Add the _s_c_r_i_p_t to the list of scripts to be invoked + when the -input or output event occurs in the Soar ker- + nel. If the _i_d is given, it is used to name the attach- + ment. If no _i_d is given, then a unique id is generated + and returned. The id is necessary if a user ever wants + to delete an action. + + -delete [-input | -output] _i_d + Remove script attachment named _i_d. + + -list [-input | -output] + List all attachments of scripts to Soar input or out- + put. + + +EXAMPLES + A detailed example of using Soar I/O in Tcl is given in the + file demos/soar-io-using-tcl.tcl. + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/learn.n b/soar-8.5.2/doc/cat/learn.n new file mode 100644 index 0000000..25ad1be --- /dev/null +++ b/soar-8.5.2/doc/cat/learn.n @@ -0,0 +1,132 @@ + + + +learn(n) Soar Commands learn(n) + + + +_________________________________________________________________ + +NAME + learn - Control the learning of productions + +SYNOPSIS + learn [-_o_n | -_o_f_f | -_e_x_c_e_p_t | -_o_n_l_y | -_l_i_s_t | -_a_l_l-_l_e_v_e_l_s | + -_b_o_t_t_o_m-_u_p] +_________________________________________________________________ + + +DESCRIPTION + This command is used to control the learning (or "chunking") + of productions. With no arguments, this command prints out + the current learning environment status. The watch command + can be used to provide various levels of detail when produc- + tions are learned. + + Learning is on by default. + + +OPTIONS + Any _o_p_t_i_o_ns given must match one of the following keywords: + + -on turn learning on + + -off turn all learning off + + -except + learning is on, except as specified by RHS dont-learn + actions + + -only + learning is off, except as specified by RHS force-learn + actions + + -list + lists the force-learn and dont-learn states registered + by the RHS actions + + + -all-levels + when learning is on, this allows learning whenever a + subgoal returns a result (in contrast to bottom-up + learning) + + -bottom-up + when learning is on, this allows learning at only the + lowest level; i.e., build chunks only for subgoals that + have not yet had any subgoals with chunks built. + + + + + +Soar Last change: 1 + + + + + + +learn(n) Soar Commands learn(n) + + + +SEE ALSO + watch, explain-backtraces, save_backtraces + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/log.n b/soar-8.5.2/doc/cat/log.n new file mode 100644 index 0000000..e71bfa9 --- /dev/null +++ b/soar-8.5.2/doc/cat/log.n @@ -0,0 +1,64 @@ + + + +log(n) Soar Commands log(n) + + + +_________________________________________________________________ + +NAME + log - Log a Soar agent session + +SYNOPSIS + log _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command records the prompts, commands, printing, and + command results that are printed to stdout for a given + agent. The _a_c_t_i_o_n must be one of the following: + + -new _p_a_t_h_n_a_m_e + A log file named _p_a_t_h_n_a_m_e is created and logging is + initiated. + + -existing _p_a_t_h_n_a_m_e + An existing log file named _p_a_t_h_n_a_m_e is opened and log- + ging is added to the end of the file. + + -add _s_t_r_i_n_g + Add the given _s_t_r_i_n_g to the open log file + + -query + Returns open if logging is active or closed if logging + is not active. + + -off Close the open log file. + + +EXAMPLES + This initiates logging and places the record in foo.log: + + log -new foo.log +9 + This appends log data to an existing foo.log file: + + log -existing foo.log +9 + This terminates logging and closes the open log file: + + log -off +9 + + + + +9 + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/matches.n b/soar-8.5.2/doc/cat/matches.n new file mode 100644 index 0000000..9f71938 --- /dev/null +++ b/soar-8.5.2/doc/cat/matches.n @@ -0,0 +1,130 @@ + + + +matches(n) Soar Commands matches(n) + + + +_________________________________________________________________ + +NAME + matches - List production match information + +SYNOPSIS + matches _p_r_o_d_u_c_t_i_o_n-_n_a_m_e [-count | -timetags | -wmes | 0 | 1 + | 2] + matches [-assertions | -retractions] [-names | -timetags | + -wmes | 0 | 1 | 2] +_________________________________________________________________ + + +DESCRIPTION + This command prints partial match information for a selected + production. If issued at the end of the Decision Phase, it + also prints the current set of productions that are about to + fire or retract in the next preference phase. This informa- + tion is useful for determining what changes to working + memory are necessary in order to achieve a match of the + left-hand sides of productions. + + If no production name is given, then it is assumed that the + user desires information about the match set, including both + assertions and retractions. + + +OPTIONS + Normally both assertions and retractions are printed by the + matches command. This can be restricted using one of the + following options: + + -assertions + List only those productions about to fire + + -retractions + List only those productions about to retract + + The optional detail specifies the kind of information + desired and must be one of the following (the 0 option is + the default): + + -count or -names or 0 + Print just the partial match counts. If the match set + is being printed, then print just the production names. + + -timetags or 1 + Print the same information as the -count option plus + the timetags of wmes at the the first failing condition + + -wmes or 2 + Print the same information as the -timetags option + + + +Soar Last change: 1 + + + + + + +matches(n) Soar Commands matches(n) + + + + except print the full wmes rather than just their time- + tags + + +EXAMPLES + This example prints the productions which are about to fire + and the wmes that match the productions on their left-hand + sides: + + matches -assertions -wmes +9 + This example prints the wme timetags for a single produc- + tion. This example takes advantage of the unique prefix + abbreviation feature of switches. + + matches -t my*first*production +9 +WARNINGS + In Soar 8, the Decision Phase occurs in the middle of the + Decision Cycle, followed by the Apply Phase. Therefore, at + the end of the Decision Cycle, productions will have already + fired and the "matches" command will not be very helpful. + To examine the match information in immediately after the + Decision Phase in Soar 8, users can implement either of the + following callbacks: + + monitor -add {matches -wmes} after-decision-phase-cycle +9 + monitor -add {stop-soar -self} after-decision-phase-cycle +9 + The first example can use any options to the matches com- + mand, whatever the user finds most helpful. The second + option, which stops Soar at the end of the Decision Phase, + offers the most flexibility for debugging. It is recom- + mended that users issue this callback for all agents, so + they don't get out of synch when running. Once the produc- + tions have been debugged, the monitors can be deleted. + + +SEE ALSO + monitor + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/max-chunks.n b/soar-8.5.2/doc/cat/max-chunks.n new file mode 100644 index 0000000..40fba9c --- /dev/null +++ b/soar-8.5.2/doc/cat/max-chunks.n @@ -0,0 +1,131 @@ + + + +max-chunks(n) Soar Commands max-chunks(n) + + + +_________________________________________________________________ + +NAME + max-chunks - Set or list the maximum chunk count + +SYNOPSIS + max-chunks [_c_o_u_n_t] +_________________________________________________________________ + + +DESCRIPTION + This command sets and prints the maximum number of chunks + that can be created in a single decision cycle. If _c_o_u_n_t is + not given, this command prints the maximum number of chunks + that can be created. If _c_o_u_n_t is given, it must be a posi- + tive integer and is used to reset the number of chunks + allowed. + + The "max-chunks" parameter controls the maximum number of + chunks that can be created in a single decision cycle. + After this limit has been reached in a decision cycle, Soar + proceeds to decision phase even if quiescence hasn't really + been reached yet. The default initial setting of the "max- + chunks" parameter is 50. + + In Soar8, chunks may be built during both the Propose Phase + or the Apply Phase. If Soar8 builds more than the max- + chunks limit in either of these phases, Soar8 proceeds to + the next phase (either Decision or Output) even if quies- + cence has not been reached. + + If max-chunks are reached, and Soar moves on to the next + phase, a warning message is printed. + +EXAMPLES + The command issued with no arguments, returns the maximum + chunk count: + + max-chunks +9 + The next example makes use of Tcl command abbreviation while + setting the max-chunks to 100: + + max-c 100 +9 + + +VARIABLE + Note that the commandname uses dashes to separate the words. + There is also a Soar variable "max_chunks" (with under- + scores) that can be used to set the chunk limit through the + + + +Soar Last change: 1 + + + + + + +max-chunks(n) Soar Commands max-chunks(n) + + + + the Tcl _s_e_t command. If _c_o_u_n_t is not given, 'set + max_chunks' prints the maximum number of chunks that can be + created. If _c_o_u_n_t is given, it must be a positive integer + and is used to reset the number of chunks allowed. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/max-elaborations.n b/soar-8.5.2/doc/cat/max-elaborations.n new file mode 100644 index 0000000..42281b8 --- /dev/null +++ b/soar-8.5.2/doc/cat/max-elaborations.n @@ -0,0 +1,131 @@ + + + +max-elaborations(n) Soar Commands max-elaborations(n) + + + +_________________________________________________________________ + +NAME + max-elaborations - Set or list the maximum elaborations + allowed + +SYNOPSIS + max-elaborations [_c_o_u_n_t] +_________________________________________________________________ + + +DESCRIPTION + This command sets and prints the maximum number of elabora- + tion cycles allowed. If _c_o_u_n_t is not given, this command + prints the current number of elaboration cycles allowed. If + _c_o_u_n_t is given, it must be a positive integer and is used to + reset the number of allowed elaboration cycles. + + The "max-elaborations" parameter controls the maximum number + of elaborations allowed in a single decision cycle. After + this limit has been reached, Soar moves on to the next phase + and a warning message is printed. The default initial set- + ting of the "max-elaborations" parameter is 100. + + In Soar8, max-elaborations is checked during both the Pro- + pose Phase and the Apply Phase. If Soar8 runs more than the + max-elaborations limit in either of these phases, Soar8 + proceeds to the next phase (either Decision or Output) even + if quiescence has not been reached. + +EXAMPLES + The command issued with no arguments, returns the max ela- + borations allowed: + + max-elaborations +9 + The next example makes use of Tcl command abbreviation while + setting the maximum value to 50: + + max-e 50 +9 + +VARIABLE + Note that the commandname uses dashes to separate the words. + There is also a Soar variable "max_elaborations" (with + underscores) that can be used to set the limit through the + the Tcl _s_e_t command. If _c_o_u_n_t is not given, 'set + max_elaborations' prints the current number of elaboration + cycles allowed. If _c_o_u_n_t is given, it must be a positive + integer and is used to reset the number of allowed elabora- + tion cycles. + + + +Soar Last change: 1 + + + + + + +max-elaborations(n) Soar Commands max-elaborations(n) + + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/max-nil-output-cycles.n b/soar-8.5.2/doc/cat/max-nil-output-cycles.n new file mode 100644 index 0000000..7acc500 --- /dev/null +++ b/soar-8.5.2/doc/cat/max-nil-output-cycles.n @@ -0,0 +1,131 @@ + + + +max-nil-output-cycles(n) Soar Commands max-nil-output-cycles(n) + + + +_________________________________________________________________ + +NAME + max-nil-output-cycles - Set or list the maximum number of + empty output cycles allowed when doing run-til-output-generated + +SYNOPSIS + max-nil-output-cycles [_c_o_u_n_t] +_________________________________________________________________ + + +DESCRIPTION + This command sets and prints the maximum number of nil out- + put cycles (output cycles that put nothing on the output + link) allowed when running using run-til-output-generated + (_r_u_n _o_u_t). If _c_o_u_n_t is not given, this command prints the + current number of nil-output-cycles allowed. If _c_o_u_n_t is + given, it must be a positive integer and is used to reset + the maximum number of allowed nil output cycles. + + The "max-nil-output-cycles" parameter controls the maximum + number of output cycles that generate no output allowed when + a _r_u_n _o_u_t command is issued. After this limit has been + reached, Soar stops. The default initial setting of the + "max-nil-output-cycles" parameter is 15. + +EXAMPLES + The command issued with no arguments, returns the max empty + output cycles allowed: + + max-nil-output-cycles +9 + The next example makes use of Tcl command abbreviation while + setting the maximum value to 25: + + max-nil 25 +9 + +VARIABLE + Note that the commandname uses dashes to separate the words. + There is also a Soar variable "max_nil_output_cycles" (with + underscores) that can be used to set the limit through the + the Tcl _s_e_t command. If _c_o_u_n_t is not given, 'set + max_nil_output_cycles prints the current number of consecu- + tive nil output cycles allowed. If _c_o_u_n_t is given, it must + be a positive integer and is used to reset the number of + allowed nil output cycles. + + + + + + + +Soar Last change: 1 + + + + + + +max-nil-output-cycles(n) Soar Commands max-nil-output-cycles(n) + + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/max_chunks.n b/soar-8.5.2/doc/cat/max_chunks.n new file mode 100644 index 0000000..65320d9 --- /dev/null +++ b/soar-8.5.2/doc/cat/max_chunks.n @@ -0,0 +1,66 @@ + + + +max_chunks(n) Soar Commands max_chunks(n) + + + +_________________________________________________________________ + +NAME + max_chunks - Set or list the maximum chunk count + +SYNOPSIS + set max_chunks [_c_o_u_n_t] +_________________________________________________________________ + + +DESCRIPTION + max_chunks is a Soar variable which, through the Tcl _s_e_t + command, sets and prints the maximum number of chunks that + can be created in one decision cycle. If _c_o_u_n_t is not + given, 'set max_chunks' prints the maximum number of chunks + that can be created. If _c_o_u_n_t is given, it must be a posi- + tive integer and is used to reset the number of chunks + allowed. + + The "max_chunks" parameter controls the maximum number of + chunks that can be created in a single decision cycle. + After this limit has been reached in a decision cycle, Soar + proceeds to decision phase even if quiescence hasn't really + been reached yet. The default initial setting of the + "max_chunks" variable is 50. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/max_elaborations.n b/soar-8.5.2/doc/cat/max_elaborations.n new file mode 100644 index 0000000..f665279 --- /dev/null +++ b/soar-8.5.2/doc/cat/max_elaborations.n @@ -0,0 +1,66 @@ + + + +max_elaborations(n) Soar Commands max_elaborations(n) + + + +_________________________________________________________________ + +NAME + max_elaborations - Set or list the maximum elaborations + allowed + +SYNOPSIS + set max_elaborations [_c_o_u_n_t] +_________________________________________________________________ + + +DESCRIPTION + max_elaborations is a Soar variable which, through the Tcl + _s_e_t command, sets and prints the maximum number of elabora- + tion cycles allowed. If _c_o_u_n_t is not given, 'set + max_elaborations' prints the current number of elaboration + cycles allowed. If _c_o_u_n_t is given, it must be a positive + integer and is used to reset the number of allowed elabora- + tion cycles. + + The "max_elaborations" parameter controls the maximum number + of elaborations allowed in a single decision cycle. After + this limit has been reached in a decision cycle, Soar + proceeds to decision phase even if quiescence hasn't really + been reached yet. The default initial setting of the + "max_elaborations" parameter is 100. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/memories.n b/soar-8.5.2/doc/cat/memories.n new file mode 100644 index 0000000..d0916ad --- /dev/null +++ b/soar-8.5.2/doc/cat/memories.n @@ -0,0 +1,66 @@ + + + +memories(n) Soar Commands memories(n) + + + +_________________________________________________________________ + +NAME + memories - Print partial match memory usage + +SYNOPSIS + memories [_p_r_o_d_u_c_t_i_o_n-_n_a_m_e | _c_o_u_n_t | -chunk | -user | + -default | -justification] +_________________________________________________________________ + + +DESCRIPTION + This command prints information about memory use, in tokens, + of partial matches of productions. With no options, memory + use of all productions is printed. Other options indicate a + subset of the productions. + + +OPTIONS + If given, an option must match one of the following forms: + + _p_r_o_d_u_c_t_i_o_n-_n_a_m_e + print memory usage of the production named _p_r_o_d_u_c_t_i_o_n- + _n_a_m_e + + _c_o_u_n_t + for all specified groups (chunk, default, user, and/or + justification) print usage information on only _c_o_u_n_t of + each. + + -chunk + print memory usage of chunks + + -user + print memory usage of user productions + + -default + print memory usage of the default productions + + -justification + print memory usage of justifications + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/monitor.n b/soar-8.5.2/doc/cat/monitor.n new file mode 100644 index 0000000..e265e9a --- /dev/null +++ b/soar-8.5.2/doc/cat/monitor.n @@ -0,0 +1,326 @@ + + + +monitor(n) Soar Commands monitor(n) + + + +_________________________________________________________________ + +NAME + monitor - Manage attachment of scripts to Soar events + +SYNOPSIS + monitor _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command manages the attachment of scripts to Soar + events. Soar events are important events that occur in Soar + as an agent is being processed. Scripts can be attached to + these Soar events so that they are invoked every time the + Soar event occurs. These scripts can also be removed using + the monitor command. The status of attachments can be listed + and tested. If a new attachment is created, its identifier + is returned as the result of this command. The identifier + is used when deleting a script from an event. + + The specified _a_c_t_i_o_n must have one of the following forms: + + -add _s_o_a_r-_e_v_e_n_t _s_c_r_i_p_t [_i_d] + Add the _s_c_r_i_p_t to the list of scripts to be invoked + when the _s_o_a_r-_e_v_e_n_t occurs in the Soar kernel. See + below for a list of valid Soar event names. If the _i_d + is given, it is used to name the attachment. If no _i_d + is given, then a unique id is generated and returned. + + -delete _s_o_a_r-_e_v_e_n_t [_i_d] + Remove scripts attached to _s_o_a_r-_e_v_e_n_t. The _s_o_a_r-_e_v_e_n_t + must match a valid Soar event name (see below). If _i_d + is given after a _s_o_a_r-_e_v_e_n_t, then only that particular + attachment is removed. Otherwise, all attachments + under _s_o_a_r-_e_v_e_n_t are removed. + + -list + List all attachments of scripts to Soar events + + -test + Test the script attachment process by attaching a print + message to every Soar event. + + -clear + Remove _a_l_l attached scripts. + +EXAMPLES + This command creates an attachment which prints a message + after every Soar decision cycle: + + monitor -add after-decision-cycle {puts "Finished DC!"} + + + +Soar Last change: 1 + + + + + + +monitor(n) Soar Commands monitor(n) + + + + This example creates an attachment which calls the Tcl pro- + cedure "DoSomething" (presumably user-defined) after every + production firing: + + monitor -add firing DoSomething +9 + This example creates an attachment which processes pending X + events after every decision cycle. This is needed in long- + running Soar agents so that GUIs do not appear frozen: + + monitor -add after-decision-cycle update +9 + This example adds an attachment which ticks a simulator + after each agent has completed a cycle in the Soar + scheduler. Note that this example command is executed in + the global agent's interpreter so that the simulator is + ticked only once per schedule cycle. The "TickSimulator" + command would be defined by the user. + + monitor -add after-schedule-cycle TickSimulator +9 + This example adds an attachment that could be used to inform + the Soar development tool SDE that an agent has been + selected for scheduling. SDE expects certain strings in + Soar output and uses them to control some SDE operations. + + monitor -add before-schedule-cycle {puts "0electing agent $soar_agent_name"} +9 + This example removes the single attachment "m1" which asso- + ciates a script with the Soar event after-init-agent: + + monitor -delete after-init-agent m1 +9 + This example removes all script attachments to the Soar + event before-preference-phase-cycle: + + monitor -delete before-preference-phase-cycle +9 + This example removes all script attachments that have been + added with the monitor command: + + monitor -clear +9 +SOAR EVENTS + This command utilizes the Soar callback system which can + associate TCL or C functions with Soar events. The permiss- + able Soar event names are: + + system-termination + + + +Soar Last change: 2 + + +9 + + +monitor(n) Soar Commands monitor(n) + + + + The Soar system is exiting. + + after-init-agent + + An agent has just been created and initialized. + + before-init-soar + + The agent is about to be initialized. The init-soar + command will generate this event. + + after-init-soar + + The agent has just been initialized. The init-soar + command will generate this event. + + + after-halt-soar + + The agent has just been halted. + + before-schedule-cycle + + This event is triggered by the schedule command. In + the global control agent, this event is triggered + before each schedule cycle starts. In other agents, + this event is triggered during the schedule cycle, just + before the agent is run. + + after-schedule-cycle + + This event is triggered by the schedule command. In + the global control agent, this event is triggered just + after each schedule cycle ends. In other agents, this + event is triggered during the schedule cycle, just + after the agent is run. + + before-decision-cycle + + A decision cycle is just about to start. + + after-decision-cycle + + A decision cycle has just ended. + + before-input-phase + + An input phase is just about to start. + + after-input-phase + + An input phase has just ended. + + + +Soar Last change: 3 + + + + + + +monitor(n) Soar Commands monitor(n) + + + + before-preference-phase-cycle + + A preference phase is just about to begin. + + after-preference-phase-cycle + + A preference phase has just ended. + + before-wm-phase-cycle + + A working memory phase is just about to begin. + + after-wm-phase-cycle + + A working memory phase is just about to begin. + + before-output-phase + + An output phase is just about to begin. + + after-output-phase + + An output phase has just ended. + + before-decision-phase-cycle + + A decision phase is about to begin. + + after-decision-phase-cycle + + A decision phase has just ended. + + wm-changes + + Changes to working memory have just completed. + + create-new-context + + A new state has been created on the goal stack. + + pop-context-stack + + A subgoal has finished. + + create-new-attribute-impasse + + A new attribute impasse has occurred. + + remove-attribute-impasse + + An attribute impasse has been removed. + + + + +Soar Last change: 4 + + + + + + +monitor(n) Soar Commands monitor(n) + + + + production-just-added + + A productions has just been added to the agent. + + + production-just-about-to-be-excised + + A production is just about to be removed from the + agent. + + firing + + A production instantiation has just fired. + + + retraction + + A production instantiation is just about to retract. + + system-parameter-changed + + A system parameter has just been changed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 5 + + + diff --git a/soar-8.5.2/doc/cat/multi-attributes.n b/soar-8.5.2/doc/cat/multi-attributes.n new file mode 100644 index 0000000..69dcf31 --- /dev/null +++ b/soar-8.5.2/doc/cat/multi-attributes.n @@ -0,0 +1,66 @@ + + + +multi-attributes(n) Soar Commands multi-attributes(n) + + + +_________________________________________________________________ + +NAME + multi-attributes - Declare a symbol to be multi-attributed + +SYNOPSIS + multi-attributes [_s_y_m_b_o_l [_n]] +_________________________________________________________________ + + +DESCRIPTION + This command declares the given _s_y_m_b_o_l to be an attribute + which can take on multiple values. The optional _n is an + integer (>1) indicating an upper limit on the number of + expected values that will appear for an attribute. If _n is + not specified, the value 10 is used for each declared + multi-attribute. More informed values will tend to result + in greater efficiency. + + + This command is used _o_n_l_y to provide hints to the production + condition reorderer so it can produce better condition ord- + erings. Better orderings enable the Rete network to run + faster. This command has no effect on the actual contents + of working memory and most users needn't use this at all. + + +WARNING + Note that multi-attributes declarations must be made _b_e_f_o_r_e + productions are loaded into production + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/o-support-mode.n b/soar-8.5.2/doc/cat/o-support-mode.n new file mode 100644 index 0000000..09fc217 --- /dev/null +++ b/soar-8.5.2/doc/cat/o-support-mode.n @@ -0,0 +1,66 @@ + + + +o-support-mode(n) Soar Commands o-support-mode(n) + + + +_________________________________________________________________ + +NAME + o-support-mode - Control O-support calculations + +SYNOPSIS + o-support-mode 0|1|2 +_________________________________________________________________ + + +DESCRIPTION + This command controls the way o-support calculations are + done for the agent. The o-support calculation mode must be + one of the following choices: + + 0 Do o-support calculations the Soar 6 way + + 1 Do o-support calculations the Soar 6 way, but print a + warning message whenever a preference is created that + would get different support under Doug Pearson's propo- + sal. + + 2 Do o-support calculations according to Doug Pearson's + proposal. + + +VARIABLE + Note that the command name uses dashes to separate the + words. There is also a Soar command "o_support_mode" (with + underscores) that can be used to set the mode through the + the Tcl _s_e_t command. If the mode is not specified, 'set + o_support_mode' prints the current mode. If the mode is + specified, it must have a value of 0, 1 or 2 as above. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/o_support_mode.n b/soar-8.5.2/doc/cat/o_support_mode.n new file mode 100644 index 0000000..dcf80f3 --- /dev/null +++ b/soar-8.5.2/doc/cat/o_support_mode.n @@ -0,0 +1,66 @@ + + + +o_support_mode(n) Soar Commands o_support_mode(n) + + + +_________________________________________________________________ + +NAME + o_support_mode - Control O-support calculations + +SYNOPSIS + set o_support_mode [0|1|2] +_________________________________________________________________ + + +DESCRIPTION + o_support_mode is a Soar variable which, through the Tcl _s_e_t + command, controls the way o-support calculations are done + for the agent. If the mode is not specified, 'set + o_support_mode' prints the current mode. The o-support cal- + culation mode must be one of the following choices: + + 0 Do o-support calculations the Soar 6 way + + 1 Do o-support calculations the Soar 6 way, but print a + warning message whenever a preference is created that + would get different support under Doug Pearson's propo- + sal. + + 2 Do o-support calculations according to Doug Pearson's + proposal. + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/output-strings-destination.n b/soar-8.5.2/doc/cat/output-strings-destination.n new file mode 100644 index 0000000..18f22d9 --- /dev/null +++ b/soar-8.5.2/doc/cat/output-strings-destination.n @@ -0,0 +1,195 @@ + + + +output-strings-destination(n)Soar Commandsoutput-strings-destination(n) + + + +_________________________________________________________________ + +NAME + output-strings-destination - Specify destination of print + actions + +SYNOPSIS + output-strings-destination _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command redirects the printing of output strings. This + is useful for applications which need to change where + printed results are placed. Printed output is normally sent + to standard output. However, if a Graphical User Interface + (GUI) is being used in place of the command line inter- + preter, then printed output should appear in the GUI. GUIs + are composed of elements called "widget"s and printed output + would be directed to a "text widget", or procedure. + + Printed output is normally sent to standard output which is + an open file descriptor in UNIX. Printed output can be sent + to any other open file descriptor as well, such as an open + file or pipe. It is also possible that the user is not + interested in an agent's printed output. In that case, the + printed output can be discarded -- which results in faster + processing for the agent as well. + + Some Soar commands return results and some print results. + If the user wishes to have printed results returned so that + they can be saved for later use, then this command can setup + the agent to append the printed output to the normal result. + This capability is also useful when sending Soar commands + from remote Tcl/Tk interpreters. By appending the printed + results, all printed characters can be returned to the + remote interpreter rather than going to a screen. + + The printing facility is implemented as a stack, so newly + installed print redirections are in force until popped off + the stack. This is done to allow easy transient redirection + and the restoration of prior printing contexts after com- + pleting a printing task. Hence, there are two primary + _a_c_t_i_o_ns, -push and -pop. The -pop action takes no addi- + tional arguments as it serves only to pop the print- + redirection stack to re-establish the prior printing con- + text. The -push action takes the following additional argu- + ments: + + -append-to-result + Instead of printing, append the output string to the + result returned by a command. This option is useful + + + +Soar Last change: 1 + + + + + + +output-strings-destination(n)Soar Commandsoutput-strings-destination(n) + + + + for getting all the output when the command is invoked + remotely. + + -channel _o_p_e_n-_f_i_l_e-_i_d + Redirect prints to the open channel (file or pipe) + denoted by _o_p_e_n-_f_i_l_e-_i_d + + -discard + Ignore prints (similar to redirecting to /dev/null in + the Bourne shell, sh) + + -procedure _p_r_o_c-_n_a_m_e + Redirect prints to the Tcl procedure named _p_r_o_c-_n_a_m_e in + the current interpreter. Tk widgets are also pro- + cedures, so this action sends output to widget pro- + cedures (or any other Tcl procedure). + + -text-widget _w_i_d_g_e_t-_n_a_m_e [_i_n_t_e_r_p-_n_a_m_e] + Redirect prints to the text widget named _w_i_d_g_e_t-_n_a_m_e in + the current interpreter. If _i_n_t_e_r_p-_n_a_m_e is specified, + then prints are redirected to the text widget named + _w_i_d_g_e_t-_n_a_m_e in the interpreter named _i_n_t_e_r_p-_n_a_m_e. + + +EXAMPLES + This example redirects prints to the text widget ".text": + + output-strings-destination -push -text-widget .text +9 + This example redirects prints to the text widget ".textual" + in the interpreter named control: + + output-strings-destination -push -text-widget .textual control +9 + This example redirects prints to the open file "stdout": + + output-strings-destination -push -file-id stdout +9 + This example causes all printing to be supressed: + + output-strings-destination -push -discard +9 + This example removes the most recently added print destina- + tion: + + output-strings-destination -pop +9 + + +9 + + +Soar Last change: 2 + + + + + + +output-strings-destination(n)Soar Commandsoutput-strings-destination(n) + + + +WARNINGS + This command only affects the printing generated by Soar + commands such as print and echo. It does not affect print- + ing done by the Tcl commands such as puts. + + +SEE ALSO + echo, print, log + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 3 + + + diff --git a/soar-8.5.2/doc/cat/popd.n b/soar-8.5.2/doc/cat/popd.n new file mode 100644 index 0000000..7a8c3d9 --- /dev/null +++ b/soar-8.5.2/doc/cat/popd.n @@ -0,0 +1,66 @@ + + + +popd(n) Soar Commands popd(n) + + + +_________________________________________________________________ + +NAME + popd - Pop a directory off the directory stack + +SYNOPSIS + popd +_________________________________________________________________ + + +DESCRIPTION + This command pops a directory off of the directory stack and + cd's to it. See the dirs command for an explanation of the + directory stack. + + +SEE ALSO + pushd, dirs, topd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/predefined-aliases.n b/soar-8.5.2/doc/cat/predefined-aliases.n new file mode 100644 index 0000000..955dc96 --- /dev/null +++ b/soar-8.5.2/doc/cat/predefined-aliases.n @@ -0,0 +1,264 @@ + + + +predefined-aliases(n) Soar Commands predefined-aliases(n) + + + +_________________________________________________________________ + +NAME + Soar predefined-aliases + + +DESCRIPTION + There are a number of command aliases that are provided by + Soar. These are used to provide short versions of built in + commands and to provide syntactic continuity with previous + versions of Soar. Soar provides a predefined set of aliases + that will be useful to most users. + + These aliases are equivalent to an existing built in command + and (possibly) a set of switches for the command. Addi- + tional arguments given after the alias are passed on to the + built in command. + + The predefined aliases in $soar_library/soar.tcl are: + + ? A short form of the help command. + + d A short form of the run 1 d command. + + e A short form of the run 1 e command. + + pf A short form of the production-find command. + + step A short form of the run 1 d command. This was + added because the TSI provides a "step" command, + and it seemed silly to not allow the same "com- + mand" when running Soar without the TSI. + + wmes Prints the contents of working memory. It is + equivalent to print -depth 0 -internal, therefore + an identifier, integer, or wme pattern must be + specified. (see "help print" for more info). + + Additional aliases are defined in $soar_library/soar7.2km- + aliases.tcl. These aliases were derived by Frank Ritter + using commonly used and psychologically supported rules, + computed to save users time and errors. The rules are based + on the keystroke model and designed to be learned by a com- + mand name rule. + + + + Most of the aliases are generated with a rule: + + If there are multiple words, use their first letters + (29 commands with some exceptions, the most common + being indifferent-selection:inds) + + + +Soar Last change: 1 + + + + + + +predefined-aliases(n) Soar Commands predefined-aliases(n) + + + + If there is a single long word (6 letters or more), use the + first two letters (8 commands, 0 exceptions) + + If there is a short word, use the first letter + (14 commands with 6 exceptions, none common) + + The predefined aliases are: + + a Equivalent to alias. + + aw Equivalent to add-wme. + + cnf Equivalent to chunk-name-format. + + ctf Equivalent to command-to-file. + + ea Equivalent to excise -all. + + eb Equivalent to explain-backtraces. + + ec Equivalent to excise -chunk. + + et Equivalent to excise -task. + + ex Equivalent to excise. + + fc Equivalent to firing-counts. + + fw Equivalent to format-watch. + + h Equivalent to help. + + ha Equivalent to help -all. + + help-all + Equivalent to help -all. + + inds Equivalent to indifferent-selection. + + ip Equivalent to input-period. + + is Equivalent to init-soar. + + l Equivalent to learn. + + m Equivalent to matches. + + osd Equivalent to output-string-destination. + + p Equivalent to print. + + pc Equivalent to print -chunks. + + + +Soar Last change: 2 + + + + + + +predefined-aliases(n) Soar Commands predefined-aliases(n) + + + + pf Equivalent to production-find. + + pr Equivalent to preferences. + + ps Equivalent to print -stack. + + pw Equivalent to pwatch. + + r Equivalent to run. + + rn Equivalent to rete-net. + + rw Equivalent to remove-wme. + + s Equivalent to source. + + sn Equivalent to soarnews. + + soar-news + Equivalent to soarnews. + + ss Equivalent to stop-soar. + + st Equivalent to stats. + + un Equivalent to unalias. + + w Equivalent to watch. + + + + See the file itself (soar7.2km-aliases.tcl in $soar_library) + for more detailed information. + +NOTES + Tcl and the TSI, when running in interactive mode, also sup- + port command abbreviation: as long as a unique prefix of a + command is specified, it will be recognized and the matching + command will be executed. For example, "wat" is enough to + completely specify the "watch" command. + + +WARNINGS + Aliases should NEVER appear in files. They may be changed + or not loaded by other users, and will not be as clear as + the full command names. + + + + + + + + + +Soar Last change: 3 + + + + + + +predefined-aliases(n) Soar Commands predefined-aliases(n) + + + +FILES + All alias definition files are in the Soar Tcl library + directory. The predefined aliases are included in the + startup file soar.tcl and in soar7.2km-aliases.tcl. The + aliases are loaded in a Soar interpreter automatically when + it is created. + + +SEE ALSO + alias, print + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/preferences.n b/soar-8.5.2/doc/cat/preferences.n new file mode 100644 index 0000000..184905b --- /dev/null +++ b/soar-8.5.2/doc/cat/preferences.n @@ -0,0 +1,65 @@ + + + +preferences(n) Soar Commands preferences(n) + + + +_________________________________________________________________ + +NAME + preferences - Print slot preferences + +SYNOPSIS + preferences [_i_d] [[^]_a_t_t_r_i_b_u_t_e] [ _0 | _1 | _2 | _3 ] + + preferences [_i_d] [[^]_a_t_t_r_i_b_u_t_e] [ -_n_o_n_e | -_n_a_m_e_s | -_t_i_m_e_t_a_g_s + | -_w_m_e_s ] +_________________________________________________________________ + + +DESCRIPTION + This command prints all the preferences for the given slot + (i.e., object and attribute). The _i_d and _a_t_t_r_i_b_u_t_e indicate + the slot of interest. If they are not specified, they + default to the current state and the current operator. The + '^' is optional when specifying the attribute. The optional + arguments indicates the level of detail to print about each + preference. + + +OPTIONS + The optional _d_e_t_a_i_l must have one of the following values: + + -none or 0 + Print just the preferences themselves + + -names or 1 + Print the preferences and the names of the productions + that generated them + + -timetags or 2 + Print the information for the -names option above plus + the timetags of the wmes matched by the indicated pro- + ductions + + -wmes or 3 + Print the information for the -timetags option above + plus the entire wme. + + If no _d_e_t_a_i_l is given, then the -none option is used. + +EXAMPLES + This example prints the preferences on the S1 operator slot + and the production names which created the preferences: + + preferences S1 operator -names +9 + +9 + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/print.n b/soar-8.5.2/doc/cat/print.n new file mode 100644 index 0000000..57141cf --- /dev/null +++ b/soar-8.5.2/doc/cat/print.n @@ -0,0 +1,197 @@ + + + +print(n) Soar Commands print(n) + + + +_________________________________________________________________ + +NAME + print - Print a Soar item from production memory or working + memory + +SYNOPSIS + print -stack [ -state | -operator ]* + print [-depth _n] [-internal] { _i_d_e_n_t_i_f_i_e_r | _i_n_t_e_g_e_r | _p_a_t_- + _t_e_r_n} + print [-internal] [-name|-full] { _p_r_o_d_n_a_m_e | -_a_l_l | -_c_h_u_n_k_s + | -_d_e_f_a_u_l_t_s | -_j_u_s_t_i_f_i_c_a_t_i_o_n_s | -_u_s_e_r} +_________________________________________________________________ + + +DESCRIPTION + The print command is used to print items from production + memory or working memory. It can take several kinds of + arguments. When printing items from working memory, the + Soar objects are printed unless the -internal flag is used, + in which case the wmes themselves are printed. + The _i_t_e_ms to be printed may be one of the following: + + _p_r_o_d_u_c_t_i_o_n-_n_a_m_e + print the production named _p_r_o_d_u_c_t_i_o_n-_n_a_m_e + + -_a_l_l print the names of all productions currently loaded + + -_c_h_u_n_k_s + print the names of all chunks currently loaded + + -_d_e_f_a_u_l_t_s + print the names of all default productions currently + loaded + + -_j_u_s_t_i_f_i_c_a_t_i_o_n_s + print the names of all justifications currently loaded + + -_u_s_e_r + print the names of all user productions currently + loaded + + _i_d_e_n_t_i_f_i_e_r + print the object _i_d_e_n_t_i_f_i_e_r. _i_d_e_n_t_i_f_i_e_r must be a + valid Soar symbol. + + _i_n_t_e_g_e_r + print the object in working memory with the timetag + _i_n_t_e_g_e_r + + _p_a_t_t_e_r_n + print the object whose working memory elements matching + + + +Soar Last change: 1 + + + + + + +print(n) Soar Commands print(n) + + + + the given _p_a_t_t_e_r_n. The pattern is interpreted by the + Soar kernel so it must be surrounded by curly braces or + double quotes to avoid being parsed by Tcl. A _p_a_t_t_e_r_n + has the following form: + + (_i_d_e_n_t_i_f_i_e_r ^_a_t_t_r_i_b_u_t_e _v_a_l_u_e [+]) +9 + The _p_a_t_t_e_r_n is surrounded by parentheses. The _i_d_e_n_t_i_f_i_e_r, + _a_t_t_r_i_b_u_t_e, and _v_a_l_u_e must be valid Soar symbols or the wild- + card symbol * which matches all occurences. The optional + + symbol restricts pattern matches to acceptable preferences. + + +OPTIONS + All options apply only to arguments which follow them on the + command line. + + -depth _n + This option overrides the default printing depth (see + the default-print-depth command for more detail). Note + that a -depth 0 argument is meaningful only with accom- + panying integer and pattern arguments. It causes only + the matching working memory elements to be printed, + instead of all elements whose identifier is an identif- + ier in one of the matching working memory elements. + + -internal + Specifies that items should be printed in their inter- + nal form. For productions, this means leaving condi- + tions in their reordered (rete net) form. For working + memory, this means printing the individual elements + with their timetags, rather than the objects. + + -full + When printing productions, print the whole production. + This is the default when printing a named production. + + -name + When printing productions, print only the name and not + the whole production. This is the default when print- + ing any catorgory of productions, as opposed to a named + production. + + -stack + Specifies that the Soar goal stack should be printed. + By default this includes both states and operators. + The stack listing can be restricted by adding the + -states and -operator restrictions. Giving both + options is equivalent to the default. The predefined + alias 'ps' is the same as print -stack. + +9 + + +Soar Last change: 2 + + + + + + +print(n) Soar Commands print(n) + + + +EXAMPLES + print -internal {(s1 ^* v2)} + Print the working memory elements (and their timetags) + which have the identifier s1 as object and v2 as value. + + print -stack + Print the Soar stack which includes states and opera- + tors. + + print -internal -full prodname + Print the named production in its RETE form. + + print -user + Print the names of all user productions currently + loaded. + + +WARNINGS + The order of options and arguments to the print command do + matter: options apply only to arguments which follow them. + + + print -chunks -full + prints only the names of chunks, while + + print -full -chunks + prints the entire chunk for all chunks. + + +SEE ALSO + default-wme-depth, predefined-aliases + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 3 + + + diff --git a/soar-8.5.2/doc/cat/production-find.n b/soar-8.5.2/doc/cat/production-find.n new file mode 100644 index 0000000..0eabdd3 --- /dev/null +++ b/soar-8.5.2/doc/cat/production-find.n @@ -0,0 +1,130 @@ + + + +production-find(n) Soar Commands production-find(n) + + + +_________________________________________________________________ + +NAME + production-find - Find matching Soar productions + +SYNOPSIS + production-find [-lhs | -rhs] [-show-bindings] [-chunks | + -no-chunks] {_p_a_t_t_e_r_n} +_________________________________________________________________ + + +DESCRIPTION + The production-find command is used to find Soar productions + by matching a given _p_a_t_t_e_r_n against the production com- + ponents. Productions may be found that test a particular + left-hand side pattern or produce particular right-hand side + preferences. For convenience, the production-find command + has the predefined alias pf. + + +OPTIONS + If given, an option must match one of the following choices: + + -lhs The following _p_a_t_t_e_r_n applies to the left-hand side of + productions. This is the default. + + -rhs The following _p_a_t_t_e_r_n applies to the right-hand side of + productions. + + -show-bindings + Show the bindings associated with the following _p_a_t_- + _t_e_r_n. + + -chunks + Search only for chunks (learned productions) that match + the following _p_a_t_t_e_r_n. + + -nochunks + Search all productions _e_x_c_e_p_t chunks that match the + following _p_a_t_t_e_r_n. + + The syntax of _p_a_t_t_e_r_n is exactly the syntax of a sequence of + clauses within a Soar production. In addition, the symbol * + may be used as a wildcard for an attribute or value. Note + that variables names do not have to match the specific names + used in productions. + +EXAMPLES + Find productions that test that some object gumby has an + attribute alive with value t. In addition, limit the rules + to only those that test an operator named foo: + + + + +Soar Last change: 1 + + + + + + +production-find(n) Soar Commands production-find(n) + + + + production-find {( ^gumby ^operator.name foo)( ^alive t)} +9 + Find productions that propose the operator foo: + + production-find -rhs {( ^operator +)( ^name foo)} +9 + Find chunks that test the attribute ^pokey: + + production-find -chunks {( ^pokey *)} +9 + +WARNINGS + Note that curly braces or double quotes must be used around + the _p_a_t_t_e_r_n to override the normal Tcl parsing. + + +SEE ALSO + sp + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +9 + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/pushd.n b/soar-8.5.2/doc/cat/pushd.n new file mode 100644 index 0000000..d44a054 --- /dev/null +++ b/soar-8.5.2/doc/cat/pushd.n @@ -0,0 +1,66 @@ + + + +pushd(n) Soar Commands pushd(n) + + + +_________________________________________________________________ + +NAME + pushd - Push a directory onto the directory stack + +SYNOPSIS + pushd _d_i_r +_________________________________________________________________ + + +DESCRIPTION + This command pushes the current directory onto the directory + stack and cd's to the given _d_i_r. See the dirs command for + an explanation of the directory stack. + + +SEE ALSO + popd, dirs, topd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/pwatch.n b/soar-8.5.2/doc/cat/pwatch.n new file mode 100644 index 0000000..db3a23a --- /dev/null +++ b/soar-8.5.2/doc/cat/pwatch.n @@ -0,0 +1,66 @@ + + + +pwatch(n) Soar Commands pwatch(n) + + + +_________________________________________________________________ + +NAME + pwatch - Trace production firings and retractions + +SYNOPSIS + pwatch [-on | -off] [_p_r_o_d_u_c_t_i_o_n-_n_a_m_e*] +_________________________________________________________________ + + +DESCRIPTION + This command enables and disables the tracing of production + activity for individual productions. Both firings and + retractions are printed. If no _p_r_o_d_u_c_t_i_o_n-_n_a_m_es are given, + this command lists the productions currently being traced. + If one or more _p_r_o_d_u_c_t_i_o_n-_n_a_m_es are given, tracing is + enabled (or disabled if -off is specified) for those produc- + tions. Tracing persists until disabled or until the produc- + tion is excised. + + This command is orthogonal to the watch productions mechan- + ism. See the watch command for more information. + + +SEE ALSO + excise, watch + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/quit.n b/soar-8.5.2/doc/cat/quit.n new file mode 100644 index 0000000..5a003b8 --- /dev/null +++ b/soar-8.5.2/doc/cat/quit.n @@ -0,0 +1,66 @@ + + + +quit(n) Soar Commands quit(n) + + + +_________________________________________________________________ + +NAME + quit - Quit Soar + +SYNOPSIS + quit +_________________________________________________________________ + + +DESCRIPTION + This command quits Soar. It calls any registered Soar ter- + mination callbacks, closes any open log files, and exits the + process. This also performs any Tcl related cleanup as + would be done for the Tcl exit command. The Tcl exit com- + mand is redefined in Soar to use this command. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/remove-wme.n b/soar-8.5.2/doc/cat/remove-wme.n new file mode 100644 index 0000000..faffe18 --- /dev/null +++ b/soar-8.5.2/doc/cat/remove-wme.n @@ -0,0 +1,66 @@ + + + +remove-wme(n) Soar Commands remove-wme(n) + + + +_________________________________________________________________ + +NAME + remove-wme - Remove an element from working memory + +SYNOPSIS + remove-wme _t_i_m_e_t_a_g +_________________________________________________________________ + + +DESCRIPTION + This command removes an element from Soar's working memory. + The _t_i_m_e_t_a_g must be a positive integer matching the timetag + of an existing working memory element. It is normally used + by the input/output functions to update Soar's world state. + + +WARNINGS + remove-wme should never be called from the RHS: if you try + to match a wme on the LHS of a production, and then remove + the matched wme on the RHS, Soar will crash. + + _T_h_i_s _c_o_m_m_a_n_d _i_s _i_n_h_e_r_e_n_t_l_y _u_n_s_t_a_b_l_e _a_n_d _m_a_y _h_a_v_e _w_e_i_r_d _s_i_d_e + _e_f_f_e_c_t_s (_p_o_s_s_i_b_l_y _e_v_e_n _i_n_c_l_u_d_i_n_g _s_y_s_t_e_m _c_r_a_s_h_e_s). For exam- + ple, the chunker can't backtrace through wmes created via + add-wme. Removing input wmes or context/impasse wmes may + have unexpected side effects. _Y_o_u'_v_e _b_e_e_n _w_a_r_n_e_d. + + +SEE ALSO + add-wme, io + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/replay-input.n b/soar-8.5.2/doc/cat/replay-input.n new file mode 100644 index 0000000..be86f90 --- /dev/null +++ b/soar-8.5.2/doc/cat/replay-input.n @@ -0,0 +1,128 @@ + + + +replay-input(n) Soar Commands replay-input(n) + + + +_________________________________________________________________ + +NAME + replay-input - Replay agent commands from a file during the + appropriate decision cycle + +SYNOPSIS + replay-input _a_c_t_i_o_n +_________________________________________________________________ + + +DESCRIPTION + This command may be used to start and stop the reading of + input function commands from a file created by the + "capture-input" command. The routine replay-input-wme is + registered as an input function to read input wmes from + the file decision cycle by decision cycle. If an EOF is + reached, the file is closed and the callback removed. + Use the command capture-input to create the file. + + The _a_c_t_i_o_n must be one of the following: + + -open _p_a_t_h_n_a_m_e + A log file named _p_a_t_h_n_a_m_e is opened and input replay is + initiated. + + -query + Returns open if replaying is active or closed if + replaying is not active. + + -off Close the input file. + + +EXAMPLES + This opens the input file foo.in and will register the call- + back function to execute the commands decision cycle by + decision cycle: + + replay-input -open foo.in +9 + This terminates replaying (removes the callback) and closes + the open log file: + + replay-input -off +9 + +WARNING + + + + +Soar Last change: 1 + + + + + + +replay-input(n) Soar Commands replay-input(n) + + + +SEE ALSO + capture-input + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/rete-net.n b/soar-8.5.2/doc/cat/rete-net.n new file mode 100644 index 0000000..fe57fac --- /dev/null +++ b/soar-8.5.2/doc/cat/rete-net.n @@ -0,0 +1,66 @@ + + + +rete-net(n) Soar Commands rete-net(n) + + + +_________________________________________________________________ + +NAME + rete-net - Save and restore the Rete net + +SYNOPSIS + rete-net {-_s_a_v_e | -_l_o_a_d} _f_i_l_e_n_a_m_e +_________________________________________________________________ + + +DESCRIPTION + The rete-net command saves and restores the state of the + Rete network. This command provides a fast method of saving + and loading productions since a binary format is used. + rete-net files are portable across platforms that support + Soar. The action must be one of the following: + + -save + Save the Rete network in the given _f_i_l_e_n_a_m_e. The Rete + network cannot be saved while there are justifications + present. These can be eliminated by using the init- + soar command. + + -load + Load the productions stored in _f_i_l_e_n_a_m_e into the Rete + network. In order to load productions stored in binary + form, working memory and production memory must both be + empty. Working memory can be emptied by using the + init-soar command. Production memory can be emptied by + using the excise -all command. + + If the _f_i_l_e_n_a_m_e contains a suffix of ".Z", then the file is + compressed automatically when it is saved and uncompressed + when it is loaded. + + +WARNINGS + Compressed files may not be portable to another platform is + that platform does not support the same uncompress utility. + + +SEE ALSO + excise, init-soar + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/rhsfun.n b/soar-8.5.2/doc/cat/rhsfun.n new file mode 100644 index 0000000..23cbb7c --- /dev/null +++ b/soar-8.5.2/doc/cat/rhsfun.n @@ -0,0 +1,264 @@ + + + +rhs-functions(n) Soar Commands rhs-functions(n) + + + +_________________________________________________________________ + +NAME + Soar righthand side functions + + +DESCRIPTION + Soar supports a number of functions which can appear on the + righthand side of productions. These functions can appear + either as values (such as the "int" of a number), or as + standalone actions (such as "write" or "halt"). The right- + hand side functions can be used to stop or pause Soar, do + text input and output, execute mathematical functions, gen- + erate and manipulate symbols, modify learning, and execute + Tcl commands. + + The Soar User's Manual should be consulted for more informa- + tion on the use of righthand side functions. + + + The available righthand side functions are: + + accept + suspends Soar's execution and waits for the user + to type a constant, followed by a carriage return. + The result of the accept is the constant. + + capitalize-symbol + given a symbol, this function returns a new symbol + with the first character capitalized. + + compute-heading + given 4 args, x1 y1 and x2 y2, this function + returns integer heading from x1,y1 to x2,y2 (Note: + this function is defined in the + interface/rhsfun_examples.c file) + + compute-range + given 4 args, x1 y1 and x2 y2, this function + returns integer range from x1,y1 to x2,y2 (Note: + this function is defined in the + interface/rhsfun_examples.c file) + + crlf short for "carriage return, line feed," this func- + tion can be called only within _w_r_i_t_e. It forces a + newline at its position in the _w_r_i_t_e action. + + dont-learn + when learning is set to _e_x_c_e_p_t, by default chunks + will be formed in all states; the dont-learn RHS + action will cause learning to be turned off for + the state specified in the LHS (condition side) of + + + +Soar Last change: 1 + + + + + + +rhs-functions(n) Soar Commands rhs-functions(n) + + + + the production. + + force-learn + when learning is set to _o_n_l_y, by default chunks + are not formed in any state; the force-learn RHS + action will cause learning to be turned on for the + state specified in the LHS (condition side) of the + production. + + halt terminates the current run, stops Soars execution + and returns to the user prompt. halt should not + be used if the current run is to be restarted. + (see interrupt below.) + + ifeq checks if the first argument is "eq" to the second + argument. if it is, then return the third argu- + ment, else return the fourth argument. Similar to + the "?" notation in C. all four arguments are + required. + + interrupt + causes Soar to stop at the end of the current + phase, and return to the user prompt. Similar to + halt, except the run may be continued. + + make-constant-symbol + returns a new constant symbol which is guaranteed + to be different from all symbols currently present + in the system. with no arguments, it returns a + symbol whose name starts with "constant". With + one or more arguments, it takes those argument + symbols, concatenates their names and uses the + resulting string as the prefix for the new symbol. + + round-off + Given two numbers, this function returns the + first rounded to the nearest second number. + (Note: this function is defined in the + interface/rhsfun_examples.c file) + + round-off-heading + Given two numbers, this function returns the + first rounded to the nearest second number. The + heading is given between -180 and +180 deg. + (Note: this function is defined in the + interface/rhsfun_examples.c file) + + strlen + returns the length of the output string so that + users can get the output to line up nicely. use- + ful with ifeq when the output string varies in + length. + + + +Soar Last change: 2 + + + + + + +rhs-functions(n) Soar Commands rhs-functions(n) + + + + timestamp + returns a symbol whose print name is a representa- + tion of the current date and local time. + + tcl concatenates its arguments into a string which is + sent to the agent's Tcl interpreter for evalua- + tion. It does not automatically insert spaces + between arguments; users must explicitly insert + spaces within vertical bars. + + write + writes its arguments to the user interface. it + does not automatically insert blanks, line feeds, + or carriage returns. It should be used only for + simple monitoring and debugging. + + + prefix notation for addition. If all arguments + are integers, this function returns an integer, + otherwise it returns a real number. + + * prefix notation for multiplication. If all argu- + ments are integers, this function returns an + integer, otherwise it returns a real number. + + - prefix notation for subtraction. If all arguments + are integers, this function returns an integer, + otherwise it returns a real number. + + / prefix notation for division. always returns a + real number. + + div prefix notation for binary integer division. + returns the integer quotient. Both arguments must + be integers or an error occurs. + + mod prefix notation for binary integer modulus. + returns the integer remainder when dividing the + first argument by the scond. Both arguments must + be integers or an error occurs. + + sin returns as a float, the sine of the angle which + must be given in radians. + + cos returns as a float, the cosine of the angle which + must be given in radians. + + atan2 + returns as a float in radians, the arctangent of + the first argument divided by the second argument. + the arguments can be integers or floats. + + sqrt returns as a float the square root of its + + + +Soar Last change: 3 + + + + + + +rhs-functions(n) Soar Commands rhs-functions(n) + + + + argument, which can be a float or an integer. + + abs returns the absolute value: of a float as a float; + of an integer as an integer. + + int converts a symbol to an integer constant. argu- + ment must be either an integer constant, a float- + ing point constant, or a symbolic constant which + can be interpreted as a single integer number. + + float + converts a symbol to an floating point constant. + argument must be either an integer constant, a + floating point constant, or a symbolic constant + which can be interpreted as a single floating + point number. + +WARNINGS + The tcl RHS function is not part of the Soar kernel. It is + added by the Tcl interface code. You can get into a lot of + trouble with it, as the arguments are unrestricted. It + should be used only with great care. + + + +SEE ALSO + learn, stop-soar + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/run.n b/soar-8.5.2/doc/cat/run.n new file mode 100644 index 0000000..a25374e --- /dev/null +++ b/soar-8.5.2/doc/cat/run.n @@ -0,0 +1,198 @@ + + + +run(n) Soar Commands run(n) + + + +_________________________________________________________________ + +NAME + run - Run Soar + +SYNOPSIS + run [_n | 'forever'] [_u_n_i_t] [-self] +_________________________________________________________________ + + +DESCRIPTION + This command runs the Soar agents. If the [-self] flag is + issued, only the agent issuing the run command will run. _n + is a single integer which specifies the number of times to + run Soar. If _n is unspecified and no _u_n_i_ts are given, OR if + _n is the single keyword 'forever', then Soar is run until + halted by problem-solving completion or an external inter- + rupt. If _n is specified, but no _u_n_i_ts are specified, then + soar is run by decision cycles. If _u_n_i_ts are specified, but + _n is unspecified, then _n defaults to '1'. The _u_n_i_t argument + indicates the unit of measure to be used in counting Soar + run cycles. _u_n_i_t must be one of the following keywords: + + p run Soar for _n phases. A phase is either an input + phase, preference phase, working memory phase, output + phase, or decision phase. + + e run Soar for _n elaboration cycles. (For purposes of + this command, decision phase is counted as an elabora- + tion cycle.) + + d run Soar for _n decision cycles + + s run Soar until the _nth time a state is selected + + o run Soar until the _nth time an operator is selected + + out run Soar until the _nth time output is generated by the + agent + + run Soar until the current level of subgoaling has ter- + minated + + run Soar until the superstate's level of subgoaling has + terminated + + + run Soar until the supersuperstate's level of subgoal- + ing has terminated + + run Soar until the _nth time an operator is selected at + this level of subgoaling or until the current level of + + + +Soar Last change: 1 + + + + + + +run(n) Soar Commands run(n) + + + + subgoaling is terminated. + + run Soar until the _nth time a superoperator is selected + or until that level of subgoaling is terminated. + + + run Soar until the _nth time a supersuperoperator is + selected or until that level of subgoaling is ter- + minated. + + Unlike the Soar 6 _g_o command, _r_u_n has no memory of settings + from previous run commands. + + There are two predefined aliases for the run command, pro- + vided as a convenience for use on the command line: + + d [_n] + run by decision cycles, equivalent to "run _n d". _n + defaults to 1. + + e [_n] + run by elaboration cycles, equivalent to "run _n e". _n + defaults to 1. + + + +EXAMPLES + run run all agents until halted by problem-solving comple- + tion or an external interrupt is given. + + run 5 d + run all agents for 5 decision cycles + + run d -self + run the current agent only for 1 decision cycle + + run 3 + run all agents for 3 decision cycles + + run 2 e + run all agents for 2 elaboration cycles + + run 1 s + run all agents until the next state is selected (i.e., + until the next time an impasse arises) + + run + run until the next superoperator is selected (or until + the superstate goes away) + + run 3 + run for 3 operator selections at this level (continuing + + + +Soar Last change: 2 + + + + + + +run(n) Soar Commands run(n) + + + + through any subgoals that arise) + + +WARNING + In Soar8, the preference phase is no longer separated from + the working memory phase, Soar continues right through from + preferences into working memory without stopping. The + phases are Input, Propose, Decide, Apply, Output; Propose + and Apply each consist of at least one, but possibly many, + preference/working-memory subphases. + + +SEE ALSO + d, e, stop-soar, predefined-aliases + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 3 + + + diff --git a/soar-8.5.2/doc/cat/save-backtraces.n b/soar-8.5.2/doc/cat/save-backtraces.n new file mode 100644 index 0000000..9b0af99 --- /dev/null +++ b/soar-8.5.2/doc/cat/save-backtraces.n @@ -0,0 +1,66 @@ + + + +save-backtraces(n) Soar Commands save-backtraces(n) + + + +_________________________________________________________________ + +NAME + save-backtraces - Enable/Disable Soar save-backtraces + +SYNOPSIS + set save-backtraces [on | off] +_________________________________________________________________ + + +DESCRIPTION + save-backtraces is a Soar variable which through the Tcl _s_e_t + command, enables and disables the the saving of backtracing + information. It must be on for the explain-backtraces com- + mand to provide backtracing information. If an enabling or + disabling _s_t_a_t_u_s of on or off is given, then the save- + backtraces are set to that state. If no _s_t_a_t_u_s is given, + then the current save-backtraces status is printed. At + startup, save-backtraces is initially enabled. + + +OPTIONS + on | 1 + Enables the saving of backtracing information (initial + default) + + off | 0 + Disables the saving of backtracing information + + +WARNINGS + save-backtraces mode must be on when a chunk or justifica- + tion is created or no explanation will be available for the + explain-backtraces command. + + +SEE ALSO + explain-backtraces variables + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/save_backtraces.n b/soar-8.5.2/doc/cat/save_backtraces.n new file mode 100644 index 0000000..8af8dc0 --- /dev/null +++ b/soar-8.5.2/doc/cat/save_backtraces.n @@ -0,0 +1,66 @@ + + + +save_backtraces(n) Soar Commands save_backtraces(n) + + + +_________________________________________________________________ + +NAME + save_backtraces - Enable/Disable Soar save_backtraces + +SYNOPSIS + set save_backtraces [on | off] +_________________________________________________________________ + + +DESCRIPTION + save_backtraces is a Soar variable which through the Tcl _s_e_t + command, enables and disables the the saving of backtracing + information. It must be on for the explain-backtraces com- + mand to provide backtracing information. If an enabling or + disabling _s_t_a_t_u_s of on or off is given, then the + save_backtraces are set to that state. If no _s_t_a_t_u_s is + given, then the current save_backtraces status is printed. + At startup, save_backtraces is initially enabled. + + +OPTIONS + on | 1 + Enables the saving of backtracing information (initial + default) + + off | 0 + Disables the saving of backtracing information + + +WARNINGS + save_backtraces mode must be on when a chunk or justifica- + tion is created or no explanation will be available for the + explain-backtraces command. + + +SEE ALSO + explain-backtraces, variables + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/send.n b/soar-8.5.2/doc/cat/send.n new file mode 100644 index 0000000..7cb641b --- /dev/null +++ b/soar-8.5.2/doc/cat/send.n @@ -0,0 +1,66 @@ + + + +send(n) Soar Commands send(n) + + + +_________________________________________________________________ + +NAME + send - Send interpreter a script to execute + +SYNOPSIS + send _n_a_m_e _s_c_r_i_p_t +_________________________________________________________________ + + +DESCRIPTION + This command sends the interpreter _n_a_m_e a Tcl _s_c_r_i_p_t to be + executed. The result of executing the command in the + receiving interpreter is returned as the result of the send + command. This command generalizes the standard Tk send com- + mand so that it applies to local non-wish interpreters as + well as wish-based ones. Remote sends are only possible + with wish-based interpreters since a connection to the X + server is needed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/soar.n b/soar-8.5.2/doc/cat/soar.n new file mode 100644 index 0000000..bff3fe3 --- /dev/null +++ b/soar-8.5.2/doc/cat/soar.n @@ -0,0 +1,131 @@ + + + +soar(n) Soar Commands soar(n) + + + +_________________________________________________________________ + +NAME + soar - Soar system + +SYNOPSIS + soar [_o_p_t_i_o_n_s] +_________________________________________________________________ + + +DESCRIPTION + This command creates new Soar interpreters identified by + given _n_a_m_es. The various options specify any special ini- + tialization conditions, if any. The most important option + is the _t_y_p_e which indicates what type of interpreter is to + be created and must be one of the following values: + + -agent + Create agent interpreter(s). This includes Tcl + Soar. + + -tclsh + Create tclsh interpreter(s). Tclsh includes only Tcl. + + One or more _n_a_m_es may be given after the above _t_y_p_es. If no + _t_y_p_e is given on the command line when Soar is invoked, a + single -agent interpreter is created with the _n_a_m_e soar. + Within Soar, it is an error to call this command without + specifying some interpreter _n_a_m_e to create. + + Once the Soar system has started, the command create-interp + can be used to add additional interpreters. + + +OPTIONS + Environment variables used below are assumed to be defined + in the Unix shell used to start Soar. + + -path + Use the given sequence of directories to scan for agent + initialization files. The sequence is a colon (:) + separated list of directories. The default value is + ".:$HOME", where $HOME is the user's home directory. + Agent initialization files are assumed to be named + _n_a_m_e.soar. + + -file + Specifies a file to run immediately after defining the + last interpreter. This only applies when invoking + Soar. + + -help + Lists all available options for this command. + + + +Soar Last change: 1 + + + + + + +soar(n) Soar Commands soar(n) + + + + -verbose + Print diagnostic information about options as each + interpreter is defined. + + +EXAMPLES + The following example starts Soar with two agents named fred + and wilma and a single tclsh interpreter named bedrock. + This setup might be used to run a simulator in the tclsh + interpreter bedrock that the agents fred and wilma can + interact in. + + soar -agent fred wilma -tclsh bedrock +9 + This example has the extra option -foo bar. Since this is + not recognized as a valid command line option, it is passed + on to each interpreter defined on the command line. This + information appears in the Tcl variable argv and can be used + to pass startup information to user-defined Tcl procedures. + + soar -foo bar -agent fred wilma -wish bedrock +9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/soar8.n b/soar-8.5.2/doc/cat/soar8.n new file mode 100644 index 0000000..dcd0715 --- /dev/null +++ b/soar-8.5.2/doc/cat/soar8.n @@ -0,0 +1,66 @@ + + + +soar8(n) Soar Commands soar8(n) + + + +_________________________________________________________________ + +NAME + soar8 - Enable/Disable Soar8 mode + +SYNOPSIS + soar8 [-on | -off] +_________________________________________________________________ + + +DESCRIPTION + The soar8 allows users to toggle between the Soar 8 metho- + dology and the Soar 7 methodology. The default value is + -on. If an enabling or disabling _s_t_a_t_u_s of -on or -off is + given, then the Soar 8 (-on) or Soar 7 (-off) methodology is + employed. If no _s_t_a_t_u_s is given, then the current soar8 + status is printed. Users can toggle between modes ONLY when + production memory and working memory are both empty. This + means that users must either change the mode at startup + before any productions are loaded, or must first issue + "excise -all" (which does an "init-soar" as well) before + changing modes. Note that there are differences in the + preference mechanism and in operator termination (among + other things) between Soar 8 and Soar 7. Users should read + the Soar 8.2 Release Notes for more details. + + +OPTIONS + -on Soar will run using Soar 8 methodology (initial + default) + + -off Soar will run using Soar 7 methodology + + +WARNINGS + Production memory and working memory must be empty to switch + between modes. + + +SEE ALSO + Soar 8.2 Release Notes on the Soar 8.2 web page + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/soarnews.n b/soar-8.5.2/doc/cat/soarnews.n new file mode 100644 index 0000000..5e90d1d --- /dev/null +++ b/soar-8.5.2/doc/cat/soarnews.n @@ -0,0 +1,66 @@ + + + +soarnews(n) Soar Commands soarnews(n) + + + +_________________________________________________________________ + +NAME + soarnews - Soar news + +SYNOPSIS + soarnews +_________________________________________________________________ + + +DESCRIPTION + This command gives information about the current Soar ver- + sion being run, the addresses of Soar email groups, the Soar + Home Page URL, and the copyright disclaimer. + + +SEE ALSO + version + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/soartk.n b/soar-8.5.2/doc/cat/soartk.n new file mode 100644 index 0000000..5a9c1cb --- /dev/null +++ b/soar-8.5.2/doc/cat/soartk.n @@ -0,0 +1,197 @@ + + + +soartk(n) Soar Commands soartk(n) + + + +_________________________________________________________________ + +NAME + soartk - Soar system with Tk extension + +SYNOPSIS + soartk [_o_p_t_i_o_n_s] +_________________________________________________________________ + + +DESCRIPTION + This command creates new Soar interpreters identified by + given _n_a_m_es. The various options specify any special ini- + tialization conditions, if any. The most important option + is the _t_y_p_e which indicates what type of interpreter is to + be created and must be one of the following values: + + -agent + Create agent interpreter(s). This includes Tcl + Tk + + Soar if Tk is enabled, otherwise this includes Tcl + + Soar. + + -wish + Create wish interpreter(s). Wish includes Tcl + Tk. + This is available only if Tk is enabled. + + -tclsh + Create tclsh interpreter(s). Tclsh includes only Tcl. + + One or more _n_a_m_es may be given after the above _t_y_p_es. If no + _t_y_p_e is given on the command line when Soar is invoked, a + single -agent interpreter is created with the _n_a_m_e soar. + Within Soar, it is an error to call this command without + specifying some interpreter _n_a_m_e to create. + + Tk is enabled if Soar has been compiled with the USE_TK + option, the $DISPLAY environment variable is set, and the + -noTk option has not been given on the command line (see + below). + + Once the Soar Tcl/Tk system has started, the command + create-interp can be used to add additional interpreters. + + +OPTIONS + Environment variables used below are assumed to be defined + in the Unix shell used to start Soar. + + -path + Use the given sequence of directories to scan for agent + initialization files. The sequence is a colon (:) + separated list of directories. The default value is + + + +Soar Last change: 1 + + + + + + +soartk(n) Soar Commands soartk(n) + + + + ".:$HOME", where $HOME is the user's home directory. + Agent initialization files are assumed to be named + _n_a_m_e.soar. + + -display + Place the top-level window associated with the inter- + preter on the indicated display. The value of this + option follows standard X conventions for specifying + displays. The default is the value of $DISPLAY. This + only applies to wish-based shells. + + -file + Specifies a file to run immediately after defining the + last interpreter. This only applies when invoking + Soar. + + -geometry + Specifies the geometry (width, height, and placement) + of the top-level window associated with the inter- + preter. The value of this option follows standard X + conventions for specifying geometries. This only + applies to wish-based shells. + + -help + Lists all available options for this command. + + -noTk + Do not use Tk when creating any subsequent inter- + preters. This option applies to the rest of the com- + mand line. + + -sync + Use synchronous X server updates with all subsequent + wish-based interpreter windows. This applies only to + wish-based shells. + + -useIPC + Enables IPCs (registered with Xserver) for all inter- + preters. This option applies to the rest of the com- + mand line. + + -verbose + Print diagnostic information about options as each + interpreter is defined. + + +EXAMPLES + The following example starts Soar with two agents named fred + and wilma and a single wish interpreter named bedrock. This + setup might be used to run a simulator in the wish inter- + preter bedrock that the agents fred and wilma can interact + in. + + + +Soar Last change: 2 + + + + + + +soartk(n) Soar Commands soartk(n) + + + + soartk -agent fred wilma -wish bedrock +9 + The next example is similar to the one above, except that + the simulator display will be moved to the X display + sgi1:0.0. Also, the switch -v has been added to indicate + that we want detailed information about defined options as + each interpreter is created. Note that all option names may + be abbreviated to any prefix which uniquely distinguishes it + from the other options. + + soartk -v -agent fred wilma -display sgi1:0.0 -wish bedrock +9 + This example has the extra option -foo bar. Since this is + not recognized as a valid command line option, it is passed + on to each interpreter defined on the command line. This + information appears in the Tcl variable argv and can be used + to pass startup information to user-defined Tcl procedures. + + soartk -foo bar -agent fred wilma -wish bedrock + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 3 + + + diff --git a/soar-8.5.2/doc/cat/sp.n b/soar-8.5.2/doc/cat/sp.n new file mode 100644 index 0000000..5a55145 --- /dev/null +++ b/soar-8.5.2/doc/cat/sp.n @@ -0,0 +1,258 @@ + + + +sp(n) Soar Commands sp(n) + + + +_________________________________________________________________ + +NAME + sp - Define a Soar production + +SYNOPSIS + sp _r_u_l_e +_________________________________________________________________ + + +DESCRIPTION + This command defines a new Soar production. _r_u_l_e is a sin- + gle argument parsed by the Soar kernel, so it should be + enclosed in curly braces to avoid being parsed by Tcl. The + overall syntax of a _r_u_l_e is as follows: + + _n_a_m_e + ["_d_o_c_u_m_e_n_t_a_t_i_o_n-_s_t_r_i_n_g"] + [_F_L_A_G*] + _L_H_S + --> + _R_H_S +9 + The first element of a _r_u_l_e is its _n_a_m_e. Conventions for + _n_a_m_e_s are given in the Soar Users Manual. If given, the + _d_o_c_u_m_e_n_t_a_t_i_o_n-_s_t_r_i_n_g must be enclosed in double quotes. + Optional flags define the type of rule and the form of sup- + port its right-hand side assertions will receive. The + specific flags are listed in a separate section below. The + _L_H_S defines the left-hand side of the production and speci- + fies the conditions under which the rule can be fired. Its + syntax is given in detail in a subsequent section. The --> + symbol serves to separate the _L_H_S and _R_H_S portions. The _R_H_S + defines the right-hand side of the production and specifies + the assertions to be made and the actions to be performed + when the rule fires. The syntax of the allowable right-hand + side actions are given in a later section. The Soar Users + Manual gives an elaborate discussion of the design and cod- + ing of productions. Please see that reference for tutorial + information about productions. + + More complex productions can be formed by surrounding the + _r_u_l_e with double quotes instead of curly braces. This + enables variable and command result substitutions in produc- + tions. If another production with the same name already + exists, it is excised, and the new production is loaded. + + +RULE FLAGS + The optional _F_L_A_Gs are given below. Note that these + switches are preceeded by a colon instead of a dash -- this + is a Soar parser convention. + + + +Soar Last change: 1 + + +9 + + +sp(n) Soar Commands sp(n) + + + + :o-support + specifies that all the RHS actions are to be given o- + support when the production fires + + :no-support + specifies that all the RHS actions are only to be given + i-support when the production fires + + :default + specifies that this production is a default production + (this matters for excise -task and watch task) + + :chunk + specifies that this production is a chunk (this matters + for learn trace) + + +LHS GRAMMAR + Grammar for left hand sides of productions: + + _l_h_s ::= _c_o_n_d+ + _c_o_n_d ::= _p_o_s_i_t_i_v_e__c_o_n_d | - _p_o_s_i_t_i_v_e__c_o_n_d + _p_o_s_i_t_i_v_e__c_o_n_d ::= _c_o_n_d_s__f_o_r__o_n_e__i_d | { _c_o_n_d+ } + _c_o_n_d_s__f_o_r__o_n_e__i_d ::= ( [state |impasse] [_i_d__t_e_s_t] _a_t_t_r__v_a_l_u_e__t_e_s_t_s* ) + _i_d__t_e_s_t ::= _t_e_s_t + _a_t_t_r__v_a_l_u_e__t_e_s_t_s ::= [-] ^ _a_t_t_r__t_e_s_t [._a_t_t_r__t_e_s_t]* _v_a_l_u_e__t_e_s_t* + _a_t_t_r__t_e_s_t ::= _t_e_s_t + _v_a_l_u_e__t_e_s_t ::= _t_e_s_t [+] | _c_o_n_d_s__f_o_r__o_n_e__i_d [+] + + _t_e_s_t ::= _c_o_n_j_u_n_c_t_i_v_e__t_e_s_t | _s_i_m_p_l_e__t_e_s_t + _c_o_n_j_u_n_c_t_i_v_e__t_e_s_t ::= { _s_i_m_p_l_e__t_e_s_t+ } + _s_i_m_p_l_e__t_e_s_t ::= _d_i_s_j_u_n_c_t_i_o_n__t_e_s_t | _r_e_l_a_t_i_o_n_a_l__t_e_s_t + _d_i_s_j_u_n_c_t_i_o_n__t_e_s_t ::= << _c_o_n_s_t_a_n_t* >> + _r_e_l_a_t_i_o_n_a_l__t_e_s_t ::= [_r_e_l_a_t_i_o_n] _s_i_n_g_l_e__t_e_s_t + _r_e_l_a_t_i_o_n ::= <> | < | > | <= | >= | = | <=> + _s_i_n_g_l_e__t_e_s_t ::= variable | _c_o_n_s_t_a_n_t + _c_o_n_s_t_a_n_t ::= sym_constant | int_constant | float_constant +9 +RHS GRAMMAR + Grammar for right hand sides of productions: + + _r_h_s ::= _r_h_s__a_c_t_i_o_n* + _r_h_s__a_c_t_i_o_n ::= ( variable _a_t_t_r__v_a_l_u_e__m_a_k_e+ ) | _f_u_n_c_t_i_o_n__c_a_l_l + _f_u_n_c_t_i_o_n__c_a_l_l ::= ( _f_u_n_c_t_i_o_n__n_a_m_e _r_h_s__v_a_l_u_e* ) + _f_u_n_c_t_i_o_n__n_a_m_e ::= sym_constant | + | - + _r_h_s__v_a_l_u_e ::= _c_o_n_s_t_a_n_t | _f_u_n_c_t_i_o_n__c_a_l_l | variable + _c_o_n_s_t_a_n_t ::= sym_constant | int_constant | float_constant + _a_t_t_r__v_a_l_u_e__m_a_k_e ::= ^ _r_h_s__v_a_l_u_e [._r_h_s__v_a_l_u_e]* _v_a_l_u_e__m_a_k_e+ + _v_a_l_u_e__m_a_k_e ::= _r_h_s__v_a_l_u_e _p_r_e_f_e_r_e_n_c_e_s + + _p_r_e_f_e_r_e_n_c_e_s ::= [,] | _p_r_e_f_e_r_e_n_c_e-_s_p_e_c_i_f_i_e_r+ + _p_r_e_f_e_r_e_n_c_e-_s_p_e_c_i_f_i_e_r ::= _n_a_t_u_r_a_l_l_y-_u_n_a_r_y-_p_r_e_f_e_r_e_n_c_e [,] + + + +Soar Last change: 2 + + +9 + + +sp(n) Soar Commands sp(n) + + + + | _f_o_r_c_e_d-_u_n_a_r_y-_p_r_e_f_e_r_e_n_c_e + | _b_i_n_a_r_y-_p_r_e_f_e_r_e_n_c_e _r_h_s__v_a_l_u_e [,] + _n_a_t_u_r_a_l_l_y-_u_n_a_r_y-_p_r_e_f_e_r_e_n_c_e ::= + | - | ! | ~ | @ + _b_i_n_a_r_y-_p_r_e_f_e_r_e_n_c_e ::= > | = | < | & + _f_o_r_c_e_d-_u_n_a_r_y-_p_r_e_f_e_r_e_n_c_e ::= _b_i_n_a_r_y-_p_r_e_f_e_r_e_n_c_e {, | ) | ^} +9 + +EXAMPLES + There are many examples in the Soar Users Manual and the + demos subdirectory. Here is a simple production to create a + problem space. It comes from the critter-world demo (see + the file critter.tcl): + + + sp {critter*create*space*critter + "Formulate the initial problem space" + (state ^superstate nil) + --> + ( ^name move-around ^problem-space

                                                                                                                                    ) + (

                                                                                                                                    ^name critter)} + +9 + The production above has the _n_a_m_e + critter*create*space*critter. It has a documentation string + that is surrounded by double quotes. The _L_H_S is (state + ^superstate nil) and indicates that this rule will match + whenever there is a state object that has the attribute- + value pair ^superstate nil. The --> arrow separates the + left and right-hand sides. The _R_H_S consists of two lines. + The first asserts that the state object is to be augmented + with the name move-around and a problem space should be + created. The second line of the _R_H_S indicates that this + problem space should be named critter. + + New for Soar 8, is right-hand-side dot notation. So this + production could also be written: + + + sp {critter*create*space*critter + "Formulate the initial problem space" + (state ^superstate nil) + --> + ( ^name move-around ^problem-space.name critter)} + +9 + Here is a variant of the above example using double quotes + instead of curly braces. Double quotes are needed in order + to imbed the value of the Tcl variable soar_agent_name in + the production. The value of this variable is used to name + the problem-space created. +9 + + +Soar Last change: 3 + + + + + + +sp(n) Soar Commands sp(n) + + + + sp "critter*create*space*critter + (state ^superstate nil) + --> + ( ^name move-around ^problem-space

                                                                                                                                    ) + (

                                                                                                                                    ^name $soar_agent_name)" + +9 + The primary change in the rule is the last clause of the + _R_H_S. In that clause, the Tcl variable soar_agent_name is + expanded. If this rule is given in an interpreter which has + the variable soar_agent_name set to fred, then the _R_H_S would + expand to the following before being sent to the Soar kernel + to be parsed: + + + (

                                                                                                                                    ^name fred) + +9 + Please be aware that when using double quotes, both the dol- + lar sign (variable expansion) and square brackets (command + result substitution) will be interpreted by Tcl. If these + characters ($, [, and ]) are to be passed to the Soar pro- + duction parser, they must be escaped (using a backslash) to + avoid interpretation by Tcl. + + +WARNINGS + The last production above does not contain a documentation + string. If one were added, double quotes would need to be + escaped to avoid premature termination of the rule: + + + sp "critter*create*space*critter + + (state ... + +9 + +SEE ALSO + excise, learn, watch + + + + + + + + + + +9 + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/start-attention-lapse.n b/soar-8.5.2/doc/cat/start-attention-lapse.n new file mode 100644 index 0000000..e6fa50f --- /dev/null +++ b/soar-8.5.2/doc/cat/start-attention-lapse.n @@ -0,0 +1,59 @@ + + + +start-attention-lapse(n) Soar Commands start-attention-lapse(n) + + + +_________________________________________________________________ + +NAME + start-attention-lapse - Sets the amount of real time that + should pass before ending the lapse, and sets the + attention-lapsing to true. Not normally called by the user. + +SYNOPSIS + start-attention-lapse [ _^Hi_n_t_e_g_e_r(_m_i_l_l_i_s_e_c_o_n_d_s)]] +_________________________________________________________________ + + +DESCRIPTION + This command, which should not normally be called by the + user or an agent (attention lapses normally get started + automatically by the architecture), sets the "attention-lapsing" + variable to TRUE (1), and starts tracking the amount of real + time that should pass before ending the lapse (with + wake_from_attention_lapse). The duration of the lapse is + the number of milleseconds specified by the argument to this + command (in real time). + + +WARNINGS + The compile time options REAL_TIME_BEHAVIOR and ATTENTION_LAPSE + _m_u_s_t _b_e _e_n_a_b_l_e_d _f_o_r _t_h_i_s _f_u_n_c_t_i_o_n_a_l_i_t_y. + +SEE ALSO + attention-lapse wake-from-attention-lapse variables + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/stats.n b/soar-8.5.2/doc/cat/stats.n new file mode 100644 index 0000000..f2cd896 --- /dev/null +++ b/soar-8.5.2/doc/cat/stats.n @@ -0,0 +1,323 @@ + + + +stats(n) Soar Commands stats(n) + + + +_________________________________________________________________ + +NAME + stats - Print statistical data about Soar + +SYNOPSIS + stats [-_s_y_s_t_e_m [_s_t_a_t] | -_m_e_m_o_r_y [_s_t_a_t] |-_r_e_t_e [_s_t_a_t]] +_________________________________________________________________ + + +DESCRIPTION + This command prints Soar internal statistics. The _m_o_d_u_l_e + indicates the component of interest. If specified, _m_o_d_u_l_e + must be one of -system, -memory, or -rete. If no specific + _s_t_a_t is given for the specified _m_o_d_u_l_e, then all statistics + are listed for that _m_o_d_u_l_e. If no _m_o_d_u_l_e is given, then the + -system statistics are listed. + + The -system module contains the following _s_t_a_ts: + + -default-production-count + -user-production-count + -chunk-count + -justification-count + -all-productions-count + -dc-count + -ec-count + -ecs/dc + -firings-count + -firings/ec + -wme-change-count + -wme-addition-count + -wme-removal-count + -wme-count + -wme-avg-count + -wme-max-count +9 + If Soar has been compiled with the NO_TIMING_STUFF NOT set, + then the following statistics are also available in the + -system module: + + -total-time + -ms/dc + -ms/ec + -ms/firing + -ms/wme-change +9 + If Soar has been compiled with the DETAILED_TIMING_STATS + SET, then the following statistics are also available in the + -system module: + + + + +Soar Last change: 1 + + + + + + +stats(n) Soar Commands stats(n) + + + + -match-time + -ownership-time + -chunking-time +9 + The -memory module contains the following statistics: + + -total + -overhead + -strings + -hash-table + -pool _p_o_o_l-_s_t_a_t_i_s_t_i_c + -misc +9 + The -pool statistic is additionally qualified by a _p_o_o_l- + _s_t_a_t_i_s_t_i_c option. If this option is not given, then all + -memory pool statistics are printed. If given, _p_o_o_l- + _s_t_a_t_i_s_t_i_c must have one of the following forms: + + -total + Print just the overall totals for the pools + + _p_o_o_l-_n_a_m_e [_a_s_p_e_c_t] + Print statistics about the specific pool _p_o_o_l-_n_a_m_e. + The permissable _p_o_o_l-_n_a_m_es are: + + chunk condition + io wme + output link + preference + wme + slot + instantiation + ms change + right mem + negative token + token + node varnames + rete node + rete test + alpha mem + saved test + not + action + production + condition + complex test + float constant + int constant + sym constant + identifier + variable + + + +Soar Last change: 2 + + + + + + +stats(n) Soar Commands stats(n) + + + + dl cons + cons cell +9 + If no _a_s_p_e_c_t is given, then print all statistics about the + given pool. If given, _a_s_p_e_c_t must have one of the following + forms: + + -used + -free + -item-size + -total-bytes +9 The first two _a_s_p_e_c_ts are available only if Soar has been + compiled with MEMORY_POOL_STATS SET. + + The -rete module contains statistics for the following node + types: + + unhashed memory + memory + unhashed mem-pos + mem-pos + unhashed negative + negative + unhashed positive + positive + dummy top + dummy matches + conj. neg. + conj. neg. partner + production + total +9 The total statistic gives a total count over all node types. + + A -rete statistic is obtained by specifying one of the above + nodes followed by a _q_u_a_l_i_f_i_e_r. The _q_u_a_l_i_f_i_e_r is one of + -actual, -if-no-merging, and -if-no-sharing. The -if-no- + sharing option is only available if Soar has been compiled + with the SHARING_FACTORS option SET. + + +EXAMPLES + This prints all statistics in the -system module: + + stats -system +9 + This prints the number of io wme's: + + stats -memory -pool {io wme} -used +9 Note that this particular pool name, "io wme", contains an + embedded space character. Hence, the name must be + + + +Soar Last change: 3 + + +9 + + +stats(n) Soar Commands stats(n) + + + + surrounded by curly braces or double quotes to override the + normal Tcl parsing of words separated by whitespace. This + is not necessary for pool names that do not include spaces: + + stats -memory -pool wme -used +9 + This prints the actual number of unhashed negative nodes in + the Rete memory: + + stats -rete {unhashed negative} -actual +9 + +A NOTE ON TIMERS + The current implementation of Soar uses a number of timers + to provide time-based statistics for use in the stats com- + mand calculations. These timers are: + + total CPU time + total kernel time + phase kernel time (per phase) + phase callbacks time (per phase) + input function time + output function time +9 + Total CPU time is calculated from the time a decision cycle + (or number of decision cycles) is initiated until stopped. + Kernel time is the time spent in core Soar functions. In + this case, kernel time is defined as the all functions other + than the execution of callbacks and the input and output + functions. The total kernel timer is only stopped for these + functions. + + The phase timers (for the kernel and callbacks) track the + execution time for individual phases of the decision cycle + (i.e., input phase, preference phase, working memory phase, + output phase, and decision phase). Because there is over- + head associated with turning these timers on and off, the + actual kernel time will always be greater than the derived + kernel time (i.e., the sum of all the phase kernel timers). + Similarly, the total CPU time will always be greater than + the derived total (the sum of the other timers) because the + overhead of turning these timers on and off is included in + the total CPU time. In general, the times reported by the + single timers should always be greater than than the + corresponding derived time. Additionally, as execution time + increases, the difference between these two values will also + increase. + + For those concerned about the performance cost of the + timers, all the run time timing calculations can be compiled + out of the code by defining NO_TIMING_STUFF (in + + + +Soar Last change: 4 + + +9 + + +stats(n) Soar Commands stats(n) + + + + soarkernel.h) before compilation. + + +FILES + soarkernel.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 5 + + + diff --git a/soar-8.5.2/doc/cat/stop-soar.n b/soar-8.5.2/doc/cat/stop-soar.n new file mode 100644 index 0000000..8065f95 --- /dev/null +++ b/soar-8.5.2/doc/cat/stop-soar.n @@ -0,0 +1,132 @@ + + + +stop-soar(n) Soar Commands stop-soar(n) + + + +_________________________________________________________________ + +NAME + stop-soar - Stop Soar + +SYNOPSIS + stop-soar [ -self [reason-string] ] +_________________________________________________________________ + + +DESCRIPTION + Agents may be run using the run command. The stop-soar com- + mand stops any running Soar agents. It sets a flag in the + Soar kernel so that Soar will stop running at a "safe" point + and return control to the user. This operates exactly as if + the user had issued a control-C (SIGINT) interrupt to the + Soar process. + + -self + Stop only the soar agent where the command is issued. + All other agents continue running as previously speci- + fied. + + _r_e_a_s_o_n-_s_t_r_i_n_g + An optional string following -self which will be + printed when Soar is stopped, to indicate why it was + stopped. If left blank, no message will be printed + when Soar is stopped. + + This command is usually not issued at the command line + prompt. A more common use of this command is as a side- + effect of pressing a button on a Graphical User Interface + (GUI), or as a monitor to be executed at a specific Soar + Event. For example, a user may wish to examine an agent's + "matches" after the Soar Decision Phase. In order to do + this in Soar 8, the user must register a monitor, or call- + back, to issue the "stop-soar -self" command for the event, + after-decision-phase-cycle. + +EXAMPLES + This example shows how to stop Soar8 after this decision + phase using stop-soar -self in a monitor to stop after the + decision phase so that memory can be examined. + + monitor -add {stop-soar -self "after decision phase"} after-decision-phase-cycle + + +WARNINGS + If the graphical interface doesn't periodically do a Tcl + "update" command, then it may not be possible to interrupt a + Soar agent from the command line. + + + + +Soar Last change: 1 + + + + + + +stop-soar(n) Soar Commands stop-soar(n) + + + +SEE ALSO + run, monitor, matches + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/topd.n b/soar-8.5.2/doc/cat/topd.n new file mode 100644 index 0000000..f786ccf --- /dev/null +++ b/soar-8.5.2/doc/cat/topd.n @@ -0,0 +1,66 @@ + + + +topd(n) Soar Commands topd(n) + + + +_________________________________________________________________ + +NAME + topd - List the top of the directory stack + +SYNOPSIS + topd +_________________________________________________________________ + + +DESCRIPTION + This command returns the top directory on the directory + stack. See the dirs command for an explanation of the + directory stack. + + +SEE ALSO + dirs, pushd, popd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/tsi.n b/soar-8.5.2/doc/cat/tsi.n new file mode 100644 index 0000000..3197b60 --- /dev/null +++ b/soar-8.5.2/doc/cat/tsi.n @@ -0,0 +1,264 @@ + + + +TclSoar-Interface(n) Soar Commands TclSoar-Interface(n) + + + +_________________________________________________________________ + +NAME + Soar TSI: TclSoar Interface + + +DESCRIPTION + The TSI provides a graphical user interface for interacting + with Soar. It is based on ideas from Frank Ritter's DSI, + and the SCA2 work done by Doug Pearson. The Soar Command + Line Interface window is essentially the one produced by + Randy Jones as a development of Karl Schwamb's original GUI + for Soar. + + The TSI consists of a set of optional windows that include: + + 1. A control panel to provide easy access to the basic + functions that are necessary or useful to run a Soar + model. It also supports running multiple Soar agents + at the same time. + + 2. An interaction window for Soar, providing equivalent + functionality to the old command line interface, but + with a set of menus and buttons available. + + 3. A display of the match set of rules about to fire. + + 4. A continuous display of the current state of the goal + stack. + + 5. A print window that supports the examination of objects + selected by the user. (The user either presses p, or + double clicks with the middle mouse button once an + object has been selected.) + + + The TSI is normally found in the $soar_library directory + (folder), but can be moved anywhere, provided the global + variable, tsi_library, is properly and accurately defined + when running Wish. However, if the TSI is moved, it's pos- + sible (likely) that it will not be able to find the Soar + help files or Soar demo files. Users should become quite + familiar with the TSI code before trying to move it to + another location. In $tsi_library is the main "tcl library" + of code that implements the TSI. All tsi commands will be + autoloaded from this directory or folder (assuming your tcl + interpreter knows where this directory or folder is). See + the file "start-soar.tcl" in the top-level directory of the + Soar distribution for more information on what needs to be + defined when starting Soar. + + + + + +Soar Last change: 1 + + + + + + +TclSoar-Interface(n) Soar Commands TclSoar-Interface(n) + + + + Comments, questions, suggestions and discussions relevant to + the TSI should be sent to _s_o_a_r-_t_s_i@_u_m_i_c_h._e_d_u. + + + +LOADING THE TSI + Since Soar version 7.2, the TSI has been packaged with the + Soar distribution. It will be invoked if Soar is started + using the "start-soar.tcl" script found in the top-level + directory (folder) of the Soar distribution. The "start- + soar.tcl" script defines the $tsi_library variable and adds + it to the auto_path so that the TSI commands are automati- + cally available in Soar. + + +MODIFYING THE TSI + Users can change some settings for the TSI by creating their + own tsi-defaults.tcl file. Users wishing to further modify + the TSI, are encouraged to create a new folder or subdirec- + tory in the $soar_library folder, and copy the TSI files + into the new folder, and then redefine the $tsi_library + variable. That way there will always be a distribution copy + of the TSI, and there will be less confusion if the modified + TSI is sent to other Soar users or TSI developers. If the + working copy of the TSI is moved out of the $soar_library + location, the TSI may not be able to find the Soar help + pages or the Soar demos, unless it is specifically modified + to look in the proper locations. + + +FILES + Unless otherwise noted, all files listed below are found in + the library/tsi* directory (folder). + + + README + Description of the TSI, similar to this man page + + tsi-defaults.tcl + This specifies some default values for the configura- + tion of the TSI. To override the defaults, you can + make a file named tsi-defaults.tcl in the directory or + folder from which you run Soar, and specify the values + you want to override. + + tsiInit.tcl + Provides the hooks to start up the TSI and to create + new agent (and other) interpreters. + + tsiControlPanel.tcl + Creates a simple control panel to drive Soar. Allows + the creation of mutiple Soar agents. + + + +Soar Last change: 2 + + + + + + +TclSoar-Interface(n) Soar Commands TclSoar-Interface(n) + + + + tsiDialogs.tcl + A set of "standard" dialogs for user interaction. + + tsiPopUp.tcl + Implements PopUp menus for interacting with Soar. + + termText.tcl + A simple terminal widget for tcl/tk (which the TSI + agent windows use). + + tsiAgentText.tcl + Enhancements to termText for Soar agents + + tsiAgentWindow.tcl + Implements a window for interacting with Soar agents. + Uses tsiAgentText for the main window, and adds a bunch + of menus, buttons, and whirligigs. + + tsiUtils.tcl + A collection of utilities supporting the interface, + including agent windows as well as other types of win- + dows (such as monitor windows). + + tclIndex + This file is used by Tcl to autoload various TSI com- + mands and procedures. Do not mess with it or move it + (unless you are making enhancements to the TSI code and + know what you are doing). + + tsi/demos subdirectory or subfolder: + This directory or folder contains a few Soar programs + that make use (to varying degrees) of some of the + features in the TSI. The TSI code assumes that this + demos directory (folder) is a subdirectory (subfolder) + of the directory (folder) holding the main TSI code. + If you move this directory or folder somewhere else, or + rename it, the menus for selecting these demo programs + will probably fail to function. + + TSI Demo programs: (for Soar 7; won't work in Soar8) + analogy.s7 + analogy.topspace.s7 + analogy.toptwo.s7 + default.s7 + ht.s7 + ht2.s7 + + ../../demos + The Soar distribution demos that get loaded into the + TSI "Demos" pulldownMenu when in Soar8 mode. + + ../../demos_soar7 + + + +Soar Last change: 3 + + + + + + +TclSoar-Interface(n) Soar Commands TclSoar-Interface(n) + + + + The Soar distribution demos that get loaded into the + TSI "Demos" pulldownMenu when in Soar7 mode. + + start-soar.tcl + This file is located in the top level of the Soar dis- + tribution. It defines soar_library and tsi_library, + appends them to the Tcl auto_path, and starts the TSI. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/unalias.n b/soar-8.5.2/doc/cat/unalias.n new file mode 100644 index 0000000..9f7ee72 --- /dev/null +++ b/soar-8.5.2/doc/cat/unalias.n @@ -0,0 +1,66 @@ + + + +unalias(n) Soar Commands unalias(n) + + + +_________________________________________________________________ + +NAME + unalias - Remove a Soar alias + +SYNOPSIS + unalias _n_a_m_e +_________________________________________________________________ + + +DESCRIPTION + This command removes an existing alias named _n_a_m_e. This + command simply removes the definition of the associated pro- + cedure called _n_a_m_e. If no alias named _n_a_m_e exists, an error + message is printed. + + +SEE ALSO + alias + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/variables.n b/soar-8.5.2/doc/cat/variables.n new file mode 100644 index 0000000..7a29768 --- /dev/null +++ b/soar-8.5.2/doc/cat/variables.n @@ -0,0 +1,133 @@ + + + +variables(n) Soar Commands variables(n) + + + +_________________________________________________________________ + +NAME + Soar variables + + +DESCRIPTION + There are a number of Soar variables that influence the + behavior of Soar. These variables are given default values, + which can be changed using the Tcl _s_e_t command. However, + unlike normal Tcl variables, Soar variables do have an + enforced type and can not be unset. + + The defined Soar variables are: + + attribute_preferences_mode [0|1|2] + The "attribute_preferences_mode" variable is used + to control the handling of preferences (other than + acceptable and reject preferences). + + default_wme_depth [0|1|2] + The "default_wme_depth" variable is used to con- + trol the default printing depth of the print com- + mand. + + max_chunks [positive integer] + The "max_chunks" variable controls the maximum + number of chunks that can be created in a single + decision cycle. + + max_elaborations [positive integer] + The "max_elaborations" variable controls the max- + imum number of elaborations allowed in a single + decision cycle. + + max_nil_output_cycles [positive integer] + The "max_nil_output_cycles" variable controls the + maximum number of consecutive nil output cycles + allowed when run-til-output-generated (or _r_u_n _o_u_t) + is used. + + o_support_mode [0|1|2] + The "o_support_mode" variable is used to control + the way o-support calculations are done for the + agent. + + real_time_per_decision [positive integer] + The "real_time_per_decision" variable controls the + minumum amount of time that Soar will take to com- + plete a decision cycle (in milliseconds). A deci- + sion cycle may take longer if Soar is still work- + ing. The compiler option REAL_TIME_BEHAVIOR must + + + +Soar Last change: 1 + + + + + + +variables(n) Soar Commands variables(n) + + + + be enabled for this variable. + + save_backtraces (boolean) + The "save_backtraces" variable enables and dis- + ables the saving of backtracing information. It + must be on for the _e_x_p_l_a_i_n-_b_a_c_k_t_r_a_c_e_s command to + provide backtracing information. + + warnings (boolean) + This "warnings" variable enables and disables the + printing of warning messages. + +SEE ALSO + set attribute_preferences_mode default_wme_depth max_chunks + max_elaborations max-nil-output-cycles o_support_mode + real_time_per_decision save_backtraces warnings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 2 + + + diff --git a/soar-8.5.2/doc/cat/version.n b/soar-8.5.2/doc/cat/version.n new file mode 100644 index 0000000..8307beb --- /dev/null +++ b/soar-8.5.2/doc/cat/version.n @@ -0,0 +1,65 @@ + + + +version(n) Soar Commands version(n) + + + +_________________________________________________________________ + +NAME + version - Soar version + +SYNOPSIS + version +_________________________________________________________________ + + +DESCRIPTION + This command gives information about the current Soar ver- + sion being run. It returns the version number itself, which + can then be used in any Tcl expression. + + +EXAMPLE + The following is a test that will be true for any version of + Soar that is at least 8.0 or higher. + + if {[version] > 8.0} { ... +9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +9 + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/viSTEAM.n b/soar-8.5.2/doc/cat/viSTEAM.n new file mode 100644 index 0000000..92ce34d --- /dev/null +++ b/soar-8.5.2/doc/cat/viSTEAM.n @@ -0,0 +1,66 @@ + + + +viSTEAM(n) Soar Commands viSTEAM(n) + + + +_________________________________________________________________ + +NAME + viSTEAM - Embryonic visual environment for developing Soar + productions + +SYNOPSIS + viSTEAM +_________________________________________________________________ + + +DESCRIPTION + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + + + + diff --git a/soar-8.5.2/doc/cat/vt.n b/soar-8.5.2/doc/cat/vt.n new file mode 100644 index 0000000..b61a2c6 --- /dev/null +++ b/soar-8.5.2/doc/cat/vt.n @@ -0,0 +1,264 @@ + + + +vt(n) Soar Commands vt(n) + + + +_________________________________________________________________ + +NAME + vt.tcl - Embryonic visual environment for developing Soar + productions + +SYNOPSIS + source vt.tcl +_________________________________________________________________ + + +DESCRIPTION + By sourcing _v_t._t_c_l in wish or a soartk environment, a visual + environment for writing Soar productions is launched. The + intention is to provide a set of useful tools for writing + syntactically correct productions, for example by providing + a suite of tools dedicated to bracket checking. Compatabil- + ity with other productions in a ruleset is provided by + automatically parsing a sourced ruleset and producing a + navigable tree of attribute value pairs. Such a facility + also supports a user attempting to trace the 'execution + path' through a ruleset. + + In addition to primitive and general tools, a set of exten- + sions are provided for writing STEAM compatible productions. + +USAGE + The best way into the environment is to start a _s_o_a_r_t_k shell + in the viSTEAM directory and type source vt.tcl. The user + will then be lead through a series of dialogues that reflect + the base interpreter. A quick tutorial through the main + features of viSTEAM can be found in the man page vtutor. + + The viSTEAM environment is based around a text editor. The + top menu-bar provides usual options as regards file, editing + and Help options, as well as options that are specific to + the environment (Soar, Builder and Components). Directly + below the menu bar is a toolbar with options to clear the + text window, search for text within the text window or send + the code within the text window to a Soar interpreter for + validation. Underneath the text window is a second toolbar + that implements the bracket checking facilities: + +MENUBAR OPTIONS + _S_o_a_r - this menu is used to open a window onto a Soar inter- + preter. + + _B_u_i_l_d_e_r - this menu is used to select application specific, + menu driven code generators. + + _C_o_m_p_o_n_e_n_t_s - this menu is used to select typical, frequently + encountered Soar code structures (Skeletons) or project + + + +Soar Last change: 1 + + + + + + +vt(n) Soar Commands vt(n) + + + + specific attribute-value structures (a-v pairs - NB this + needs overhauling and is currently a throwback to some test + code in an earlier version of this environment...). + +BRACKET CHECKING + The Bracket-checking toolbar offers several options: + + _D_o_C_o_u_n_t - applies bracket-checking...mismatched or + unclosed/unopened brackets will be highlighted individually + in pink, and the line in which they appear will be + highlighted in yellow. + + _C_o_m_p_l_e_m_e_n_t - by selecting a single bracket of a well formed + pair, use of the Complement option will highlight the con- + tents of the pair in pink. + + _P_a_i_r_e_d_B_y - similar to Complement, altough any bracket + (paired or mismatched) may be selected and complement will + find the first bracket that matches it, highlighting all + text in between in pink. + + _N_e_x_t - extends PairedBy; after choosing PairedBy, Next will + identify the next, next but one etc matching bracket. + +Soar OPTIONS + The interface to a Soar intepreter is provided by a _P_r_o_d_u_c_- + _t_i_o_n _I_n_s_p_e_c_t_o_r window. The Production Inspector code may be + loaded independently of viSTEAM into a Soar interpreter, but + it also forms an integral part of the viSTEAM environment. + For example, pull down the Soar menu and select _a_g_S_T_E_A_M.... + This launches the Production Inspector within the automati- + cally launched Soar agent interpreter, agSTEAM. (NB ideally, + the Production Inspector should be able to inspect the con- + tents of an arbitrarily selected interpreter). The Produc- + tion Inspector lists all the productions loaded in an inter- + preter in a scrollable listbox. Clicking on a produciton + name highlights it, and its code may then be viewed in the + Production Inspector text window by clicking on the View + Selected Production button. The code that appears in this + window may be sent to the text editor of the main viSTEAM + window for editing (although note that at the moment code in + the viSTEAM text editor may only be sent to the testbed + interpreter). Additional files may be sourced into the + interpreter overlooked by the Production Inspector using the + Source *.soar button. + + Healthcheck launches another window that provides a set of + tools for analysing the structure of the attribute-value + pairs of the loaded ruleset. + + A-V count has a go at building the attribute-value tree that + is described implicitly within the loaded ruleset. Once this + + + +Soar Last change: 2 + + + + + + +vt(n) Soar Commands vt(n) + + + + command has been issued, it is possible to employ the + extracted information in several ways: + + View A-V - allows the user to view the attributes or values + that appear as instances in the ruleset less than or equal + to the number of times on the button; _a_l_l allows all attri- + butes, or values, to be viewed. + + More - having displayed a list of attributes or values, one + may be highlighted and by selecting the More option, the + productions in which it appears (whether on the lhs or rhs) + may be identified. Recall that selecting the appropriate + production in the Production Inspector window allows its + code to be displayed there. + + AV Tree - this option produces a cascded series of tear off + menus that correspond to the attribute value tree extracted + from the ruleset. This may be very deep so an alternative + way of navigating is also provided - + + AV list - launches a window to allow navigation of an + attribute-value tree using a listbox. This code is still a + bit dodgy, but it's a start...(e.g. Add attribute/value + haven't been implemented yet, tree climbing is a bit iffy). + Selecting an item in the list box and pressing View Selected + displays the child attributes (or value options) of an + attribute. Viewing .. goes back up to the parent. The des- + cent of the tree should be displayed in the bottom list box. + The intention is that 'Use Selection' will allow a selected + element of the lower listbox to be pasted into the viSTEAM + text editor window. + +Builder OPTIONS + The Builder options are used to launch guis that accelerate + the production of frequently encountered code constructs in + STEAM. + + Agents - used to launch GUIs for constructing either single + agents or a team of uniform (individual) agents. Following + either selection, the user is prompted for an agent name. A + dialogue is then provided for setting various attributes of + the agent. Under the _C_r_e_a_t_e _T_e_a_m option, the user may + specify how many team members are required (currently lim- + ited to the range (2..4 for no good reason). By issuing the + _B_u_i_l_d _t_e_a_m command, a team is constructed and the defining + code may then be produced automatically. An option to save + the code that defines individual team-members to separate + files is then provided, (although at the moment all that + happens here is the generation of sample code for a single + agent within a dedicated text window). Operators - used to + elaborate an operator with a functional model (although at + the moment it only really supports the production of actual + + + +Soar Last change: 3 + + + + + + +vt(n) Soar Commands vt(n) + + + + models). Comms - used to generate certain characteristics + of a selected comms channel. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/cat/vtutor.n b/soar-8.5.2/doc/cat/vtutor.n new file mode 100644 index 0000000..29662c8 --- /dev/null +++ b/soar-8.5.2/doc/cat/vtutor.n @@ -0,0 +1,396 @@ + + + +vtutor(n) Soar Commands vtutor(n) + + + +_________________________________________________________________ + +NAME + viSTEAM (Tutorial) - A quick run through the major features + of an embryonic visual environment for developing Soar pro- + ductions and essential STEAM rules. + +SYNOPSIS + source vt.tcl +_________________________________________________________________ + +TUTORIAL +able is essential. + 1. Set pathnames as required in prefs.tcl. Only the VS_DIR vari- + +soartk; when in Soar, source vt.tcl + 2. cd to the directory containing the viSTEAM code and launch + +Soar is available - hit Yes. + 3. If Soar is not v7.0.4 you should be prompted about whether + +extensions is now offered. This starts a Soar interpreter and +loads the STEAM rules into it from a user specified directory - +if it does appear (i.e. you have set env(STEAM_1pt1_DIR)), hit +No. + 4. If a STEAM directory path is provided, a prompt to load STEAM + +Yes. + 5. You are now asked whether STEAM prototypes are required - + hit + +appeared, with some familiar and not so familiar menu bar +options. There are also two toolbars, one directly above and one +directly below the main text editing window (the _c_o_d_e _w_i_n_d_o_w). +(Some info about what's what appears in the man page vt - the +purpose here is to provide a quick run through, so there'll only +be a minimum of explanation...;-). + 6. The viSTEAM main window (the _E_d_i_t_S_o_a_r)should now have + + 7. Goto Builder on the menu bar and select Agents. + + 8. Select Create Team.... + +team herein). + 9. You will now be prompted for a team-name - + choose one (test- + +tings (note that the characteristics of the chosen comms channel +may be manipulated via the Details... option of the comms channel +selection or the Comms... option of the Builder menu). When +playing's done, hit Build team.... This creates a team based on +the information provided. + + + +Soar Last change: 1 + + + + + + +vtutor(n) Soar Commands vtutor(n) + + + + 10. A team builder dialogue is now presented. Play with the set- + +- hit Generate Soar Code.... The code window should be filled +with Soar code... + 11. You are now in a position to automatically generate some code + +the code for a single team agent is presented in a new text win- +dow. Appropriate code for each team member may be saved to +independent files by pressing Save agent code; this has a side +effect of closing the example agent code window. + 12. A prompt appears to _S_a_v_e _a_g_e_n_t _c_o_d_e? - + hit Yes. A sample of + +option of the File menu. Close the teambuilder window (Close). +Now build an operator from the Operators option of the Builder +menu, and generate the soar code. + 13. Save the code appearing in the code window by using the Save + +interpreter (in this case agTestbed, which is provided as a +default). This may be directly by dropping down the Send code +to... menu and choosing agTestbed. This launches a Production +Inspector window. + 14. To prove the code is valid, we'll now send it to a soar agent + +the Production Inspector listbox. (The listbox contains a list of +Soar productions in the interpreter, so if the name appars there, +the production is well formed). Selecting the production name and +clicking on _V_i_e_w _S_e_l_e_c_t_e_d _s_p will display the production code. +Code for a selected production by be sent to the _E_d_i_t_S_o_a_r by +means of the Copy code to viSTEAM button (clear the text in the +_E_d_i_t_S_o_a_r by clicking on Clear in the top toolbar of that main +window, and then send code to it from the Production Inspec- +tor...) + 15. The name of the production sent to agTestbed should appear in + +interpreter from the File menu (Source *.soar). If several files +are to be sourced, and a load.soar, soar.soar or {current- +interpreter}.soar file exists in a directory in order to manage +the sourcing of files within that directory, it may sourced +automatically by selecting File.Source ruleset and entering the +appropriate directory path. + 16. .soar rulefiles may be loaded directly into the current + +isn't too large, but is large enough to be interesting ;-). From +the Production Inspector menubar, select View and thence Health- +check. Yet another window appears, in which we can look at the +attribute-value structure of the loaded ruleset. + 17. Now for something that helps with debugging if the ruleset + +able, it may be launched in the current interpreter from the TSI +option). A bit of chugging ensues as the loaded productions are +(badly) parsed; a shortform version of the avtree is automati- + + + +Soar Last change: 2 + + + + + + +vtutor(n) Soar Commands vtutor(n) + + + +cally saved as a .avp file. Lots of options are now available +from the View menu. + 18. Goto the Options menu and choose A- + V count. (If TSI is avail- + +allows you to look at the attributes or values that appear in the +loaded ruleset less than or equal to a user selected number of +times; the idea is to try and track down typos by identifying +attributes or values that only appear once or twice in the whole +ruleset. Select Attr. + 19. Goto the View menu and select the View A_V option. This + +they appear may now be identified. Select an item in the listbox +and press the Related sp... button. By selecting one of the pro- +duction names, its code may be viewed with the View Production +button on the toolbar at the bottom of the window. + 20. Having loaded a list of attributes, the productions in which + +ruleset may be identified directly using the appropriate options +from the View menu. Selecting a particular _p_r_o_b_l_e_m-_s_p_a_c_e or +_o_p_e_r_a_t_o_r name and clicking on Related sp... identifies the pro- +ductions which propose and exploit (and terminate in the case of +_o_p_e_r_a_t_o_r_s) the name. For the single production example used here, +this is not very interesting. + 21. Particular _p_r_o_b_l_e_m- + _s_p_a_c_e_s and _o_p_e_r_a_t_o_r_s used within the + +of the loaded ruleset as a series of cascaded menus. Wander up +and down the tree. This structure (hopefully) reflects the struc- +ture inherent within the loaded productions. + 22. From the menubar select AV Tree. This depicts the full _a_v_t_r_e_e + +ruleset is large, so an alternative way of viewing the _a_v_t_r_e_e is +using the AV Tree option from the View menu. This opens a text +window (and also saves a tabulated .avt file) containing the +_a_v_t_r_e_e. The tree may be searched for particular attributes/values +using the toolbar at the bottom of the window. Close the AV Tree +Viewer window. A related tool, OpHelia, (available from the +_H_e_a_l_t_h_c_h_e_c_k menu View.Operator Hierarchy) tries to generate an +operator hierarchy based on analysis of operator.names that +appear in the rhs of a production whose lhs contains a specific +operator or problem-space name. Again, for the single production +example used here, this is not very interesting/ + 23. Using AV Tree from the menu bar can be quite scary when the + +from the AV List option of the View menu: the screen gets ever +more cluttered with a Navigate Project window. Select the item +_c_o_m_m_a_n_d in the list box of this window and hit Traverse Path. Do +the same for _g_r_o_u_p. In this way the avtree may be scaled and a +history appears in the middle frame; selecting one of these items +(for example, ^_c_o_m_m_a_n_d._g_r_o_u_p) and pressing Use Selection pastes +the selected item at the current cursor position in the main + + + +Soar Last change: 3 + + + + + + +vtutor(n) Soar Commands vtutor(n) + + + +_E_d_i_t_S_o_a_r code window (the idea is to minimise the likelihood of +generating typos whilst writing Soar productions; a similar +facility is available in the ditSoar directly, as will be demon- +strated later). The avtree may be climbed by selecting .. and +traversing the path. + 24. Rather more flexibility in navigating the _a_v_t_r_e_e is provided + +In the lower frame appears the names of all productions that +include the selected structure, distributed howsoever throughout +the production (so for example, a search on ^_a._b _c would actually +be made over ^_a._b._c _d -->, ^_a._b --> ^_c _d, ^_a --> ^_b._c _d and --> +^_a._b._c _d, appropriately formed of course. + 25. With ^_c_o_m_m_a_n_d._g_r_o_u_p still selected, click on Identify Prods. + +filter the productions identified as containing ^_c_o_m_m_a_n_d._g_r_o_u_p +with respect to particular ^_o_p_e_r_a_t_o_r._n_a_m_e or ^_p_r_o_b_l_e_m-_s_p_a_c_e._n_a_m_e +values. So for example, if you want to know whether +^_c_o_m_m_a_n_d._g_r_o_u_p appears in a production associated with a particu- +lar operator, click on the operator in the left hand box of the +operator frame of the Filtered Search window, Add it to the +filter set, reselect ^_c_o_m_m_a_n_d._g_r_o_u_p in the Navigate window, then +press Identify Prods in the Filtered Search window. NB operators +are selected for filtered search via listboxes; problem spaces +are selected using checkbuttons. This reflects an assumption that +there will be few problem spaces and many operators. Cancel the +Filtered Search window and close the Navigator window. + 26. Click on Advanced Search. The new window may be used to + +Inspector window. In the main viSTEAM window, clear the code win- +dow (Clear on the toolbar directly above the code window. + 27. Close the Production Healthcheck window. Close the Production + +a series of cascded menus that allows you to exploit an avtree. +Only take _c_a_s_c_a_d_e options at this point. Note that two projects +are available from the av-pairs menu, soar (a default) and (a +reduced form of) STEAM (which was loaded). Goto File, Project, +Load *.avp and hit return when presented with the request for a +filename, taking the default (agTestbed.avp, which we previously +saved). Returing to av-pairs, there is now an agTestbed option, +which cascades into the avtree for the production we generated +earlier. + 28. Drop the Components menu and and goto av- + pairs; this leads to + +ject.... Take it and accept the default name. It should now +appear as an option on the av-pairs menu. + 29. Withing the first av- + pairs cascade is an option to Add pro- + +the top left hand corner of the window (it should be set to soar. +Change this to testproj. ***at the moment, agTestbed is not a +viable option because its avtree lacks 2 essential branches - + + + +Soar Last change: 4 + + + + + + +vtutor(n) Soar Commands vtutor(n) + + + +_p_r_o_b_l_e_m-_s_p_a_c_e._n_a_m_e and _o_p_e_r_a_t_o_r._n_a_m_e; these may, however, be +added by the user as we shall see*** + 30. The current project in the _E_d_i_t_S_o_a_r is given by the menu in + +Propose op.... Give it a name (no angle brackets), such as +testop.Core lhs.... Give the production a name and hit return. +Core code for this production appears in the text window, and the +operator name is appended to the list of possible name values +within the av-pairs.testproj.operator.name menu. + 31. Goto Components on the menubar and select Skeletons, then + +ponents, av-pairs, steam, ^agent, approach-to-coordination, *cau- +tious*, g.parent, (a bit laborious, I know). This inserts the +code for ^_a_g_e_n_t._a_p_p_r_o_a_c_h-_t_o-_c_o_o_r_d_i_n_a_t_i_o_n *_c_a_u_t_i_o_u_s*. Play at +will...(the sense is that parent would give ^_a_p_p_r_o_a_c_h-_t_o- +_c_o_o_r_d_i_n_a_t_i_o_n *_c_a_u_t_i_o_u_s*, *cautious* would print *_c_a_u_t_i_o_u_s*, +g.g.parent would give ^_g_r_e_a_t._g_r_a_n_d._p_a_r_e_n_t _m_e etc. + 32. Place the cursor between <_s>) and ^_p_r_o_b_l_e_m- + _s_p_a_c_e. Goto Com- + +particular avtrees from within the av-pairs.whatever-proj cas- +cade. For example, goto av-pairs.testproj.Add ^attr , and +name the attribute _t_e_s_t_a_t_t_r_i_b_u_t_e(or whatever). This means we want +to add an attribute that will point to other attributes. Goto +av-pairs.testproj.^testattribute.Add ^attr const... and name this +one _t_e_s_t_2_a_t_t_r_i_b_u_t_e (or whatever). Finally, goto av- +pairs.testproj.^testattribute.test2attribute.Add value... to add +constant values. The new avtree may be saved from the +File.Project.Save a-v menu, as a ._a_v file. + 33. Attributes and values may be added as required (Add...) to + +required)... Delete a single bracket somewhere in the production +code (NB the delete key removes stuff to the *right* of the cur- +sor...). On the toolbar below the code window, press +DoCount...chug, chug, chug...The line containing the unmatched +bracket will be highlighted, as will the unmatched bracket. + 34. Now for the bracket checking tools (NB a colour monitor is + +bracket that complements the unmatched one will be highlighted, +as will all the intervening characters. Pressing Next goes to the +next complementary braket etc. Replace the missing bracket. + 35. Select the unmatched bracket, and press Paired By. The first + +highlights the code within the well formed pair. Clear the code +window. If Soar extensions are enabled (via the Preferences menu +on the bottom toolbar) then some additional checks are made to +the Soar code (e.g. (^attr val) would be signalled as an error +because of touching >^). + 36. Select a matched bracket and press Complement. This + + 37. Goto File and select Exit. + + + + +Soar Last change: 5 + + + + + + +vtutor(n) Soar Commands vtutor(n) + + + + Here ends the quick run through the major features of + viSTEAM. Comments, project funding etc to + Tony.Hirst@port.ac.uk please. See also + _h_t_t_p://_w_w_w._d_c_s._p_o_r_t._a_c._u_k/~_h_i_r_s_t_a" + + You may want to have another run through now using a ruleset + (100 to 200 prods, say) of your own: + + a) Launch visteam in its home directory, refusing steam options; + + b) Goto Soar-->New..." and give it a name (_m_y_p_r_o_j); + + c) Goto Soar-->myproj; + +and give it the name of a directory that contains a load.soar +file to manage the loading of lots of soar files within that +directory; + d) From the _P_r_o_d_u_c_t_i_o_n _V_i_e_w_e_r menubar, goto File-- + >Source ruleset + + e) Goto View-->Healthcheck; + + f) From the _H_e_a_l_t_h_c_h_e_c_k menubar, goto Options-->A-V Count; + + g) Play with the options from the View menu. + + + Mail me with questions, suggestions, bugs etc. + Tony.Hirst@port.ac.uk + + + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 6 + + + diff --git a/soar-8.5.2/doc/cat/wake-from-attention-lapse.n b/soar-8.5.2/doc/cat/wake-from-attention-lapse.n new file mode 100644 index 0000000..c3cd5a7 --- /dev/null +++ b/soar-8.5.2/doc/cat/wake-from-attention-lapse.n @@ -0,0 +1,55 @@ + + + +wake-from-attention-lapse Soar Commands wake-from-attention-lapse + + + +_________________________________________________________________ + +NAME + wake-from-attention-lapse - primarily intended to be called + from the RHS of a production rule + + +SYNOPSIS + wake-from-attention-lapse +_________________________________________________________________ + + +DESCRIPTION + This command is primarily intended to be called from the RHS + of a production rule. This sets the "attention-lapsing" + variable to FALSE (0), and starts tracking the amount of + real time that has passed since the last lapse. + +WARNINGS + The compile time options REAL_TIME_BEHAVIOR and ATTENTION_LAPSE + _m_u_s_t _b_e _e_n_a_b_l_e_d _f_o_r _t_h_i_s _f_u_n_c_t_i_o_n_a_l_i_t_y. + + +SEE ALSO + attention-lapse start-attention-lapse variables + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/wake.n b/soar-8.5.2/doc/cat/wake.n new file mode 100644 index 0000000..19bd82c --- /dev/null +++ b/soar-8.5.2/doc/cat/wake.n @@ -0,0 +1,118 @@ +_________________________________________________________________ +NAME + + + +wake- +from- +attention- +lapse +- +pri- +marily +intended +to +be +called +from +the +RHS +of +a +pro- +duc- +tion +rule +SYNOPSIS + + + +wake- +from- +attention- +lapse +_________________________________________________________________ + +DESCRIP- +TION + + + +This +com- +mand +is +pri- +marily +intended +to +be +called +from +the +RHS +of +a +pro- +duc- +tion +rule. +This +sets +the +"attention- +lapsing" +vari- +able +to +FALSE +(0), +and +starts +track- +ing +the +amount +of +real +time +that +has +passed +since +the +last +lapse. + +WARN- +INGS + + + +The +com- +pile +time +options +REAL_TIME_BEHAVIOR +_a_n_d +ATTENTION_LAPSE +_m_u_s_t +_b_e +_e_n_a_b_l_e_d +_f_o_r +_t_h_i_s +_f_u_n_c_- +_t_i_o_n_a_l_- +_i_t_y. +SEE +ALSO + + +attention- +lapse +start- +attention- +lapse +vari- +ables diff --git a/soar-8.5.2/doc/cat/warnings.n b/soar-8.5.2/doc/cat/warnings.n new file mode 100644 index 0000000..fe88fcc --- /dev/null +++ b/soar-8.5.2/doc/cat/warnings.n @@ -0,0 +1,66 @@ + + + +warnings(n) Soar Commands warnings(n) + + + +_________________________________________________________________ + +NAME + warnings - Enable/Disable Soar warnings + +SYNOPSIS + set warnings [on | off] +_________________________________________________________________ + + +DESCRIPTION + warnings is a Soar variable which through the Tcl _s_e_t com- + mand, enables and disables the printing of warning messages. + If an enabling or disabling _s_t_a_t_u_s of on or off is given, + then the warnings are set to that state. If no _s_t_a_t_u_s is + given, then the current warnings status is printed. At + startup, warnings are initially enabled. If warnings are + disabled using this command, then _m_o_s_t warnings are + supressed since some are considered too important to ignore. + + +OPTIONS + on | 1 + Turns on all warnings (initial default) + + off | 0 + Turns off all but critical warnings + + +SEE ALSO + variables + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 1 + + + diff --git a/soar-8.5.2/doc/cat/watch.n b/soar-8.5.2/doc/cat/watch.n new file mode 100644 index 0000000..c7c7adc --- /dev/null +++ b/soar-8.5.2/doc/cat/watch.n @@ -0,0 +1,257 @@ + + + +watch(n) Soar Commands watch(n) + + + +_________________________________________________________________ + +NAME + watch - Run-time tracing of Soar + +SYNOPSIS + watch [_l_e_v_e_l*] [-on | -off | -inc[lusive]] + watch wmes [-on | -off | -inc[lusive] | filter-options] + watch [ aliases | backtracing | loading ] [-on | -off ] + watch [ learning ] [-noprint | -print | -fullprint ] +_________________________________________________________________ + +DESCRIPTION + The watch command controls run-time tracing of Soar. With + no arguments, this command prints out the current watch + status. The various _l_e_v_e_ls are used to modify the current + watch settings. Each _l_e_v_e_l can be indicated with either a + number or a named flag as follows: + + 0 none + 1 decisions + 2 phases + 3 productions + 4 wmes + 5 preferences +9 + The numerical arguments (0 - 5) do not take any arguments or + modifiers. They inclusively turn on all levels up to the + number specified. To use numerical arguments to turn off a + level, specify a number which is less than the level to be + turned off. For instance, to turn off watching of produc- + tions, specify "watch 2" (or 1 or 0). Numerical arguments + are provided for shorthand convenience. For more detailed + control over the watch settings, the named arguments should + be used. + + For the named arguments, setting either the -on or -off + switch selectively turns on or off only that setting. Set- + ting the -inclusive switch (which can be abbreviated as + -inc) or setting no flag at all has the effect of setting + all levels up to and including the level specified. For + example, watch productions -on selectively turns on the + tracing of production firings/retractions; watch productions + -off selectively turns it off again. watch productions [- + inc] turns on the tracing of productions and also turns on + tracing of all levels below productions: decisions and + phases, too. Individual watch parameters may be used to + modify the inclusive settings as well, selectively turning + on or off any levels outside or inside the inclusive range. + + +9 + + +Soar Last change: 1 + + + + + + +watch(n) Soar Commands watch(n) + + + +OPTIONS + The following options are allowed (_s_t_a_t_u_s is given as either + -on, -off, or -inclusive, -inc is the default): + + 0 | none + turns off all printing about Soar's internals + + 1 | decisions _s_t_a_t_u_s + controls whether state and operator decisions are + printed as they are made + + 2 | phases _s_t_a_t_u_s + controls whether decisions cycle phase names are + printed as Soar executes. + + 3 | productions _s_t_a_t_u_s + controls whether the names of productions are printed + as they fire and retract. See the optional arguments + below [-all|-chunks|-defaults|-justifications|-user] + which specify which types of productions the _s_t_a_t_u_s + argument refers to. + + 4 | wmes + controls the printing of working memory elements that + are added and deleted as productions are fired and + retracted. + + To improve state tracing, the following filter-options + are available to watch wmes for monitoring a specified + object-attribute-value triplet: + + {-add-filter _t_y_p_e _f_i_l_t_e_r} | + {-remove-filter _t_y_p_e _f_i_l_t_e_r} | + {-reset-filter _t_y_p_e } | + {-list-filter _t_y_p_e } +9 + where: + + _t_y_p_e = -adds | -removes | -both + _f_i_l_t_e_r = {_i_d|*} {_a_t_t_r_i_b_u_t_e|*} {_v_a_l_u_e|*} +99 + 5 | preferences _s_t_a_t_u_s + controls whether the preferences generated by the + traced productions are printed when those productions + fire or retract. When a production fires, all the + preferences it generates are printed. When it retracts, + only the ones being removed from preference memory are + printed (i.e., the i-supported ones). + + -nowmes | -timetags | -fullwmes + controls the level of detail given about the wmes + + + +Soar Last change: 2 + + +9 + + +watch(n) Soar Commands watch(n) + + + + matched by productions whose firings and retractions + are being traced. Level 0|-nowmes means no information + about the wmes is printed. Level 1|-timetags means the + wme timetags are printed. Level 2|-fullwmes means the + whole wmes are printed. + + -all|-default|-user|-chunks|-justifications [_m_o_d_i_f_i_e_r] + allows user to selectively control printing by produc- + tion *type* as they fire and retract, instead of having + to watch ALL productions or none. (NOTE: these args + can be abbreviated by the first char ONLY, otherwise + the full arg must be specified.) The modifier can be + one of: + + -noprint|-print|-fullprint +9 + -noprint prints nothing, + -print prints the production name, + -fullprint prints the entire production. (not done as of 8.2) +9 + The following options control printing of other Soar parame- + ters and are not part of the above set of levels which can + be controlled as a group. + + aliases -on | -off + controls the echoing of aliases as they are defined. + + backtracing -on | -off + controls the printing of backtracing information when a + chunk or justification is created. + + loading -on | -off + controls the printing of '*' for each production loaded + and a '#' for each production excised + + learning -noprint | -print | -fullprint + controls the printing of chunks/justifications as they + are created. -noprint is don't print anything, -print + prints just the names, -fullprint prints the entire + chunk/justification. + +EXAMPLES + The most common uses of watch are by using the numeric argu- + ments which indicate watch levels: + + watch 0 +9 which turns off all printing of Soar internals (same as + watch none), or + + watch 3 +9 + + +Soar Last change: 3 + + + + + + +watch(n) Soar Commands watch(n) + + + + which turns on printing of decisions, phases and productions + (same as watch productions). Of course, individual options + can be changed as well: + + watch 1 wmes -on +9 turns on printing of decisions and wmes, but not phases and + productions. While + + watch 4 phases -off +9 turns on printing of decisions, productions and wmes, and + turns phases off. + + To watch the firing and retraction of only USER productions: + + watch productions -user -print +9 + whereas this command would watch decisions, phases and ALL + productions: + + watch productions +9 + + +NOTE + The pwatch command is used to watch named productions. + + +SEE ALSO + pwatch, print + + + + + + + + + + + + + + + + + + + + + + + + +Soar Last change: 4 + + + diff --git a/soar-8.5.2/doc/genpages.tcl b/soar-8.5.2/doc/genpages.tcl new file mode 100644 index 0000000..8f592ee --- /dev/null +++ b/soar-8.5.2/doc/genpages.tcl @@ -0,0 +1,14 @@ +#!/usr/tcl/bin/tclsh + +## use update-man-page to generate cat pages for all commands in man/ + + +set cmds [exec ls -c1 man] + +foreach f $cmds { + set name [file rootname $f] + if {[file exists [file join man ${name}.n]]} { + exec update-man-page -cat $name + exec update-man-page -html $name + } +} diff --git a/soar-8.5.2/doc/html/add-wme.html b/soar-8.5.2/doc/html/add-wme.html new file mode 100644 index 0000000..55254e6 --- /dev/null +++ b/soar-8.5.2/doc/html/add-wme.html @@ -0,0 +1,50 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +add-wme - Add a working memory element +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +add-wme
                                                                                                                                    id
                                                                                                                                    [^
                                                                                                                                    ]attribute value [+] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command adds an element to working memory and returns the +timetag of the wme. In effect, +Soar's working memory is surgically altered by this command. +add-wme adds a new wme with the given id, attribute, +value, and optional preference. The given id must +be an existing identifier. The attribute and value fields +can be any Soar symbol. If * is given in the attribute or +value field, Soar creates a new identifier (symbol) for that +field. If the preference is given, it can only have the +value + to indicate that an acceptable preference should be +created for this wme. +

                                                                                                                                    +add-wme is often used by an input function to update Soar's +information about the state of the external world. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This example adds the attribute/value pair "message-status received" +to the identifier (symbol) S1: +
                                                                                                                                    +add-wme S1 ^message-status received
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example adds an attribute/value pair with an acceptable +preference to the identifier (symbol) Z2. The attribute is +"message" and the value is a unique identifier generated by Soar. +Note that since the ^ is optional, it has been left off in +this case. +

                                                                                                                                    +add-wme Z2 message * +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +This command is inherently unstable and may have +weird side effects (possibly even including system crashes).
                                                                                                                                    +For example, the chunker can't backtrace through wmes created +via add-wme. Removing input wmes or context/impasse wmes may +have unexpected side effects. You've been warned. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +remove-wme diff --git a/soar-8.5.2/doc/html/alias.html b/soar-8.5.2/doc/html/alias.html new file mode 100644 index 0000000..75f9264 --- /dev/null +++ b/soar-8.5.2/doc/html/alias.html @@ -0,0 +1,67 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +alias - Define a new Soar alias +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +alias [name [definition | -off]] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command defines new aliases by creating Tcl procedures +with the given name. The new procedure can then take an arbitrary +number of arguments which are post-pended to the given definition +and then that entire string is executed as a command. When invoked, +the command is executed at the global level as if typed in from +the interactive command line interpreter. The definition must +be a single command, ';' for multiple commands is not allowed. If more +complex aliases are desired, then the Tcl proc command can be used +to define a new procedure. The alias procedure +checks to see if the name already exists, and does not +destroy existing procedures or aliases by the same name. + +Existing aliases can be removed by using the command unalias, +or by specifying alias name -off. + +With no arguments, alias returns the list of defined aliases. + +With only the name given, alias returns the current definition. + + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command wmes is an alias which is defined as follows: +

                                                                                                                                    +alias wmes print -depth 0 -internal
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +If the user executes a command such as: +

                                                                                                                                    +wmes {(* ^superstate nil)}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +it is as if the user had typed this command: +

                                                                                                                                    +print -depth 0 -internal {(* ^superstate nil)}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +\f Alias is also a Tcl command that is used when creating slave +interps. In Tcl, it is used to allow slave interps to call procs that +are defined in the master interp. See the Tcl help file in your system. + + +

                                                                                                                                    FILES

                                                                                                                                    +
                                                                                                                                    +soar.tcl and soar7.2km-aliases.tcl +
                                                                                                                                    + +
                                                                                                                                    The aliases for Soar provided upon startup are defined in these files. +The files are located in the $soar_library directory (folder). + +
                                                                                                                                    +

                                                                                                                                    SEE ALSO

                                                                                                                                    +unalias, rename, proc, predefined-aliases, +and Tcl Help for the interp and alias commands + diff --git a/soar-8.5.2/doc/html/attention-lapse.html b/soar-8.5.2/doc/html/attention-lapse.html new file mode 100644 index 0000000..434ec29 --- /dev/null +++ b/soar-8.5.2/doc/html/attention-lapse.html @@ -0,0 +1,39 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +attention-lapse - Enable/Disable attentional lapsing +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +attention-lapse [-on | -off] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The attention-lapse command is used to enable/disable the +attentional lapsing capabilities of Soar. The default value is -off. +If no argument is given, then the current attentional lapsing +status is printed. The actual behavior for lapsing are controlled thru +the start-attention-lapse and wake-from-attention-lapse commands. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -on + +
                                                                                                                                    Attentional lapsing will occur according to the +start-attention-lapse and wake-from-attention-lapse commands. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    Attentional lapsing will not occur. + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +This functionality must be enabled at compile time be defining the +compiler options ATTENTION_LAPSE and REAL_TIME_BEHAVIOR in soarkernel.h. +This option is not defined in the distribution version of Soar. + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +start-attention-lapse wake-from-attention-lapse diff --git a/soar-8.5.2/doc/html/attribute-preferences-mode.html b/soar-8.5.2/doc/html/attribute-preferences-mode.html new file mode 100644 index 0000000..2f59c56 --- /dev/null +++ b/soar-8.5.2/doc/html/attribute-preferences-mode.html @@ -0,0 +1,85 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +attribute-preferences-mode - Set or list the attribute preferences mode +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +attribute-preferences-mode [mode] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command is obsolete for Soar 8. In Soar 8, the code automatically +operates as if attribute-preferences-mode = 2. +

                                                                                                                                    +For Soar 7, this command sets and prints the attributes preferences mode. +If mode is not given, this command prints the current +attribute preferences mode. If mode is given, it must +be one of the positive integers 0, 1, or 2 +and is used to reset the attribute preferences modes. +

                                                                                                                                    +The "attribute-preferences-mode" parameter is used to control the +handling of preferences (other than acceptable and reject +preferences) for non-context slots. The mode settings have +the following interpretations: +

                                                                                                                                    +
                                                                                                                                    0 + +
                                                                                                                                    Handle them the normal (Soar 6) way. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    1 + +
                                                                                                                                    Handle them the normal (Soar 6) way, but print a warning message +whenever a preference other than + or - is created for a non-context +slot. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    2 + +
                                                                                                                                    Whenever a preferences other than + or - is created for a +non-context slot, print an error message and ignore +(discard) that preference. For non-context slots, the set +of values installed in working memory is always equal to +the set of acceptable values minus the set of rejected +values. +
                                                                                                                                    +

                                                                                                                                    +The default initial setting of the "attribute-preferences-mode" +parameter is 0. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command issued with no arguments, returns the current mode: +

                                                                                                                                    +attribute-preferences-mode 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The next example makes use of Tcl command abbreviation while setting +the mode to 1: +

                                                                                                                                    +attr  1 
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    VARIABLE

                                                                                                                                    + +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "attribute_preferences_mode" (with underscores) +that can be used to set the mode through the the Tcl set command. +If the mode is not given, the Tcl set command prints the current +attribute preferences mode. If mode is given, it must +be one of the positive integers 0, 1, or 2 +and is used to reset the attribute preferences modes. +
                                                                                                                                    +
                                                                                                                                    set attribute_preferences_mode returns the current mode +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    set attribute_preferences_mode 1 sets the mode to 1 +
                                                                                                                                    +

                                                                                                                                    +Soar variables cannot be abbreviated in the same manner as commandnames. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +

                                                                                                                                    +variables + diff --git a/soar-8.5.2/doc/html/capture-input.html b/soar-8.5.2/doc/html/capture-input.html new file mode 100644 index 0000000..69ff79b --- /dev/null +++ b/soar-8.5.2/doc/html/capture-input.html @@ -0,0 +1,50 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +capture-input - Save agent commands issued from the input function +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +capture-input
                                                                                                                                    action
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command may be used to start and stop the recording of +input function commands as created by an external simulation. +commands are +recorded decision cycle by decision cycle. Use the command +replay-input to replay the sequence. The action must +be one of the following: +

                                                                                                                                    +
                                                                                                                                    -open pathname + +
                                                                                                                                    A log file named pathname is created and input capturing is initiated. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -query + +
                                                                                                                                    Returns open if capturing is active or closed if +capturing is not active. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    Close the captured input file. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This initiates input capturing and places the commands in foo.in: +
                                                                                                                                    +capture-input -new foo.in
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This terminates capturing and closes the open log file: +

                                                                                                                                    +capture-input -off
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    WARNING

                                                                                                                                    +

                                                                                                                                    + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    diff --git a/soar-8.5.2/doc/html/chunk-name-format.html b/soar-8.5.2/doc/html/chunk-name-format.html new file mode 100644 index 0000000..f4e5ff7 --- /dev/null +++ b/soar-8.5.2/doc/html/chunk-name-format.html @@ -0,0 +1,126 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +chunk-name-format - Specify format of names of newly created chunks +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +chunk-name-format [-short | -long] [-prefix [<prefix>]] [-count [<chunk-num>]] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The chunk-name-format command specifies the format to be used when +naming newly created chunks. The short format is: +

                                                                                                                                    +<prefix>-<chunk-num>
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The long format is: +

                                                                                                                                    +<prefix>-<chunk-num>*d<dc>*<impasse-type>*<dc-chunk-num>
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +where: +

                                                                                                                                    +
                                                                                                                                    <prefix> + +
                                                                                                                                    is a user-definable prefix string; <prefix> defaults to "chunk" when +unspecified by the user; +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <chunk-num> + +
                                                                                                                                    is 1 for the first chunk created, 2 for the second +chunk created, and so on. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <dc> + +
                                                                                                                                    is the number of the decision cycle in which the chunk was formed; +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <impasse-type> + +
                                                                                                                                    is [tie | conflict | cfailure | snochange | opnochange] +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <dc-chunk-num> + +
                                                                                                                                    is the number of the chunk within that specific decision cycle. +
                                                                                                                                    +

                                                                                                                                    +Notes: +

                                                                                                                                    +
                                                                                                                                    1 + +
                                                                                                                                    The <prefix> string may not contain the '*' character. (The +chunk-name-format command enforces this constraint.) The '*' +character marks the ending of the number of the chunk, and +chunk numbers are examined during production loading to allow +a starting chunk number to be identified automatically. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    2 + +
                                                                                                                                    <impasse-type> is the impasse of the lowest goal that has +a result generated by this chunk. + +
                                                                                                                                    +

                                                                                                                                    OPTIONS

                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    +
                                                                                                                                    -short + +
                                                                                                                                    When generating chunk names, use the short format. +(See the DESCRIPTION section for details.) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -long + +
                                                                                                                                    When generating chunk names, use the long format. +(See the DESCRIPTION section for details.) +This is the default format for Soar. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -prefix [<prefix>] + +
                                                                                                                                    When generating chunk names, use the string <prefix>. +<prefix> is initially "chunk". +When <prefix> is unspecified, return the current <prefix>. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -count [<chunk-num>] + +
                                                                                                                                    Set chunk counter to <chunk-num>. +<chunk-num> cannot be reset to a number lower than the +smallest chunk number of any loaded chunk. +When <chunk-num> is unspecified, return the current <chunk-num>. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    chunk-name-format -short -prefix "chunk" -count 0 + +
                                                                                                                                    To cause chunks to be named according to the "old" scheme. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    chunk-name-format -prefix "new-chunk" + +
                                                                                                                                    To begin naming a new sequence of chunks. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    chunk-name-format -count 1000 + +
                                                                                                                                    To begin numbering a new sequence of chunks at 1000. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    chunk-name-format -count + +
                                                                                                                                    To retrieve the next <chunk-num> that will be used to form a chunk name. + + + + + + + diff --git a/soar-8.5.2/doc/html/command-to-file.html b/soar-8.5.2/doc/html/command-to-file.html new file mode 100644 index 0000000..ce15a27 --- /dev/null +++ b/soar-8.5.2/doc/html/command-to-file.html @@ -0,0 +1,33 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +command-to-file - Evaluate the command and print result to file +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +command-to-file command file [mode] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This evaluates a command in the current interpreter. +The prints issued by the command and its result (both of which +are normally printed to stdout) are redirected to the given +file. The mode determines whether the file is +initially opened in write (-new) or append (-existing) +mode. If no mode is given, then -new is assumed. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command writes all productions to the file my-file: +

                                                                                                                                    +command-to-file list-productions my-file
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This command appends the memory statistics to the already +existing file my-stats-file: +

                                                                                                                                    +command-to-file {stats -memory} my-stats-file -existing
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +output-strings-destination diff --git a/soar-8.5.2/doc/html/d.html b/soar-8.5.2/doc/html/d.html new file mode 100644 index 0000000..702215e --- /dev/null +++ b/soar-8.5.2/doc/html/d.html @@ -0,0 +1,19 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +d - Run Soar by decision cycles +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +d [cycles
                                                                                                                                    ] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +d is actually a predefined alias for 'run [n] d' +which runs the Soar agent for the given number of decision +cycles. If no cycles are given, then the agent is +run for one decision cycle. 'd -1' or 'd forever' runs the agent +until the task terminates or a user interrupt is given. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +run diff --git a/soar-8.5.2/doc/html/default-wme-depth.html b/soar-8.5.2/doc/html/default-wme-depth.html new file mode 100644 index 0000000..a60870b --- /dev/null +++ b/soar-8.5.2/doc/html/default-wme-depth.html @@ -0,0 +1,63 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +default-wme-depth - Set or list the default print depth +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +default-wme-depth [depth] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command sets and prints the default printing depth. +If depth is not given, this command prints the default +printing depth. If depth is given, it must be a positive +integer and is used to reset the default printing depth. +

                                                                                                                                    +The "default-wme-depth" parameter is used to control the +default printing depth of the print command. +The default initial setting of the "default-wme-depth" +parameter is 1. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command issued with no arguments, returns the print depth: +

                                                                                                                                    +default-wme-depth 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The next example makes use of Tcl command abbreviation while setting +the depth to 3: +

                                                                                                                                    +def  3 
                                                                                                                                    +
                                                                                                                                    + + +

                                                                                                                                    VARIABLE

                                                                                                                                    +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "default_wme_depth" (with underscores) +that can be used to set the print depth through the the Tcl +set command. If depth is not given, the Tcl set +commands prints the default printing depth. If depth is given, +it must be a positive integer and is used to reset the default +printing depth. +

                                                                                                                                    +

                                                                                                                                    +
                                                                                                                                    set default_wme_depth returns the current depth +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    set default_wme_depth 3 sets the depth to 3 +
                                                                                                                                    +

                                                                                                                                    +Soar variables cannot be abbreviated in the same manner as commandnames. + +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +This parameter can be overridden in any invocation of the +print command by using the -depth option. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +print, variables + + + diff --git a/soar-8.5.2/doc/html/dirs.html b/soar-8.5.2/doc/html/dirs.html new file mode 100644 index 0000000..fea2561 --- /dev/null +++ b/soar-8.5.2/doc/html/dirs.html @@ -0,0 +1,23 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +dirs - List the directory stack +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +dirs +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command lists the directory stack. Agents can move through +a directory structure by pushing and popping directory names. The +dirs command returns the stack. +

                                                                                                                                    +The command pushd places a new "agent current directory" on +top of the directory stack and cds to it. The command +popd removes the directory at the top of the directory stack +and cds to the previous directory which now appears at the +top of the stack. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +pushd, popd, topd diff --git a/soar-8.5.2/doc/html/e.html b/soar-8.5.2/doc/html/e.html new file mode 100644 index 0000000..15c176f --- /dev/null +++ b/soar-8.5.2/doc/html/e.html @@ -0,0 +1,18 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +e - Run Soar by elaboration cycles +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +e [cycles | forever] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +e is actually a predefined alias for 'run [n] e' which +runs the Soar agent for the given number of elaboration +cycles. If no cycles are given, then the agent is +run for one elaboration cycle. 'e -1' or 'e forever' +runs the agent until the task terminates or a user interrupt is given. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    diff --git a/soar-8.5.2/doc/html/echo.html b/soar-8.5.2/doc/html/echo.html new file mode 100644 index 0000000..1593ddd --- /dev/null +++ b/soar-8.5.2/doc/html/echo.html @@ -0,0 +1,26 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +echo - Echo message +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +echo [-nonewline] args +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command echos the args to the current output +stream. This is normally stdout but can be set +to a variety of channels. If an arg is -nonewline +then no newline is printed at the end of the printed strings. +Otherwise a newline is printed after printing all the given +args. For the full details of the redirection, see the +command output-strings-destination. +

                                                                                                                                    +Users wanting to print variables and data to the screen, should +use echo rather than the Tcl command "puts." The echo +command gets redirected to the appropriate channel according +to output-strings-destination; the "puts" command does not. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +output-strings-destination diff --git a/soar-8.5.2/doc/html/excise.html b/soar-8.5.2/doc/html/excise.html new file mode 100644 index 0000000..21e38c4 --- /dev/null +++ b/soar-8.5.2/doc/html/excise.html @@ -0,0 +1,63 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +excise - Remove productions from Soar's memory +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +excise production-name | -chunks | -default | -task | -user | -all +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command removes productions from Soar's memory. Each +option given on the command line may be either a production +name or the type of the standard set of productions (indicated by a keyword). + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    production-name + +
                                                                                                                                    Remove the production named production-name from memory +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -chunks + +
                                                                                                                                    Remove all chunks (learned productions) and justifications from memory +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -default + +
                                                                                                                                    Remove all default rules (:default) from memory +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -task + +
                                                                                                                                    Remove all non-default productions from memory and perform +an init-soar command +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -user + +
                                                                                                                                    Remove all user productions (but not chunks or default rules) from memory. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -all + +
                                                                                                                                    Remove all productions from memory and perform +an init-soar command + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +This removes the production my*first*production and all chunks: +

                                                                                                                                    +excise my*first*production -chunks
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This removes all productions and does an init-soar: +

                                                                                                                                    +excise -all
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +init-soar diff --git a/soar-8.5.2/doc/html/explain-backtraces.html b/soar-8.5.2/doc/html/explain-backtraces.html new file mode 100644 index 0000000..cc2b43f --- /dev/null +++ b/soar-8.5.2/doc/html/explain-backtraces.html @@ -0,0 +1,65 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +explain-backtraces - Interpret chunking backtraces +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +explain-backtraces [prodnamename [n | -full] ] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command provides some interpretation of backtraces generated +during chunking. If no option is given, then a list of all chunks +and justifications is printed. +

                                                                                                                                    +The two most useful variants are explain-backtraces prodname and +explain-backtraces name n. +The first variant lists all of the conditions for the named +chunk or justification, and the ground which resulted in +inclusion in the chunk/justification. A ground is a +working memory element (WME) which was tested in the supergoal. +Just knowing which WME was +tested may be enough to explain why the chunk/justification +exists. If not, the conditions can be listed with an integer +value. This value can be used in +explain-backtraces name n +to obtain a list of the productions which fired to obtain this +condition in the chunk/justification (and the crucial WMEs +tested along the way). Why use an integer value to specify the +condition? To save a big parsing job. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +

                                                                                                                                    +If an option is given, it must match one of the following forms: +

                                                                                                                                    +
                                                                                                                                    name + +
                                                                                                                                    list all conditions and grounds for the chunk or justification named +name +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    name -full + +
                                                                                                                                    provide a backtrace for the chunk or justification named name +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    name n + +
                                                                                                                                    explain why condition number n is in the chunk or +justification + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +save_backtraces mode must be on when a chunk or +justification is created or no explanation will be available. +Explain-backtraces mode is toggled using the save_backtraces +boolean variable. save_backtraces is off by default. +When explain mode is on, more memory is used, and building +chunks and justifications will be slower. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +save_backtraces, variables + + diff --git a/soar-8.5.2/doc/html/firing-counts.html b/soar-8.5.2/doc/html/firing-counts.html new file mode 100644 index 0000000..eef782f --- /dev/null +++ b/soar-8.5.2/doc/html/firing-counts.html @@ -0,0 +1,52 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +firing-counts - Print production firing counts +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +firing-counts [integer | production-names] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints information about production firings. +If an option is not given, then all productions are printed in +a sorted list according to how many times they have fired. + +

                                                                                                                                    OPTIONS

                                                                                                                                    + +If given, an option can take one of two forms -- an integer or a list +of production names: +
                                                                                                                                    +
                                                                                                                                    integer + +
                                                                                                                                    List the top integer productions. If integer is 0, +only the productions which haven't fired are listed. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    production-names + +
                                                                                                                                    For each production in production-names, print how many +times the production has fired. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This example prints the 10 productions which have fired the most +times along with their firing counts: +
                                                                                                                                    +firing-counts 10
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example prints the firing counts of productions +my*first*production and my*second*production: +

                                                                                                                                    +firing-counts my*first*production my*second*production
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +firing-counts are reset to zero after an init-soar +

                                                                                                                                    +NB: This command is slow, because the sorting takes time +O(n*log n) + diff --git a/soar-8.5.2/doc/html/format-watch.html b/soar-8.5.2/doc/html/format-watch.html new file mode 100644 index 0000000..089e8ef --- /dev/null +++ b/soar-8.5.2/doc/html/format-watch.html @@ -0,0 +1,233 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +format-watch - Control the format of printed objects +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +format-watch [-stack | -object] [operation class [name] format] +
                                                                                                                                    +\toperation ::= -add | -remove +
                                                                                                                                    +\tclass ::= s | o | * +
                                                                                                                                    +\tformat ::= {sequence of format masks} +
                                                                                                                                    +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The format-watch command defines the format to use when +printing Soar objects and the Soar goal stack. The optional +type, if present, must be the switch -object or -stack +and indicates which format to manipulate. Object trace +formats control how Soar prints an object--e.g., a certain +operator, problem-space, etc. Stack trace formats control how +Soar prints its context stack selections in watch 0 and +print -stack printouts. If no type is given, then +-stack is assumed. +

                                                                                                                                    +The second portion of the format-watch command is the +action to apply to the selected trace format. An action +consists of adding or removing formats to selected classes +of objects. An action has the following form: +

                                                                                                                                    +     operation class [name] format
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The operation must be either -add or -remove. +An -add operation adds new trace formats replacing any +existing ones with identical applicability conditions. A +-remove operation removes trace formats with the given +applicability conditions. +The combination of class and name define the +applicability conditions of the format (i.e., which classes +of objects the format applies to). +The class must be either s or o +and indicates that the operation applies to states or operators, +respectively. The wildcard symbol * +may also be used to indicate that the format applies to all objects. +If an -object trace is being manipulated, then an optional +name may be given indicating the format applies only +to objects with that name. If a -stack trace is being +manipulated, then an optional name may be given indicating +the format applies only within problem spaces of that name. +

                                                                                                                                    +The format string can be any sequence of characters +surrounded by curly braces. Note that double quotes are not +sufficient because the square brackets in the format string will +be interpreted as a command to be evaluated by Tcl. Certain +formatting controls can be used within the string--see the +section FORMAT CONTROLS below for more information. + +

                                                                                                                                    +If no arguments are given, then format-watch prints the +current format settings. + +

                                                                                                                                    FORMAT CONTROLS

                                                                                                                                    +

                                                                                                                                    +The following control sequences can be used within trace format +strings. The S indicates the sequence is ONLY usable in +stack traces: +

                                                                                                                                    +
                                                                                                                                    %cs + +
                                                                                                                                    print the current state using the appropriate object trace format (S) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %co + +
                                                                                                                                    print the current operator using the appropriate object trace format (S) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %dc + +
                                                                                                                                    print the current decision cycle number (S). Not meaningful and +therefore ignored in stack traces produced by the print -stack command. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %ec + +
                                                                                                                                    print the current elaboration cycle number (S). Not meaningful and +therefore ignored in stack traces produced by the print -stack command. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %sd + +
                                                                                                                                    print the current subgoal depth (S). This uses 0 as the top level. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %rsd[pattern] + +
                                                                                                                                    repeat (subgoal depth) times: print the given pattern (S). +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %left[num,pattern] + +
                                                                                                                                    print the pattern left justified in a field of num spaces. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %right[num,pattern] + +
                                                                                                                                    print the pattern right justified in a field of num +spaces. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %id + +
                                                                                                                                    print the identifier of the current object. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %v[attr] + +
                                                                                                                                    print the value(s) of attribute ^attr on the current object. +If there is no ^attr on the current object, nothing is printed. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %v[path] + +
                                                                                                                                    same as the above, only follow the given attribute path to +get the value(s). A path is a sequence of attribute names +separated by periods, such as foo.bar.baz. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %v[*] + +
                                                                                                                                    print all values of all attributes on the current object. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %o[args] + +
                                                                                                                                    same as %v, except that if the value is an identifier, it is +printed using the appropriate object trace format. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %av[args] + +
                                                                                                                                    same as %v, except the printed value is preceeded with "^attr +" to indicate the attribute name. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %ao[args] + +
                                                                                                                                    a combination of the above two. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %ifdef[pattern] + +
                                                                                                                                    print the given pattern if and only if all escape sequences +inside it are "meaningful" or "well-defined." For example, +the format string %ifdef[foo has value: %v[foo]] will print +nothing if there is no ^foo on the current object. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %nl + +
                                                                                                                                    print a newline +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %% + +
                                                                                                                                    print a percent sign +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %[ + +
                                                                                                                                    print a left bracket +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    %] + +
                                                                                                                                    print a right bracket + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +In the following examples, the phrase "the command prints X" is simply +an abbreviation for the more accurate phrase "the command defines a +trace format string which when used for printing will print X". +

                                                                                                                                    +These commands are equivalent to the default settings for stack traces: +

                                                                                                                                    +format-watch -stack -add s {%right[6,%dc]: %rsd[   ]==>S: %cs}
                                                                                                                                    +format-watch -stack -add o {%right[6,%dc]: %rsd[   ]   O: %co}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The above format strings print the decision cycle number right +justified in a field 6 characters wide. After that, a colon and +space are printed. Then, three spaces are printed as many times as +the subgoal is deep. Finally, a few more characters are printed +to indicate the item type and then the item itself is printed. +

                                                                                                                                    +The following commands are equivalent to the default settings for +object traces: +

                                                                                                                                    +format-watch -object -add * {%id %ifdef[(%v[name])]}
                                                                                                                                    +format-watch -object -add s {%id %ifdef[(%v[attribute] %v[impasse])]}
                                                                                                                                    +format-watch -object -add o evaluate-object {%id (evaluate-object %o[object])}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The first command prints an identifier followed by its name in +parentheses (if a name is defined) for all objects. This will +hold unless overridden by more specific applicability conditions. +This first format might print something like: O37 (my-operator-name). +The last two commands define (overriding) formats for states and +operators. The second command, for states, prints the state identifier +followed, in parentheses, by its ^attribute and ^impasse +attributes, if they are defined. For example, this might print +G5 (operator no-change). Finally, the third command handles +evaluate-object operators in the selection space. These +operators will be printed as an id followed, in parentheses, by +the string "evaluate-object " and the printed representation of the +object being printed. +

                                                                                                                                    +The following stack trace format causes both the current state +and current operator to be printed whenever an operator is selected. +(There is a linefeed in the middle of the format string.) +

                                                                                                                                    +format-watch -stack -add o {%right[6,%dc]: %rsd[   ]   S: %cs
                                                                                                                                    +        %rsd[   ]   O: %co}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The above format is useful for watching the effects of operator +applications. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    + +watch, print diff --git a/soar-8.5.2/doc/html/gds-print.html b/soar-8.5.2/doc/html/gds-print.html new file mode 100644 index 0000000..512a19a --- /dev/null +++ b/soar-8.5.2/doc/html/gds-print.html @@ -0,0 +1,14 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +init-soar - Initialize Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +init-soar +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command initializes or re-initializes Soar. Initialization +removes all elements from working memory, wipes out the goal stack, +and resets all statistics. It does not excise chunks. diff --git a/soar-8.5.2/doc/html/gds_print.html b/soar-8.5.2/doc/html/gds_print.html new file mode 100644 index 0000000..94df1ba --- /dev/null +++ b/soar-8.5.2/doc/html/gds_print.html @@ -0,0 +1,15 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +gds_print - Examine the goal dependency set. +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +gds_print +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +A debugging command for examing the GDS when necessary. It is horribly +inefficient and should not generally be used except when something +is going wrong and you want to take a peak at the Goal Dependency Set. + diff --git a/soar-8.5.2/doc/html/help.html b/soar-8.5.2/doc/html/help.html new file mode 100644 index 0000000..f859ac7 --- /dev/null +++ b/soar-8.5.2/doc/html/help.html @@ -0,0 +1,70 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +help - Print man pages for Soar commands +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +help [-all | commandname [-usage]] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints the formatted manual page for the given +commandname. Soar's help facility is able to do command +completion, so as long as a unique substring of the commandname +is specified, Soar will find and display the help page. +

                                                                                                                                    +Under the TSI (Tcl-Soar Interface, a graphical interface to Soar), +the help will pop up a separate window to display the text. +

                                                                                                                                    +Under Unix with no TSI running, the help command attempts to +locate a pager program to +use to display help pages page-by-page since some are longer than a +typical screen. The command first examines the environment +variable PAGER to see if the user has defined a preference there. +If that is not present, the help system checks to see if one +of the commonly used pagers "less", "more", or "page" is +available (in that order). If no pager is available, then +an error message is given. If no pagers exist on your system, +then you can set the environment variable PAGER to "cat" and +the help pages will simply be cat'ed to the screen. Since +some pages are long, this will make it difficult to read an +entire page. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -all + +
                                                                                                                                    List all commands for which help is available +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -usage + +
                                                                                                                                    List only the SYNOPSIS section of the man page. This includes +the abbreviated syntax for the command. -usage may not work properly +on some windows and mac systems. + +
                                                                                                                                    +

                                                                                                                                    FILES

                                                                                                                                    +

                                                                                                                                    +The nroff sources for the manual pages are stored in the +subdirectory .../doc/man. These files are used to +generate the "cat" and "HTML" versions which are stored +in .../doc/cat and .../doc/html, respectively. + +

                                                                                                                                    ENVIRONMENT

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    PAGER + +
                                                                                                                                    +This variable contains the user's preferred paging program +which shows text page by page rather than spewing all text at once +to standard output. Typical pagers are more, less, +and page. + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    + +Some pages, such as less clear the screen upon exit, removing +the help page from view. If you wish to retain the help page, use +a pager such as more. diff --git a/soar-8.5.2/doc/html/indifferent-selection.html b/soar-8.5.2/doc/html/indifferent-selection.html new file mode 100644 index 0000000..24e22ea --- /dev/null +++ b/soar-8.5.2/doc/html/indifferent-selection.html @@ -0,0 +1,53 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +indifferent-selection - Control indifferent preference arbitration +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +indifferent-selection [-first | -last | -ask | -random] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command controls indifferent preference arbitration. When +an indifferent preference tie is created among two or more items, +then the "indifferent-selection" parameter is used by the Soar decision +procedure to control the selection of one item to resolve the tie +and avoid an impasse. +

                                                                                                                                    +If no option is given, this command prints the current setting of +the "indifferent-selection" parameter. If an option is given, it is +used to guide the resolution of indifferent preference ties. At +startup, the default setting of the "indifferent-selection" parameter is +-random. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +If given, the option must match one of the following: +
                                                                                                                                    +
                                                                                                                                    -first + +
                                                                                                                                    Choose the first object found (deterministically) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -last + +
                                                                                                                                    Choose the last object found (deterministically) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -ask + +
                                                                                                                                    Ask the user to choose one of the items +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -random + +
                                                                                                                                    Choose an object randomly. This is the default setting. +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    + +-ask currently only works under Unix, when Soar is run from +the console window (not the TSI). This is because indifferent-selection +is handled deep in the kernel, and the kernel has no knowledge of +Tcl, and therefore no information on how to read data from anywhere +except stdin. diff --git a/soar-8.5.2/doc/html/init-soar.html b/soar-8.5.2/doc/html/init-soar.html new file mode 100644 index 0000000..512a19a --- /dev/null +++ b/soar-8.5.2/doc/html/init-soar.html @@ -0,0 +1,14 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +init-soar - Initialize Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +init-soar +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command initializes or re-initializes Soar. Initialization +removes all elements from working memory, wipes out the goal stack, +and resets all statistics. It does not excise chunks. diff --git a/soar-8.5.2/doc/html/input-period.html b/soar-8.5.2/doc/html/input-period.html new file mode 100644 index 0000000..a7b1fc6 --- /dev/null +++ b/soar-8.5.2/doc/html/input-period.html @@ -0,0 +1,29 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +input-period - Set or list the input period +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +input-period [period] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command is obsolete for Soar8. In Soar8, input is done +at the start of every decision cycle. +

                                                                                                                                    +This command controls the rate of input to the Soar agent. +If period is not specified, this command prints the current +input period. If period is specified, it must be a non-negative +integer and is used to reset the input period. A period of +0 sets input to occur every elaboration cycle. +A positive value for period sets Soar +to accept input only every nth period decision cycles. +The default initial setting of the "input-period" +parameter is 0. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    input-period 5 + +
                                                                                                                                    Input is accepted only every 5th decision cycle by the Soar agent. diff --git a/soar-8.5.2/doc/html/internal-symbols.html b/soar-8.5.2/doc/html/internal-symbols.html new file mode 100644 index 0000000..8f936ba --- /dev/null +++ b/soar-8.5.2/doc/html/internal-symbols.html @@ -0,0 +1,14 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +internal-symbols - Print contents of the Soar symbol table +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +internal-symbols +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints information about the Soar symbol table. Such +information is typically only useful for users attempting to debug +Soar by locating memory leaks. diff --git a/soar-8.5.2/doc/html/io.html b/soar-8.5.2/doc/html/io.html new file mode 100644 index 0000000..07baaa7 --- /dev/null +++ b/soar-8.5.2/doc/html/io.html @@ -0,0 +1,45 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +io - Manage attachment of scripts to Soar I/O +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +io action +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command manages the attachment of scripts to Soar I/O. +Soar has an event defined for input and another for output. +Scripts can be attached to these Soar events so that they are +invoked every time the Soar event occurs. +These scripts can later be removed using the io command. +The status of attachments can be listed also. If a new +attachment is created, its identifier is returned as the result +of this command. +

                                                                                                                                    +The specified action must have one of the following forms: +

                                                                                                                                    +
                                                                                                                                    -add [-input | -output] script [id] + +
                                                                                                                                    Add the script to the list of scripts to be invoked when the +-input or output event occurs in the Soar kernel. +If the id is given, it is used to name the attachment. +If no id is given, then a unique id is generated and returned. +The id is necessary if a user ever wants to delete an action. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -delete [-input | -output] id + +
                                                                                                                                    Remove script attachment named id. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -list [-input | -output] + +
                                                                                                                                    List all attachments of scripts to Soar input or output. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +A detailed example of using Soar I/O in Tcl is given in the +file demos/soar-io-using-tcl.tcl. diff --git a/soar-8.5.2/doc/html/learn.html b/soar-8.5.2/doc/html/learn.html new file mode 100644 index 0000000..ea1cca8 --- /dev/null +++ b/soar-8.5.2/doc/html/learn.html @@ -0,0 +1,65 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +learn - Control the learning of productions +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +learn [-on | -off | -except | -only | -list | -all-levels | -bottom-up] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command is used to control the learning (or "chunking") of productions. +With no arguments, this command prints out the current learning +environment status. The watch command can be used to +provide various levels of detail when productions are learned. + +Learning is on by default. + +

                                                                                                                                    OPTIONS

                                                                                                                                    + +Any options given must match one of the following keywords: +
                                                                                                                                    +
                                                                                                                                    -on + +
                                                                                                                                    turn learning on +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    turn all learning off +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -except + +
                                                                                                                                    learning is on, except as specified by RHS dont-learn actions +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    \fb-only + +
                                                                                                                                    learning is off, except as specified by RHS force-learn actions +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    \fb-list + +
                                                                                                                                    lists the force-learn and dont-learn states registered by the RHS actions + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -all-levels + +
                                                                                                                                    when learning is on, this allows learning whenever +a subgoal returns a result (in contrast to bottom-up learning) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -bottom-up + +
                                                                                                                                    when learning is on, this allows learning at only +the lowest level; i.e., build chunks only for subgoals that have +not yet had any subgoals with chunks built. + + + +
                                                                                                                                    +

                                                                                                                                    SEE ALSO

                                                                                                                                    +watch, explain-backtraces, save_backtraces diff --git a/soar-8.5.2/doc/html/log.html b/soar-8.5.2/doc/html/log.html new file mode 100644 index 0000000..3cab746 --- /dev/null +++ b/soar-8.5.2/doc/html/log.html @@ -0,0 +1,57 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +log - Log a Soar agent session +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +log action +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command records the prompts, commands, printing, and command +results that are printed to stdout for a given agent. The +action must be one of the following: +

                                                                                                                                    +
                                                                                                                                    -new pathname + +
                                                                                                                                    A log file named pathname is created and logging is initiated. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -existing pathname + +
                                                                                                                                    An existing log file named pathname is opened and logging is +added to the end of the file. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -add string + +
                                                                                                                                    Add the given string to the open log file +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -query + +
                                                                                                                                    Returns open if logging is active or closed if +logging is not active. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    Close the open log file. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This initiates logging and places the record in foo.log: +
                                                                                                                                    +log -new foo.log
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This appends log data to an existing foo.log file: +

                                                                                                                                    +log -existing foo.log
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This terminates logging and closes the open log file: +

                                                                                                                                    +log -off
                                                                                                                                    +
                                                                                                                                    diff --git a/soar-8.5.2/doc/html/matches.html b/soar-8.5.2/doc/html/matches.html new file mode 100644 index 0000000..0ceb2cd --- /dev/null +++ b/soar-8.5.2/doc/html/matches.html @@ -0,0 +1,103 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +matches - List production match information +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +matches production-name [-count | -timetags | -wmes | 0 | 1 | 2] +
                                                                                                                                    +matches [-assertions | -retractions] [-names | +-timetags | -wmes | 0 | 1 | 2] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints partial match information for a selected +production. If issued at the end of the Decision Phase, it also +prints the current set of productions that +are about to fire or retract in the next preference phase. This +information is useful for determining what changes to working memory +are necessary in order to achieve a match of the left-hand sides +of productions. +

                                                                                                                                    +If no production name is given, then it is assumed that the user +desires information about the match set, including both assertions +and retractions. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +Normally both assertions and retractions are printed by the matches +command. This can be restricted using one of the following options: +
                                                                                                                                    +
                                                                                                                                    -assertions + +
                                                                                                                                    List only those productions about to fire +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -retractions + +
                                                                                                                                    List only those productions about to retract +
                                                                                                                                    +

                                                                                                                                    +The optional detail specifies the kind of information desired and +must be one of the following (the 0 option is the default): +

                                                                                                                                    +
                                                                                                                                    -count or -names or 0 + +
                                                                                                                                    Print just the partial match counts. If the match set is being +printed, then print just the production names. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -timetags or 1 + +
                                                                                                                                    Print the same information as the -count option plus +the timetags of wmes at the the first failing condition +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -wmes or 2 + +
                                                                                                                                    Print the same information as the -timetags option except +print the full wmes rather than just their timetags + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This example prints the productions which are about to fire +and the wmes that match the productions on their left-hand sides: +
                                                                                                                                    +matches -assertions -wmes
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example prints the wme timetags for a single production. This +example takes advantage of the unique prefix abbreviation feature of +switches. +

                                                                                                                                    +matches -t my*first*production
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +In Soar 8, the Decision Phase occurs in the middle of the Decision Cycle, +followed by the Apply Phase. Therefore, at the end of the Decision +Cycle, productions will have already fired and the "matches" command +will not be very helpful. To examine the match information in +immediately after the Decision Phase in Soar 8, users can implement +either of the following callbacks: +

                                                                                                                                    +monitor -add {matches -wmes} after-decision-phase-cycle
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +monitor -add {stop-soar -self} after-decision-phase-cycle
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The first example can use any options to the matches command, +whatever the user finds most helpful. +The second option, which stops Soar at the end of the Decision Phase, +offers the most flexibility for debugging. It is recommended that +users issue this callback for all agents, so they don't get out +of synch when running. Once the productions have been debugged, +the monitors can be deleted. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +monitor + + + + diff --git a/soar-8.5.2/doc/html/max-chunks.html b/soar-8.5.2/doc/html/max-chunks.html new file mode 100644 index 0000000..56d1101 --- /dev/null +++ b/soar-8.5.2/doc/html/max-chunks.html @@ -0,0 +1,60 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +max-chunks - Set or list the maximum chunk count +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +max-chunks [count
                                                                                                                                    ] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command sets and prints the maximum number of chunks +that can be created in a single decision cycle. If count is +not given, this command +prints the maximum number of chunks that can be created. +If count is given, it must be a positive integer and is used +to reset the number of chunks allowed. +

                                                                                                                                    +The "max-chunks" parameter controls the maximum number of chunks +that can be created in a single decision cycle. After this limit +has been reached in a decision cycle, Soar proceeds to decision +phase even if quiescence hasn't really been reached yet. The +default initial setting of the "max-chunks" parameter is 50. +

                                                                                                                                    +In Soar8, chunks may be built during both the Propose Phase or +the Apply Phase. If Soar8 builds more than the max-chunks limit in either +of these phases, Soar8 proceeds to the next phase (either Decision +or Output) even if quiescence has not been reached. +

                                                                                                                                    +If max-chunks are reached, and Soar moves on to the next phase, +a warning message is printed. +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command issued with no arguments, returns the maximum chunk count: +

                                                                                                                                    +max-chunks 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The next example makes use of Tcl command abbreviation while setting +the max-chunks to 100: +

                                                                                                                                    +max-c  100 
                                                                                                                                    +
                                                                                                                                    + + +

                                                                                                                                    VARIABLE

                                                                                                                                    +

                                                                                                                                    +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_chunks" (with underscores) +that can be used to set the chunk limit through the the Tcl +set command. If count is not given, 'set max_chunks' +prints the maximum number of chunks that can be created. +If count is given, it must be a positive integer and is used +to reset the number of chunks allowed. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +variables + + + diff --git a/soar-8.5.2/doc/html/max-elaborations.html b/soar-8.5.2/doc/html/max-elaborations.html new file mode 100644 index 0000000..f1ef4d5 --- /dev/null +++ b/soar-8.5.2/doc/html/max-elaborations.html @@ -0,0 +1,55 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +max-elaborations - Set or list the maximum elaborations allowed +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +max-elaborations [count] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command sets and prints the maximum number of elaboration +cycles allowed. If count is not given, this command +prints the current number of elaboration cycles allowed. +If count is given, it must be a positive integer and is used +to reset the number of allowed elaboration cycles. +

                                                                                                                                    +The "max-elaborations" parameter controls the maximum number of +elaborations allowed in a single decision cycle. After this limit +has been reached, Soar moves on to the next phase and +a warning message is printed. The +default initial setting of the "max-elaborations" parameter is 100. +

                                                                                                                                    +In Soar8, max-elaborations is checked during both the Propose Phase and +the Apply Phase. If Soar8 runs more than the max-elaborations limit in either +of these phases, Soar8 proceeds to the next phase (either Decision +or Output) even if quiescence has not been reached. +

                                                                                                                                    + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command issued with no arguments, returns the max elaborations allowed: +

                                                                                                                                    +max-elaborations 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The next example makes use of Tcl command abbreviation while setting +the maximum value to 50: +

                                                                                                                                    +max-e  50 
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    VARIABLE

                                                                                                                                    +

                                                                                                                                    +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_elaborations" (with underscores) +that can be used to set the limit through the the Tcl set +command. If count is not given, 'set max_elaborations' +prints the current number of elaboration cycles allowed. +If count is given, it must be a positive integer and is used +to reset the number of allowed elaboration cycles. + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +variables diff --git a/soar-8.5.2/doc/html/max-nil-output-cycles.html b/soar-8.5.2/doc/html/max-nil-output-cycles.html new file mode 100644 index 0000000..441d9df --- /dev/null +++ b/soar-8.5.2/doc/html/max-nil-output-cycles.html @@ -0,0 +1,51 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +max-elaborations - Set or list the maximum number of empty output cycles allowed when doing run-til-output-generated +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +max-elaborations [count] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command sets and prints the maximum number of nil output cycles +(output cycles that put nothing on the output link) allowed when +running using run-til-output-generated (run out). +If count is not given, this command +prints the current number of nil-output-cycles allowed. +If count is given, it must be a positive integer and is used +to reset the maximum number of allowed nil output cycles. +

                                                                                                                                    +The "max-nil-output-cycles" parameter controls the maximum number of +output cycles that generate no output allowed when a run out +command is issued. After this limit has been reached, Soar stops. +The default initial setting of the "max-nil-output-cycles" parameter is 15. +

                                                                                                                                    + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +The command issued with no arguments, returns the max empty output cycles allowed: +

                                                                                                                                    +max-nil-output-cycles 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The next example makes use of Tcl command abbreviation while setting +the maximum value to 25: +

                                                                                                                                    +max-nil 25 
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    VARIABLE

                                                                                                                                    +

                                                                                                                                    +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_nil_output_cycles" (with underscores) +that can be used to set the limit through the the Tcl set +command. If count is not given, 'set max_nil_output_cycles +prints the current number of consecutive nil output cycles allowed. +If count is given, it must be a positive integer and is used +to reset the number of allowed nil output cycles. + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +variables diff --git a/soar-8.5.2/doc/html/memories.html b/soar-8.5.2/doc/html/memories.html new file mode 100644 index 0000000..e4da74e --- /dev/null +++ b/soar-8.5.2/doc/html/memories.html @@ -0,0 +1,50 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +memories - Print partial match memory usage +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +memories [production-name | count | -chunk | -user | -default | -justification] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints information about memory use, in tokens, of +partial matches of productions. With no options, memory +use of all productions is printed. Other options indicate +a subset of the productions. + +

                                                                                                                                    OPTIONS

                                                                                                                                    + +If given, an option must match one of the following forms: +
                                                                                                                                    +
                                                                                                                                    production-name + +
                                                                                                                                    print memory usage of the production named production-name +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    count + +
                                                                                                                                    for all specified groups (chunk, default, user, and/or justification) +print usage information on only count of each. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -chunk + +
                                                                                                                                    print memory usage of chunks +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -user + +
                                                                                                                                    print memory usage of user productions +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -default + +
                                                                                                                                    print memory usage of the default productions +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -justification + +
                                                                                                                                    print memory usage of justifications + diff --git a/soar-8.5.2/doc/html/monitor.html b/soar-8.5.2/doc/html/monitor.html new file mode 100644 index 0000000..ec9e5ea --- /dev/null +++ b/soar-8.5.2/doc/html/monitor.html @@ -0,0 +1,303 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +monitor - Manage attachment of scripts to Soar events +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +monitor action +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command manages the attachment of scripts to Soar events. +Soar events are important events that occur in Soar as an agent +is being processed. Scripts can be attached to these Soar +events so that they are invoked every time the Soar event occurs. +These scripts can also be removed using the monitor command. +The status of attachments can be listed and tested. If a new +attachment is created, its identifier is returned as the result +of this command. The identifier is used when deleting a +script from an event. +

                                                                                                                                    +The specified action must have one of the following forms: +

                                                                                                                                    +
                                                                                                                                    -add soar-event script [id] + +
                                                                                                                                    Add the script to the list of scripts to be invoked when the +soar-event occurs in the Soar kernel. See below for a list +of valid Soar event names. If the id is given, it +is used to name the attachment. If no id is given, then +a unique id is generated and returned. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -delete soar-event [id] + +
                                                                                                                                    Remove scripts attached to soar-event. The soar-event +must match a valid Soar event name +(see below). If id is given after a soar-event, then +only that particular attachment is removed. Otherwise, all +attachments under soar-event are removed. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -list + +
                                                                                                                                    List all attachments of scripts to Soar events +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -test + +
                                                                                                                                    Test the script attachment process by attaching a print message to +every Soar event. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -clear + +
                                                                                                                                    Remove all attached scripts. +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This command creates an attachment which prints a message +after every Soar decision cycle: +
                                                                                                                                    +monitor -add after-decision-cycle {puts "Finished DC!"} 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example creates an attachment which calls the Tcl procedure +"DoSomething" (presumably user-defined) after every production firing: +

                                                                                                                                    +monitor -add firing DoSomething
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example creates an attachment which processes pending X events +after every decision cycle. This is needed in long-running Soar +agents so that GUIs do not appear frozen: +

                                                                                                                                    +monitor -add after-decision-cycle update
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example adds an attachment which ticks a simulator after +each agent has completed a cycle in the Soar scheduler. Note +that this example command is executed in the global agent's +interpreter so that the simulator is ticked only once per +schedule cycle. The "TickSimulator" command would be defined +by the user. +

                                                                                                                                    +monitor -add after-schedule-cycle TickSimulator
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example adds an attachment that could be used to inform the +Soar development tool SDE that an agent has been selected for +scheduling. SDE expects certain strings in Soar output and uses +them to control some SDE operations. +

                                                                                                                                    +monitor -add before-schedule-cycle {puts "\nSelecting agent $soar_agent_name"}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example removes the single attachment "m1" which associates a +script with the Soar event after-init-agent: +

                                                                                                                                    +monitor -delete after-init-agent m1
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example removes all script attachments to the Soar event +before-preference-phase-cycle: +

                                                                                                                                    +monitor -delete before-preference-phase-cycle
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example removes all script attachments that have been added with +the monitor command: +

                                                                                                                                    +monitor -clear
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    SOAR EVENTS

                                                                                                                                    + +This command utilizes the Soar callback system which can associate +TCL or C functions with Soar events. The permissable Soar event names +are: +
                                                                                                                                    +
                                                                                                                                    system-termination + +
                                                                                                                                    +The Soar system is exiting. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-init-agent + +
                                                                                                                                    +An agent has just been created and initialized. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-init-soar + +
                                                                                                                                    +The agent is about to be initialized. The init-soar command +will generate this event. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-init-soar + +
                                                                                                                                    +The agent has just been initialized. The init-soar command +will generate this event. + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-halt-soar + +
                                                                                                                                    +The agent has just been halted. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-schedule-cycle + +
                                                                                                                                    +This event is triggered by the schedule command. In the +global control agent, this event is triggered before each schedule +cycle starts. In other agents, this event is triggered during +the schedule cycle, just before the agent is run. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-schedule-cycle + +
                                                                                                                                    +This event is triggered by the schedule command. In the +global control agent, this event is triggered just after each schedule +cycle ends. In other agents, this event is triggered during +the schedule cycle, just after the agent is run. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-decision-cycle + +
                                                                                                                                    +A decision cycle is just about to start. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-decision-cycle + +
                                                                                                                                    +A decision cycle has just ended. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-input-phase + +
                                                                                                                                    +An input phase is just about to start. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-input-phase + +
                                                                                                                                    +An input phase has just ended. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-preference-phase-cycle + +
                                                                                                                                    +A preference phase is just about to begin. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-preference-phase-cycle + +
                                                                                                                                    +A preference phase has just ended. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-wm-phase-cycle + +
                                                                                                                                    +A working memory phase is just about to begin. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-wm-phase-cycle + +
                                                                                                                                    +A working memory phase is just about to begin. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-output-phase + +
                                                                                                                                    +An output phase is just about to begin. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-output-phase + +
                                                                                                                                    +An output phase has just ended. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    before-decision-phase-cycle + +
                                                                                                                                    +A decision phase is about to begin. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    after-decision-phase-cycle + +
                                                                                                                                    +A decision phase has just ended. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    wm-changes + +
                                                                                                                                    +Changes to working memory have just completed. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    create-new-context + +
                                                                                                                                    +A new state has been created on the goal stack. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pop-context-stack + +
                                                                                                                                    +A subgoal has finished. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    create-new-attribute-impasse + +
                                                                                                                                    +A new attribute impasse has occurred. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    remove-attribute-impasse + +
                                                                                                                                    +An attribute impasse has been removed. + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    production-just-added + +
                                                                                                                                    +A productions has just been added to the agent. + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    production-just-about-to-be-excised + +
                                                                                                                                    +A production is just about to be removed from the agent. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    firing + +
                                                                                                                                    +A production instantiation has just fired. + +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    retraction + +
                                                                                                                                    +A production instantiation is just about to retract. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    system-parameter-changed + +
                                                                                                                                    +A system parameter has just been changed. diff --git a/soar-8.5.2/doc/html/multi-attributes.html b/soar-8.5.2/doc/html/multi-attributes.html new file mode 100644 index 0000000..2bd8844 --- /dev/null +++ b/soar-8.5.2/doc/html/multi-attributes.html @@ -0,0 +1,28 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +multi-attributes - Declare a symbol to be multi-attributed +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +multi-attributes [symbol [n]] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command declares the given symbol to be an attribute +which can take on multiple values. The optional n is an integer +(>1) indicating an upper limit on the number of expected values +that will appear for an attribute. If n is not specified, +the value 10 is used for each declared multi-attribute. More informed +values will tend to result in greater efficiency. + +

                                                                                                                                    +This command is used only to provide hints to the +production condition reorderer so it can produce better condition +orderings. Better orderings enable the Rete network to run faster. +This command has no effect on the actual contents of working memory +and most users needn't use this at all. + +

                                                                                                                                    WARNING

                                                                                                                                    +

                                                                                                                                    +Note that multi-attributes declarations must be made before diff --git a/soar-8.5.2/doc/html/o-support-mode.html b/soar-8.5.2/doc/html/o-support-mode.html new file mode 100644 index 0000000..3a4b0dd --- /dev/null +++ b/soar-8.5.2/doc/html/o-support-mode.html @@ -0,0 +1,44 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +o-support-mode - Control O-support calculations +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +o-support-mode 0|1|2 +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command controls the way o-support calculations are done +for the agent. The o-support calculation mode must be one of +the following choices: +

                                                                                                                                    +
                                                                                                                                    0 + +
                                                                                                                                    Do o-support calculations the Soar 6 way +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    1 + +
                                                                                                                                    Do o-support calculations the Soar 6 way, but +print a warning message whenever a preference is created +that would get different support under Doug Pearson's proposal. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    2 + +
                                                                                                                                    Do o-support calculations according to Doug Pearson's proposal. + +
                                                                                                                                    +

                                                                                                                                    VARIABLE

                                                                                                                                    +

                                                                                                                                    +Note that the command name uses dashes to separate the words. There +is also a Soar command "o_support_mode" (with underscores) +that can be used to set the mode through the the Tcl set command. +If the mode is not specified, 'set o_support_mode' +prints the current mode. If the mode is specified, it must have +a value of 0, 1 or 2 as above. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +variables + diff --git a/soar-8.5.2/doc/html/output-strings-destination.html b/soar-8.5.2/doc/html/output-strings-destination.html new file mode 100644 index 0000000..0513695 --- /dev/null +++ b/soar-8.5.2/doc/html/output-strings-destination.html @@ -0,0 +1,118 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +output-strings-destination - Specify destination of print actions +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +output-strings-destination action +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command redirects the printing of output strings. This is +useful for applications which need to change where printed results +are placed. Printed output is normally sent to standard output. +However, if a Graphical User Interface (GUI) is being used in +place of the command line interpreter, then printed output should +appear in the GUI. GUIs are composed of elements called "widget"s +and printed output would be directed to a "text widget", or procedure. +

                                                                                                                                    +Printed output is normally sent to standard output which is an open file +descriptor in UNIX. Printed output can be sent to any other +open file descriptor as well, such as an open file or pipe. +It is also possible that the +user is not interested in an agent's printed +output. In that case, the printed output can be discarded -- which +results in faster processing for the agent as well. +

                                                                                                                                    +Some Soar commands +return results and some print results. If the user wishes to +have printed results returned so that they can be saved for later +use, then this command can setup the agent to append the printed +output to the normal result. This capability is also useful when +sending Soar commands from remote Tcl/Tk interpreters. By appending +the printed results, all printed characters can be returned to +the remote interpreter rather than going to a screen. +

                                                                                                                                    +The printing facility is implemented as a stack, so newly installed +print redirections are in force until popped off the stack. This is +done to allow easy transient redirection and the restoration of +prior printing contexts after completing a printing task. Hence, +there are two primary actions, -push and -pop. +The -pop action takes no additional arguments as it serves +only to pop the print-redirection stack to re-establish the prior +printing context. The -push action takes the following +additional arguments: +

                                                                                                                                    +
                                                                                                                                    -append-to-result + +
                                                                                                                                    Instead of printing, append the output string to the result returned +by a command. This option is useful for getting all the output when the +command is invoked remotely. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -channel open-file-id + +
                                                                                                                                    Redirect prints to the open channel (file or pipe) denoted +by open-file-id +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -discard + +
                                                                                                                                    Ignore prints (similar to redirecting to /dev/null in the Bourne +shell, sh) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -procedure proc-name + +
                                                                                                                                    Redirect prints to the Tcl procedure named proc-name in the +current interpreter. Tk widgets are also procedures, so this action +sends output to widget procedures (or any other Tcl procedure). +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -text-widget widget-name [interp-name] + +
                                                                                                                                    Redirect prints to the text widget named widget-name in the +current interpreter. If interp-name is specified, then +prints are redirected to the text widget named widget-name +in the interpreter named interp-name. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This example redirects prints to the text widget ".text": +
                                                                                                                                    +output-strings-destination -push -text-widget .text
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    + +

                                                                                                                                    +This example redirects prints to the text widget ".textual" in +the interpreter named control: +

                                                                                                                                    +output-strings-destination -push -text-widget .textual control
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example redirects prints to the open file "stdout": +

                                                                                                                                    +output-strings-destination -push -file-id stdout
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example causes all printing to be supressed: +

                                                                                                                                    +output-strings-destination -push -discard
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This example removes the most recently added print destination: +

                                                                                                                                    +output-strings-destination -pop
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    WARNINGS

                                                                                                                                    + +This command only affects the printing generated by Soar commands such +as print and echo. It does not affect printing done +by the Tcl commands such as puts. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +echo, print, log + diff --git a/soar-8.5.2/doc/html/popd.html b/soar-8.5.2/doc/html/popd.html new file mode 100644 index 0000000..0f6ee4d --- /dev/null +++ b/soar-8.5.2/doc/html/popd.html @@ -0,0 +1,17 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +popd - Pop a directory off the directory stack +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +popd +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command pops a directory off of the directory +stack and cd's to it. See the dirs command for +an explanation of the directory stack. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +pushd, dirs, topd diff --git a/soar-8.5.2/doc/html/predefined-aliases.html b/soar-8.5.2/doc/html/predefined-aliases.html new file mode 100644 index 0000000..29c367c --- /dev/null +++ b/soar-8.5.2/doc/html/predefined-aliases.html @@ -0,0 +1,298 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +Soar predefined-aliases + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +There are a number of command aliases that are provided by Soar. +These are used to provide short versions of built in commands +and to provide syntactic continuity with previous versions of +Soar. Soar provides a predefined set of aliases that will be +useful to most users. +

                                                                                                                                    +These aliases are equivalent to an existing built in command +and (possibly) a set of switches for the command. Additional +arguments given after the alias are passed on to the built in +command. +

                                                                                                                                    +The predefined aliases in $soar_library/soar.tcl are: +

                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      ? + +
                                                                                                                                      A short form of the help command. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      d + +
                                                                                                                                      A short form of the run 1 d command. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      e + +
                                                                                                                                      A short form of the run 1 e command. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      pf + +
                                                                                                                                      A short form of the production-find command. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      step + +
                                                                                                                                      A short form of the run 1 d command. This was added because the +TSI provides a "step" command, and it seemed silly to not allow the +same "command" when running Soar without the TSI. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      wmes + +
                                                                                                                                      Prints the contents of working memory. It is equivalent to +print -depth 0 -internal, therefore an identifier, integer, or +wme pattern must be specified. (see "help print" for more info). +
                                                                                                                                      +

                                                                                                                                      +

                                                                                                                                    +

                                                                                                                                    +Additional aliases are defined in $soar_library/soar7.2km-aliases.tcl. +These aliases were derived by Frank Ritter using commonly used and +psychologically supported rules, computed to save users time and errors. +The rules are based on the keystroke model and designed to be learned by +a command name rule. + + + +Most of the aliases are generated with a rule: +

                                                                                                                                    +
                                                                                                                                    If there are multiple words, use their first letters + +
                                                                                                                                    (29 commands with some exceptions, the most common being +indifferent-selection:inds) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    If there is a single long word (6 letters or more), use the + +
                                                                                                                                    first two letters (8 commands, 0 exceptions) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    If there is a short word, use the first letter + +
                                                                                                                                    (14 commands with 6 exceptions, none common) +
                                                                                                                                    +

                                                                                                                                    +The predefined aliases are: +

                                                                                                                                    +

                                                                                                                                    +
                                                                                                                                    a + +
                                                                                                                                    Equivalent to alias. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    aw + +
                                                                                                                                    Equivalent to add-wme. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    cnf + +
                                                                                                                                    Equivalent to chunk-name-format. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ctf + +
                                                                                                                                    Equivalent to command-to-file. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ea + +
                                                                                                                                    Equivalent to excise -all. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    eb + +
                                                                                                                                    Equivalent to explain-backtraces. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ec + +
                                                                                                                                    Equivalent to excise -chunk. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    et + +
                                                                                                                                    Equivalent to excise -task. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ex + +
                                                                                                                                    Equivalent to excise. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    fc + +
                                                                                                                                    Equivalent to firing-counts. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    fw + +
                                                                                                                                    Equivalent to format-watch. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    h + +
                                                                                                                                    Equivalent to help. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ha + +
                                                                                                                                    Equivalent to help -all. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    help-all + +
                                                                                                                                    Equivalent to help -all. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    inds + +
                                                                                                                                    Equivalent to indifferent-selection. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ip + +
                                                                                                                                    Equivalent to input-period. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    is + +
                                                                                                                                    Equivalent to init-soar. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    l + +
                                                                                                                                    Equivalent to learn. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    m + +
                                                                                                                                    Equivalent to matches. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    osd + +
                                                                                                                                    Equivalent to output-string-destination. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    p + +
                                                                                                                                    Equivalent to print. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pc + +
                                                                                                                                    Equivalent to print -chunks. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pf + +
                                                                                                                                    Equivalent to production-find. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pr + +
                                                                                                                                    Equivalent to preferences. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ps + +
                                                                                                                                    Equivalent to print -stack. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pw + +
                                                                                                                                    Equivalent to pwatch. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    r + +
                                                                                                                                    Equivalent to run. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    rn + +
                                                                                                                                    Equivalent to rete-net. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    rw + +
                                                                                                                                    Equivalent to remove-wme. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    s + +
                                                                                                                                    Equivalent to source. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    sn + +
                                                                                                                                    Equivalent to soarnews. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    soar-news + +
                                                                                                                                    Equivalent to soarnews. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    ss + +
                                                                                                                                    Equivalent to stop-soar. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    st + +
                                                                                                                                    Equivalent to stats. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    un + +
                                                                                                                                    Equivalent to unalias. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    w + +
                                                                                                                                    Equivalent to watch. + + +
                                                                                                                                    +

                                                                                                                                    +See the file itself (soar7.2km-aliases.tcl in $soar_library) for +more detailed information. +

                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    NOTES

                                                                                                                                    +

                                                                                                                                    +Tcl and the TSI, when running in interactive mode, also support +command abbreviation: as long as a unique prefix of a command +is specified, it will be recognized and the matching command +will be executed. For example, "wat" is enough to completely +specify the "watch" command. + +

                                                                                                                                    WARNINGS

                                                                                                                                    +Aliases should NEVER appear in files. They may be changed +or not loaded by other users, and will not be as clear as the +full command names. + + + + +

                                                                                                                                    FILES

                                                                                                                                    +

                                                                                                                                    +All alias definition files are in the Soar Tcl library directory. +The predefined aliases are included in the startup file +soar.tcl and in soar7.2km-aliases.tcl. The aliases are loaded in +a Soar interpreter automatically when it is created. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +alias, print diff --git a/soar-8.5.2/doc/html/preferences.html b/soar-8.5.2/doc/html/preferences.html new file mode 100644 index 0000000..8676d3a --- /dev/null +++ b/soar-8.5.2/doc/html/preferences.html @@ -0,0 +1,54 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +preferences - Print slot preferences +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +preferences [id] [[^]attribute] [ 0 | 1 | 2 | 3 ] + +preferences [id] [[^]attribute] [ -none | -names | -timetags | -wmes ] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints all the preferences for the given slot (i.e., +object and attribute). The id and attribute indicate +the slot of interest. If they are not specified, they default to the +current state and the current operator. The '^' is optional when +specifying the attribute. The optional arguments indicates +the level of detail to print about each preference. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +The optional detail must have one of the following values: +
                                                                                                                                    +
                                                                                                                                    -none or 0 + +
                                                                                                                                    Print just the preferences themselves +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -names or 1 + +
                                                                                                                                    Print the preferences and the names of the productions that +generated them +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -timetags or 2 + +
                                                                                                                                    Print the information for the -names option above plus +the timetags of the wmes matched by the indicated productions +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -wmes or 3 + +
                                                                                                                                    Print the information for the -timetags option above plus +the entire wme. +
                                                                                                                                    +

                                                                                                                                    +If no detail is given, then the -none option is +used. +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This example prints the preferences on the S1 operator slot +and the production names which created the preferences: +
                                                                                                                                    +preferences S1 operator -names
                                                                                                                                    +
                                                                                                                                    diff --git a/soar-8.5.2/doc/html/print.html b/soar-8.5.2/doc/html/print.html new file mode 100644 index 0000000..e1bfa99 --- /dev/null +++ b/soar-8.5.2/doc/html/print.html @@ -0,0 +1,175 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +print - Print a Soar item from production memory or working memory +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +print -stack [ -state | -operator ]* +
                                                                                                                                    +print [-depth n] [-internal] { identifier | integer | pattern} +
                                                                                                                                    +print [-internal] [-name|-full] { prodname | -all | -chunks | -defaults | -justifications | -user} +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The print command is used to print items from production +memory or working memory. It can take several kinds of arguments. When +printing items from working memory, the Soar objects are printed unless the +-internal flag is used, in which case the wmes themselves are printed. + The items to be printed may be one of the following: +

                                                                                                                                    +
                                                                                                                                    production-name + +
                                                                                                                                    print the production named production-name +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -all + +
                                                                                                                                    print the names of all productions currently loaded +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -chunks + +
                                                                                                                                    print the names of all chunks currently loaded +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -defaults + +
                                                                                                                                    print the names of all default productions currently loaded +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -justifications + +
                                                                                                                                    print the names of all justifications currently loaded +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -user + +
                                                                                                                                    print the names of all user productions currently loaded +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    identifier + +
                                                                                                                                    print the object identifier. identifier must be a +valid Soar symbol. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    integer + +
                                                                                                                                    print the object in working memory with the timetag integer +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pattern + +
                                                                                                                                    print the object whose working memory elements matching the given +pattern. +The pattern is interpreted by the Soar kernel so it must be surrounded +by curly braces or double quotes to avoid being parsed by Tcl. A +pattern has the following form: +
                                                                                                                                    +
                                                                                                                                    +       (identifier ^attribute value [+])
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The pattern is surrounded by parentheses. The identifier, +attribute, and value must be valid Soar symbols or the +wildcard symbol * which matches all occurences. The optional ++ symbol restricts pattern matches to acceptable preferences. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +

                                                                                                                                    +All options apply only to arguments which follow them on the command line. +

                                                                                                                                    +
                                                                                                                                    -depth n + +
                                                                                                                                    This option overrides the default +printing depth (see the default-print-depth command for more +detail). Note that a -depth 0 argument is meaningful only with +accompanying integer and pattern arguments. It causes only the +matching working memory elements to be printed, instead of all +elements whose identifier is an identifier in one of the matching +working memory elements. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -internal + +
                                                                                                                                    Specifies that items should be printed +in their internal form. For productions, this means leaving +conditions in their reordered (rete net) form. For working memory, +this means printing the individual elements with their +timetags, rather than the objects. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -full + +
                                                                                                                                    When printing productions, print the whole production. This is the +default when printing a named production. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -name + +
                                                                                                                                    When printing productions, print only the name and not the whole +production. This is the default when printing any catorgory of +productions, as opposed to a named production. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -stack + +
                                                                                                                                    Specifies that the Soar goal stack should be printed. By default +this includes both states and operators. The stack listing can +be restricted by adding the -states and -operator +restrictions. Giving both options is equivalent to the default. +The predefined alias 'ps' is the same as print -stack. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    print -internal {(s1 ^* v2)} + +
                                                                                                                                    Print the working memory elements (and their timetags) which have +the identifier s1 as object and v2 as value. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    print -stack + +
                                                                                                                                    Print the Soar stack which includes states and operators. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    print -internal -full prodname + +
                                                                                                                                    Print the named production in its RETE form. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    print -user + +
                                                                                                                                    Print the names of all user productions currently loaded. + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    + +The order of options and arguments to the print command +do matter: options apply only to arguments which follow them. + +
                                                                                                                                    +
                                                                                                                                    print -chunks -full + +
                                                                                                                                    prints only the names of chunks, while +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    print -full -chunks + +
                                                                                                                                    prints the entire chunk for all chunks. + +
                                                                                                                                    +

                                                                                                                                    SEE ALSO

                                                                                                                                    +default-wme-depth, predefined-aliases + + + + + + + + + diff --git a/soar-8.5.2/doc/html/production-find.html b/soar-8.5.2/doc/html/production-find.html new file mode 100644 index 0000000..9242ff1 --- /dev/null +++ b/soar-8.5.2/doc/html/production-find.html @@ -0,0 +1,82 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +production-find - Find matching Soar productions +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +production-find [-lhs | -rhs] [-show-bindings] +[-chunks | -no-chunks] {pattern} +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The production-find command is used to find Soar productions by matching +a given pattern against the production components. Productions +may be found that test a particular left-hand side pattern or +produce particular right-hand side preferences. For convenience, the +production-find command has the predefined alias pf. + +

                                                                                                                                    OPTIONS

                                                                                                                                    + +If given, an option must match one of the following choices: +
                                                                                                                                    +
                                                                                                                                    -lhs + +
                                                                                                                                    The following pattern applies to the left-hand side of +productions. This is the default. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -rhs + +
                                                                                                                                    The following pattern applies to the right-hand side of +productions. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -show-bindings + +
                                                                                                                                    Show the bindings associated with the following pattern. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -chunks + +
                                                                                                                                    Search only for chunks (learned productions) that match the +following pattern. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -nochunks + +
                                                                                                                                    Search all productions except chunks that match the +following pattern. +
                                                                                                                                    +

                                                                                                                                    +The syntax of +pattern is exactly the syntax of a sequence of clauses within +a Soar production. In addition, the symbol * may be used as +a wildcard for an attribute or value. Note that variables names +do not have to match the specific names used in productions. +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +Find productions that test that some object gumby has an +attribute alive with value t. In addition, limit +the rules to only those that test an operator named foo: +

                                                                                                                                    +production-find {(<s> ^gumby <gv> ^operator.name foo)(<gv> ^alive t)}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +Find productions that propose the operator foo: +

                                                                                                                                    +production-find -rhs {(<x> ^operator <op> +)(<op> ^name foo)}
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +Find chunks that test the attribute ^pokey: +

                                                                                                                                    +production-find -chunks {(<x> ^pokey *)}
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    WARNINGS

                                                                                                                                    + +Note that curly braces or double quotes must be used around the +pattern to override the normal Tcl parsing. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +sp diff --git a/soar-8.5.2/doc/html/pushd.html b/soar-8.5.2/doc/html/pushd.html new file mode 100644 index 0000000..85d74cb --- /dev/null +++ b/soar-8.5.2/doc/html/pushd.html @@ -0,0 +1,17 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +pushd - Push a directory onto the directory stack +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +pushd dir +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command pushes the current directory onto the directory +stack and cd's to the given dir. See the dirs +command for an explanation of the directory stack. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +popd, dirs, topd diff --git a/soar-8.5.2/doc/html/pwatch.html b/soar-8.5.2/doc/html/pwatch.html new file mode 100644 index 0000000..e084e08 --- /dev/null +++ b/soar-8.5.2/doc/html/pwatch.html @@ -0,0 +1,26 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +pwatch - Trace production firings and retractions +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +pwatch [-on | -off] [production-name*] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command enables and disables the tracing of production activity for +individual productions. Both firings and retractions are printed. +If no production-names are given, this command lists the +productions currently being traced. If one or more +production-names are given, tracing is enabled (or disabled if +-off is specified) for those productions. +Tracing persists until disabled or until the production is excised. +

                                                                                                                                    +This command is orthogonal to the watch productions mechanism. +See the watch command for more information. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +excise, watch + + diff --git a/soar-8.5.2/doc/html/quit.html b/soar-8.5.2/doc/html/quit.html new file mode 100644 index 0000000..cf72a6f --- /dev/null +++ b/soar-8.5.2/doc/html/quit.html @@ -0,0 +1,16 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +quit - Quit Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +quit +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command quits Soar. It calls any registered Soar termination +callbacks, closes any open log files, and exits the process. This +also performs any Tcl related cleanup as would be done for the +Tcl exit command. The Tcl exit command is redefined +in Soar to use this command. diff --git a/soar-8.5.2/doc/html/remove-wme.html b/soar-8.5.2/doc/html/remove-wme.html new file mode 100644 index 0000000..f487069 --- /dev/null +++ b/soar-8.5.2/doc/html/remove-wme.html @@ -0,0 +1,31 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +remove-wme - Remove an element from working memory +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +remove-wme timetag +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command removes an element from Soar's working memory. The +timetag must be a positive integer matching the timetag of +an existing working memory element. It is normally used by the +input/output functions to update Soar's world state. + +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +remove-wme should never be called from the RHS: if you +try to match a wme on the LHS of a production, and then remove +the matched wme on the RHS, Soar will crash. +

                                                                                                                                    +This command is inherently unstable and may have +weird side effects (possibly even including system crashes). +For example, the chunker can't backtrace through wmes created +via add-wme. Removing input wmes or context/impasse wmes may +have unexpected side effects. You've been warned. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +add-wme, io + diff --git a/soar-8.5.2/doc/html/replay-input.html b/soar-8.5.2/doc/html/replay-input.html new file mode 100644 index 0000000..d98bad2 --- /dev/null +++ b/soar-8.5.2/doc/html/replay-input.html @@ -0,0 +1,53 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +capture-input - Replay agent commands from a file during the appropriate decision cycle +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +replay-input action +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    + This command may be used to start and stop the reading of + input function commands from a file created by the "capture-input" command. + The routine replay-input-wme is registered as an input function + to read input wmes from the file decision cycle by decision cycle. + If an EOF is reached, the file is closed and the callback removed. + Use the command capture-input to create the file. + +The action must be one of the following: +

                                                                                                                                    +
                                                                                                                                    -open pathname + +
                                                                                                                                    A log file named pathname is opened and input replay is initiated. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -query + +
                                                                                                                                    Returns open if replaying is active or closed if +replaying is not active. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    Close the input file. + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This opens the input file foo.in and will register the callback function +to execute the commands decision cycle by decision cycle: +
                                                                                                                                    +replay-input -open foo.in
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This terminates replaying (removes the callback) and closes the open log file: +

                                                                                                                                    +replay-input -off
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    WARNING

                                                                                                                                    +

                                                                                                                                    + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    diff --git a/soar-8.5.2/doc/html/rete-net.html b/soar-8.5.2/doc/html/rete-net.html new file mode 100644 index 0000000..9125968 --- /dev/null +++ b/soar-8.5.2/doc/html/rete-net.html @@ -0,0 +1,44 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +rete-net - Save and restore the Rete net +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +rete-net {-save | -load} filename +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The rete-net command saves and restores the state of the +Rete network. This command provides a fast method of saving +and loading productions since a binary format is used. rete-net +files are portable across platforms that support Soar. +The action must be one of the following: +

                                                                                                                                    +
                                                                                                                                    -save + +
                                                                                                                                    Save the Rete network in the given filename. The Rete +network cannot be saved while there are justifications present. +These can be eliminated by using the init-soar command. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -load + +
                                                                                                                                    Load the productions stored in filename into the Rete +network. In order to load productions stored in binary form, +working memory and production memory must both be empty. Working +memory can be emptied by using the init-soar command. +Production memory can be emptied by using the excise -all +command. +
                                                                                                                                    +

                                                                                                                                    +If the filename contains a suffix of ".Z", then the file +is compressed automatically when it is saved and uncompressed +when it is loaded. + +

                                                                                                                                    WARNINGS

                                                                                                                                    +Compressed files may not be portable to another platform is that +platform does not support the same uncompress utility. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +excise, init-soar diff --git a/soar-8.5.2/doc/html/rhsfun.html b/soar-8.5.2/doc/html/rhsfun.html new file mode 100644 index 0000000..340332a --- /dev/null +++ b/soar-8.5.2/doc/html/rhsfun.html @@ -0,0 +1,236 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +Soar righthand side functions + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +Soar supports a number of functions which can appear on the +righthand side of productions. These functions can appear +either as values (such as the "int" of a number), or as +standalone actions (such as "write" or "halt"). The righthand +side functions can be used to stop or pause Soar, do text input +and output, execute mathematical functions, generate and +manipulate symbols, modify learning, and execute Tcl commands. + +The Soar User's Manual should be consulted for more information +on the use of righthand side functions. + +

                                                                                                                                    +The available righthand side functions are: +

                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      accept + +
                                                                                                                                      suspends Soar's execution and waits for the user to type a constant, +followed by a carriage return. The result of the accept is the constant. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      capitalize-symbol + +
                                                                                                                                      given a symbol, this function returns a new symbol with +the first character capitalized. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      compute-heading + +
                                                                                                                                      given 4 args, x1 y1 and x2 y2, this function returns integer heading +from x1,y1 to x2,y2 +(Note: this function is defined in the interface/rhsfun_examples.c file) +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      compute-range + +
                                                                                                                                      given 4 args, x1 y1 and x2 y2, this function returns integer range +from x1,y1 to x2,y2 +(Note: this function is defined in the interface/rhsfun_examples.c file) +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      crlf + +
                                                                                                                                      short for "carriage return, line feed," this function can be called +only within write. It forces a newline at its position in +the write action. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      dont-learn + +
                                                                                                                                      when learning is set to except, by default chunks will be formed in +all states; the dont-learn RHS action will cause learning to +be turned off for the state specified in the LHS (condition side) +of the production. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      force-learn + +
                                                                                                                                      when learning is set to only, by default chunks are not formed +in any state; the force-learn RHS action will cause learning to +be turned on for the state specified in the LHS (condition side) +of the production. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      halt + +
                                                                                                                                      terminates the current run, stops Soars execution and returns to +the user prompt. halt should not be used if the current run is +to be restarted. (see interrupt below.) +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      ifeq + +
                                                                                                                                      checks if the first argument is "eq" to the second argument. if it +is, then return the third argument, else return the fourth argument. +Similar to the "?" notation in C. all four arguments are required. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      interrupt + +
                                                                                                                                      causes Soar to stop at the end of the current phase, and return to +the user prompt. Similar to halt, except the run may be +continued. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      make-constant-symbol + +
                                                                                                                                      returns a new constant symbol which is guaranteed to be different +from all symbols currently present in the system. with no arguments, +it returns a symbol whose name starts with "constant". With one or +more arguments, it takes those argument symbols, concatenates their +names and uses the resulting string as the prefix for the new symbol. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      round-off + +
                                                                                                                                      Given two numbers, this function returns the first rounded to the +nearest second number. +(Note: this function is defined in the interface/rhsfun_examples.c file) +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      round-off-heading + +
                                                                                                                                      Given two numbers, this function returns the first rounded to the +nearest second number. The heading is given between -180 and +180 deg. +(Note: this function is defined in the interface/rhsfun_examples.c file) +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      strlen + +
                                                                                                                                      returns the length of the output string so that users can get the +output to line up nicely. useful with ifeq when the output +string varies in length. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      timestamp + +
                                                                                                                                      returns a symbol whose print name is a representation of the current +date and local time. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      tcl + +
                                                                                                                                      concatenates its arguments into a string which is sent to the +agent's Tcl interpreter for evaluation. It does not automatically +insert spaces between arguments; users must explicitly insert +spaces within vertical bars. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      write + +
                                                                                                                                      writes its arguments to the user interface. it does not automatically +insert blanks, line feeds, or carriage returns. It should be used +only for simple monitoring and debugging. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      + + +
                                                                                                                                      prefix notation for addition. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      * + +
                                                                                                                                      prefix notation for multiplication. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      - + +
                                                                                                                                      prefix notation for subtraction. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      / + +
                                                                                                                                      prefix notation for division. always returns a real number. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      div + +
                                                                                                                                      prefix notation for binary integer division. returns the integer +quotient. Both arguments must be integers or an error occurs. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      mod + +
                                                                                                                                      prefix notation for binary integer modulus. returns the integer +remainder when dividing the first argument by the scond. Both +arguments must be integers or an error occurs. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      sin + +
                                                                                                                                      returns as a float, the sine of the angle which must be +given in radians. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      cos + +
                                                                                                                                      returns as a float, the cosine of the angle which must +be given in radians. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      atan2 + +
                                                                                                                                      returns as a float in radians, the arctangent of the first argument +divided by the second argument. the arguments can be integers or floats. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      sqrt + +
                                                                                                                                      returns as a float the square root of its argument, which can be +a float or an integer. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      abs + +
                                                                                                                                      returns the absolute value: of a float as a float; of an integer +as an integer. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      int + +
                                                                                                                                      converts a symbol to an integer constant. argument must be either +an integer constant, a floating point constant, or a symbolic constant +which can be interpreted as a single integer number. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      float + +
                                                                                                                                      converts a symbol to an floating point constant. argument must be either +an integer constant, a floating point constant, or a symbolic constant +which can be interpreted as a single floating point number. +
                                                                                                                                      +

                                                                                                                                      +

                                                                                                                                    + +

                                                                                                                                    WARNINGS

                                                                                                                                    +The tcl RHS function is not part of the Soar kernel. +It is added by the Tcl interface code. You can get into a lot of +trouble with it, as the arguments are unrestricted. It should +be used only with great care. + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +learn, stop-soar + diff --git a/soar-8.5.2/doc/html/run.html b/soar-8.5.2/doc/html/run.html new file mode 100644 index 0000000..e5c7039 --- /dev/null +++ b/soar-8.5.2/doc/html/run.html @@ -0,0 +1,164 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +run - Run Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +run [n | 'forever'] [unit] [-self] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command runs the Soar agents. If the [-self] flag is issued, +only the agent issuing the run command will run. n is a single integer +which specifies the number of times to run Soar. If n is +unspecified and no units are given, OR if n +is the single keyword 'forever', then Soar is run until halted +by problem-solving completion or an external interrupt. If n +is specified, but no units are specified, then soar is run +by decision cycles. If units +are specified, but n is unspecified, then n defaults to '1'. The +unit argument indicates the unit of measure to be used +in counting Soar run cycles. unit must be one of the following +keywords: +

                                                                                                                                    +
                                                                                                                                    p + +
                                                                                                                                    run Soar for n phases. A phase is either an input +phase, preference phase, working memory phase, output +phase, or decision phase. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    e + +
                                                                                                                                    run Soar for n elaboration cycles. (For purposes of +this command, decision phase is counted as an elaboration cycle.) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    d + +
                                                                                                                                    run Soar for n decision cycles +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    s + +
                                                                                                                                    run Soar until the nth time a state is selected +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    o + +
                                                                                                                                    run Soar until the nth time an operator is selected +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    out + +
                                                                                                                                    run Soar until the nth time output is generated by the agent +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <s> + +
                                                                                                                                    run Soar until the current level of subgoaling has terminated +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <ss> + +
                                                                                                                                    run Soar until the superstate's level of subgoaling has terminated +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <sss> + +
                                                                                                                                    run Soar until the supersuperstate's level of subgoaling has terminated +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <o> + +
                                                                                                                                    run Soar until the nth time an operator is selected at this level of +subgoaling or until the current level of subgoaling is terminated. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <so> + +
                                                                                                                                    run Soar until the nth time a superoperator is selected or until +that level of subgoaling is terminated. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    <sso> + +
                                                                                                                                    run Soar until the nth time a supersuperoperator is selected or until +that level of subgoaling is terminated. +
                                                                                                                                    +

                                                                                                                                    +Unlike the Soar 6 go command, run has no memory of settings from +previous run commands. +

                                                                                                                                    +There are two predefined aliases for the run command, provided as a convenience +for use on the command line: +

                                                                                                                                    +
                                                                                                                                    d [n] + +
                                                                                                                                    run by decision cycles, equivalent to "run n d". n defaults to 1. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    e [n] + +
                                                                                                                                    run by elaboration cycles, equivalent to "run n e". n defaults to 1. + + +
                                                                                                                                    +

                                                                                                                                    EXAMPLES

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run + +
                                                                                                                                    run all agents until halted by problem-solving completion or +an external interrupt is given. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run 5 d + +
                                                                                                                                    run all agents for 5 decision cycles +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run d -self + +
                                                                                                                                    run the current agent only for 1 decision cycle +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run 3 + +
                                                                                                                                    run all agents for 3 decision cycles +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run 2 e + +
                                                                                                                                    run all agents for 2 elaboration cycles +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run 1 s + +
                                                                                                                                    run all agents until the next state is selected (i.e., +until the next time an impasse arises) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run <so> + +
                                                                                                                                    run until the next superoperator is selected +(or until the superstate goes away) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    run 3 <o> + +
                                                                                                                                    run for 3 operator selections at this level +(continuing through any subgoals that arise) + +
                                                                                                                                    +

                                                                                                                                    WARNING

                                                                                                                                    +

                                                                                                                                    +In Soar8, the preference phase is no longer separated from the +working memory phase, Soar continues right through from preferences +into working memory without stopping. The phases +are Input, Propose, Decide, Apply, Output; Propose and Apply each +consist of at least one, but possibly many, +preference/working-memory subphases. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +d, e, stop-soar, predefined-aliases diff --git a/soar-8.5.2/doc/html/save_backtraces.html b/soar-8.5.2/doc/html/save_backtraces.html new file mode 100644 index 0000000..72194c5 --- /dev/null +++ b/soar-8.5.2/doc/html/save_backtraces.html @@ -0,0 +1,41 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +save_backtraces - Enable/Disable Soar save_backtraces +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +set save_backtraces [on | off] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +save_backtraces is a Soar variable which through the Tcl set +command, enables and disables the the saving of backtracing information. +It must be on for the explain-backtraces command to provide +backtracing information. +If an enabling or disabling status of on or off +is given, then the save_backtraces are +set to that state. If no status is given, then the current +save_backtraces status is printed. At startup, save_backtraces is initially +enabled. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    on | 1 + +
                                                                                                                                    Enables the saving of backtracing information (initial default) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    off | 0 + +
                                                                                                                                    Disables the saving of backtracing information + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +save_backtraces mode must be on when a chunk or +justification is created or no explanation will be available +for the explain-backtraces command. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +explain-backtraces, variables diff --git a/soar-8.5.2/doc/html/soar8.html b/soar-8.5.2/doc/html/soar8.html new file mode 100644 index 0000000..2132da9 --- /dev/null +++ b/soar-8.5.2/doc/html/soar8.html @@ -0,0 +1,44 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +soar8 - Enable/Disable Soar8 mode +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +soar8 [-on | -off] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The soar8 allows users to toggle between the Soar 8 methodology +and the Soar 7 methodology. The default value is -on. +If an enabling or disabling status of -on or -off +is given, then the Soar 8 (-on) or Soar 7 (-off) methodology is employed. +If no status is given, then the current +soar8 status is printed. Users can toggle between modes ONLY when +production memory and working memory are both empty. This means +that users must either change the mode at startup before any +productions are loaded, or must first issue "excise -all" (which +does an "init-soar" as well) before changing modes. Note that +there are differences in the preference mechanism and in operator +termination (among other things) between Soar 8 and Soar 7. Users +should read the Soar 8.2 Release Notes for more details. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -on + +
                                                                                                                                    Soar will run using Soar 8 methodology (initial default) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -off + +
                                                                                                                                    Soar will run using Soar 7 methodology + +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +Production memory and working memory must be empty to switch +between modes. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +Soar 8.2 Release Notes on the Soar 8.2 web page diff --git a/soar-8.5.2/doc/html/soarnews.html b/soar-8.5.2/doc/html/soarnews.html new file mode 100644 index 0000000..adb62fa --- /dev/null +++ b/soar-8.5.2/doc/html/soarnews.html @@ -0,0 +1,18 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +soarnews - Soar news +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +soarnews +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command gives information about the current Soar version +being run, the addresses of Soar email groups, the Soar Home Page URL, +and the copyright disclaimer. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +version + diff --git a/soar-8.5.2/doc/html/sp.html b/soar-8.5.2/doc/html/sp.html new file mode 100644 index 0000000..a038e32 --- /dev/null +++ b/soar-8.5.2/doc/html/sp.html @@ -0,0 +1,210 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +sp - Define a Soar production +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +sp rule +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command defines a new Soar production. rule +is a single argument parsed by the Soar kernel, so it should +be enclosed in curly braces to avoid being parsed by Tcl. +The +overall syntax of a rule is as follows: +

                                                                                                                                    +   name 
                                                                                                                                    +       ["documentation-string"] 
                                                                                                                                    +       [FLAG*]
                                                                                                                                    +       LHS
                                                                                                                                    +       -->
                                                                                                                                    +       RHS
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The first element of a rule is its name. Conventions +for names are given in the Soar Users Manual. If given, +the documentation-string must be enclosed in double quotes. +Optional flags define the type of rule and the form of support its +right-hand side assertions will receive. The specific flags are +listed in a separate section below. The LHS defines the +left-hand side of the production and specifies the conditions +under which the rule can be fired. Its syntax is given in detail +in a subsequent section. The --> symbol serves to separate +the LHS and RHS portions. +The RHS defines the right-hand side of +the production and specifies the assertions to +be made and the actions to be performed when the rule fires. The +syntax of the allowable right-hand side actions are given in a later +section. The Soar Users Manual gives an elaborate discussion of +the design and coding of productions. Please see that reference +for tutorial information about productions. +

                                                                                                                                    +More complex productions can be formed by surrounding the rule with +double quotes instead of curly braces. This enables variable and +command result substitutions in productions. +If another production with the same name already exists, it is +excised, and the new production is loaded. + +

                                                                                                                                    RULE FLAGS

                                                                                                                                    +

                                                                                                                                    +The optional FLAGs are given below. Note that these switches +are preceeded by a colon instead of a dash -- this is a Soar parser +convention. +

                                                                                                                                    +
                                                                                                                                    :o-support + +
                                                                                                                                    specifies that all the RHS actions are to be given +o-support when the production fires +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    :no-support + +
                                                                                                                                    specifies that all the RHS actions are only +to be given i-support when the production fires +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    :default + +
                                                                                                                                    specifies that this production is a default +production (this matters for excise -task and watch task) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    :chunk + +
                                                                                                                                    specifies that this production is a chunk (this +matters for learn trace) + +
                                                                                                                                    +

                                                                                                                                    LHS GRAMMAR

                                                                                                                                    +Grammar for left hand sides of productions: +
                                                                                                                                    +   lhs ::= cond+
                                                                                                                                    +   cond ::= positive_cond  | - positive_cond
                                                                                                                                    +   positive_cond ::= conds_for_one_id  | { cond+ }
                                                                                                                                    +   conds_for_one_id ::= ( [state |impasse] [id_test] attr_value_tests* )
                                                                                                                                    +   id_test ::= test
                                                                                                                                    +   attr_value_tests ::= [-] ^ attr_test [.attr_test]* value_test*
                                                                                                                                    +   attr_test ::= test
                                                                                                                                    +   value_test ::= test [+]  | conds_for_one_id [+]
                                                                                                                                    +
                                                                                                                                    +   test ::= conjunctive_test  | simple_test
                                                                                                                                    +   conjunctive_test ::= { simple_test+ }
                                                                                                                                    +   simple_test ::= disjunction_test  | relational_test
                                                                                                                                    +   disjunction_test ::= << constant* >>
                                                                                                                                    +   relational_test ::= [relation] single_test
                                                                                                                                    +   relation ::= <>  | <  | >  | <=  | >=  | =  | <=>
                                                                                                                                    +   single_test ::= variable  | constant
                                                                                                                                    +   constant ::= sym_constant  | int_constant  | float_constant
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    RHS GRAMMAR

                                                                                                                                    +Grammar for right hand sides of productions: +
                                                                                                                                    +   rhs ::= rhs_action*
                                                                                                                                    +   rhs_action ::= ( variable attr_value_make+ )  | function_call
                                                                                                                                    +   function_call ::= ( function_name rhs_value* )
                                                                                                                                    +   function_name ::= sym_constant  | +  | -
                                                                                                                                    +   rhs_value ::= constant  | function_call  | variable
                                                                                                                                    +   constant ::= sym_constant  | int_constant  | float_constant
                                                                                                                                    +   attr_value_make ::= ^ rhs_value [.rhs_value]* value_make+
                                                                                                                                    +   value_make ::= rhs_value preferences
                                                                                                                                    +
                                                                                                                                    +   preferences ::= [,] | preference-specifier+
                                                                                                                                    +   preference-specifier ::= naturally-unary-preference [,]
                                                                                                                                    +                             | forced-unary-preference
                                                                                                                                    +                             | binary-preference rhs_value [,]
                                                                                                                                    +   naturally-unary-preference ::= +  | -  | !  | ~  | @
                                                                                                                                    +   binary-preference ::= >  | =  | <  | &
                                                                                                                                    +   forced-unary-preference ::= binary-preference {,  | )  | ^}
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +There are many examples in the Soar Users Manual and the demos +subdirectory. Here is a simple production to create a problem space. +It comes from the critter-world demo (see the file critter.tcl): +
                                                                                                                                    +
                                                                                                                                    +sp {critter*create*space*critter
                                                                                                                                    +   "Formulate the initial problem space"
                                                                                                                                    +  (state <s> ^superstate nil)
                                                                                                                                    +  -->
                                                                                                                                    +  (<s> ^name move-around ^problem-space <p>)
                                                                                                                                    +  (<p> ^name critter)}
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The production above has the name +critter*create*space*critter. It has a documentation string +that is surrounded by double quotes. The LHS is (state <s> +^superstate nil) and indicates that this rule will match whenever +there is a state object that has the attribute-value pair +^superstate +nil. The --> arrow separates the left and right-hand sides. +The RHS consists of two lines. The first asserts that the state +object is to be augmented with the name move-around and a +problem space should be created. The second line of the RHS +indicates that this problem space should be named critter. +

                                                                                                                                    +New for Soar 8, is right-hand-side dot notation. So this production +could also be written: +

                                                                                                                                    +
                                                                                                                                    +sp {critter*create*space*critter
                                                                                                                                    +   "Formulate the initial problem space"
                                                                                                                                    +  (state <s> ^superstate nil)
                                                                                                                                    +  -->
                                                                                                                                    +  (<s> ^name move-around ^problem-space.name critter)}
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +Here is a variant of the above example using +double quotes instead of curly braces. Double quotes are needed in order +to imbed the value of the Tcl variable soar_agent_name +in the production. The value of this variable is used to name +the problem-space created. +

                                                                                                                                    +
                                                                                                                                    +sp "critter*create*space*critter
                                                                                                                                    +   (state <s> ^superstate nil)
                                                                                                                                    +  -->
                                                                                                                                    +  (<s> ^name move-around ^problem-space <p>)
                                                                                                                                    +  (<p> ^name $soar_agent_name)"
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The primary change in the rule is the last clause of the +RHS. In that clause, the Tcl variable soar_agent_name +is expanded. If this rule is given in an interpreter which has +the variable soar_agent_name set to fred, then the +RHS would expand to the following before being sent to +the Soar kernel to be parsed: +

                                                                                                                                    +
                                                                                                                                    +  (<p> ^name fred)
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +Please be aware that when using double quotes, both the dollar +sign (variable expansion) and square brackets (command result +substitution) will be interpreted by Tcl. If these characters +($, [, and ]) are to be passed to the Soar +production parser, they must be escaped (using a backslash) +to avoid interpretation by Tcl. + +

                                                                                                                                    WARNINGS

                                                                                                                                    +

                                                                                                                                    +The last production above does not contain a documentation string. +If one were added, double quotes would need to be escaped to avoid +premature termination of the rule: +

                                                                                                                                    +
                                                                                                                                    +sp "critter*create*space*critter
                                                                                                                                    +   \"Formulate the initial problem space\"
                                                                                                                                    +   (state ...
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +excise, learn, watch + diff --git a/soar-8.5.2/doc/html/start-attention-lapse.html b/soar-8.5.2/doc/html/start-attention-lapse.html new file mode 100644 index 0000000..856e445 --- /dev/null +++ b/soar-8.5.2/doc/html/start-attention-lapse.html @@ -0,0 +1,29 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +start-attention-lapse - Sets the amount of real time that should pass before ending the lapse and sets attention-lapsing to true. Not normally called by user. +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +start-attention-lapse [integer (milliseconds)] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command, which should not normally be called by the user or +an agent (attention lapses normally get started automatically +by the architecture), sets the "attention-lapsing" variable to +TRUE (1), and starts tracking the amount of real time that should pass before +ending the lapse (with wake_from_attention_lapse). The duration +of the lapse is the number of milleseconds specified by the +argument to this command (in real time). + +

                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +The compile time options REAL_TIME_BEHAVIOR and ATTENTION_LAPSE +must be enabled for this functionality. +

                                                                                                                                    + + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +
                                                                                                                                    attention-lapse wake-from-attention-lapse variables diff --git a/soar-8.5.2/doc/html/stats.html b/soar-8.5.2/doc/html/stats.html new file mode 100644 index 0000000..2777928 --- /dev/null +++ b/soar-8.5.2/doc/html/stats.html @@ -0,0 +1,225 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +stats - Print statistical data about Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +stats [-system [stat] | -memory [stat] |-rete [stat]] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command prints Soar internal statistics. The module +indicates the component of interest. If specified, module +must be one of -system, -memory, or -rete. If no +specific stat is given for the specified module, then +all statistics are listed for that module. If no module +is given, then the -system statistics are listed. +

                                                                                                                                    +The -system module contains the following stats: +

                                                                                                                                    +-default-production-count
                                                                                                                                    +-user-production-count
                                                                                                                                    +-chunk-count
                                                                                                                                    +-justification-count
                                                                                                                                    +-all-productions-count
                                                                                                                                    +-dc-count
                                                                                                                                    +-ec-count
                                                                                                                                    +-ecs/dc
                                                                                                                                    +-firings-count
                                                                                                                                    +-firings/ec
                                                                                                                                    +-wme-change-count
                                                                                                                                    +-wme-addition-count
                                                                                                                                    +-wme-removal-count
                                                                                                                                    +-wme-count
                                                                                                                                    +-wme-avg-count
                                                                                                                                    +-wme-max-count
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +If Soar has been compiled with the NO_TIMING_STUFF NOT set, +then the following statistics are also available in the +-system module: +

                                                                                                                                    +-total-time
                                                                                                                                    +-ms/dc
                                                                                                                                    +-ms/ec
                                                                                                                                    +-ms/firing
                                                                                                                                    +-ms/wme-change
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +If Soar has been compiled with the DETAILED_TIMING_STATS SET, +then the following statistics are also available in the +-system module: +

                                                                                                                                    +-match-time
                                                                                                                                    +-ownership-time
                                                                                                                                    +-chunking-time
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The -memory module contains the following statistics: +

                                                                                                                                    +-total
                                                                                                                                    +-overhead
                                                                                                                                    +-strings
                                                                                                                                    +-hash-table
                                                                                                                                    +-pool pool-statistic
                                                                                                                                    +-misc
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The -pool statistic is additionally qualified by a +pool-statistic option. If this option is not given, +then all -memory pool statistics are printed. If +given, pool-statistic must have one of the following +forms: +

                                                                                                                                    +
                                                                                                                                    -total + +
                                                                                                                                    Print just the overall totals for the pools +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    pool-name [aspect] + +
                                                                                                                                    Print statistics about the specific pool pool-name. The +permissable pool-names are: +
                                                                                                                                    +
                                                                                                                                    +     chunk condition
                                                                                                                                    +     io wme
                                                                                                                                    +     output link
                                                                                                                                    +     preference
                                                                                                                                    +     wme
                                                                                                                                    +     slot
                                                                                                                                    +     instantiation
                                                                                                                                    +     ms change
                                                                                                                                    +     right mem
                                                                                                                                    +     negative token
                                                                                                                                    +     token
                                                                                                                                    +     node varnames
                                                                                                                                    +     rete node
                                                                                                                                    +     rete test
                                                                                                                                    +     alpha mem
                                                                                                                                    +     saved test
                                                                                                                                    +     not
                                                                                                                                    +     action
                                                                                                                                    +     production
                                                                                                                                    +     condition
                                                                                                                                    +     complex test
                                                                                                                                    +     float constant
                                                                                                                                    +     int constant
                                                                                                                                    +     sym constant
                                                                                                                                    +     identifier
                                                                                                                                    +     variable
                                                                                                                                    +     dl cons
                                                                                                                                    +     cons cell
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +If no aspect is given, then print all statistics about the +given pool. If given, aspect must have one of the +following forms: +

                                                                                                                                    +     -used
                                                                                                                                    +     -free
                                                                                                                                    +     -item-size
                                                                                                                                    +     -total-bytes
                                                                                                                                    +
                                                                                                                                    +The first two aspects are available only if Soar has been +compiled with MEMORY_POOL_STATS SET. +

                                                                                                                                    +The -rete module contains statistics for the following node +types: +

                                                                                                                                    +unhashed memory
                                                                                                                                    +memory
                                                                                                                                    +unhashed mem-pos
                                                                                                                                    +mem-pos
                                                                                                                                    +unhashed negative
                                                                                                                                    +negative
                                                                                                                                    +unhashed positive
                                                                                                                                    +positive
                                                                                                                                    +dummy top
                                                                                                                                    +dummy matches
                                                                                                                                    +conj. neg.
                                                                                                                                    +conj. neg. partner
                                                                                                                                    +production
                                                                                                                                    +total
                                                                                                                                    +
                                                                                                                                    +The total statistic gives a total count over all node types. +

                                                                                                                                    +A -rete statistic is obtained by specifying one of the above +nodes followed by a qualifier. The qualifier is one +of -actual, -if-no-merging, and -if-no-sharing. +The -if-no-sharing option is only available if Soar has been +compiled with the SHARING_FACTORS option SET. + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +This prints all statistics in the -system module: +
                                                                                                                                    +stats -system
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This prints the number of io wme's: +

                                                                                                                                    +stats -memory -pool {io wme} -used
                                                                                                                                    +
                                                                                                                                    +Note that this particular pool name, "io wme", contains an +embedded space character. Hence, the name must be surrounded +by curly braces or double quotes to override the normal Tcl +parsing of words separated by whitespace. This is not necessary +for pool names that do not include spaces: +
                                                                                                                                    +stats -memory -pool wme -used
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +This prints the actual number of unhashed negative nodes in the +Rete memory: +

                                                                                                                                    +stats -rete {unhashed negative} -actual
                                                                                                                                    +
                                                                                                                                    + +

                                                                                                                                    A NOTE ON TIMERS

                                                                                                                                    +

                                                                                                                                    +The current implementation of Soar uses a number of timers to +provide time-based statistics for use in the stats command +calculations. These timers are: +

                                                                                                                                    +total CPU time
                                                                                                                                    +total kernel time
                                                                                                                                    +phase kernel time (per phase)
                                                                                                                                    +phase callbacks time (per phase)
                                                                                                                                    +input function time
                                                                                                                                    +output function time
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    + +Total CPU time is calculated from the time a decision cycle (or number +of decision cycles) is initiated until stopped. Kernel time is the +time spent in core Soar functions. In this case, kernel time is +defined as the all functions other than the execution of callbacks and +the input and output functions. The total kernel timer is only +stopped for these functions. + +The phase timers (for the kernel and callbacks) track the execution +time for individual phases of the decision cycle (i.e., input phase, +preference phase, working memory phase, output phase, and decision +phase). Because there is overhead associated with turning these +timers on and off, the actual kernel time will always be greater than +the derived kernel time (i.e., the sum of all the phase kernel +timers). Similarly, the total CPU time will always be greater than +the derived total (the sum of the other timers) because the overhead +of turning these timers on and off is included in the total CPU time. +In general, the times reported by the single timers should always be +greater than than the corresponding derived time. Additionally, as +execution time increases, the difference between these two values will +also increase. + +For those concerned about the performance cost of the timers, all the +run time timing calculations can be compiled out of the code by +defining NO_TIMING_STUFF (in soarkernel.h) before compilation. + +

                                                                                                                                    +

                                                                                                                                    FILES

                                                                                                                                    +soarkernel.h + + + + diff --git a/soar-8.5.2/doc/html/stop-soar.html b/soar-8.5.2/doc/html/stop-soar.html new file mode 100644 index 0000000..e8a0cc3 --- /dev/null +++ b/soar-8.5.2/doc/html/stop-soar.html @@ -0,0 +1,58 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +stop-soar - Stop Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +stop-soar [ -self [reason-string] ] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +Agents may be run using the run command. +The stop-soar command stops any running Soar agents. It +sets a flag in the Soar kernel so that Soar will stop running at +a "safe" point and return control to the user. This operates exactly +as if the user had issued a control-C (SIGINT) interrupt to the Soar +process. +

                                                                                                                                    +
                                                                                                                                    -self + +
                                                                                                                                    Stop only the soar agent where the command is issued. All other agents +continue running as previously specified. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    reason-string + +
                                                                                                                                    An optional string following -self which will be printed +when Soar is stopped, to indicate why it was stopped. If left +blank, no message will be printed when Soar is stopped. +
                                                                                                                                    +

                                                                                                                                    +This command is usually not issued at the command line prompt. A +more common use of this command is as a side-effect of pressing a +button on a Graphical User Interface (GUI), or as a monitor to +be executed at a specific Soar Event. For example, a user may +wish to examine an agent's "matches" after the Soar Decision Phase. +In order to do this in Soar 8, the user must register a monitor, +or callback, to issue the "stop-soar -self" command for the event, +after-decision-phase-cycle. +

                                                                                                                                    + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +

                                                                                                                                    +This example shows how to stop Soar8 after this decision phase +using stop-soar -self in a monitor to stop after the +decision phase so that memory can be examined. +

                                                                                                                                    + monitor -add {stop-soar -self "after decision phase"} \
                                                                                                                                    +        after-decision-phase-cycle
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +If the graphical interface doesn't periodically do a Tcl "update" +command, then it may not be possible to interrupt a Soar agent +from the command line. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +run, monitor, matches + diff --git a/soar-8.5.2/doc/html/topd.html b/soar-8.5.2/doc/html/topd.html new file mode 100644 index 0000000..79c3d7c --- /dev/null +++ b/soar-8.5.2/doc/html/topd.html @@ -0,0 +1,17 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +topd - List the top of the directory stack +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +topd +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command returns the top directory on the directory stack. +See the dirs command for an explanation of the directory +stack. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +dirs, pushd, popd diff --git a/soar-8.5.2/doc/html/tsi.html b/soar-8.5.2/doc/html/tsi.html new file mode 100644 index 0000000..8a469ef --- /dev/null +++ b/soar-8.5.2/doc/html/tsi.html @@ -0,0 +1,202 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +Soar TSI: TclSoar Interface + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    + +The TSI provides a graphical user interface for interacting with Soar. +It is based on ideas from Frank Ritter's DSI, and the SCA2 work done +by Doug Pearson. The Soar Command Line Interface window is +essentially the one produced by Randy Jones as a development of Karl +Schwamb's original GUI for Soar. +

                                                                                                                                    +The TSI consists of a set of optional windows that include: +

                                                                                                                                    + +

                                                                                                                                    +1. +
                                                                                                                                    A control panel to provide easy access to the basic functions that + +
                                                                                                                                    are necessary or useful to run a Soar model. It also supports running +multiple Soar agents at the same time. +
                                                                                                                                    +
                                                                                                                                    +2. +
                                                                                                                                    An interaction window for Soar, providing equivalent functionality + +
                                                                                                                                    to the old command line interface, but with a set of menus and buttons +available. +
                                                                                                                                    +
                                                                                                                                    +3. +
                                                                                                                                    A display of the match set of rules about to fire. +
                                                                                                                                    +
                                                                                                                                    +4. +
                                                                                                                                    A continuous display of the current state of the goal stack. +
                                                                                                                                    +
                                                                                                                                    +5. +
                                                                                                                                    A print window that supports the examination of objects selected + +
                                                                                                                                    by the user. (The user either presses p, or double clicks with the +middle mouse button once an object has been selected.) + +
                                                                                                                                    +

                                                                                                                                    +The TSI is normally found in the $soar_library directory (folder), +but can be moved anywhere, provided the global variable, tsi_library, +is properly and accurately defined when running Wish. However, if +the TSI is moved, it's possible (likely) that it will not be able to +find the Soar help files or Soar demo files. Users should become +quite familiar with the TSI code before trying to move it to another +location. In $tsi_library is the main "tcl library" of code that +implements the TSI. All tsi commands will be autoloaded from this +directory or folder (assuming your tcl interpreter knows where this +directory or folder is). See the file "start-soar.tcl" in the +top-level directory of the Soar distribution for more information +on what needs to be defined when starting Soar. + + +Comments, questions, suggestions and discussions relevant to the +TSI should be sent to soar-tsi@umich.edu. + + +

                                                                                                                                    LOADING THE TSI

                                                                                                                                    + +Since Soar version 7.2, the TSI has been packaged with the Soar distribution. +It will be invoked if Soar is started using the "start-soar.tcl" script +found in the top-level directory (folder) of the Soar distribution. +The "start-soar.tcl" script defines the $tsi_library variable and adds +it to the auto_path so that the TSI commands are automatically available +in Soar. + +

                                                                                                                                    MODIFYING THE TSI

                                                                                                                                    +Users can change some settings for the TSI by creating their own +tsi-defaults.tcl file. +Users wishing to further modify the TSI, are encouraged to create a +new folder or subdirectory in the $soar_library folder, and copy +the TSI files into the new folder, and then redefine the $tsi_library +variable. That way there will always be a distribution copy of the TSI, +and there will be less confusion if the modified TSI is sent to +other Soar users or TSI developers. If the working copy +of the TSI is moved out of the $soar_library location, the TSI may not be +able to find the Soar help pages or the Soar demos, unless it is +specifically modified to look in the proper locations. + +

                                                                                                                                    FILES

                                                                                                                                    + +Unless otherwise noted, all files listed below are found in the +library/tsi* directory (folder). + +
                                                                                                                                    +
                                                                                                                                    README + +
                                                                                                                                    Description of the TSI, similar to this man page +
                                                                                                                                    +
                                                                                                                                    +tsi-defaults.tcl +
                                                                                                                                    This specifies some default values for the configuration of the TSI. + +
                                                                                                                                    To override the defaults, you can make a file named tsi-defaults.tcl +in the directory or folder from which you run Soar, and specify the +values you want to override. +
                                                                                                                                    +
                                                                                                                                    +tsiInit.tcl +
                                                                                                                                    Provides the hooks to start up the TSI and to create + +
                                                                                                                                    new agent (and other) interpreters. +
                                                                                                                                    +
                                                                                                                                    +tsiControlPanel.tcl +
                                                                                                                                    Creates a simple control panel to drive Soar. + +
                                                                                                                                    Allows the creation of mutiple Soar agents. +
                                                                                                                                    +
                                                                                                                                    +tsiDialogs.tcl +
                                                                                                                                    A set of "standard" dialogs for user interaction. +
                                                                                                                                    +
                                                                                                                                    +tsiPopUp.tcl +
                                                                                                                                    Implements PopUp menus for interacting with Soar. +
                                                                                                                                    +
                                                                                                                                    +termText.tcl +
                                                                                                                                    A simple terminal widget for tcl/tk (which the TSI agent windows use). +
                                                                                                                                    +
                                                                                                                                    +tsiAgentText.tcl +
                                                                                                                                    Enhancements to termText for Soar agents +
                                                                                                                                    +
                                                                                                                                    +tsiAgentWindow.tcl +
                                                                                                                                    Implements a window for interacting with Soar agents. + +
                                                                                                                                    Uses tsiAgentText for the main window, and adds a +bunch of menus, buttons, and whirligigs. +
                                                                                                                                    +
                                                                                                                                    +tsiUtils.tcl +
                                                                                                                                    A collection of utilities supporting the interface, + +
                                                                                                                                    including agent windows as well as other types +of windows (such as monitor windows). +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    tclIndex + +
                                                                                                                                    This file is used by Tcl to autoload various TSI +commands and procedures. Do not mess with it or +move it (unless you are making enhancements to the +TSI code and know what you are doing). +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    tsi/demos subdirectory or subfolder: + +
                                                                                                                                    This directory or folder contains a few Soar programs +that make use (to varying degrees) of some of the +features in the TSI. The TSI code assumes that +this demos directory (folder) is a subdirectory +(subfolder) of the directory (folder) holding the main +TSI code. If you move this directory or folder +somewhere else, or rename it, the menus for selecting +these demo programs will probably fail to function. +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                      +TSI Demo programs: (for Soar 7; won't work in Soar8) + analogy.s7 + analogy.topspace.s7 + analogy.toptwo.s7 + default.s7 + ht.s7 + ht2.s7 +
                                                                                                                                    +
                                                                                                                                    + ../../demos +
                                                                                                                                    The Soar distribution demos that get loaded into + +
                                                                                                                                    the TSI "Demos" pulldownMenu when in Soar8 mode. +
                                                                                                                                    +
                                                                                                                                    + ../../demos_soar7 +
                                                                                                                                    The Soar distribution demos that get loaded into + +
                                                                                                                                    the TSI "Demos" pulldownMenu when in Soar7 mode. +
                                                                                                                                    +
                                                                                                                                    +start-soar.tcl +
                                                                                                                                    This file is located in the top level of the Soar distribution. It + +
                                                                                                                                    defines soar_library and tsi_library, appends them to the Tcl auto_path, +and starts the TSI. + + + + + + diff --git a/soar-8.5.2/doc/html/unalias.html b/soar-8.5.2/doc/html/unalias.html new file mode 100644 index 0000000..7b18d69 --- /dev/null +++ b/soar-8.5.2/doc/html/unalias.html @@ -0,0 +1,19 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +unalias - Remove a Soar alias +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +unalias name +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command removes an existing alias named name. This +command simply removes the definition of the associated procedure +called name. If no alias named name exists, an error +message is printed. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +alias + diff --git a/soar-8.5.2/doc/html/variables.html b/soar-8.5.2/doc/html/variables.html new file mode 100644 index 0000000..1f5a570 --- /dev/null +++ b/soar-8.5.2/doc/html/variables.html @@ -0,0 +1,82 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +Soar variables + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +There are a number of Soar variables that influence the +behavior of Soar. These variables are given default values, +which can be changed using the Tcl set command. However, unlike +normal Tcl variables, Soar variables do have an enforced +type and can not be unset. +

                                                                                                                                    +The defined Soar variables are: +

                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      attribute_preferences_mode [0|1|2] + +
                                                                                                                                      The "attribute_preferences_mode" variable is used to control the +handling of preferences (other than acceptable and reject preferences). +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      default_wme_depth [0|1|2] + +
                                                                                                                                      The "default_wme_depth" variable is used to control the +default printing depth of the print command. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      max_chunks [positive integer] + +
                                                                                                                                      The "max_chunks" variable controls the maximum number of chunks +that can be created in a single decision cycle. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      max_elaborations [positive integer] + +
                                                                                                                                      The "max_elaborations" variable controls the maximum number of +elaborations allowed in a single decision cycle. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      max_nil_output_cycles [positive integer] + +
                                                                                                                                      The "max_nil_output_cycles" variable controls the maximum number of +consecutive nil output cycles allowed when run-til-output-generated +(or run out) is used. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      o_support_mode [0|1|2] + +
                                                                                                                                      The "o_support_mode" variable is used to control the +way o-support calculations are done for the agent. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      \freal_time_per_decision [positive integer] + +
                                                                                                                                      The "real_time_per_decision" variable controls the minumum amount +of time that Soar will take to complete a decision cycle (in milliseconds). +A decision cycle may take longer if Soar is still working. +The compiler option REAL_TIME_BEHAVIOR must be enabled for this variable. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      save_backtraces (boolean) + +
                                                                                                                                      The "save_backtraces" variable enables and disables the saving +of backtracing information. It must be on for the explain-backtraces +command to provide backtracing information. +
                                                                                                                                      +
                                                                                                                                      +
                                                                                                                                      warnings (boolean) + +
                                                                                                                                      This "warnings" variable enables and disables the printing of +warning messages. +
                                                                                                                                      +

                                                                                                                                      +

                                                                                                                                    + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +set attribute_preferences_mode default_wme_depth +max_chunks max_elaborations o_support_mode +save_backtraces warnings + diff --git a/soar-8.5.2/doc/html/version.html b/soar-8.5.2/doc/html/version.html new file mode 100644 index 0000000..7860167 --- /dev/null +++ b/soar-8.5.2/doc/html/version.html @@ -0,0 +1,22 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +version - Soar version +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +version +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command gives information about the current Soar version +being run. It returns the version number itself, which can +then be used in any Tcl expression. + +

                                                                                                                                    EXAMPLE

                                                                                                                                    +The following is a test that will be true for any version of Soar +that is at least 8.0 or higher. +
                                                                                                                                    +if {[version] > 8.0} { ...
                                                                                                                                    +
                                                                                                                                    + diff --git a/soar-8.5.2/doc/html/wake-from-attention-lapse.html b/soar-8.5.2/doc/html/wake-from-attention-lapse.html new file mode 100644 index 0000000..4b7699f --- /dev/null +++ b/soar-8.5.2/doc/html/wake-from-attention-lapse.html @@ -0,0 +1,26 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +wake-from-attention-lapse - primarily intended to be called from the RHS of a production rule +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +wake-from-attention-lapse +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +This command is primarily intended to be called from the RHS of a +production rule. This sets the "attention-lapsing" variable to FALSE (0), +and starts tracking the amount of real time that has passed since +the last lapse. + +

                                                                                                                                    +

                                                                                                                                    WARNINGS

                                                                                                                                    +The compile time options
                                                                                                                                    REAL_TIME_BEHAVIOR and ATTENTION_LAPSE +must be enabled for this functionality. +

                                                                                                                                    + + + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +
                                                                                                                                    attention-lapse start-attention-lapse variables diff --git a/soar-8.5.2/doc/html/warnings.html b/soar-8.5.2/doc/html/warnings.html new file mode 100644 index 0000000..b973a73 --- /dev/null +++ b/soar-8.5.2/doc/html/warnings.html @@ -0,0 +1,35 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +warnings - Enable/Disable Soar warnings +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +set warnings [on | off] +
                                                                                                                                    + +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +warnings is a Soar variable which through the Tcl set command, +enables and disables the printing of warning messages. +If an enabling or disabling status of on or off +is given, then the warnings are +set to that state. If no status is given, then the current +warnings status is printed. At startup, warnings are initially +enabled. If warnings are disabled using this command, then most +warnings are supressed since some are considered too important to +ignore. + +

                                                                                                                                    OPTIONS

                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    on | 1 + +
                                                                                                                                    Turns on all warnings (initial default) +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    off | 0 + +
                                                                                                                                    Turns off all but critical warnings + +
                                                                                                                                    +

                                                                                                                                    SEE ALSO

                                                                                                                                    +variables diff --git a/soar-8.5.2/doc/html/watch.html b/soar-8.5.2/doc/html/watch.html new file mode 100644 index 0000000..f1501de --- /dev/null +++ b/soar-8.5.2/doc/html/watch.html @@ -0,0 +1,213 @@ + + + +

                                                                                                                                    NAME

                                                                                                                                    +watch - Run-time tracing of Soar +

                                                                                                                                    SYNOPSIS

                                                                                                                                    +watch [level*] [-on | -off | -inc[lusive]] +
                                                                                                                                    +watch wmes [-on | -off | -inc[lusive] | filter-options] +
                                                                                                                                    +watch [ aliases | backtracing | loading ] [-on | -off ] +
                                                                                                                                    +watch [ learning ] [-noprint | -print | -fullprint ] +
                                                                                                                                    +

                                                                                                                                    DESCRIPTION

                                                                                                                                    +

                                                                                                                                    +The watch command controls run-time tracing of Soar. +With no arguments, this command prints out the current watch +status. +The various levels are used to modify the current watch +settings. Each level can be indicated with either a number or a +named flag as follows: +

                                                                                                                                    +0  none
                                                                                                                                    +1  decisions
                                                                                                                                    +2  phases
                                                                                                                                    +3  productions
                                                                                                                                    +4  wmes
                                                                                                                                    +5  preferences
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +The numerical arguments (0 - 5) do not take any arguments or modifiers. +They inclusively turn on all levels up to the number specified. To use +numerical arguments to turn off a level, specify a number which is +less than the level to be turned off. For instance, to turn off watching +of productions, specify "watch 2" (or 1 or 0). Numerical arguments are +provided for shorthand convenience. For more detailed control over +the watch settings, the named arguments should be used. +

                                                                                                                                    +For the named arguments, +setting either the -on or -off switch selectively turns on or +off only that setting. Setting the -inclusive switch (which can be +abbreviated as -inc) or setting no flag at all has the effect of setting +all levels up to and including the level specified. +For example, watch productions -on selectively turns +on the +tracing of production firings/retractions; watch productions -off +selectively turns it off again. watch productions [-inc] turns on the +tracing of productions and also turns on tracing of all levels below +productions: decisions and phases, too. Individual watch parameters may +be used to modify the inclusive settings as well, selectively turning on +or off any levels outside or inside the inclusive range. + + +

                                                                                                                                    OPTIONS

                                                                                                                                    +

                                                                                                                                    +The following options are allowed (status is given as either +-on, -off, or -inclusive, -inc is the default): +

                                                                                                                                    +
                                                                                                                                    0 | none + +
                                                                                                                                    turns off all printing about Soar's internals +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    1 | decisions status + +
                                                                                                                                    controls whether state and operator decisions are printed as they are made +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    2 | phases status + +
                                                                                                                                    controls whether decisions cycle phase names are printed as Soar executes. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    3 | productions status + +
                                                                                                                                    controls whether the names of +productions are printed as they fire and retract. See the +optional arguments below [-all|-chunks|-defaults|-justifications|-user] +which specify which types of productions the status argument refers to. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    4 | wmes + +
                                                                                                                                    controls the printing of working memory elements that are added and deleted as +productions are fired and retracted. +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    +To improve state tracing, the following filter-options
                                                                                                                                    +are available to watch wmes for monitoring a specified
                                                                                                                                    +object-attribute-value triplet:
                                                                                                                                    +
                                                                                                                                    +{-add-filter    type filter} |
                                                                                                                                    +{-remove-filter type filter} |
                                                                                                                                    +{-reset-filter  type       } |
                                                                                                                                    +{-list-filter   type       } 
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +where: +

                                                                                                                                    +type   = -adds | -removes | -both
                                                                                                                                    +filter = {id|*} {attribute|*} {value|*}
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    +
                                                                                                                                    5 | preferences status + +
                                                                                                                                    controls whether the preferences +generated by the traced productions are printed when +those productions fire or retract. When a production +fires, all the preferences it generates are printed. +When it retracts, only the ones being removed from +preference memory are printed (i.e., the i-supported ones). +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -nowmes | -timetags | -fullwmes + +
                                                                                                                                    controls the level of detail given about the wmes matched by productions +whose firings and retractions are being traced. Level 0|-nowmes means no +information about the wmes is printed. Level 1|-timetags means the wme +timetags are printed. Level 2|-fullwmes means the whole wmes are printed. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    -all|-default|-user|-chunks|-justifications [modifier] + +
                                                                                                                                    allows user to selectively control printing by production *type* +as they fire and retract, instead of having to watch ALL productions +or none. (NOTE: these args can be abbreviated by the first +char ONLY, otherwise the full arg must be specified.) +The modifier can be one of: +
                                                                                                                                    +
                                                                                                                                    +-noprint|-print|-fullprint
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    +-noprint prints nothing, 
                                                                                                                                    +-print prints the production name,
                                                                                                                                    +-fullprint prints the entire production. (not done as of 8.2)
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +

                                                                                                                                    +The following options control printing of other Soar parameters and are +not part of the above set of levels which can be controlled as a group. +

                                                                                                                                    +
                                                                                                                                    aliases -on | -off + +
                                                                                                                                    controls the echoing of aliases as they are defined. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    backtracing -on | -off + +
                                                                                                                                    controls the printing of backtracing information when a chunk or +justification is created. +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    loading -on | -off + +
                                                                                                                                    controls the printing of '*' for each production loaded and a '#' for +each production excised +
                                                                                                                                    +
                                                                                                                                    +
                                                                                                                                    learning -noprint | -print | -fullprint + +
                                                                                                                                    controls the printing of +chunks/justifications as they are created. -noprint is +don't print anything, -print prints just the names, +-fullprint prints the entire chunk/justification. +
                                                                                                                                    +

                                                                                                                                    + +

                                                                                                                                    EXAMPLES

                                                                                                                                    +The most common uses of watch are by using the numeric arguments +which indicate watch levels: +
                                                                                                                                    +watch 0
                                                                                                                                    +
                                                                                                                                    +which turns off all printing of Soar internals (same as watch none), or +
                                                                                                                                    +watch 3
                                                                                                                                    +
                                                                                                                                    +which turns on printing of decisions, phases and productions (same as +watch productions). +Of course, individual options can be changed as well: +
                                                                                                                                    +watch 1 wmes -on 
                                                                                                                                    +
                                                                                                                                    +turns on printing of decisions and wmes, but not phases and productions. +While +
                                                                                                                                    +watch 4 phases -off
                                                                                                                                    +
                                                                                                                                    +turns on printing of decisions, productions and wmes, and turns phases off. +

                                                                                                                                    +To watch the firing and retraction of only USER productions: +

                                                                                                                                    +watch productions -user -print
                                                                                                                                    +
                                                                                                                                    +

                                                                                                                                    +whereas this command would watch decisions, phases and ALL productions: +

                                                                                                                                    +watch productions
                                                                                                                                    +
                                                                                                                                    + + +

                                                                                                                                    NOTE

                                                                                                                                    +The pwatch command is used to watch named productions. + +

                                                                                                                                    SEE ALSO

                                                                                                                                    +pwatch, print + diff --git a/soar-8.5.2/doc/make_doc_from_C_file.pl b/soar-8.5.2/doc/make_doc_from_C_file.pl new file mode 100644 index 0000000..33508a6 --- /dev/null +++ b/soar-8.5.2/doc/make_doc_from_C_file.pl @@ -0,0 +1,28 @@ +#!/local/bin/perl + +while (<>) { + &gen_doc_page if (/\f/); +} + +sub gen_doc_page { + while (<>) { + if (/\s+\*\s+(\S+)Cmd\s+--/) { + open(DOCFILE, ">doc/$1") || die "Can't open file doc/$1!"; + while (<>) { + if (/\*\//) + { + close (DOCFILE); + return; + } + elsif (/\s+\*-/) + { + # skip *--- lines + } + elsif (/\s+\*(.*)/) + { + print DOCFILE "$1\n"; + } + } + } + } +} diff --git a/soar-8.5.2/doc/man/add-wme.n b/soar-8.5.2/doc/man/add-wme.n new file mode 100644 index 0000000..4c01970 --- /dev/null +++ b/soar-8.5.2/doc/man/add-wme.n @@ -0,0 +1,54 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS add-wme soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +add-wme \- Add a working memory element +.SH SYNOPSIS +\fBadd-wme\fR \fIid\fR \fR[\fB^\fR]\fIattribute\fR \fIvalue\fR [\fI+\fR] +.BE + +.SH DESCRIPTION +.PP +This command adds an element to working memory and returns the +timetag of the wme. In effect, +Soar's working memory is surgically altered by this command. +\fBadd-wme\fR adds a new wme with the given \fIid\fR, \fIattribute\fR, +\fIvalue\fR, and optional \fIpreference\fR. The given \fIid\fR must +be an existing identifier. The \fIattribute\fR and \fIvalue\fR fields +can be any Soar symbol. If \fB*\fR is given in the \fIattribute\fR or +\fIvalue\fR field, Soar creates a new identifier (symbol) for that +field. If the \fIpreference\fR is given, it can only have the +value \fB+\fR to indicate that an acceptable preference should be +created for this wme. +.PP +add-wme is often used by an input function to update Soar's +information about the state of the external world. + +.SH EXAMPLES +This example adds the attribute/value pair "message-status received" +to the identifier (symbol) \fBS1\fR: +.DS +\fBadd-wme S1 ^message-status received\fR +.DE +.PP +This example adds an attribute/value pair with an acceptable +preference to the identifier (symbol) \fBZ2\fR. The attribute is +"message" and the value is a unique identifier generated by Soar. +Note that since the \fB^\fR is optional, it has been left off in +this case. +.DS +\fBadd-wme Z2 message * +\fR +.DE +.SH WARNINGS +\fIThis command is inherently unstable and may have +weird side effects (possibly even including system crashes).\fR +For example, the chunker can't backtrace through wmes created +via \fBadd-wme\fR. Removing input wmes or context/impasse wmes may +have unexpected side effects. \fIYou've been warned.\fR + +.SH SEE ALSO +\fBremove-wme\fR diff --git a/soar-8.5.2/doc/man/alias.n b/soar-8.5.2/doc/man/alias.n new file mode 100644 index 0000000..37d2578 --- /dev/null +++ b/soar-8.5.2/doc/man/alias.n @@ -0,0 +1,69 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS alias soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +alias \- Define a new Soar alias +.SH SYNOPSIS +\fBalias\fR [\fIname\fR [\fIdefinition\fR | \fI-off\fR]] +.BE + +.SH DESCRIPTION +.PP +This command defines new aliases by creating Tcl procedures +with the given \fIname\fR. The new procedure can then take an arbitrary +number of arguments which are post-pended to the given \fIdefinition\fR +and then that entire string is executed as a command. When invoked, +the command is executed at the global level as if typed in from +the interactive command line interpreter. The \fIdefinition\fR must +be a single command, ';' for multiple commands is not allowed. If more +complex aliases are desired, then the Tcl \fBproc\fR command can be used +to define a new procedure. The \fBalias\fR procedure +checks to see if the \fIname\fR already exists, and does not +destroy existing procedures or aliases by the same name. + +Existing aliases can be removed by using the command \fBunalias\fR, +or by specifying \fB alias \fIname -off\fR\fR. + +With no arguments, \fBalias\fR returns the list of defined aliases. + +With only the \fIname\fR given, \fBalias\fR returns the current definition. + + +.SH EXAMPLES +.PP +The command \fBwmes\fR is an alias which is defined as follows: +.DS +\fBalias wmes print -depth 0 -internal\fR +.DE +.PP +If the user executes a command such as: +.DS +\fBwmes {(* ^superstate nil)}\fR +.DE +.PP +it is as if the user had typed this command: +.DS +\fBprint -depth 0 -internal {(* ^superstate nil)}\fR +.DE +.SH WARNINGS +.PP +\f Alias is also a Tcl command that is used when creating slave +interps. In Tcl, it is used to allow slave interps to call procs that +are defined in the master interp. See the Tcl help file in your system. + + +.SH FILES +.TP +\fBsoar.tcl\fR and \fBsoar7.2km-aliases.tcl\fR + +The aliases for Soar provided upon startup are defined in these files. +The files are located in the \fB$soar_library\fR directory (folder). + +.SH SEE ALSO +\fBunalias\fR, \fBrename\fR, \fBproc\fR, \fBpredefined-aliases\fR, +and Tcl Help for the \fBinterp\fR and \fBalias\fR commands + diff --git a/soar-8.5.2/doc/man/attention-lapse.n b/soar-8.5.2/doc/man/attention-lapse.n new file mode 100644 index 0000000..12b989d --- /dev/null +++ b/soar-8.5.2/doc/man/attention-lapse.n @@ -0,0 +1,39 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS attention-lapse soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +attention-lapse \- Enable/Disable attentional lapsing +.SH SYNOPSIS +\fBattention-lapse \fR [\fB-on\fR | \fB-off\fR] +.BE + +.SH DESCRIPTION +.PP +The \fBattention-lapse\fR command is used to enable/disable the +attentional lapsing capabilities of Soar. The default value is -off. +If no argument is given, then the current attentional lapsing +status is printed. The actual behaviors for lapsing are controlled thru +the start-attention-lapse and wake-from-attention-lapse commands. + +.SH OPTIONS +.TP +\fB-on\fR +Attentional lapsing will occur according to the +\fIstart-attention-lapse\fR and \fIwake-from-attention-lapse\fR commands. +.TP +\fB-off\fR +Attentional lapsing will not occur. + +.SH WARNINGS +.PP +This functionality must be enabled at compile time by defining the +compiler options ATTENTION_LAPSE and REAL_TIME_BEHAVIOR in soarkernel.h. +This option is not defined in the distribution version of Soar. + + +.SH SEE ALSO +\fBstart-attention-lapse\fR \fBwake-from-attention-lapse\fR diff --git a/soar-8.5.2/doc/man/attribute-preferences-mode.n b/soar-8.5.2/doc/man/attribute-preferences-mode.n new file mode 100644 index 0000000..c864b54 --- /dev/null +++ b/soar-8.5.2/doc/man/attribute-preferences-mode.n @@ -0,0 +1,81 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS attribute-preferences-mode soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +attribute-preferences-mode \- Set or list the attribute preferences mode +.SH SYNOPSIS +\fBattribute-preferences-mode \fR[\fImode\fR] +.BE + +.SH DESCRIPTION +.PP +\fBThis command is obsolete for Soar 8.\fR In Soar 8, the code automatically +operates as if attribute-preferences-mode = 2. +.PP +For Soar 7, this command sets and prints the attributes preferences mode. +If \fImode\fR is not given, this command prints the current +attribute preferences mode. If \fImode\fR is given, it must +be one of the positive integers \fB0\fR, \fB1\fR, or \fB2\fR +and is used to reset the attribute preferences modes. +.PP +The "attribute-preferences-mode" parameter is used to control the +handling of preferences (other than acceptable and reject +preferences) for non-context slots. The \fImode\fR settings have +the following interpretations: +.TP +\fB0\fR +Handle them the normal (Soar 6) way. +.TP +\fB1\fR +Handle them the normal (Soar 6) way, but print a warning message +whenever a preference other than + or - is created for a non-context +slot. +.TP +\fB2\fR +Whenever a preferences other than + or - is created for a +non-context slot, print an error message and ignore +(discard) that preference. For non-context slots, the set +of values installed in working memory is always equal to +the set of acceptable values minus the set of rejected +values. +.PP +The default initial setting of the "attribute-preferences-mode" +parameter is 0. + +.SH EXAMPLES +.PP +The command issued with no arguments, returns the current mode: +.DS +\fBattribute-preferences-mode\fR +.DE +.PP +The next example makes use of Tcl command abbreviation while setting +the mode to 1: +.DS +\fBattr 1\fR +.DE + +.SH VARIABLE + +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "attribute_preferences_mode" (with underscores) +that can be used to set the mode through the the Tcl \fIset\fR command. +If the \fImode\fR is not given, the Tcl \fIset\fR command prints the current +attribute preferences mode. If \fImode\fR is given, it must +be one of the positive integers \fB0\fR, \fB1\fR, or \fB2\fR +and is used to reset the attribute preferences modes. +.TP +\fBset attribute_preferences_mode\fR returns the current mode +.TP +\fBset attribute_preferences_mode 1\fR sets the mode to 1 +.PP +Soar variables cannot be abbreviated in the same manner as commandnames. + +.SH SEE ALSO +.PP +\fBvariables\fI + diff --git a/soar-8.5.2/doc/man/capture-input.n b/soar-8.5.2/doc/man/capture-input.n new file mode 100644 index 0000000..fa80fe7 --- /dev/null +++ b/soar-8.5.2/doc/man/capture-input.n @@ -0,0 +1,45 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS capture-input soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +capture-input \- Save agent commands issued from the input function +.SH SYNOPSIS +\fBcapture-input\fR \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command may be used to start and stop the recording of +input function commands as created by an external simulation. +Commands are +recorded decision cycle by decision cycle. Use the command +replay-input to replay the sequence. The \fIaction\fR must +be one of the following: +.TP +\fB-open\fR \fIpathname\fR +A log file named \fIpathname\fR is created and input capturing is initiated. +.TP +\fB-query\fR +Returns \fBopen\fR if capturing is active, or \fBclosed\fR if +capturing is not active. +.TP +\fB-off\fR +Close the captured input file. + +.SH EXAMPLES +This initiates input capturing and places the commands in foo.in: +.DS +\fBcapture-input -new foo.in\fR +.DE +.PP +This terminates capturing and closes the open log file: +.DS +\fBcapture-input -off\fR +.DE + +.SH SEE ALSO +\fBreplay-input\fR \ No newline at end of file diff --git a/soar-8.5.2/doc/man/chunk-name-format.n b/soar-8.5.2/doc/man/chunk-name-format.n new file mode 100644 index 0000000..fbc0cfc --- /dev/null +++ b/soar-8.5.2/doc/man/chunk-name-format.n @@ -0,0 +1,101 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS chunk-name-format soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +chunk-name-format \- Specify format of names of newly created chunks +.SH SYNOPSIS +\fBchunk-name-format\fR [\fB-short | -long\fR] [\fB-prefix\fR [\fI\fR]] [\fB-count\fR [\fI\fR]] +.BE + +.SH DESCRIPTION +.PP +The \fBchunk-name-format\fR command specifies the format to be used when +naming newly created chunks. The short format is: +.DS +\fI\fR-\fI\fR +.DE +.PP +The long format is: +.DS +\fI-\fR*d\fI**\fR +.DE +.PP +where: +.TP +\fI\fR +is a user-definable prefix string; \fI\fR defaults to "chunk" when +unspecified by the user; +.TP +\fI\fR +is 1 for the first chunk created, 2 for the second +chunk created, and so on. +.TP +\fI\fR +is the number of the decision cycle in which the chunk was formed; +.TP +\fI\fR +is [\fBtie | conflict | cfailure | snochange | opnochange\fR] +.TP +\fI\fR +is the number of the chunk within that specific decision cycle. +.PP +Notes: +.TP +1 +The \fI\fR string may not contain the '*' character. (The +\fBchunk-name-format\fR command enforces this constraint.) The '*' +character marks the ending of the number of the chunk, and +chunk numbers are examined during production loading to allow +a starting chunk number to be identified automatically. +.TP +2 +\fI\fR is the impasse of the lowest goal that has +a result generated by this chunk. + +.SH OPTIONS +.PP +.TP +\fB-short\fR +When generating chunk names, use the short format. +(See the DESCRIPTION section for details.) +.TP +\fB-long\fR +When generating chunk names, use the long format. +(See the DESCRIPTION section for details.) +This is the default format for Soar. +.TP +\fB-prefix\fR [\fI\fR] +When generating chunk names, use the string \fI\fR. +\fI\fR is initially "chunk". +When \fI\fR is unspecified, return the current \fI\fR. +.TP +\fB-count\fR [\fI\fR] +Set chunk counter to \fI\fR. +\fI\fR cannot be reset to a number lower than the +smallest chunk number of any loaded chunk. +When \fI\fR is unspecified, return the current \fI\fR. + +.SH EXAMPLES +.TP +\fBchunk-name-format -short -prefix "chunk" -count 0\fR +To cause chunks to be named according to the "old" scheme. +.TP +\fBchunk-name-format -prefix "new-chunk"\fR +To begin naming a new sequence of chunks. +.TP +\fBchunk-name-format -count 1000\fR +To begin numbering a new sequence of chunks at 1000. +.TP +\fBchunk-name-format -count\fR +To retrieve the next \fI\fR that will be used to form a chunk name. + + + + + + + diff --git a/soar-8.5.2/doc/man/command-to-file.n b/soar-8.5.2/doc/man/command-to-file.n new file mode 100644 index 0000000..fb72531 --- /dev/null +++ b/soar-8.5.2/doc/man/command-to-file.n @@ -0,0 +1,37 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS command-to-file soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +command-to-file \- Evaluate the command and print result to file +.SH SYNOPSIS +\fBcommand-to-file\fR \fIcommand\fR \fIfile\fR [\fImode\fR] +.BE + +.SH DESCRIPTION +.PP +This evaluates a \fIcommand\fR in the current interpreter. +The prints issued by the command and its result (both of which +are normally printed to stdout) are redirected to the given +\fIfile\fR. The \fImode\fR determines whether the file is +initially opened in write (\fB-new\fR) or append (\fB-existing\fR) +mode. If no \fImode\fR is given, then \fB-new\fR is assumed. + +.SH EXAMPLES +.PP +The command writes all productions to the file \fBmy-file\fR: +.DS +\fBcommand-to-file list-productions my-file\fR +.DE +.PP +This command appends the memory statistics to the already +existing file \fBmy-stats-file\fR: +.DS +\fBcommand-to-file {stats -memory} my-stats-file -existing +.DE + +.SH SEE ALSO +\fBoutput-strings-destination\fR diff --git a/soar-8.5.2/doc/man/d.n b/soar-8.5.2/doc/man/d.n new file mode 100644 index 0000000..cd2f7f2 --- /dev/null +++ b/soar-8.5.2/doc/man/d.n @@ -0,0 +1,23 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS d soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +d \- Run Soar by decision cycles +.SH SYNOPSIS +\fBd\fR [\fIcycles\fR] +.BE + +.SH DESCRIPTION +.PP +\fBd\fR is actually a predefined alias for 'run [n] d' +which runs the Soar agent for the given number of decision +\fIcycles\fR. If no \fRcycles\fR are given, then the agent is +run for one decision cycle. 'd -1' or 'd forever' runs the agent +until the task terminates or a user interrupt is given. + +.SH SEE ALSO +\fBrun\fR diff --git a/soar-8.5.2/doc/man/default-wme-depth.n b/soar-8.5.2/doc/man/default-wme-depth.n new file mode 100644 index 0000000..1407f92 --- /dev/null +++ b/soar-8.5.2/doc/man/default-wme-depth.n @@ -0,0 +1,65 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS default-wme-depth soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +default-wme-depth \- Set or list the default print depth +.SH SYNOPSIS +\fBdefault-wme-depth \fR[\fIdepth\fR] +.BE + +.SH DESCRIPTION +.PP +This command sets and prints the default printing depth. +If \fIdepth\fR is not given, this command prints the default +printing depth. If \fIdepth\fR is given, it must be a positive +integer and is used to reset the default printing depth. +.PP +The "default-wme-depth" parameter is used to control the +default printing depth of the \fBprint\fR command. +The default initial setting of the "default-wme-depth" +parameter is 1. + +.SH EXAMPLES +.PP +The command issued with no arguments, returns the print depth: +.DS +\fBdefault-wme-depth\fR +.DE +.PP +The next example makes use of Tcl command abbreviation while setting +the depth to 3: +.DS +\fBdef 3\fR +.DE + + +.SH VARIABLE +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "default_wme_depth" (with underscores) +that can be used to set the print depth through the the Tcl +\fIset\fR command. If \fIdepth\fR is not given, the Tcl \fIset\fR +commands prints the default printing depth. If \fIdepth\fR is given, +it must be a positive integer and is used to reset the default +printing depth. +.PP +.TP +\fBset default_wme_depth\fR returns the current depth +.TP +\fBset default_wme_depth 3\fR sets the depth to 3 +.PP +Soar variables cannot be abbreviated in the same manner as commandnames. + +.SH WARNINGS +.PP +This parameter can be overridden in any invocation of the +\fBprint\fR command by using the \fB-depth\fR option. + +.SH SEE ALSO +\fBprint\fR, \fBvariables\fR + + + diff --git a/soar-8.5.2/doc/man/dirs.n b/soar-8.5.2/doc/man/dirs.n new file mode 100644 index 0000000..60be7fe --- /dev/null +++ b/soar-8.5.2/doc/man/dirs.n @@ -0,0 +1,27 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS dirs soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +dirs \- List the directory stack +.SH SYNOPSIS +\fBdirs\fR +.BE + +.SH DESCRIPTION +.PP +This command lists the directory stack. Agents can move through +a directory structure by pushing and popping directory names. The +\fBdirs\fR command returns the stack. +.PP +The command \fBpushd\fR places a new "agent current directory" on +top of the directory stack and \fBcd\fRs to it. The command +\fBpopd\fR removes the directory at the top of the directory stack +and \fBcd\fRs to the previous directory which now appears at the +top of the stack. + +.SH SEE ALSO +\fBpushd\fR, \fBpopd\fR, \fBtopd\fR diff --git a/soar-8.5.2/doc/man/e.n b/soar-8.5.2/doc/man/e.n new file mode 100644 index 0000000..5c34ab4 --- /dev/null +++ b/soar-8.5.2/doc/man/e.n @@ -0,0 +1,23 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS e soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +e \- Run Soar by elaboration cycles +.SH SYNOPSIS +\fBe\fR [\fIcycles\fR | \fBforever\fR] +.BE + +.SH DESCRIPTION +.PP +\fBe\fR is actually a predefined alias for 'run [n] e' which +runs the Soar agent for the given number of elaboration +\fIcycles\fR. If no \fRcycles\fR are given, then the agent is +run for one elaboration cycle. 'e -1' or 'e forever' +runs the agent until the task terminates or a user interrupt is given. + +.SH SEE ALSO +\fBrun\fI \ No newline at end of file diff --git a/soar-8.5.2/doc/man/echo.n b/soar-8.5.2/doc/man/echo.n new file mode 100644 index 0000000..3929415 --- /dev/null +++ b/soar-8.5.2/doc/man/echo.n @@ -0,0 +1,30 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS echo soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +echo \- Echo message +.SH SYNOPSIS +\fBecho\fR [\fI-nonewline\fR] \fIargs\fR +.BE + +.SH DESCRIPTION +.PP +This command echos the \fIargs\fR to the current output +stream. This is normally \fBstdout\fR but can be set +to a variety of channels. If an \fIarg\fR is \fB-nonewline\fR +then no newline is printed at the end of the printed strings. +Otherwise a newline is printed after printing all the given +\fIargs\fR. For the full details of the redirection, see the +command \fBoutput-strings-destination\fR. +.PP +Users wanting to print variables and data to the screen, should +use \fBecho\fR rather than the Tcl command "puts." The \fBecho\fR +command gets redirected to the appropriate channel according +to output-strings-destination; the "puts" command does not. + +.SH SEE ALSO +\fBoutput-strings-destination\fR diff --git a/soar-8.5.2/doc/man/excise.n b/soar-8.5.2/doc/man/excise.n new file mode 100644 index 0000000..c3e7cbc --- /dev/null +++ b/soar-8.5.2/doc/man/excise.n @@ -0,0 +1,55 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS excise soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +excise \- Remove productions from Soar's memory +.SH SYNOPSIS +\fBexcise \fR\fIproduction-name\fR | \fB\-chunks\fR | \fB\-default\fR | \fB\-task\fR | \fB\-user\fR | \fB\-all\fR +.BE + +.SH DESCRIPTION +.PP +This command removes productions from Soar's memory. Each +option given on the command line may be either a production +name or the type of the standard set of productions (indicated by a keyword). + +.SH OPTIONS +.TP +\fIproduction-name\fR +Remove the production named \fIproduction-name\fR from memory +.TP +\fB\-chunks\fR +Remove all chunks (learned productions) and justifications from memory +.TP +\fB\-default\fR +Remove all default rules (:default) from memory +.TP +\fB\-task\fR +Remove all non-default productions from memory and perform +an \fBinit-soar\fR command +.TP +\fB\-user\fR +Remove all user productions (but not chunks or default rules) from memory. +.TP +\fB\-all\fR +Remove all productions from memory and perform +an \fBinit-soar\fR command + +.SH EXAMPLES +.PP +This removes the production my*first*production and all chunks: +.DS +\fBexcise my*first*production -chunks\fR +.DE +.PP +This removes all productions and does an init-soar: +.DS +\fBexcise -all\fR +.DE + +.SH SEE ALSO +\fBinit-soar\fR diff --git a/soar-8.5.2/doc/man/explain-backtraces.n b/soar-8.5.2/doc/man/explain-backtraces.n new file mode 100644 index 0000000..c3ead18 --- /dev/null +++ b/soar-8.5.2/doc/man/explain-backtraces.n @@ -0,0 +1,63 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS explain-backtraces soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +explain-backtraces \- Interpret chunking backtraces +.SH SYNOPSIS +\fBexplain-backtraces\fR [\fIprodnamename\fR [\fIn\fR | \fB-full\fR] ] +.BE + +.SH DESCRIPTION +.PP +This command provides some interpretation of backtraces generated +during chunking. If no option is given, then a list of all chunks +and justifications is printed. +.PP +The two most useful variants are \fBexplain-backtraces\fR \fIprodname\fR and +\fBexplain-backtraces\fR \fIname n\fR. +The first variant lists all of the conditions for the named +chunk or justification, and the \fIground\fR which resulted in +inclusion in the chunk/justification. A \fIground\fR is a +working memory element (WME) which was tested in the supergoal. +Just knowing which WME was +tested may be enough to explain why the chunk/justification +exists. If not, the conditions can be listed with an integer +value. This value can be used in +\fBexplain-backtraces\fR \fIname n\fR +to obtain a list of the productions which fired to obtain this +condition in the chunk/justification (and the crucial WMEs +tested along the way). Why use an integer value to specify the +condition? To save a big parsing job. + +.SH OPTIONS +.PP +If an option is given, it must match one of the following forms: +.TP +\fIname\fR +list all conditions and grounds for the chunk or justification named +\fIname\fR +.TP +\fIname\fR \fB-full\fR +provide a backtrace for the chunk or justification named \fIname\fR +.TP +\fIname n \fR +explain why condition number \fIn\fR is in the chunk or +justification + +.SH WARNINGS +.PP +\fBsave_backtraces\fR mode must be on when a chunk or +justification is created or no explanation will be available. +Explain-backtraces mode is toggled using the \fBsave_backtraces\fR +boolean variable. \fBsave_backtraces\fR is \fBoff\fR by default. +When explain mode is on, more memory is used, and building +chunks and justifications will be slower. + +.SH SEE ALSO +\fIsave_backtraces\fR, \fIvariables\fR + + diff --git a/soar-8.5.2/doc/man/firing-counts.n b/soar-8.5.2/doc/man/firing-counts.n new file mode 100644 index 0000000..60aae42 --- /dev/null +++ b/soar-8.5.2/doc/man/firing-counts.n @@ -0,0 +1,52 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS firing-counts soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +firing-counts \- Print production firing counts +.SH SYNOPSIS +\fBfiring-counts\fR [\fIinteger\fR | \fIproduction-names\fR] +.BE + +.SH DESCRIPTION +.PP +This command prints information about production firings. +If an option is not given, then all productions are printed in +a sorted list according to how many times they have fired. + +.SH OPTIONS + +If given, an option can take one of two forms -- an integer or a list +of production names: +.TP +\fIinteger\fR +List the top \fIinteger\fR productions. If \fIinteger\fR is 0, +only the productions which haven't fired are listed. +.TP +\fIproduction-names\fR +For each production in \fIproduction-names\fR, print how many +times the production has fired. + +.SH EXAMPLES +This example prints the 10 productions which have fired the most +times along with their firing counts: +.DS +\fBfiring-counts 10\fR +.DE +.PP +This example prints the firing counts of productions +my*first*production and my*second*production: +.DS +\fBfiring-counts my*first*production my*second*production\fR +.DE + +.SH WARNINGS +.PP +firing-counts are reset to zero after an init-soar +.PP +\fBNB\fR: This command is slow, because the sorting takes time +O(n*log n) + diff --git a/soar-8.5.2/doc/man/format-watch.n b/soar-8.5.2/doc/man/format-watch.n new file mode 100644 index 0000000..a68f003 --- /dev/null +++ b/soar-8.5.2/doc/man/format-watch.n @@ -0,0 +1,197 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS format-watch soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +format-watch \- Control the format of printed objects +.SH SYNOPSIS +\fBformat-watch\fR [\fI-stack | -object\fR] [\fIoperation class [name] format\fR] +.br +\t\fBoperation ::= -add | -remove\fR +.br +\t\fBclass ::= s | o | *\fR +.br +\t\fBformat ::= {sequence of format masks}\fR +.BE +.SH DESCRIPTION +.PP +The \fBformat-watch\fR command defines the format to use when +printing Soar objects and the Soar goal stack. The optional +\fItype\fR, if present, must be the switch \fB-object\fR or \fB-stack\fR +and indicates which format to manipulate. Object trace +formats control how Soar prints an object--e.g., a certain +operator, problem-space, etc. Stack trace formats control how +Soar prints its context stack selections in \fBwatch 0\fR and +\fBprint -stack\fR printouts. If no \fItype\fR is given, then +\fB-stack\fR is assumed. +.PP +The second portion of the \fBformat-watch\fR command is the +\fIaction\fR to apply to the selected trace format. An action +consists of adding or removing formats to selected classes +of objects. An \fIaction\fR has the following form: +.DS + \fIoperation\fR \fIclass\fR [\fIname\fR] \fIformat\fR +.DE +.PP +The \fIoperation\fR must be either \fB-add\fR or \fB-remove\fR. +An \fB-add\fR operation adds new trace formats replacing any +existing ones with identical applicability conditions. A +\fB-remove\fR operation removes trace formats with the given +applicability conditions. +The combination of \fIclass\fR and \fIname\fR define the +applicability conditions of the \fIformat\fR (i.e., which classes +of objects the \fIformat\fR applies to). +The \fIclass\fR must be either \fBs\fR or \fBo\fR +and indicates that the operation applies to states or operators, +respectively. The wildcard symbol \fB*\fR +may also be used to indicate that the \fIformat\fR applies to all objects. +If an \fB-object\fR trace is being manipulated, then an optional +\fIname\fR may be given indicating the format applies only +to objects with that name. If a \fB-stack\fR trace is being +manipulated, then an optional \fIname\fR may be given indicating +the format applies only within problem spaces of that name. +.PP +The \fIformat\fR string can be any sequence of characters +surrounded by curly braces. Note that double quotes are not +sufficient because the square brackets in the format string will +be interpreted as a command to be evaluated by Tcl. Certain +formatting controls can be used within the string--see the +section FORMAT CONTROLS below for more information. + +.PP +If no arguments are given, then \fBformat-watch\fR prints the +current format settings. + +.SH FORMAT CONTROLS +.PP +The following control sequences can be used within trace format +strings. The \fIS\fR indicates the sequence is ONLY usable in +stack traces: +.TP +\fB%cs\fR +print the current state using the appropriate object trace format (\fIS\fR) +.TP +\fB%co\fR +print the current operator using the appropriate object trace format (\fIS\fR) +.TP +\fB%dc\fR +print the current decision cycle number (\fIS\fR). Not meaningful and +therefore ignored in stack traces produced by the \fBprint -stack\fR command. +.TP +\fB%ec\fR +print the current elaboration cycle number (\fIS\fR). Not meaningful and +therefore ignored in stack traces produced by the \fBprint -stack\fR command. +.TP +\fB%sd\fR +print the current subgoal depth (\fIS\fR). This uses 0 as the top level. +.TP +\fB%rsd[\fIpattern\fB]\fR +repeat (subgoal depth) times: print the given \fIpattern\fR (\fIS\fR). +.TP +\fB%left[\fInum\fB,\fIpattern\fB]\fR +\fRprint the \fIpattern\fR left justified in a field of \fInum\fR spaces. +.TP +\fB%right[\fInum\fB,\fIpattern\fB]\fR +\fRprint the \fIpattern\fR right justified in a field of \fInum\fR +spaces. +.TP +\fB%id\fR +print the identifier of the current object. +.TP +\fB%v[\fIattr\fB] +\fRprint the value(s) of attribute ^\fIattr\fR on the current object. +If there is no ^\fIattr\fR on the current object, nothing is printed. +.TP +\fB%v[\fIpath\fB]\fR +\fRsame as the above, only follow the given attribute \fIpath\fR to +get the value(s). A \fIpath\fR is a sequence of attribute names +separated by periods, such as \fBfoo.bar.baz\fR. +.TP +\fB%v[*]\fR +\fRprint all values of all attributes on the current object. +.TP +\fB%o[args]\fR +\fRsame as \fB%v\fR, except that if the value is an identifier, it is +printed using the appropriate object trace format. +.TP +\fB%av[args]\fR +\fRsame as \fB%v\fR, except the printed value is preceeded with "\fB^attr +\fR" to indicate the attribute name. +.TP +\fB%ao[args]\fR +\fRa combination of the above two. +.TP +\fB%ifdef[\fIpattern\fB]\fR +\fRprint the given \fIpattern\fR if and only if all escape sequences +inside it are "meaningful" or "well-defined." For example, +the format string \fB%ifdef[foo has value: %v[foo]]\fR will print +nothing if there is no \fB^foo\fR on the current object. +.TP +\fB%nl\fR +print a newline +.TP +\fB%%\fR +\fRprint a percent sign +.TP +\fB%[\fR +print a left bracket +.TP +\fB%]\fR +print a right bracket + +.SH EXAMPLES +In the following examples, the phrase "the command prints X" is simply +an abbreviation for the more accurate phrase "the command defines a +trace format string which when used for printing will print X". +.PP +These commands are equivalent to the default settings for stack traces: +.DS +\fBformat-watch -stack -add s {%right[6,%dc]: %rsd[ ]==>S: %cs} +format-watch -stack -add o {%right[6,%dc]: %rsd[ ] O: %co}\fR +.DE +.PP +The above format strings print the decision cycle number right +justified in a field 6 characters wide. After that, a colon and +space are printed. Then, three spaces are printed as many times as +the subgoal is deep. Finally, a few more characters are printed +to indicate the item type and then the item itself is printed. +.PP +The following commands are equivalent to the default settings for +object traces: +.DS +\fBformat-watch -object -add * {%id %ifdef[(%v[name])]} +format-watch -object -add s {%id %ifdef[(%v[attribute] %v[impasse])]} +format-watch -object -add o evaluate-object {%id (evaluate-object %o[object])}\fR +.DE +.PP +The first command prints an identifier followed by its name in +parentheses (if a name is defined) for all objects. This will +hold unless overridden by more specific applicability conditions. +This first format might print something like: \fBO37 (my-operator-name)\fR. +The last two commands define (overriding) formats for states and +operators. The second command, for states, prints the state identifier +followed, in parentheses, by its \fB^attribute\fR and \fB^impasse\fR +attributes, if they are defined. For example, this might print +\fBG5 (operator no-change)\fR. Finally, the third command handles +\fBevaluate-object\fR operators in the \fBselection\fR space. These +operators will be printed as an id followed, in parentheses, by +the string "evaluate-object " and the printed representation of the +object being printed. +.PP +The following stack trace format causes both the current state +and current operator to be printed whenever an operator is selected. +(There is a linefeed in the middle of the format string.) +.DS +\fBformat-watch -stack -add o {%right[6,%dc]: %rsd[ ] S: %cs + %rsd[ ] O: %co}\fR +.DE +.PP +The above format is useful for watching the effects of operator +applications. + +.SH SEE ALSO + +\fBwatch\fR, \fBprint\fR diff --git a/soar-8.5.2/doc/man/gds_print.n b/soar-8.5.2/doc/man/gds_print.n new file mode 100644 index 0000000..354cdbe --- /dev/null +++ b/soar-8.5.2/doc/man/gds_print.n @@ -0,0 +1,20 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS gds_print soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +gds_print \- Examine the goal dependency set. +.SH SYNOPSIS +\fBgds_print\fR +.BE + +.SH DESCRIPTION +.PP +\fRgds_print\fI is a debugging command for examing the GDS when necessary. +It is horribly +inefficient and should not generally be used except when something +is going wrong and you want to take a peak at the Goal Dependency Set. + diff --git a/soar-8.5.2/doc/man/help.n b/soar-8.5.2/doc/man/help.n new file mode 100644 index 0000000..8e03b31 --- /dev/null +++ b/soar-8.5.2/doc/man/help.n @@ -0,0 +1,68 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS help soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +help \- Print man pages for Soar commands +.SH SYNOPSIS +\fBhelp\fR [\fB-all\fR | \fIcommandname\fR [\fB-usage\fR]] +.BE + +.SH DESCRIPTION +.PP +This command prints the formatted manual page for the given +\fIcommandname\fR. Soar's help facility is able to do command +completion, so as long as a unique substring of the commandname +is specified, Soar will find and display the help page. +.PP +Under the TSI (Tcl-Soar Interface, a graphical interface to Soar), +the \fBhelp\fR will pop up a separate window to display the text. +.PP +Under Unix with no TSI running, the \fBhelp\fR command attempts to +locate a pager program to +use to display help pages page-by-page since some are longer than a +typical screen. The command first examines the environment +variable PAGER to see if the user has defined a preference there. +If that is not present, the help system checks to see if one +of the commonly used pagers "less", "more", or "page" is +available (in that order). If no pager is available, then +an error message is given. If no pagers exist on your system, +then you can set the environment variable PAGER to "cat" and +the help pages will simply be cat'ed to the screen. Since +some pages are long, this will make it difficult to read an +entire page. + +.SH OPTIONS +.TP +\fB-all\fR +List all commands for which help is available +.TP +\fB-usage\fR +List only the SYNOPSIS section of the man page. This includes +the abbreviated syntax for the command. -usage may not work properly +on some windows and mac systems. + +.SH FILES +.PP +The nroff sources for the manual pages are stored in the +subdirectory .../doc/man. These files are used to +generate the "cat" and "HTML" versions which are stored +in .../doc/cat and .../doc/html, respectively. + +.SH ENVIRONMENT +.TP +\fBPAGER\fR + +This variable contains the user's preferred paging program +which shows text page by page rather than spewing all text at once +to standard output. Typical pagers are \fBmore\fR, \fBless\fR, +and \fBpage\fR. + +.SH WARNINGS + +Some pages, such as \fBless\fR clear the screen upon exit, removing +the help page from view. If you wish to retain the help page, use +a pager such as \fBmore\fR. diff --git a/soar-8.5.2/doc/man/indifferent-selection.n b/soar-8.5.2/doc/man/indifferent-selection.n new file mode 100644 index 0000000..7439bdc --- /dev/null +++ b/soar-8.5.2/doc/man/indifferent-selection.n @@ -0,0 +1,49 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS indifferent-selection soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +indifferent-selection \- Control indifferent preference arbitration +.SH SYNOPSIS +\fBindifferent-selection \fR[\fB-first\fR | \fB-last\fR | \fB-ask\fR | \fB-random\fR] +.BE + +.SH DESCRIPTION +.PP +This command controls indifferent preference arbitration. When +an indifferent preference tie is created among two or more items, +then the "indifferent-selection" parameter is used by the Soar decision +procedure to control the selection of one item to resolve the tie +and avoid an impasse. +.PP +If no option is given, this command prints the current setting of +the "indifferent-selection" parameter. If an option is given, it is +used to guide the resolution of indifferent preference ties. At +startup, the default setting of the "indifferent-selection" parameter is +\fB-random\fR. + +.SH OPTIONS +If given, the option must match one of the following: +.TP +\fB-first\fR +Choose the first object found (deterministically) +.TP +\fB-last\fR +Choose the last object found (deterministically) +.TP +\fB-ask\fR +Ask the user to choose one of the items +.TP +\fB-random\fR +Choose an object randomly. This is the default setting. +.PP +.SH WARNINGS + +\fB\-ask\fR currently only works under Unix, when Soar is run from +the console window (not the TSI). This is because indifferent-selection +is handled deep in the kernel, and the kernel has no knowledge of +Tcl, and therefore no information on how to read data from anywhere +except stdin. diff --git a/soar-8.5.2/doc/man/init-soar.n b/soar-8.5.2/doc/man/init-soar.n new file mode 100644 index 0000000..4fa7078 --- /dev/null +++ b/soar-8.5.2/doc/man/init-soar.n @@ -0,0 +1,18 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS init-soar soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +init-soar \- Initialize Soar +.SH SYNOPSIS +\fBinit-soar\fR +.BE + +.SH DESCRIPTION +.PP +This command initializes or re-initializes Soar. Initialization +removes all elements from working memory, wipes out the goal stack, +and resets all statistics. It does \fBnot\fR excise chunks. diff --git a/soar-8.5.2/doc/man/input-period.n b/soar-8.5.2/doc/man/input-period.n new file mode 100644 index 0000000..0274087 --- /dev/null +++ b/soar-8.5.2/doc/man/input-period.n @@ -0,0 +1,32 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS input-period soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +input-period \- Set or list the input period +.SH SYNOPSIS +\fBinput-period \fR[\fIperiod\fR] +.BE + +.SH DESCRIPTION +.PP +This command is obsolete for Soar8. In Soar8, input is done +at the start of every decision cycle. +.PP +This command controls the rate of input to the Soar agent. +If \fIperiod\fR is not specified, this command prints the current +input period. If \fIperiod\fR is specified, it must be a non-negative +integer and is used to reset the input period. A \fIperiod\fR of +0 sets input to occur every elaboration cycle. +A positive value for \fIperiod\fR sets Soar +to accept input only every nth \fIperiod\fR decision cycles. +The default initial setting of the "input-period" +parameter is 0. + +.SH EXAMPLES +.TP +\fBinput-period 5\fR +Input is accepted only every 5th decision cycle by the Soar agent. diff --git a/soar-8.5.2/doc/man/internal-symbols.n b/soar-8.5.2/doc/man/internal-symbols.n new file mode 100644 index 0000000..e2e56d9 --- /dev/null +++ b/soar-8.5.2/doc/man/internal-symbols.n @@ -0,0 +1,18 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS internal-symbols soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +internal-symbols \- Print contents of the Soar symbol table +.SH SYNOPSIS +\fBinternal-symbols\fR +.BE + +.SH DESCRIPTION +.PP +This command prints information about the Soar symbol table. Such +information is typically only useful for users attempting to debug +Soar by locating memory leaks. diff --git a/soar-8.5.2/doc/man/io.n b/soar-8.5.2/doc/man/io.n new file mode 100644 index 0000000..71e8dfb --- /dev/null +++ b/soar-8.5.2/doc/man/io.n @@ -0,0 +1,43 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS io soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +io \- Manage attachment of scripts to Soar I/O +.SH SYNOPSIS +\fBio\fR \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command manages the attachment of scripts to Soar I/O. +Soar has an event defined for input and another for output. +Scripts can be attached to these Soar events so that they are +invoked every time the Soar event occurs. +These scripts can later be removed using the \fBio\fR command. +The status of attachments can be listed also. If a new +attachment is created, its identifier is returned as the result +of this command. +.PP +The specified \fIaction\fR must have one of the following forms: +.TP +\fB\-add\fR [\fB-input\fR | \fB-output\fR] \fIscript [id]\fR +Add the \fIscript\fR to the list of scripts to be invoked when the +\fB-input\fR or \fBoutput\fR event occurs in the Soar kernel. +If the \fIid\fR is given, it is used to name the attachment. +If no \fIid\fR is given, then a unique id is generated and returned. +The id is necessary if a user ever wants to delete an action. +.TP +\fB\-delete\fR [\fB-input\fR | \fB-output\fR] \fIid\fR +Remove script attachment named \fIid\fR. +.TP +\fB\-list\fR [\fB-input\fR | \fB-output\fR] +List all attachments of scripts to Soar input or output. + +.SH EXAMPLES +.PP +A detailed example of using Soar I/O in Tcl is given in the +file \fBdemos/soar-io-using-tcl.tcl\fR. diff --git a/soar-8.5.2/doc/man/learn.n b/soar-8.5.2/doc/man/learn.n new file mode 100644 index 0000000..e9d4af1 --- /dev/null +++ b/soar-8.5.2/doc/man/learn.n @@ -0,0 +1,55 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS learn soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +learn \- Control the learning of productions +.SH SYNOPSIS +\fBlearn\fR [\fI-on\fR | \fI-off\fR | \fI-except\fR | \fI-only\fR | \fI-list\fR | \fI-all-levels\fR | \fI-bottom-up\fR] +.BE + +.SH DESCRIPTION +.PP +This command is used to control the learning (or "chunking") of productions. +With no arguments, this command prints out the current learning +environment status. The \fBwatch\fR command can be used to +provide various levels of detail when productions are learned. + +Learning is on by default. + +.SH OPTIONS + +Any \fIoption\fRs given must match one of the following keywords: +.TP +\fB-on\fR +turn learning on +.TP +\fB-off\fR +turn all learning off +.TP +\fB-except\fR +learning is on, except as specified by RHS \fBdont-learn\fR actions +.TP +\fb-only\fR +learning is off, except as specified by RHS \fBforce-learn\fR actions +.TP +\fb-list\fR +lists the force-learn and dont-learn states registered by the RHS actions + +.TP +\fB-all-levels\fR +when learning is on, this allows learning whenever +a subgoal returns a result (in contrast to bottom-up learning) +.TP +\fB-bottom-up\fR +when learning is on, this allows learning at only +the lowest level; i.e., build chunks only for subgoals that have +not yet had any subgoals with chunks built. + + + +.SH SEE ALSO +\fBwatch\fR, \fBexplain-backtraces\fR, \fBsave_backtraces\fR diff --git a/soar-8.5.2/doc/man/log.n b/soar-8.5.2/doc/man/log.n new file mode 100644 index 0000000..97f181c --- /dev/null +++ b/soar-8.5.2/doc/man/log.n @@ -0,0 +1,51 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS log soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +log \- Log a Soar agent session +.SH SYNOPSIS +\fBlog\fR \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command records the prompts, commands, printing, and command +results that are printed to stdout for a given agent. The +\fIaction\fR must be one of the following: +.TP +\fB-new\fR \fIpathname\fR +A log file named \fIpathname\fR is created and logging is initiated. +.TP +\fB-existing\fR \fIpathname\fR +An existing log file named \fIpathname\fR is opened and logging is +added to the end of the file. +.TP +\fB-add\fR \fIstring\fR +Add the given \fIstring\fR to the open log file +.TP +\fB-query\fR +Returns \fBopen\fR if logging is active or \fBclosed\fR if +logging is not active. +.TP +\fB-off\fR +Close the open log file. + +.SH EXAMPLES +This initiates logging and places the record in foo.log: +.DS +\fBlog -new foo.log\fR +.DE +.PP +This appends log data to an existing foo.log file: +.DS +\fBlog -existing foo.log\fR +.DE +.PP +This terminates logging and closes the open log file: +.DS +\fBlog -off\fR +.DE diff --git a/soar-8.5.2/doc/man/man.macros b/soar-8.5.2/doc/man/man.macros new file mode 100644 index 0000000..3fd881f --- /dev/null +++ b/soar-8.5.2/doc/man/man.macros @@ -0,0 +1,183 @@ +.\" The definitions below are for supplemental macros used in Tcl/Tk +.\" manual entries. +.\" +.\" .HS name section [date [version]] +.\" Replacement for .TH in other man pages. See below for valid +.\" section names. +.\" +.\" .AP type name in/out [indent] +.\" Start paragraph describing an argument to a library procedure. +.\" type is type of argument (int, etc.), in/out is either "in", "out", +.\" or "in/out" to describe whether procedure reads or modifies arg, +.\" and indent is equivalent to second arg of .IP (shouldn't ever be +.\" needed; use .AS below instead) +.\" +.\" .AS [type [name]] +.\" Give maximum sizes of arguments for setting tab stops. Type and +.\" name are examples of largest possible arguments that will be passed +.\" to .AP later. If args are omitted, default tab stops are used. +.\" +.\" .BS +.\" Start box enclosure. From here until next .BE, everything will be +.\" enclosed in one large box. +.\" +.\" .BE +.\" End of box enclosure. +.\" +.\" .VS +.\" Begin vertical sidebar, for use in marking newly-changed parts +.\" of man pages. +.\" +.\" .VE +.\" End of vertical sidebar. +.\" +.\" .DS +.\" Begin an indented unfilled display. +.\" +.\" .DE +.\" End of indented unfilled display. +.\" +'\" # Heading for Tcl/Tk man pages +.de HS +.ds ^3 \\0 +.if !"\\$3"" .ds ^3 \\$3 +.if '\\$2'cmds' .TH \\$1 1 \\*(^3 \\$4 +.if '\\$2'lib' .TH \\$1 3 \\*(^3 \\$4 +.if '\\$2'tcl' .TH \\$1 n \\*(^3 Tcl "Tcl Built-In Commands" +.if '\\$2'tk' .TH \\$1 n \\*(^3 Tk "Tk Commands" +.if '\\$2'soar' .TH \\$1 n \\*(^3 Soar "Soar Commands" +.if '\\$2'tclc' .TH \\$1 3 \\*(^3 Tcl "Tcl Library Procedures" +.if '\\$2'tkc' .TH \\$1 3 \\*(^3 Tk "Tk Library Procedures" +.if '\\$2'tclcmds' .TH \\$1 1 \\*(^3 Tk "Tcl Applications" +.if '\\$2'tkcmds' .TH \\$1 1 \\*(^3 Tk "Tk Applications" +.if t .wh -1.3i ^B +.nr ^l \\n(.l +.ad b +.. +'\" # Start an argument description +.de AP +.ie !"\\$4"" .TP \\$4 +.el \{\ +. ie !"\\$2"" .TP \\n()Cu +. el .TP 15 +.\} +.ie !"\\$3"" \{\ +.ta \\n()Au \\n()Bu +\&\\$1 \\fI\\$2\\fP (\\$3) +.\".b +.\} +.el \{\ +.br +.ie !"\\$2"" \{\ +\&\\$1 \\fI\\$2\\fP +.\} +.el \{\ +\&\\fI\\$1\\fP +.\} +.\} +.. +'\" # define tabbing values for .AP +.de AS +.nr )A 10n +.if !"\\$1"" .nr )A \\w'\\$1'u+3n +.nr )B \\n()Au+15n +.\" +.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n +.nr )C \\n()Bu+\\w'(in/out)'u+2n +.. +'\" # BS - start boxed text +'\" # ^y = starting y location +'\" # ^b = 1 +.de BS +.br +.mk ^y +.nr ^b 1u +.if n .nf +.if n .ti 0 +.if n \l'\\n(.lu\(ul' +.if n .fi +.. +'\" # BE - end boxed text (draw box now) +.de BE +.nf +.ti 0 +.mk ^t +.ie n \l'\\n(^lu\(ul' +.el \{\ +.\" Draw four-sided box normally, but don't draw top of +.\" box if the box started on an earlier page. +.ie !\\n(^b-1 \{\ +\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.el \}\ +\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' +.\} +.\} +.fi +.br +.nr ^b 0 +.. +'\" # VS - start vertical sidebar +'\" # ^Y = starting y location +'\" # ^v = 1 (for troff; for nroff this doesn't matter) +.de VS +.mk ^Y +.ie n 'mc \s12\(br\s0 +.el .nr ^v 1u +.. +'\" # VE - end of vertical sidebar +.de VE +.ie n 'mc +.el \{\ +.ev 2 +.nf +.ti 0 +.mk ^t +\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' +.sp -1 +.fi +.ev +.\} +.nr ^v 0 +.. +'\" # Special macro to handle page bottom: finish off current +'\" # box/sidebar if in box/sidebar mode, then invoked standard +'\" # page bottom macro. +.de ^B +.ev 2 +'ti 0 +'nf +.mk ^t +.if \\n(^b \{\ +.\" Draw three-sided box if this is the box's first page, +.\" draw two sides but no top otherwise. +.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c +.\} +.if \\n(^v \{\ +.nr ^x \\n(^tu+1v-\\n(^Yu +\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c +.\} +.bp +'fi +.ev +.if \\n(^b \{\ +.mk ^y +.nr ^b 2 +.\} +.if \\n(^v \{\ +.mk ^Y +.\} +.. +'\" # DS - begin display +.de DS +.RS +.nf +.sp +.. +'\" # DE - end display +.de DE +.fi +.RE +.sp .5 +.. diff --git a/soar-8.5.2/doc/man/matches.n b/soar-8.5.2/doc/man/matches.n new file mode 100644 index 0000000..8ca86f2 --- /dev/null +++ b/soar-8.5.2/doc/man/matches.n @@ -0,0 +1,97 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS matches soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +matches \- List production match information +.SH SYNOPSIS +\fBmatches\fR \fIproduction-name\fR [\fB-count\fR | \fB-timetags\fR | \fB-wmes\fR | \fB0\fR | \fB1\fR | \fB2\fR] +.br +\fBmatches \fR[\fB-assertions\fR | \fB-retractions\fR] [\fB-names\fR | +\fB-timetags\fR | \fB-wmes\fR | \fB0\fR | \fB1\fR | \fB2\fR] +.BE + +.SH DESCRIPTION +.PP +This command prints partial match information for a selected +production. If issued at the end of the Decision Phase, it also +prints the current set of productions that +are about to fire or retract in the next preference phase. This +information is useful for determining what changes to working memory +are necessary in order to achieve a match of the left-hand sides +of productions. +.PP +If no production name is given, then it is assumed that the user +desires information about the match set, including both assertions +and retractions. + +.SH OPTIONS +Normally both assertions and retractions are printed by the \fBmatches\fR +command. This can be restricted using one of the following options: +.TP +\fB-assertions\fR +List only those productions about to fire +.TP +\fB-retractions\fR +List only those productions about to retract +.PP +The optional detail specifies the kind of information desired and +must be one of the following (the \fB0\fR option is the default): +.TP +\fB-count\fR or \fB-names\fR or \fB0\fR +Print just the partial match counts. If the match set is being +printed, then print just the production names. +.TP +\fB-timetags\fR or \fB1\fR +Print the same information as the \fB-count\fR option plus +the timetags of wmes at the the first failing condition +.TP +\fB-wmes\fR or \fB2\fR +Print the same information as the \fB-timetags\fR option except +print the full wmes rather than just their timetags + +.SH EXAMPLES +This example prints the productions which are about to fire +and the wmes that match the productions on their left-hand sides: +.DS +\fBmatches -assertions -wmes\fR +.DE +.PP +This example prints the wme timetags for a single production. This +example takes advantage of the unique prefix abbreviation feature of +switches. +.DS +\fBmatches -t my*first*production +.DE +.SH WARNINGS +.PP +In Soar 8, the Decision Phase occurs in the middle of the Decision Cycle, +followed by the Apply Phase. Therefore, at the end of the Decision +Cycle, productions will have already fired and the "matches" command +will not be very helpful. To examine the match information in +immediately after the Decision Phase in Soar 8, users can implement +either of the following callbacks: +.DS +\fBmonitor -add {matches -wmes} after-decision-phase-cycle\fR +.DE +.DS +\fBmonitor -add {stop-soar -self} after-decision-phase-cycle +.DE +.PP +The first example can use any options to the \fBmatches\fR command, +whatever the user finds most helpful. +The second option, which stops Soar at the end of the Decision Phase, +offers the most flexibility for debugging. It is recommended that +users issue this callback for all agents, so they don't get out +of synch when running. Once the productions have been debugged, +the monitors can be deleted. + +.SH SEE ALSO +\fBmonitor\fR + + + + diff --git a/soar-8.5.2/doc/man/max-chunks.n b/soar-8.5.2/doc/man/max-chunks.n new file mode 100644 index 0000000..3a7edb4 --- /dev/null +++ b/soar-8.5.2/doc/man/max-chunks.n @@ -0,0 +1,64 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS max-chunks soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +max-chunks \- Set or list the maximum chunk count +.SH SYNOPSIS +\fBmax-chunks \fR[\fIcount\fR] +.BE + +.SH DESCRIPTION +.PP +This command sets and prints the maximum number of chunks +that can be created in a single decision cycle. If \fIcount\fR is +not given, this command +prints the maximum number of chunks that can be created. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the number of chunks allowed. +.PP +The "max-chunks" parameter controls the maximum number of chunks +that can be created in a single decision cycle. After this limit +has been reached in a decision cycle, Soar proceeds to decision +phase even if quiescence hasn't really been reached yet. The +default initial setting of the "max-chunks" parameter is 50. +.PP +In Soar8, chunks may be built during both the Propose Phase or +the Apply Phase. If Soar8 builds more than the max-chunks limit in either +of these phases, Soar8 proceeds to the next phase (either Decision +or Output) even if quiescence has not been reached. +.PP +If max-chunks are reached, and Soar moves on to the next phase, +a warning message is printed. +.SH EXAMPLES +.PP +The command issued with no arguments, returns the maximum chunk count: +.DS +\fBmax-chunks\fR +.DE +.PP +The next example makes use of Tcl command abbreviation while setting +the max-chunks to 100: +.DS +\fBmax-c 100\fR +.DE + + +.SH VARIABLE +.PP +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_chunks" (with underscores) +that can be used to set the chunk limit through the the Tcl +\fIset\fR command. If \fIcount\fR is not given, \fB'set max_chunks'\fR +prints the maximum number of chunks that can be created. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the number of chunks allowed. + +.SH SEE ALSO +\fBvariables\fR + + + diff --git a/soar-8.5.2/doc/man/max-elaborations.n b/soar-8.5.2/doc/man/max-elaborations.n new file mode 100644 index 0000000..d21badb --- /dev/null +++ b/soar-8.5.2/doc/man/max-elaborations.n @@ -0,0 +1,59 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS max-elaborations soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +max-elaborations \- Set or list the maximum elaborations allowed +.SH SYNOPSIS +\fBmax-elaborations \fR[\fIcount\fR] +.BE + +.SH DESCRIPTION +.PP +This command sets and prints the maximum number of elaboration +cycles allowed. If \fIcount\fR is not given, this command +prints the current number of elaboration cycles allowed. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the number of allowed elaboration cycles. +.PP +The "max-elaborations" parameter controls the maximum number of +elaborations allowed in a single decision cycle. After this limit +has been reached, Soar moves on to the next phase and +a warning message is printed. The +default initial setting of the "max-elaborations" parameter is 100. +.PP +In Soar8, max-elaborations is checked during both the Propose Phase and +the Apply Phase. If Soar8 runs more than the max-elaborations limit in either +of these phases, Soar8 proceeds to the next phase (either Decision +or Output) even if quiescence has not been reached. +.PP + +.SH EXAMPLES +.PP +The command issued with no arguments, returns the max elaborations allowed: +.DS +\fBmax-elaborations\fR +.DE +.PP +The next example makes use of Tcl command abbreviation while setting +the maximum value to 50: +.DS +\fBmax-e 50\fR +.DE + +.SH VARIABLE +.PP +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_elaborations" (with underscores) +that can be used to set the limit through the the Tcl \fIset\fR +command. If \fIcount\fR is not given, \fB'set max_elaborations'\fR +prints the current number of elaboration cycles allowed. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the number of allowed elaboration cycles. + + +.SH SEE ALSO +\fBvariables\fR diff --git a/soar-8.5.2/doc/man/max-nil-output-cycles.n b/soar-8.5.2/doc/man/max-nil-output-cycles.n new file mode 100644 index 0000000..5b6c3ff --- /dev/null +++ b/soar-8.5.2/doc/man/max-nil-output-cycles.n @@ -0,0 +1,55 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS max-nil-output-cycles soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +max-nil-output-cycles \- Set or list the maximum number of empty output cycles allowed when doing run-til-output-generated +.SH SYNOPSIS +\fBmax-nil-output-cycles \fR[\fIcount\fR] +.BE + +.SH DESCRIPTION +.PP +This command sets and prints the maximum number of nil output cycles +(output cycles that put nothing on the output link) allowed when +running using run-til-output-generated (\fIrun out\fR). +If \fIcount\fR is not given, this command +prints the current number of nil-output-cycles allowed. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the maximum number of allowed nil output cycles. +.PP +The "max-nil-output-cycles" parameter controls the maximum number of +output cycles that generate no output allowed when a \fI run out\fR +command is issued. After this limit has been reached, Soar stops. +The default initial setting of the "max-nil-output-cycles" parameter is 15. +.PP + +.SH EXAMPLES +.PP +The command issued with no arguments, returns the max empty output cycles allowed: +.DS +\fBmax-nil-output-cycles\fR +.DE +.PP +The next example makes use of Tcl command abbreviation while setting +the maximum value to 25: +.DS +\fBmax-nil 25\fR +.DE + +.SH VARIABLE +.PP +Note that the commandname uses dashes to separate the words. There +is also a Soar variable "max_nil_output_cycles" (with underscores) +that can be used to set the limit through the the Tcl \fIset\fR +command. If \fIcount\fR is not given, \fB'set max_nil_output_cycles\fR +prints the current number of consecutive nil output cycles allowed. +If \fIcount\fR is given, it must be a positive integer and is used +to reset the number of allowed nil output cycles. + + +.SH SEE ALSO +\fBvariables\fR diff --git a/soar-8.5.2/doc/man/memories.n b/soar-8.5.2/doc/man/memories.n new file mode 100644 index 0000000..3b312a9 --- /dev/null +++ b/soar-8.5.2/doc/man/memories.n @@ -0,0 +1,43 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS memories soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +memories \- Print partial match memory usage +.SH SYNOPSIS +\fBmemories\fR [\fIproduction-name\fR | \fIcount\fR | \fB-chunk\fR | \fB-user\fR | \fB-default\fR | \fB-justification\fR] +.BE + +.SH DESCRIPTION +.PP +This command prints information about memory use, in tokens, of +partial matches of productions. With no options, memory +use of all productions is printed. Other options indicate +a subset of the productions. + +.SH OPTIONS + +If given, an option must match one of the following forms: +.TP +\fIproduction-name\fR +print memory usage of the production named \fIproduction-name\fR +.TP +\fIcount\fR +for all specified groups (chunk, default, user, and/or justification) +print usage information on only \fIcount\fR of each. +.TP +\fB-chunk\fR +print memory usage of chunks +.TP +\fB-user\fR +print memory usage of user productions +.TP +\fB-default\fR +print memory usage of the default productions +.TP +\fB-justification\fR +print memory usage of justifications + diff --git a/soar-8.5.2/doc/man/monitor.n b/soar-8.5.2/doc/man/monitor.n new file mode 100644 index 0000000..24d59d4 --- /dev/null +++ b/soar-8.5.2/doc/man/monitor.n @@ -0,0 +1,240 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS monitor soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +monitor \- Manage attachment of scripts to Soar events +.SH SYNOPSIS +\fBmonitor\fR \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command manages the attachment of scripts to Soar events. +Soar events are important events that occur in Soar as an agent +is being processed. Scripts can be attached to these Soar +events so that they are invoked every time the Soar event occurs. +These scripts can also be removed using the \fBmonitor\fR command. +The status of attachments can be listed and tested. If a new +attachment is created, its identifier is returned as the result +of this command. The identifier is used when deleting a +script from an event. +.PP +The specified \fIaction\fR must have one of the following forms: +.TP +\fB\-add\fR \fIsoar-event script [id]\fR +Add the \fIscript\fR to the list of scripts to be invoked when the +\fIsoar-event\fR occurs in the Soar kernel. See below for a list +of valid Soar event names. If the \fIid\fR is given, it +is used to name the attachment. If no \fIid\fR is given, then +a unique id is generated and returned. +.TP +\fB\-delete\fR \fIsoar-event [id]\fR +Remove scripts attached to \fIsoar-event\fR. The \fIsoar-event\fR +must match a valid Soar event name +(see below). If \fIid\fR is given after a \fIsoar-event\fR, then +only that particular attachment is removed. Otherwise, all +attachments under \fIsoar-event\fR are removed. +.TP +\fB\-list\fR +List all attachments of scripts to Soar events +.TP +\fB\-test\fR +Test the script attachment process by attaching a print message to +every Soar event. +.TP +\fB\-clear\fR +Remove \fIall\fR attached scripts. +.PP +.SH EXAMPLES +This command creates an attachment which prints a message +after every Soar decision cycle: +.DS +\fBmonitor -add after-decision-cycle {puts "Finished DC!"} \fR +.DE +.PP +This example creates an attachment which calls the Tcl procedure +"DoSomething" (presumably user-defined) after every production firing: +.DS +\fBmonitor -add firing DoSomething\fR +.DE +.PP +This example creates an attachment which processes pending X events +after every decision cycle. This is needed in long-running Soar +agents so that GUIs do not appear frozen: +.DS +\fBmonitor -add after-decision-cycle update\fR +.DE +.PP +This example adds an attachment which ticks a simulator after +each agent has completed a cycle in the Soar scheduler. Note +that this example command is executed in the global agent's +interpreter so that the simulator is ticked only once per +schedule cycle. The "TickSimulator" command would be defined +by the user. +.DS +\fBmonitor -add after-schedule-cycle TickSimulator\fR +.DE +.PP +This example adds an attachment that could be used to inform the +Soar development tool SDE that an agent has been selected for +scheduling. SDE expects certain strings in Soar output and uses +them to control some SDE operations. +.DS +\fBmonitor -add before-schedule-cycle {puts "\nSelecting agent $soar_agent_name"}\fR +.DE +.PP +This example removes the single attachment "m1" which associates a +script with the Soar event after-init-agent: +.DS +\fBmonitor -delete after-init-agent m1\fR +.DE +.PP +This example removes all script attachments to the Soar event +before-preference-phase-cycle: +.DS +\fBmonitor -delete before-preference-phase-cycle\fR +.DE +.PP +This example removes all script attachments that have been added with +the monitor command: +.DS +\fBmonitor -clear\fR +.DE +.PP +.SH SOAR EVENTS + +This command utilizes the Soar callback system which can associate +TCL or C functions with Soar events. The permissable Soar event names +are: +.TP +\fBsystem-termination\fR + +The Soar system is exiting. +.TP +\fBafter-init-agent\fR + +An agent has just been created and initialized. +.TP +\fBbefore-init-soar\fR + +The agent is about to be initialized. The \fBinit-soar\fR command +will generate this event. +.TP +\fBafter-init-soar\fR + +The agent has just been initialized. The \fBinit-soar\fR command +will generate this event. + +.TP +\fBafter-halt-soar\fR + +The agent has just been halted. +.TP +\fBbefore-schedule-cycle\fR + +This event is triggered by the \fBschedule\fR command. In the +global control agent, this event is triggered before each schedule +cycle starts. In other agents, this event is triggered during +the schedule cycle, just before the agent is run. +.TP +\fBafter-schedule-cycle\fR + +This event is triggered by the \fBschedule\fR command. In the +global control agent, this event is triggered just after each schedule +cycle ends. In other agents, this event is triggered during +the schedule cycle, just after the agent is run. +.TP +\fBbefore-decision-cycle\fR + +A decision cycle is just about to start. +.TP +\fBafter-decision-cycle\fR + +A decision cycle has just ended. +.TP +\fBbefore-input-phase\fR + +An input phase is just about to start. +.TP +\fBafter-input-phase\fR + +An input phase has just ended. +.TP +\fBbefore-preference-phase-cycle\fR + +A preference phase is just about to begin. +.TP +\fBafter-preference-phase-cycle\fR + +A preference phase has just ended. +.TP +\fBbefore-wm-phase-cycle\fR + +A working memory phase is just about to begin. +.TP +\fBafter-wm-phase-cycle\fR + +A working memory phase is just about to begin. +.TP +\fBbefore-output-phase\fR + +An output phase is just about to begin. +.TP +\fBafter-output-phase\fR + +An output phase has just ended. +.TP +\fBbefore-decision-phase-cycle\fR + +A decision phase is about to begin. +.TP +\fBafter-decision-phase-cycle\fR + +A decision phase has just ended. +.TP +\fBwm-changes\fR + +Changes to working memory have just completed. +.TP +\fBcreate-new-context\fR + +A new state has been created on the goal stack. +.TP +\fBpop-context-stack\fR + +A subgoal has finished. +.TP +\fBcreate-new-attribute-impasse\fR + +A new attribute impasse has occurred. +.TP +\fBremove-attribute-impasse\fR + +An attribute impasse has been removed. + +.TP +\fBproduction-just-added\fR + +A productions has just been added to the agent. + +.TP +\fBproduction-just-about-to-be-excised\fR + +A production is just about to be removed from the agent. +.TP +\fBfiring\fR + +A production instantiation has just fired. + +.TP +\fBretraction\fR + +A production instantiation is just about to retract. +.TP +\fBsystem-parameter-changed\fR + +A system parameter has just been changed. diff --git a/soar-8.5.2/doc/man/multi-attributes.n b/soar-8.5.2/doc/man/multi-attributes.n new file mode 100644 index 0000000..17fe6ea --- /dev/null +++ b/soar-8.5.2/doc/man/multi-attributes.n @@ -0,0 +1,33 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS multi-attributes soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +multi-attributes \- Declare a symbol to be multi-attributed +.SH SYNOPSIS +\fBmulti-attributes\fR [\fIsymbol\fR [\fIn\fR]] +.BE + +.SH DESCRIPTION +.PP +This command declares the given \fIsymbol\fR to be an attribute +which can take on multiple values. The optional \fIn\fR is an integer +(>1) indicating an upper limit on the number of expected values +that will appear for an attribute. If \fIn\fR is not specified, +the value 10 is used for each declared multi-attribute. More informed +values will tend to result in greater efficiency. + +.PP +This command is used \fIonly\fR to provide hints to the +production condition reorderer so it can produce better condition +orderings. Better orderings enable the Rete network to run faster. +This command has no effect on the actual contents of working memory +and most users needn't use this at all. + +.SH WARNING +.PP +Note that multi-attributes declarations must be made \fIbefore\fR +productions are loaded into production memory. \ No newline at end of file diff --git a/soar-8.5.2/doc/man/o-support-mode.n b/soar-8.5.2/doc/man/o-support-mode.n new file mode 100644 index 0000000..e3370bc --- /dev/null +++ b/soar-8.5.2/doc/man/o-support-mode.n @@ -0,0 +1,42 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS o-support-mode soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +o-support-mode \- Control O-support calculations +.SH SYNOPSIS +\fBo-support-mode\fR \fB0\fR|\fB1\fR|\fB2\fR +.BE + +.SH DESCRIPTION +.PP +This command controls the way o-support calculations are done +for the agent. The o-support calculation mode must be one of +the following choices: +.TP +\fB0\fR +Do o-support calculations the Soar 6 way +.TP +\fB1\fR +Do o-support calculations the Soar 6 way, but +print a warning message whenever a preference is created +that would get different support under Doug Pearson's proposal. +.TP +\fB2\fR +Do o-support calculations according to Doug Pearson's proposal. + +.SH VARIABLE +.PP +Note that the command name uses dashes to separate the words. There +is also a Soar command "o_support_mode" (with underscores) +that can be used to set the mode through the the Tcl \fIset\fR command. +If the mode is not specified, \fB'set o_support_mode'\fR +prints the current mode. If the mode is specified, it must have +a value of 0, 1 or 2 as above. + +.SH SEE ALSO +\fBvariables\fR + diff --git a/soar-8.5.2/doc/man/output-strings-destination.n b/soar-8.5.2/doc/man/output-strings-destination.n new file mode 100644 index 0000000..7f74910 --- /dev/null +++ b/soar-8.5.2/doc/man/output-strings-destination.n @@ -0,0 +1,112 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS output-strings-destination soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +output-strings-destination \- Specify destination of print actions +.SH SYNOPSIS +\fBoutput-strings-destination \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command redirects the printing of output strings. This is +useful for applications which need to change where printed results +are placed. Printed output is normally sent to standard output. +However, if a Graphical User Interface (GUI) is being used in +place of the command line interpreter, then printed output should +appear in the GUI. GUIs are composed of elements called "widget"s +and printed output would be directed to a "text widget", or procedure. +.PP +Printed output is normally sent to standard output which is an open file +descriptor in UNIX. Printed output can be sent to any other +open file descriptor as well, such as an open file or pipe. +It is also possible that the +user is not interested in an agent's printed +output. In that case, the printed output can be discarded -- which +results in faster processing for the agent as well. +.PP +Some Soar commands +return results and some print results. If the user wishes to +have printed results returned so that they can be saved for later +use, then this command can setup the agent to append the printed +output to the normal result. This capability is also useful when +sending Soar commands from remote Tcl/Tk interpreters. By appending +the printed results, all printed characters can be returned to +the remote interpreter rather than going to a screen. +.PP +The printing facility is implemented as a stack, so newly installed +print redirections are in force until popped off the stack. This is +done to allow easy transient redirection and the restoration of +prior printing contexts after completing a printing task. Hence, +there are two primary \fIaction\fRs, \fB-push\fR and \fB-pop\fR. +The \fB-pop\fR action takes no additional arguments as it serves +only to pop the print-redirection stack to re-establish the prior +printing context. The \fB-push\fR action takes the following +additional arguments: +.TP +\fB-append-to-result\fR +Instead of printing, append the output string to the result returned +by a command. This option is useful for getting all the output when the +command is invoked remotely. +.TP +\fB-channel\fR \fIopen-file-id\fR +Redirect prints to the open channel (file or pipe) denoted +by \fIopen-file-id\fR +.TP +\fB-discard\fR +Ignore prints (similar to redirecting to /dev/null in the Bourne +shell, sh) +.TP +\fB-procedure\fR \fIproc-name\fR +Redirect prints to the Tcl procedure named \fIproc-name\fR in the +current interpreter. Tk widgets are also procedures, so this action +sends output to widget procedures (or any other Tcl procedure). +.TP +\fB-text-widget\fR \fIwidget-name\fR [\fIinterp-name\fR] +Redirect prints to the text widget named \fIwidget-name\fR in the +current interpreter. If \fIinterp-name\fR is specified, then +prints are redirected to the text widget named \fIwidget-name\fR +in the interpreter named \fIinterp-name\fR. + +.SH EXAMPLES +This example redirects prints to the text widget ".text": +.DS +\fBoutput-strings-destination -push -text-widget .text\fR +.DE +.PP + +.PP +This example redirects prints to the text widget ".textual" in +the interpreter named \fBcontrol\fR: +.DS +\fBoutput-strings-destination -push -text-widget .textual control\fR +.DE +.PP +This example redirects prints to the open file "stdout": +.DS +\fBoutput-strings-destination -push -file-id stdout\fR +.DE +.PP +This example causes all printing to be supressed: +.DS +\fBoutput-strings-destination -push -discard\fR +.DE +.PP +This example removes the most recently added print destination: +.DS +\fBoutput-strings-destination -pop\fR +.DE + +.SH WARNINGS + +This command only affects the printing generated by Soar commands such +as \fBprint\fR and \fBecho\fR. It does not affect printing done +by the Tcl commands such as \fBputs\fR. + +.SH SEE ALSO +\fBecho\fR, \fBprint\fR, \fBlog\fR + diff --git a/soar-8.5.2/doc/man/popd.n b/soar-8.5.2/doc/man/popd.n new file mode 100644 index 0000000..103c72a --- /dev/null +++ b/soar-8.5.2/doc/man/popd.n @@ -0,0 +1,21 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS popd soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +popd \- Pop a directory off the directory stack +.SH SYNOPSIS +\fBpopd\fR +.BE + +.SH DESCRIPTION +.PP +This command pops a directory off of the directory +stack and cd's to it. See the \fBdirs\fR command for +an explanation of the directory stack. + +.SH SEE ALSO +\fBpushd\fR, \fBdirs\fR, \fBtopd\fR diff --git a/soar-8.5.2/doc/man/predefined-aliases.n b/soar-8.5.2/doc/man/predefined-aliases.n new file mode 100644 index 0000000..7f6e4e5 --- /dev/null +++ b/soar-8.5.2/doc/man/predefined-aliases.n @@ -0,0 +1,212 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS predefined-aliases soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +Soar predefined-aliases + +.SH DESCRIPTION +.PP +There are a number of command aliases that are provided by Soar. +These are used to provide short versions of built in commands +and to provide syntactic continuity with previous versions of +Soar. Soar provides a predefined set of aliases that will be +useful to most users. +.PP +These aliases are equivalent to an existing built in command +and (possibly) a set of switches for the command. Additional +arguments given after the alias are passed on to the built in +command. +.PP +The predefined aliases in $soar_library/soar.tcl are: +.RS +.TP +\fB?\fR +A short form of the \fBhelp\fR command. +.TP +\fBd\fR +A short form of the \fBrun 1 d\fR command. +.TP +\fBe\fR +A short form of the \fBrun 1 e\fR command. +.TP +\fBpf\fR +A short form of the \fBproduction-find\fR command. +.TP +\fBstep\fR +A short form of the \fBrun 1 d\fR command. This was added because the +TSI provides a "step" command, and it seemed silly to not allow the +same "command" when running Soar without the TSI. +.TP +\fBwmes\fR +Prints the contents of working memory. It is equivalent to +\fBprint -depth 0 -internal\fR, therefore an identifier, integer, or +wme pattern must be specified. (see "help print" for more info). +.PP +.RE +.PP +Additional aliases are defined in $soar_library/soar7.2km-aliases.tcl. +These aliases were derived by Frank Ritter using commonly used and +psychologically supported rules, computed to save users time and errors. +The rules are based on the keystroke model and designed to be learned by +a command name rule. + + + +Most of the aliases are generated with a rule: +.TP +If there are multiple words, use their first letters +(29 commands with some exceptions, the most common being +indifferent-selection:inds) +.TP +If there is a single long word (6 letters or more), use the +first two letters (8 commands, 0 exceptions) +.TP +If there is a short word, use the first letter +(14 commands with 6 exceptions, none common) +.PP +The predefined aliases are: +.PP +.TP +\fBa\fR +Equivalent to \fBalias\fR. +.TP +\fBaw\fR +Equivalent to \fBadd-wme\fR. +.TP +\fBcnf\fR +Equivalent to \fBchunk-name-format\fR. +.TP +\fBctf\fR +Equivalent to \fBcommand-to-file\fR. +.TP +\fBea\fR +Equivalent to \fBexcise -all\fR. +.TP +\fBeb\fR +Equivalent to \fBexplain-backtraces\fR. +.TP +\fBec\fR +Equivalent to \fBexcise -chunk\fR. +.TP +\fBet\fR +Equivalent to \fBexcise -task\fR. +.TP +\fBex\fR +Equivalent to \fBexcise\fR. +.TP +\fBfc\fR +Equivalent to \fBfiring-counts\fR. +.TP +\fBfw\fR +Equivalent to \fBformat-watch\fR. +.TP +\fBh\fR +Equivalent to \fBhelp\fR. +.TP +\fBha\fR +Equivalent to \fBhelp -all\fR. +.TP +\fBhelp-all\fR +Equivalent to \fBhelp -all\fR. +.TP +\fBinds\fR +Equivalent to \fBindifferent-selection\fR. +.TP +\fBip\fR +Equivalent to \fBinput-period\fR. +.TP +\fBis\fR +Equivalent to \fBinit-soar\fR. +.TP +\fBl\fR +Equivalent to \fBlearn\fR. +.TP +\fBm\fR +Equivalent to \fBmatches\fR. +.TP +\fBosd\fR +Equivalent to \fBoutput-string-destination\fR. +.TP +\fBp\fR +Equivalent to \fBprint\fR. +.TP +\fBpc\fR +Equivalent to \fBprint -chunks\fR. +.TP +\fBpf\fR +Equivalent to \fBproduction-find\fR. +.TP +\fBpr\fR +Equivalent to \fBpreferences\fR. +.TP +\fBps\fR +Equivalent to \fBprint -stack\fR. +.TP +\fBpw\fR +Equivalent to \fBpwatch\fR. +.TP +\fBr\fR +Equivalent to \fBrun\fR. +.TP +\fBrn\fR +Equivalent to \fBrete-net\fR. +.TP +\fBrw\fR +Equivalent to \fBremove-wme\fR. +.TP +\fBs\fR +Equivalent to \fBsource\fR. +.TP +\fBsn\fR +Equivalent to \fBsoarnews\fR. +.TP +\fBsoar-news\fR +Equivalent to \fBsoarnews\fR. +.TP +\fBss\fR +Equivalent to \fBstop-soar\fR. +.TP +\fBst\fR +Equivalent to \fBstats\fR. +.TP +\fBun\fR +Equivalent to \fBunalias\fR. +.TP +\fBw\fR +Equivalent to \fBwatch\fR. + + +.PP +See the file itself (soar7.2km-aliases.tcl in $soar_library) for +more detailed information. +.PP +.PP +.SH NOTES +.PP +Tcl and the TSI, when running in interactive mode, also support +command abbreviation: as long as a unique prefix of a command +is specified, it will be recognized and the matching command +will be executed. For example, "wat" is enough to completely +specify the "watch" command. + +.SH WARNINGS +Aliases should NEVER appear in files. They may be changed +or not loaded by other users, and will not be as clear as the +full command names. + + + + +.SH FILES +.PP +All alias definition files are in the Soar Tcl library directory. +The predefined aliases are included in the startup file +\fBsoar.tcl\fR and in \fBsoar7.2km-aliases.tcl\fR. The aliases are loaded in +a Soar interpreter automatically when it is created. + +.SH SEE ALSO +\fBalias\fR, \fBprint\fR diff --git a/soar-8.5.2/doc/man/preferences.n b/soar-8.5.2/doc/man/preferences.n new file mode 100644 index 0000000..449dae4 --- /dev/null +++ b/soar-8.5.2/doc/man/preferences.n @@ -0,0 +1,50 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS preferences soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +preferences \- Print slot preferences +.SH SYNOPSIS +\fBpreferences\fR [\fIid\fR] [[^]\fIattribute\fR] [\fI 0 | 1 | 2 | 3 \fR] + +\fBpreferences\fR [\fIid\fR] [[^]\fIattribute\fR] [\fI -none | -names | -timetags | -wmes \fR] +.BE + +.SH DESCRIPTION +.PP +This command prints all the preferences for the given slot (i.e., +object and attribute). The \fIid\fR and \fIattribute\fR indicate +the slot of interest. If they are not specified, they default to the +current state and the current operator. The '^' is optional when +specifying the attribute. The optional arguments indicates +the level of detail to print about each preference. + +.SH OPTIONS +The optional \fIdetail\fR must have one of the following values: +.TP +\fB-none\fR or \fB0\fR +Print just the preferences themselves +.TP +\fB-names\fR or \fB1\fR +Print the preferences and the names of the productions that +generated them +.TP +\fB-timetags\fR or \fB2\fR +Print the information for the \fB-names\fR option above plus +the timetags of the wmes matched by the indicated productions +.TP +\fB-wmes\fR or \fB3\fR +Print the information for the \fB-timetags\fR option above plus +the entire wme. +.PP +If no \fIdetail\fR is given, then the \fB-none\fR option is +used. +.SH EXAMPLES +This example prints the preferences on the \fBS1 operator\fR slot +and the production names which created the preferences: +.DS +\fBpreferences S1 operator -names\fR +.DE diff --git a/soar-8.5.2/doc/man/print.n b/soar-8.5.2/doc/man/print.n new file mode 100644 index 0000000..096641e --- /dev/null +++ b/soar-8.5.2/doc/man/print.n @@ -0,0 +1,139 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS print soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +print \- Print a Soar item from production memory or working memory +.SH SYNOPSIS +\fBprint\fR -stack [ \fB-state\fR | \fB-operator\fR ]* +.br +\fBprint\fR [\fB-depth\fR \fIn\fR] [\fB-internal\fR] {\fI identifier | integer | pattern\fR} +.br +\fBprint\fR [\fB-internal\fR] [\fB-name|-full\fR] {\fI prodname | -all | -chunks | -defaults | -justifications | -user\fR} +.BE + +.SH DESCRIPTION +.PP +The \fBprint\fR command is used to print items from production +memory or working memory. It can take several kinds of arguments. When +printing items from working memory, the Soar objects are printed unless the +\fB-internal\fR flag is used, in which case the wmes themselves are printed. + The \fIitem\fRs to be printed may be one of the following: +.TP +\fIproduction-name\fR +print the production named \fIproduction-name\fR +.TP +\fI-all\fR +print the names of all productions currently loaded +.TP +\fI-chunks\fR +print the names of all chunks currently loaded +.TP +\fI-defaults\fR +print the names of all default productions currently loaded +.TP +\fI-justifications\fR +print the names of all justifications currently loaded +.TP +\fI-user\fR +print the names of all user productions currently loaded +.TP +\fIidentifier\fR +print the object \fIidentifier\fR. \fIidentifier\fR must be a +valid Soar symbol. +.TP +\fIinteger\fR +print the object in working memory with the timetag \fIinteger\fR +.TP +\fIpattern\fR +print the object whose working memory elements matching the given +\fIpattern\fR. +The pattern is interpreted by the Soar kernel so it must be surrounded +by curly braces or double quotes to avoid being parsed by Tcl. A +\fIpattern\fR has the following form: +.DS + \fB(\fIidentifier \fB^\fIattribute value\fR\fR [\fB\fB+\fR]\fB)\fR +.DE +.PP +The \fIpattern\fR is surrounded by parentheses. The \fIidentifier\fR, +\fIattribute\fR, and \fIvalue\fR must be valid Soar symbols or the +wildcard symbol \fB*\fR which matches all occurences. The optional +\fB+\fR symbol restricts pattern matches to acceptable preferences. + +.SH OPTIONS +.PP +All options apply only to arguments which follow them on the command line. +.TP +\fB-depth\fR \fIn\fR +This option overrides the default +printing depth (see the \fBdefault-print-depth\fR command for more +detail). Note that a \fB-depth 0\fR argument is meaningful only with +accompanying integer and pattern arguments. It causes only the +matching working memory elements to be printed, instead of all +elements whose identifier is an identifier in one of the matching +working memory elements. +.TP +\fB-internal\fR +Specifies that items should be printed +in their internal form. For productions, this means leaving +conditions in their reordered (rete net) form. For working memory, +this means printing the individual elements with their +timetags, rather than the objects. +.TP +\fB-full\fR +When printing productions, print the whole production. This is the +default when printing a named production. +.TP +\fB-name\fR +When printing productions, print only the name and not the whole +production. This is the default when printing any catorgory of +productions, as opposed to a named production. +.TP +\fB-stack\fR +Specifies that the Soar goal stack should be printed. By default +this includes both states and operators. The stack listing can +be restricted by adding the \fB-states\fR and \fB-operator\fR +restrictions. Giving both options is equivalent to the default. +The predefined alias 'ps' is the same as \fBprint -stack\fR. + +.SH EXAMPLES +.TP +\fBprint -internal {(s1 ^* v2)}\fR +Print the working memory elements (and their timetags) which have +the identifier s1 as object and v2 as value. +.TP +\fBprint -stack\fR +Print the Soar stack which includes states and operators. +.TP +\fBprint -internal -full prodname\fR +Print the named production in its RETE form. +.TP +\fBprint -user\fR +Print the names of all user productions currently loaded. + +.SH WARNINGS + +The order of options and arguments to the \fBprint\fR command +do matter: options apply only to arguments which follow them. + +.TP +\fB print -chunks -full\fR +prints only the names of chunks, while +.TP +\fB print -full -chunks \fR +prints the entire chunk for all chunks. + +.SH SEE ALSO +\fBdefault-wme-depth\fR, \fBpredefined-aliases\fR + + + + + + + + + diff --git a/soar-8.5.2/doc/man/production-find.n b/soar-8.5.2/doc/man/production-find.n new file mode 100644 index 0000000..b027606 --- /dev/null +++ b/soar-8.5.2/doc/man/production-find.n @@ -0,0 +1,76 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS production-find soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +production-find \- Find matching Soar productions +.SH SYNOPSIS +\fBproduction-find\fR [\fB-lhs\fR | \fB-rhs\fR] [\fB-show-bindings\fR] +[\fB-chunks\fR | \fB-no-chunks\fR] {\fIpattern\fR} +.BE + +.SH DESCRIPTION +.PP +The \fBproduction-find\fR command is used to find Soar productions by matching +a given \fIpattern\fR against the production components. Productions +may be found that test a particular left-hand side pattern or +produce particular right-hand side preferences. For convenience, the +production-find command has the predefined alias \fBpf\fR. + +.SH OPTIONS + +If given, an option must match one of the following choices: +.TP +\fB-lhs\fR +The following \fIpattern\fR applies to the left-hand side of +productions. This is the default. +.TP +\fB-rhs\fR +The following \fIpattern\fR applies to the right-hand side of +productions. +.TP +\fB-show-bindings\fR +Show the bindings associated with the following \fIpattern\fR. +.TP +\fB-chunks\fR +Search only for chunks (learned productions) that match the +following \fIpattern\fR. +.TP +\fB-nochunks\fR +Search all productions \fIexcept\fR chunks that match the +following \fIpattern\fR. +.PP +The syntax of +\fIpattern\fR is exactly the syntax of a sequence of clauses within +a Soar production. In addition, the symbol \fB*\fR may be used as +a wildcard for an attribute or value. Note that variables names +do not have to match the specific names used in productions. +.SH EXAMPLES +.PP +Find productions that test that some object \fBgumby\fR has an +attribute \fBalive\fR with value \fBt\fR. In addition, limit +the rules to only those that test an operator named \fBfoo\fR: +.DS +\fBproduction-find {( ^gumby ^operator.name foo)( ^alive t)}\fR +.DE +.PP +Find productions that propose the operator \fBfoo\fR: +.DS +\fBproduction-find -rhs {( ^operator +)( ^name foo)}\fR +.DE +.PP +Find chunks that test the attribute ^\fBpokey\fR: +.DS +\fBproduction-find -chunks {( ^pokey *)}\fR +.DE + +.SH WARNINGS + +Note that curly braces or double quotes must be used around the +\fIpattern\fR to override the normal Tcl parsing. + +.SH SEE ALSO +\fBsp\fR diff --git a/soar-8.5.2/doc/man/pushd.n b/soar-8.5.2/doc/man/pushd.n new file mode 100644 index 0000000..dd9d9d6 --- /dev/null +++ b/soar-8.5.2/doc/man/pushd.n @@ -0,0 +1,21 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS pushd soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +pushd \- Push a directory onto the directory stack +.SH SYNOPSIS +\fBpushd\fR \fIdir\fR +.BE + +.SH DESCRIPTION +.PP +This command pushes the current directory onto the directory +stack and cd's to the given \fIdir\fR. See the \fBdirs\fR +command for an explanation of the directory stack. + +.SH SEE ALSO +\fBpopd\fR, \fBdirs\fR, \fBtopd\fR diff --git a/soar-8.5.2/doc/man/pwatch.n b/soar-8.5.2/doc/man/pwatch.n new file mode 100644 index 0000000..66d98ee --- /dev/null +++ b/soar-8.5.2/doc/man/pwatch.n @@ -0,0 +1,30 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS pwatch soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +pwatch \- Trace production firings and retractions +.SH SYNOPSIS +\fBpwatch\fR [\fB-on\fR | \fB-off\fR] \fR[\fIproduction-name\fR*] +.BE + +.SH DESCRIPTION +.PP +This command enables and disables the tracing of production activity for +individual productions. Both firings and retractions are printed. +If no \fIproduction-name\fRs are given, this command lists the +productions currently being traced. If one or more +\fIproduction-name\fRs are given, tracing is enabled (or disabled if +\fB-off\fR is specified) for those productions. +Tracing persists until disabled or until the production is \fBexcise\fRd. +.PP +This command is orthogonal to the \fBwatch productions\fR mechanism. +See the \fBwatch\fR command for more information. + +.SH SEE ALSO +\fBexcise\fR, \fBwatch\fR + + diff --git a/soar-8.5.2/doc/man/quit.n b/soar-8.5.2/doc/man/quit.n new file mode 100644 index 0000000..36e7c72 --- /dev/null +++ b/soar-8.5.2/doc/man/quit.n @@ -0,0 +1,20 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS quit soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +quit \- Quit Soar +.SH SYNOPSIS +\fBquit\fR +.BE + +.SH DESCRIPTION +.PP +This command quits Soar. It calls any registered Soar termination +callbacks, closes any open log files, and exits the process. This +also performs any Tcl related cleanup as would be done for the +Tcl \fBexit\fR command. The Tcl \fBexit\fR command is redefined +in Soar to use this command. diff --git a/soar-8.5.2/doc/man/remove-wme.n b/soar-8.5.2/doc/man/remove-wme.n new file mode 100644 index 0000000..f1bce6f --- /dev/null +++ b/soar-8.5.2/doc/man/remove-wme.n @@ -0,0 +1,35 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS remove-wme soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +remove-wme \- Remove an element from working memory +.SH SYNOPSIS +\fBremove-wme\fR \fItimetag\fR +.BE + +.SH DESCRIPTION +.PP +This command removes an element from Soar's working memory. The +\fItimetag\fR must be a positive integer matching the timetag of +an existing working memory element. It is normally used by the +input/output functions to update Soar's world state. + +.SH WARNINGS +.PP +\fBremove-wme\fR should never be called from the RHS: if you +try to match a wme on the LHS of a production, and then remove +the matched wme on the RHS, Soar will crash. +.PP +\fIThis command is inherently unstable and may have +weird side effects (possibly even including system crashes).\fR +For example, the chunker can't backtrace through wmes created +via \fBadd-wme\fR. Removing input wmes or context/impasse wmes may +have unexpected side effects. \fIYou've been warned.\fR + +.SH SEE ALSO +\fBadd-wme\fR, \fBio\fR + diff --git a/soar-8.5.2/doc/man/replay-input.n b/soar-8.5.2/doc/man/replay-input.n new file mode 100644 index 0000000..bf97366 --- /dev/null +++ b/soar-8.5.2/doc/man/replay-input.n @@ -0,0 +1,50 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS replay-input soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +replay-input \- Replay agent commands from a file during the appropriate decision cycle +.SH SYNOPSIS +\fBreplay-input\fR \fIaction\fR +.BE + +.SH DESCRIPTION +.PP +This command may be used to start and stop the reading of input +function commands from a file created by the "capture-input" command. +The routine replay-input-wme is registered as an input function +to read input wmes from the file decision cycle by decision cycle. +If an EOF is reached, the file is closed and the callback removed. +Use the command capture-input to create the file. + +The \fIaction\fR must be one of the following: +.TP +\fB-open\fR \fIpathname\fR +A log file named \fIpathname\fR is opened and input replay is initiated. +.TP +\fB-query\fR +Returns \fBopen\fR if replaying is active or \fBclosed\fR if +replaying is not active. +.TP +\fB-off\fR +Close the input file. + +.SH EXAMPLES +This opens the input file foo.in and will register the callback function +to execute the commands decision cycle by decision cycle: +.DS +\fBreplay-input -open foo.in\fR +.DE +.PP +This terminates replaying (removes the callback) and closes the open log file: +.DS +\fBreplay-input -off\fR +.DE + + + +.SH SEE ALSO +\fBcapture-input\fR \ No newline at end of file diff --git a/soar-8.5.2/doc/man/rete-net.n b/soar-8.5.2/doc/man/rete-net.n new file mode 100644 index 0000000..5dc6e68 --- /dev/null +++ b/soar-8.5.2/doc/man/rete-net.n @@ -0,0 +1,44 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS rete-net soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +rete-net \- Save and restore the Rete net +.SH SYNOPSIS +\fBrete-net\fR \fI{-save | -load} filename\fR +.BE + +.SH DESCRIPTION +.PP +The \fBrete-net\fR command saves and restores the state of the +Rete network. This command provides a fast method of saving +and loading productions since a binary format is used. rete-net +files are portable across platforms that support Soar. +The action must be one of the following: +.TP +\fB-save\fR +Save the Rete network in the given \fIfilename\fR. The Rete +network cannot be saved while there are justifications present. +These can be eliminated by using the \fBinit-soar\fR command. +.TP +\fB-load\fR +Load the productions stored in \fIfilename\fR into the Rete +network. In order to load productions stored in binary form, +working memory and production memory must both be empty. Working +memory can be emptied by using the \fBinit-soar\fR command. +Production memory can be emptied by using the \fBexcise -all\fR +command. +.PP +If the \fIfilename\fR contains a suffix of ".Z", then the file +is compressed automatically when it is saved and uncompressed +when it is loaded. + +.SH WARNINGS +Compressed files may not be portable to another platform is that +platform does not support the same uncompress utility. + +.SH SEE ALSO +\fBexcise\fR, \fBinit-soar\fR diff --git a/soar-8.5.2/doc/man/rhsfun.n b/soar-8.5.2/doc/man/rhsfun.n new file mode 100644 index 0000000..d451567 --- /dev/null +++ b/soar-8.5.2/doc/man/rhsfun.n @@ -0,0 +1,180 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS rhs-functions soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +Soar righthand side functions + +.SH DESCRIPTION +.PP +Soar supports a number of functions which can appear on the +righthand side of productions. These functions can appear +either as values (such as the "int" of a number), or as +standalone actions (such as "write" or "halt"). The righthand +side functions can be used to stop or pause Soar, do text input +and output, execute mathematical functions, generate and +manipulate symbols, modify learning, and execute Tcl commands. + +The Soar User's Manual should be consulted for more information +on the use of righthand side functions. + +.PP +The available righthand side functions are: +.RS +.TP +\fBaccept\fR +suspends Soar's execution and waits for the user to type a constant, +followed by a carriage return. The result of the accept is the constant. +.TP +\fBcapitalize-symbol\fR +given a symbol, this function returns a new symbol with +the first character capitalized. +.TP +\fBcompute-heading\fR +given 4 args, x1 y1 and x2 y2, this function returns integer heading +from x1,y1 to x2,y2 +(Note: this function is defined in the interface/rhsfun_examples.c file) +.TP +\fBcompute-range\fR +given 4 args, x1 y1 and x2 y2, this function returns integer range +from x1,y1 to x2,y2 +(Note: this function is defined in the interface/rhsfun_examples.c file) +.TP +\fBcrlf\fR +short for "carriage return, line feed," this function can be called +only within \fIwrite\fR. It forces a newline at its position in +the \fIwrite\fR action. +.TP +\fBdont-learn\fR +when learning is set to \fIexcept\fR, by default chunks will be formed in +all states; the \fBdont-learn\fR RHS action will cause learning to +be turned off for the state specified in the LHS (condition side) +of the production. +.TP +\fBforce-learn\fR +when learning is set to \fIonly\fR, by default chunks are not formed +in any state; the \fBforce-learn\fR RHS action will cause learning to +be turned on for the state specified in the LHS (condition side) +of the production. +.TP +\fBhalt \fR +terminates the current run, stops Soars execution and returns to +the user prompt. \fBhalt\fR should not be used if the current run is +to be restarted. (see \fBinterrupt\fR below.) +.TP +\fBifeq \fR +checks if the first argument is "eq" to the second argument. if it +is, then return the third argument, else return the fourth argument. +Similar to the "?" notation in C. all four arguments are required. +.TP +\fBinterrupt\fR +causes Soar to stop at the end of the current phase, and return to +the user prompt. Similar to \fBhalt\fR, except the run may be +continued. +.TP +\fBmake-constant-symbol\fR +returns a new constant symbol which is guaranteed to be different +from all symbols currently present in the system. with no arguments, +it returns a symbol whose name starts with "constant". With one or +more arguments, it takes those argument symbols, concatenates their +names and uses the resulting string as the prefix for the new symbol. +.TP +\fBround-off\fR + Given two numbers, this function returns the first rounded to the +nearest second number. +(Note: this function is defined in the interface/rhsfun_examples.c file) +.TP +\fBround-off-heading\fR + Given two numbers, this function returns the first rounded to the +nearest second number. The heading is given between -180 and +180 deg. +(Note: this function is defined in the interface/rhsfun_examples.c file) +.TP +\fBstrlen\fR +returns the length of the output string so that users can get the +output to line up nicely. useful with \fBifeq\fR when the output +string varies in length. +.TP +\fBtimestamp\fR +returns a symbol whose print name is a representation of the current +date and local time. +.TP +\fBtcl\fR +concatenates its arguments into a string which is sent to the +agent's Tcl interpreter for evaluation. It does not automatically +insert spaces between arguments; users must explicitly insert +spaces within vertical bars. +.TP +\fBwrite\fR +writes its arguments to the user interface. it does not automatically +insert blanks, line feeds, or carriage returns. It should be used +only for simple monitoring and debugging. +.TP +\fB+\fR +prefix notation for addition. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +.TP +\fB*\fR +prefix notation for multiplication. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +.TP +\fB-\fR +prefix notation for subtraction. If all arguments are integers, +this function returns an integer, otherwise it returns a real number. +.TP +\fB/\fR +prefix notation for division. always returns a real number. +.TP +\fBdiv\fR +prefix notation for binary integer division. returns the integer +quotient. Both arguments must be integers or an error occurs. +.TP +\fBmod\fR +prefix notation for binary integer modulus. returns the integer +remainder when dividing the first argument by the scond. Both +arguments must be integers or an error occurs. +.TP +\fBsin\fR +returns as a float, the sine of the angle which must be +given in radians. +.TP +\fBcos\fR +returns as a float, the cosine of the angle which must +be given in radians. +.TP +\fBatan2\fR +returns as a float in radians, the arctangent of the first argument +divided by the second argument. the arguments can be integers or floats. +.TP +\fBsqrt\fR +returns as a float the square root of its argument, which can be +a float or an integer. +.TP +\fBabs\fR +returns the absolute value: of a float as a float; of an integer +as an integer. +.TP +\fBint\fR +converts a symbol to an integer constant. argument must be either +an integer constant, a floating point constant, or a symbolic constant +which can be interpreted as a single integer number. +.TP +\fBfloat\fR +converts a symbol to an floating point constant. argument must be either +an integer constant, a floating point constant, or a symbolic constant +which can be interpreted as a single floating point number. +.PP +.RE + +.SH WARNINGS +The \fBtcl\fR RHS function is not part of the Soar kernel. +It is added by the Tcl interface code. You can get into a lot of +trouble with it, as the arguments are unrestricted. It should +be used only with great care. + + +.SH SEE ALSO +\fBlearn\fR, \fBstop-soar\fR + diff --git a/soar-8.5.2/doc/man/run.n b/soar-8.5.2/doc/man/run.n new file mode 100644 index 0000000..353fea2 --- /dev/null +++ b/soar-8.5.2/doc/man/run.n @@ -0,0 +1,124 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS run soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +run \- Run Soar +.SH SYNOPSIS +\fBrun\fR [\fIn\fR | 'forever'] [\fIunit\fR] [-self] +.BE + +.SH DESCRIPTION +.PP +This command runs the Soar agents. If the [-self] flag is issued, +only the agent issuing the run command will run. \fIn\fR is a single integer +which specifies the number of times to run Soar. If \fIn\fR is +unspecified and no \fIunit\fRs are given, OR if \fIn\fR +is the single keyword '\fBforever\fR', then Soar is run until halted +by problem-solving completion or an external interrupt. If \fIn\fR +is specified, but no \fIunit\fRs are specified, then soar is run +by decision cycles. If \fIunit\fRs +are specified, but \fIn\fR is unspecified, then \fIn\fR defaults to '1'. The +\fIunit\fR argument indicates the unit of measure to be used +in counting Soar run cycles. \fIunit\fR must be one of the following +keywords: +.TP +\fBp\fR +run Soar for \fIn\fR phases. A phase is either an input +phase, preference phase, working memory phase, output +phase, or decision phase. +.TP +\fBe\fR +run Soar for \fIn\fR elaboration cycles. (For purposes of +this command, decision phase is counted as an elaboration cycle.) +.TP +\fBd\fR +run Soar for \fIn\fR decision cycles +.TP +\fBs\fR +run Soar until the \fIn\fRth time a state is selected +.TP +\fBo\fR +run Soar until the \fIn\fRth time an operator is selected +.TP +\fBout\fR +run Soar until the \fIn\fRth time output is generated by the agent +.TP +\fB\fR +run Soar until the current level of subgoaling has terminated +.TP +\fB\fR +run Soar until the superstate's level of subgoaling has terminated +.TP +\fB\fR +run Soar until the supersuperstate's level of subgoaling has terminated +.TP +\fB\fR +run Soar until the \fIn\fRth time an operator is selected at this level of +subgoaling or until the current level of subgoaling is terminated. +.TP +\fB\fR +run Soar until the \fIn\fRth time a superoperator is selected or until +that level of subgoaling is terminated. +.TP +\fB\fR +run Soar until the \fIn\fRth time a supersuperoperator is selected or until +that level of subgoaling is terminated. +.PP +Unlike the Soar 6 \fIgo\fR command, \fIrun\fR has no memory of settings from +previous run commands. +.PP +There are two predefined aliases for the run command, provided as a convenience +for use on the command line: +.TP +\fBd\fR [\fIn\fR] +run by decision cycles, equivalent to "run \fIn\fR d". \fIn\fR defaults to 1. +.TP +\fBe\fR [\fIn\fR] +run by elaboration cycles, equivalent to "run \fIn\fR e". \fIn\fR defaults to 1. + + +.SH EXAMPLES +.TP +\fBrun\fR +run all agents until halted by problem-solving completion or +an external interrupt is given. +.TP +\fBrun 5 d\fR +run all agents for 5 decision cycles +.TP +\fBrun d -self\fR +run the current agent only for 1 decision cycle +.TP +\fBrun 3\fR +run all agents for 3 decision cycles +.TP +\fBrun 2 e\fR +run all agents for 2 elaboration cycles +.TP +\fBrun 1 s\fR +run all agents until the next state is selected (i.e., +until the next time an impasse arises) +.TP +\fBrun \fR +run until the next superoperator is selected +(or until the superstate goes away) +.TP +\fBrun 3 \fR +run for 3 operator selections at this level +(continuing through any subgoals that arise) + +.SH WARNING +.PP +In Soar8, the preference phase is no longer separated from the +working memory phase, Soar continues right through from preferences +into working memory without stopping. The phases +are Input, Propose, Decide, Apply, Output; Propose and Apply each +consist of at least one, but possibly many, +preference/working-memory subphases. + +.SH SEE ALSO +\fBd\fR, \fBe\fR, \fBstop-soar\fR, \fBpredefined-aliases\fR diff --git a/soar-8.5.2/doc/man/save_backtraces.n b/soar-8.5.2/doc/man/save_backtraces.n new file mode 100644 index 0000000..628fae7 --- /dev/null +++ b/soar-8.5.2/doc/man/save_backtraces.n @@ -0,0 +1,41 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS save_backtraces soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +save_backtraces \- Enable/Disable Soar save_backtraces +.SH SYNOPSIS +\fBset save_backtraces\fR [\fBon\fR | \fBoff\fR] +.BE + +.SH DESCRIPTION +.PP +\fBsave_backtraces\fR is a Soar variable which through the Tcl \fIset\fR +command, enables and disables the the saving of backtracing information. +It must be \fBon\fR for the explain-backtraces command to provide +backtracing information. +If an enabling or disabling \fIstatus\fR of \fBon\fR or \fBoff\fR +is given, then the save_backtraces are +set to that state. If no \fIstatus\fR is given, then the current +save_backtraces status is printed. At startup, save_backtraces is initially +enabled. + +.SH OPTIONS +.TP +\fBon | 1\fR +Enables the saving of backtracing information (initial default) +.TP +\fBoff | 0\fR +Disables the saving of backtracing information + +.SH WARNINGS +.PP +save_backtraces mode must be on when a chunk or +justification is created or no explanation will be available +for the \fBexplain-backtraces\fR command. + +.SH SEE ALSO +\fBexplain-backtraces\fR, \fBvariables\fR diff --git a/soar-8.5.2/doc/man/soar.n.off b/soar-8.5.2/doc/man/soar.n.off new file mode 100644 index 0000000..a6fedc6 --- /dev/null +++ b/soar-8.5.2/doc/man/soar.n.off @@ -0,0 +1,76 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS soar soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +soar \- Soar system +.SH SYNOPSIS +\fBsoar\fR [\fIoptions\fR] +.BE + +.SH DESCRIPTION +.PP +This command creates new Soar interpreters identified by +given \fIname\fRs. The various options specify any special +initialization conditions, if any. The most important +option is the \fItype\fR which indicates what type of +interpreter is to be created and must be one of the following +values: +.TP +\fB-agent\fR +Create agent interpreter(s). This includes Tcl + Soar. +.TP +\fB-tclsh\fR +Create tclsh interpreter(s). Tclsh includes only Tcl. +.PP +One or more \fIname\fRs may be given after the above \fItype\fRs. +If no \fItype\fR is given on the command line when Soar is +invoked, a single \fB-agent\fR interpreter is created with the +\fIname\fR \fBsoar\fR. Within Soar, it is an error to call this +command without specifying some interpreter \fIname\fR to create. +.PP +Once the Soar system has started, the command +\fBcreate-interp\fR can be used to add additional interpreters. + +.SH OPTIONS +Environment variables used below are assumed to be defined in the Unix +shell used to start Soar. +.TP +\fB-path\fR +Use the given sequence of directories to scan for agent initialization +files. The sequence is a colon (:) separated list of directories. The +default value is ".:$HOME", where $HOME is the user's home directory. +Agent initialization files are assumed to be named \fIname\fR.soar. +.TP +\fB-file\fR +Specifies a file to run immediately after defining the last interpreter. +This only applies when invoking Soar. +.TP +\fB-help\fR +Lists all available options for this command. +.TP +\fB-verbose\fR +Print diagnostic information about options as each interpreter is +defined. + +.SH EXAMPLES +.PP +The following example starts Soar with two agents named \fBfred\fR and +\fBwilma\fR and a single tclsh interpreter named \fBbedrock\fR. This setup +might be used to run a simulator in the tclsh interpreter \fBbedrock\fR +that the agents \fBfred\fR and \fBwilma\fR can interact in. +.DS +\fBsoar -agent fred wilma -tclsh bedrock\fR +.DE +.PP +This example has the extra option \fB-foo bar\fR. Since this is not +recognized as a valid command line option, it is passed on to each +interpreter defined on the command line. This information appears in +the Tcl variable \fBargv\fR and can be used to pass startup +information to user-defined Tcl procedures. +.DS +\fBsoar -foo bar -agent fred wilma -wish bedrock\fR +.DE diff --git a/soar-8.5.2/doc/man/soar8.n b/soar-8.5.2/doc/man/soar8.n new file mode 100644 index 0000000..57a2788 --- /dev/null +++ b/soar-8.5.2/doc/man/soar8.n @@ -0,0 +1,44 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS soar8 soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +soar8 \- Enable/Disable Soar8 mode +.SH SYNOPSIS +\fBsoar8 \fR [\fB-on\fR | \fB-off\fR] +.BE + +.SH DESCRIPTION +.PP +The \fBsoar8\fR allows users to toggle between the Soar 8 methodology +and the Soar 7 methodology. The default value is -on. +If an enabling or disabling \fIstatus\fR of \fB-on\fR or \fB-off\fR +is given, then the Soar 8 (-on) or Soar 7 (-off) methodology is employed. +If no \fIstatus\fR is given, then the current +soar8 status is printed. Users can toggle between modes ONLY when +production memory and working memory are both empty. This means +that users must either change the mode at startup before any +productions are loaded, or must first issue "excise -all" (which +does an "init-soar" as well) before changing modes. Note that +there are differences in the preference mechanism and in operator +termination (among other things) between Soar 8 and Soar 7. Users +should read the Soar 8.2 Release Notes for more details. + +.SH OPTIONS +.TP +\fB-on\fR +Soar will run using Soar 8 methodology (initial default) +.TP +\fB-off\fR +Soar will run using Soar 7 methodology + +.SH WARNINGS +.PP +Production memory and working memory must be empty to switch +between modes. + +.SH SEE ALSO +\fBSoar 8.2 Release Notes on the Soar 8.2 web page\fR diff --git a/soar-8.5.2/doc/man/soarnews.n b/soar-8.5.2/doc/man/soarnews.n new file mode 100644 index 0000000..404a11b --- /dev/null +++ b/soar-8.5.2/doc/man/soarnews.n @@ -0,0 +1,22 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS soarnews soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +soarnews \- Soar news +.SH SYNOPSIS +\fBsoarnews\fR +.BE + +.SH DESCRIPTION +.PP +This command gives information about the current Soar version +being run, the addresses of Soar email groups, the Soar Home Page URL, +and the copyright disclaimer. + +.SH SEE ALSO +\fBversion\fR + diff --git a/soar-8.5.2/doc/man/soartk.n.off b/soar-8.5.2/doc/man/soartk.n.off new file mode 100644 index 0000000..6a5c71b --- /dev/null +++ b/soar-8.5.2/doc/man/soartk.n.off @@ -0,0 +1,120 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS soartk soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +soartk \- Soar system with Tk extension +.SH SYNOPSIS +\fBsoartk\fR [\fIoptions\fR] +.BE + +.SH DESCRIPTION +.PP +This command creates new Soar interpreters identified by +given \fIname\fRs. The various options specify any special +initialization conditions, if any. The most important +option is the \fItype\fR which indicates what type of +interpreter is to be created and must be one of the following +values: +.TP +\fB-agent\fR +Create agent interpreter(s). This includes Tcl + Tk + Soar if +Tk is enabled, otherwise this includes Tcl + Soar. +.TP +\fB-wish\fR +Create wish interpreter(s). Wish includes Tcl + Tk. This is +available only if Tk is enabled. +.TP +\fB-tclsh\fR +Create tclsh interpreter(s). Tclsh includes only Tcl. +.PP +One or more \fIname\fRs may be given after the above \fItype\fRs. +If no \fItype\fR is given on the command line when Soar is +invoked, a single \fB-agent\fR interpreter is created with the +\fIname\fR \fBsoar\fR. Within Soar, it is an error to call this +command without specifying some interpreter \fIname\fR to create. +.PP +Tk is enabled if Soar has been compiled with the USE_TK option, +the $DISPLAY environment variable is set, and the \fB-noTk\fR +option has not been given on the command line +(see below). +.PP +Once the Soar Tcl/Tk system has started, the command +\fBcreate-interp\fR can be used to add additional interpreters. + +.SH OPTIONS +Environment variables used below are assumed to be defined in the Unix +shell used to start Soar. +.TP +\fB-path\fR +Use the given sequence of directories to scan for agent initialization +files. The sequence is a colon (:) separated list of directories. The +default value is ".:$HOME", where $HOME is the user's home directory. +Agent initialization files are assumed to be named \fIname\fR.soar. +.TP +\fB-display\fR +Place the top-level window associated with the interpreter on the indicated +display. The value of this option follows standard X conventions for +specifying displays. The default is the value of $DISPLAY. This +only applies to wish-based shells. +.TP +\fB-file\fR +Specifies a file to run immediately after defining the last interpreter. +This only applies when invoking Soar. +.TP +\fB-geometry\fR +Specifies the geometry (width, height, and placement) of the top-level +window associated with the interpreter. The value of this option +follows standard X conventions for specifying geometries. This only +applies to wish-based shells. +.TP +\fB-help\fR +Lists all available options for this command. +.TP +\fB-noTk\fR +Do not use Tk when creating any subsequent interpreters. This option +applies to the rest of the command line. +.TP +\fB-sync\fR +Use synchronous X server updates with all subsequent wish-based +interpreter windows. This applies only to wish-based shells. +.TP +\fB-useIPC\fR +Enables IPCs (registered with Xserver) for all interpreters. This option +applies to the rest of the command line. +.TP +\fB-verbose\fR +Print diagnostic information about options as each interpreter is +defined. + +.SH EXAMPLES +.PP +The following example starts Soar with two agents named \fBfred\fR and +\fBwilma\fR and a single wish interpreter named \fBbedrock\fR. This setup +might be used to run a simulator in the wish interpreter \fBbedrock\fR +that the agents \fBfred\fR and \fBwilma\fR can interact in. +.DS +\fBsoartk -agent fred wilma -wish bedrock\fR +.DE +.PP +The next example is similar to the one above, except that the simulator +display will be moved to the X display \fBsgi1:0.0\fR. Also, the +switch \fB-v\fR has been added to indicate that we want detailed +information about defined options as each interpreter is created. +Note that all option names may be abbreviated to any prefix which +uniquely distinguishes it from the other options. +.DS +\fBsoartk -v -agent fred wilma -display sgi1:0.0 -wish bedrock\fR +.DE +.PP +This example has the extra option \fB-foo bar\fR. Since this is not +recognized as a valid command line option, it is passed on to each +interpreter defined on the command line. This information appears in +the Tcl variable \fBargv\fR and can be used to pass startup +information to user-defined Tcl procedures. +.DS +\fBsoartk -foo bar -agent fred wilma -wish bedrock\fR +.DE \ No newline at end of file diff --git a/soar-8.5.2/doc/man/sp.n b/soar-8.5.2/doc/man/sp.n new file mode 100644 index 0000000..485a90e --- /dev/null +++ b/soar-8.5.2/doc/man/sp.n @@ -0,0 +1,206 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS sp soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +sp \- Define a Soar production +.SH SYNOPSIS +\fBsp \fIrule\fR +.BE + +.SH DESCRIPTION +.PP +This command defines a new Soar production. \fIrule\fR +is a single argument parsed by the Soar kernel, so it should +be enclosed in curly braces to avoid being parsed by Tcl. +The +overall syntax of a \fIrule\fR is as follows: +.DS + \fIname\fR + [\fB"\fR\fIdocumentation-string\fR\fB"\fR] + [\fIFLAG\fR*] + \fILHS\fR + \fB-->\fR + \fIRHS\fR +.DE +.PP +The first element of a \fIrule\fR is its \fIname\fR. Conventions +for \fInames\fR are given in the Soar Users Manual. If given, +the \fIdocumentation-string\fR must be enclosed in double quotes. +Optional flags define the type of rule and the form of support its +right-hand side assertions will receive. The specific flags are +listed in a separate section below. The \fILHS\fR defines the +left-hand side of the production and specifies the conditions +under which the rule can be fired. Its syntax is given in detail +in a subsequent section. The \fB-->\fR symbol serves to separate +the \fILHS\fR and \fIRHS\fR portions. +The \fIRHS\fR defines the right-hand side of +the production and specifies the assertions to +be made and the actions to be performed when the rule fires. The +syntax of the allowable right-hand side actions are given in a later +section. The Soar Users Manual gives an elaborate discussion of +the design and coding of productions. Please see that reference +for tutorial information about productions. +.PP +More complex productions can be formed by surrounding the \fIrule\fR with +double quotes instead of curly braces. This enables variable and +command result substitutions in productions. +If another production with the same name already exists, it is +excised, and the new production is loaded. + +.SH RULE FLAGS +.PP +The optional \fIFLAG\fRs are given below. Note that these switches +are preceeded by a colon instead of a dash -- this is a Soar parser +convention. +.TP +\fB:o-support\fR +specifies that all the RHS actions are to be given +o-support when the production fires +.TP +\fB:no-support\fR +specifies that all the RHS actions are only +to be given i-support when the production fires +.TP +\fB:default\fR +specifies that this production is a default +production (this matters for \fBexcise -task\fR and \fBwatch task\fR) +.TP +\fB:chunk\fR +specifies that this production is a chunk (this +matters for \fBlearn trace\fR) + +.SH LHS GRAMMAR +Grammar for left hand sides of productions: +.DS +\fR \fIlhs\fR ::= \fIcond\fR+ + \fIcond\fR ::= \fIpositive_cond\fR | - \fIpositive_cond\fR + \fIpositive_cond\fR ::= \fIconds_for_one_id\fR | { \fIcond\fR+ } + \fIconds_for_one_id\fR ::= ( [state |impasse] [\fIid_test\fR] \fIattr_value_tests\fR* ) + \fIid_test\fR ::= \fItest\fR + \fIattr_value_tests\fR ::= [-] ^ \fIattr_test\fR [.\fIattr_test\fR]* \fIvalue_test\fR* + \fIattr_test\fR ::= \fItest\fR + \fIvalue_test\fR ::= \fItest\fR [+] | \fIconds_for_one_id\fR [+] + + \fItest\fR ::= \fIconjunctive_test\fR | \fIsimple_test\fR + \fIconjunctive_test\fR ::= { \fIsimple_test\fR+ } + \fIsimple_test\fR ::= \fIdisjunction_test\fR | \fIrelational_test\fR + \fIdisjunction_test\fR ::= << \fIconstant\fR* >> + \fIrelational_test\fR ::= [\fIrelation\fR] \fIsingle_test\fR + \fIrelation\fR ::= <> | < | > | <= | >= | = | <=> + \fIsingle_test\fR ::= variable | \fIconstant\fR + \fIconstant\fR ::= sym_constant | int_constant | float_constant +.DE +.SH RHS GRAMMAR +Grammar for right hand sides of productions: +.DS +\fR \fIrhs\fR ::= \fIrhs_action\fR* + \fIrhs_action\fR ::= ( variable \fIattr_value_make\fR+ ) | \fIfunction_call\fR + \fIfunction_call\fR ::= ( \fIfunction_name\fR \fIrhs_value\fR* ) + \fIfunction_name\fR ::= sym_constant | + | - + \fIrhs_value\fR ::= \fIconstant\fR | \fIfunction_call\fR | variable + \fIconstant\fR ::= sym_constant | int_constant | float_constant + \fIattr_value_make\fR ::= ^ \fIrhs_value\fR [.\fIrhs_value\fR]* \fIvalue_make\fR+ + \fIvalue_make\fR ::= \fIrhs_value\fR \fIpreferences\fR + + \fIpreferences\fR ::= [,] | \fIpreference-specifier\fR+ + \fIpreference-specifier\fR ::= \fInaturally-unary-preference\fR [,] + | \fIforced-unary-preference\fR + | \fIbinary-preference\fR \fIrhs_value\fR [,] + \fInaturally-unary-preference\fR ::= + | - | ! | ~ | @ + \fIbinary-preference\fR ::= > | = | < | & + \fIforced-unary-preference\fR ::= \fIbinary-preference\fR {, | ) | ^} +.DE + +.SH EXAMPLES +There are many examples in the Soar Users Manual and the demos +subdirectory. Here is a simple production to create a problem space. +It comes from the critter-world demo (see the file critter.tcl): +.DS +\fB +sp {critter*create*space*critter + "Formulate the initial problem space" + (state ^superstate nil) + --> + ( ^name move-around ^problem-space

                                                                                                                                    ) + (

                                                                                                                                    ^name critter)} +\fR +.DE +.PP +The production above has the \fIname\fR +\fBcritter*create*space*critter\fR. It has a documentation string +that is surrounded by double quotes. The \fILHS\fR is \fB(state +^superstate nil)\fR and indicates that this rule will match whenever +there is a state object that has the attribute-value pair +\fB^superstate +nil\fR. The \fB-->\fR arrow separates the left and right-hand sides. +The \fIRHS\fR consists of two lines. The first asserts that the state +object is to be augmented with the name \fBmove-around\fR and a +problem space should be created. The second line of the \fIRHS\fR +indicates that this problem space should be named \fBcritter\fR. +.PP +New for Soar 8, is right-hand-side dot notation. So this production +could also be written: +.DS +\fB +sp {critter*create*space*critter + "Formulate the initial problem space" + (state ^superstate nil) + --> + ( ^name move-around ^problem-space.name critter)} +\fR +.DE +.PP +Here is a variant of the above example using +double quotes instead of curly braces. Double quotes are needed in order +to imbed the value of the Tcl variable \fBsoar_agent_name\fR +in the production. The value of this variable is used to name +the problem-space created. +.DS +\fB +sp "critter*create*space*critter + (state ^superstate nil) + --> + ( ^name move-around ^problem-space

                                                                                                                                    ) + (

                                                                                                                                    ^name $soar_agent_name)" +\fR +.DE +.PP +The primary change in the rule is the last clause of the +\fIRHS\fR. In that clause, the Tcl variable \fBsoar_agent_name\fR +is expanded. If this rule is given in an interpreter which has +the variable \fBsoar_agent_name\fR set to \fBfred\fR, then the +\fIRHS\fR would expand to the following before being sent to +the Soar kernel to be parsed: +.DS +\fB + (

                                                                                                                                    ^name fred) +\fR +.DE +.PP +Please be aware that when using double quotes, both the dollar +sign (variable expansion) and square brackets (command result +substitution) will be interpreted by Tcl. If these characters +(\fB$\fR, \fB[\fR, and \fB]\fR) are to be passed to the Soar +production parser, they must be escaped (using a backslash) +to avoid interpretation by Tcl. + +.SH WARNINGS +.PP +The last production above does not contain a documentation string. +If one were added, double quotes would need to be escaped to avoid +premature termination of the rule: +.DS +\fB +sp "critter*create*space*critter + \"Formulate the initial problem space\" + (state ... +\fR +.DE + +.SH SEE ALSO +\fBexcise\fR, \fBlearn\fR, \fBwatch\fR + diff --git a/soar-8.5.2/doc/man/start-attention-lapse.n b/soar-8.5.2/doc/man/start-attention-lapse.n new file mode 100644 index 0000000..6cb815d --- /dev/null +++ b/soar-8.5.2/doc/man/start-attention-lapse.n @@ -0,0 +1,33 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS start-attention-lapse +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +start-attention-lapse \- Sets the amount of real time that should pass before ending the lapse and sets attention-lapsing to true. Not normally called by user. +.SH SYNOPSIS +\fBstart-attention-lapse \fR[\fIinteger (milliseconds)\fR] +.BE + +.SH DESCRIPTION +.PP +This command, which should not normally be called by the user or +an agent (attention lapses normally get started automatically +by the architecture), sets the "attention-lapsing" variable to +TRUE (1), and starts tracking the amount of real time that should pass before +ending the lapse (with wake_from_attention_lapse). The duration +of the lapse is the number of milleseconds specified by the +argument to this command (in real time). + +.PP +.SH WARNINGS +The compile time options \fR REAL_TIME_BEHAVIOR\fI and \fRATTENTION_LAPSE\fI +must be enabled for this functionality. +.PP + + + +.SH SEE ALSO +\fRattention-lapse\fI \fRwake-from-attention-lapse\fI \fBvariables\fR diff --git a/soar-8.5.2/doc/man/stats.n b/soar-8.5.2/doc/man/stats.n new file mode 100644 index 0000000..8b0d4fc --- /dev/null +++ b/soar-8.5.2/doc/man/stats.n @@ -0,0 +1,225 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS stats soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +stats \- Print statistical data about Soar +.SH SYNOPSIS +\fBstats \fR[\fI-system \fR[\fIstat\fR] | \fI-memory \fR[\fIstat\fR] |\fI-rete \fR[\fIstat\fR]] +.BE + +.SH DESCRIPTION +.PP +This command prints Soar internal statistics. The \fImodule\fR +indicates the component of interest. If specified, \fImodule\fR +must be one of \fB-system\fR, \fB-memory\fR, or \fB-rete\fR. If no +specific \fIstat\fR is given for the specified \fImodule\fR, then +all statistics are listed for that \fImodule\fR. If no \fImodule\fR +is given, then the \fB-system\fR statistics are listed. +.PP +The \fB-system\fR module contains the following \fIstat\fRs: +.DS +-default-production-count +-user-production-count +-chunk-count +-justification-count +-all-productions-count +-dc-count +-ec-count +-ecs/dc +-firings-count +-firings/ec +-wme-change-count +-wme-addition-count +-wme-removal-count +-wme-count +-wme-avg-count +-wme-max-count +.DE +.PP +If Soar has been compiled with the NO_TIMING_STUFF \fBNOT\fR set, +then the following statistics are also available in the +\fB-system\fR module: +.DS +-total-time +-ms/dc +-ms/ec +-ms/firing +-ms/wme-change +.DE +.PP +If Soar has been compiled with the DETAILED_TIMING_STATS \fBSET\fR, +then the following statistics are also available in the +\fB-system\fR module: +.DS +-match-time +-ownership-time +-chunking-time +.DE +.PP +The \fB-memory\fR module contains the following statistics: +.DS +-total +-overhead +-strings +-hash-table +-pool \fIpool-statistic\fR +-misc +.DE +.PP +The \fB-pool\fR statistic is additionally qualified by a +\fIpool-statistic\fR option. If this option is not given, +then all \fB-memory\fR pool statistics are printed. If +given, \fIpool-statistic\fR must have one of the following +forms: +.TP +\fB-total\fR +Print just the overall totals for the pools +.TP +\fIpool-name\fR [\fIaspect\fR] +Print statistics about the specific pool \fIpool-name\fR. The +permissable \fIpool-name\fRs are: +.DS + chunk condition + io wme + output link + preference + wme + slot + instantiation + ms change + right mem + negative token + token + node varnames + rete node + rete test + alpha mem + saved test + not + action + production + condition + complex test + float constant + int constant + sym constant + identifier + variable + dl cons + cons cell +.DE +.PP +If no \fIaspect\fR is given, then print all statistics about the +given pool. If given, \fIaspect\fR must have one of the +following forms: +.DS + -used + -free + -item-size + -total-bytes +.DE +The first two \fIaspect\fRs are available only if Soar has been +compiled with MEMORY_POOL_STATS \fBSET\fR. +.PP +The \fB-rete\fR module contains statistics for the following node +types: +.DS +unhashed memory +memory +unhashed mem-pos +mem-pos +unhashed negative +negative +unhashed positive +positive +dummy top +dummy matches +conj. neg. +conj. neg. partner +production +total +.DE +The \fBtotal\fR statistic gives a total count over all node types. +.PP +A \fB-rete\fR statistic is obtained by specifying one of the above +nodes followed by a \fIqualifier\fR. The \fIqualifier\fR is one +of \fB-actual\fR, \fB-if-no-merging\fR, and \fB-if-no-sharing\fR. +The \fB-if-no-sharing\fR option is only available if Soar has been +compiled with the SHARING_FACTORS option \fBSET\fR. + +.SH EXAMPLES +This prints all statistics in the \fB-system\fR module: +.DS +\fBstats -system\fR +.DE +.PP +This prints the number of io wme's: +.DS +\fBstats -memory -pool {io wme} -used\fR +.DE +Note that this particular pool name, "io wme", contains an +embedded space character. Hence, the name must be surrounded +by curly braces or double quotes to override the normal Tcl +parsing of words separated by whitespace. This is not necessary +for pool names that do not include spaces: +.DS +\fBstats -memory -pool wme -used\fR +.DE +.PP +This prints the actual number of unhashed negative nodes in the +Rete memory: +.DS +\fBstats -rete {unhashed negative} -actual\fR +.DE + +.SH A NOTE ON TIMERS +.PP +The current implementation of Soar uses a number of timers to +provide time-based statistics for use in the \fBstats\fR command +calculations. These timers are: +.DS +total CPU time +total kernel time +phase kernel time (per phase) +phase callbacks time (per phase) +input function time +output function time +.DE +.PP + +Total CPU time is calculated from the time a decision cycle (or number +of decision cycles) is initiated until stopped. Kernel time is the +time spent in core Soar functions. In this case, kernel time is +defined as the all functions other than the execution of callbacks and +the input and output functions. The total kernel timer is only +stopped for these functions. + +The phase timers (for the kernel and callbacks) track the execution +time for individual phases of the decision cycle (i.e., input phase, +preference phase, working memory phase, output phase, and decision +phase). Because there is overhead associated with turning these +timers on and off, the actual kernel time will always be greater than +the derived kernel time (i.e., the sum of all the phase kernel +timers). Similarly, the total CPU time will always be greater than +the derived total (the sum of the other timers) because the overhead +of turning these timers on and off is included in the total CPU time. +In general, the times reported by the single timers should always be +greater than than the corresponding derived time. Additionally, as +execution time increases, the difference between these two values will +also increase. + +For those concerned about the performance cost of the timers, all the +run time timing calculations can be compiled out of the code by +defining NO_TIMING_STUFF (in soarkernel.h) before compilation. + +.PP +.SH FILES +soarkernel.h + + + + diff --git a/soar-8.5.2/doc/man/stop-soar.n b/soar-8.5.2/doc/man/stop-soar.n new file mode 100644 index 0000000..34095dc --- /dev/null +++ b/soar-8.5.2/doc/man/stop-soar.n @@ -0,0 +1,58 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS stop-soar soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +stop-soar \- Stop Soar +.SH SYNOPSIS +\fBstop-soar\fR [\fB -self \fR [reason-string] ] +.BE + +.SH DESCRIPTION +.PP +Agents may be run using the \fBrun\fR command. +The \fBstop-soar\fR command stops any running Soar agents. It +sets a flag in the Soar kernel so that Soar will stop running at +a "safe" point and return control to the user. This operates exactly +as if the user had issued a control-C (SIGINT) interrupt to the Soar +process. +.TP +\fB-self\fR +Stop only the soar agent where the command is issued. All other agents +continue running as previously specified. +.TP +\fIreason-string\fR +An optional string following \fB-self\fR which will be printed +when Soar is stopped, to indicate why it was stopped. If left +blank, no message will be printed when Soar is stopped. +.PP +This command is usually not issued at the command line prompt. A +more common use of this command is as a side-effect of pressing a +button on a Graphical User Interface (GUI), or as a monitor to +be executed at a specific Soar Event. For example, a user may +wish to examine an agent's "matches" after the Soar Decision Phase. +In order to do this in Soar 8, the user must register a monitor, +or callback, to issue the "stop-soar -self" command for the event, +after-decision-phase-cycle. +.PP + +.SH EXAMPLES +.PP +This example shows how to stop Soar8 after this decision phase +using \fBstop-soar -self\fR in a monitor to stop after the +decision phase so that memory can be examined. +.DS +\fB monitor -add {stop-soar -self "after decision phase"} \ + after-decision-phase-cycle + +.SH WARNINGS +If the graphical interface doesn't periodically do a Tcl "update" +command, then it may not be possible to interrupt a Soar agent +from the command line. + +.SH SEE ALSO +\fBrun\fR, \fBmonitor\fR, \fBmatches\fR + diff --git a/soar-8.5.2/doc/man/topd.n b/soar-8.5.2/doc/man/topd.n new file mode 100644 index 0000000..f88d35a --- /dev/null +++ b/soar-8.5.2/doc/man/topd.n @@ -0,0 +1,21 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS topd soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +topd \- List the top of the directory stack +.SH SYNOPSIS +\fBtopd\fR +.BE + +.SH DESCRIPTION +.PP +This command returns the top directory on the directory stack. +See the \fBdirs\fR command for an explanation of the directory +stack. + +.SH SEE ALSO +\fBdirs\fR, \fBpushd\fR, \fBpopd\fR diff --git a/soar-8.5.2/doc/man/tsi.n b/soar-8.5.2/doc/man/tsi.n new file mode 100644 index 0000000..a34561a --- /dev/null +++ b/soar-8.5.2/doc/man/tsi.n @@ -0,0 +1,173 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS TclSoar-Interface soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +Soar TSI: TclSoar Interface + +.SH DESCRIPTION + +The TSI provides a graphical user interface for interacting with Soar. +It is based on ideas from Frank Ritter's DSI, and the SCA2 work done +by Doug Pearson. The Soar Command Line Interface window is +essentially the one produced by Randy Jones as a development of Karl +Schwamb's original GUI for Soar. +.PP +The TSI consists of a set of optional windows that include: +.PP + +.TP +1. +A control panel to provide easy access to the basic functions that +are necessary or useful to run a Soar model. It also supports running +multiple Soar agents at the same time. +.TP +2. +An interaction window for Soar, providing equivalent functionality +to the old command line interface, but with a set of menus and buttons +available. +.TP +3. +A display of the match set of rules about to fire. +.TP +4. +A continuous display of the current state of the goal stack. +.TP +5. +A print window that supports the examination of objects selected +by the user. (The user either presses p, or double clicks with the +middle mouse button once an object has been selected.) + +.PP +The TSI is normally found in the \fB$soar_library\fR directory (folder), +but can be moved anywhere, provided the global variable, tsi_library, +is properly and accurately defined when running Wish. However, if +the TSI is moved, it's possible (likely) that it will not be able to +find the Soar help files or Soar demo files. Users should become +quite familiar with the TSI code before trying to move it to another +location. In \fB$tsi_library\fR is the main "tcl library" of code that +implements the TSI. All tsi commands will be autoloaded from this +directory or folder (assuming your tcl interpreter knows where this +directory or folder is). See the file "start-soar.tcl" in the +top-level directory of the Soar distribution for more information +on what needs to be defined when starting Soar. + + +Comments, questions, suggestions and discussions relevant to the +TSI should be sent to \fIsoar-tsi@umich.edu\fR. + + +.SH LOADING THE TSI + +Since Soar version 7.2, the TSI has been packaged with the Soar distribution. +It will be invoked if Soar is started using the "start-soar.tcl" script +found in the top-level directory (folder) of the Soar distribution. +The "start-soar.tcl" script defines the $tsi_library variable and adds +it to the auto_path so that the TSI commands are automatically available +in Soar. + +.SH MODIFYING THE TSI +Users can change some settings for the TSI by creating their own +tsi-defaults.tcl file. +Users wishing to further modify the TSI, are encouraged to create a +new folder or subdirectory in the $soar_library folder, and copy +the TSI files into the new folder, and then redefine the $tsi_library +variable. That way there will always be a distribution copy of the TSI, +and there will be less confusion if the modified TSI is sent to +other Soar users or TSI developers. If the working copy +of the TSI is moved out of the $soar_library location, the TSI may not be +able to find the Soar help pages or the Soar demos, unless it is +specifically modified to look in the proper locations. + +.SH FILES + +Unless otherwise noted, all files listed below are found in the +library/tsi* directory (folder). + +.TP +README +Description of the TSI, similar to this man page +.TP +tsi-defaults.tcl +This specifies some default values for the configuration of the TSI. +To override the defaults, you can make a file named tsi-defaults.tcl +in the directory or folder from which you run Soar, and specify the +values you want to override. +.TP +tsiInit.tcl +Provides the hooks to start up the TSI and to create +new agent (and other) interpreters. +.TP +tsiControlPanel.tcl +Creates a simple control panel to drive Soar. +Allows the creation of mutiple Soar agents. +.TP +tsiDialogs.tcl +A set of "standard" dialogs for user interaction. +.TP +tsiPopUp.tcl +Implements PopUp menus for interacting with Soar. +.TP +termText.tcl +A simple terminal widget for tcl/tk (which the TSI agent windows use). +.TP +tsiAgentText.tcl +Enhancements to termText for Soar agents +.TP +tsiAgentWindow.tcl +Implements a window for interacting with Soar agents. +Uses tsiAgentText for the main window, and adds a +bunch of menus, buttons, and whirligigs. +.TP +tsiUtils.tcl +A collection of utilities supporting the interface, +including agent windows as well as other types +of windows (such as monitor windows). +.TP +tclIndex +This file is used by Tcl to autoload various TSI +commands and procedures. Do not mess with it or +move it (unless you are making enhancements to the +TSI code and know what you are doing). +.TP +tsi/demos subdirectory or subfolder: +This directory or folder contains a few Soar programs +that make use (to varying degrees) of some of the +features in the TSI. The TSI code assumes that +this demos directory (folder) is a subdirectory +(subfolder) of the directory (folder) holding the main +TSI code. If you move this directory or folder +somewhere else, or rename it, the menus for selecting +these demo programs will probably fail to function. +.PP +.RS +TSI Demo programs: (for Soar 7; won't work in Soar8) + analogy.s7 + analogy.topspace.s7 + analogy.toptwo.s7 + default.s7 + ht.s7 + ht2.s7 +.RE +.TP + ../../demos +The Soar distribution demos that get loaded into +the TSI "Demos" pulldownMenu when in Soar8 mode. +.TP + ../../demos_soar7 +The Soar distribution demos that get loaded into +the TSI "Demos" pulldownMenu when in Soar7 mode. +.TP +start-soar.tcl +This file is located in the top level of the Soar distribution. It +defines soar_library and tsi_library, appends them to the Tcl auto_path, +and starts the TSI. + + + + + + diff --git a/soar-8.5.2/doc/man/unalias.n b/soar-8.5.2/doc/man/unalias.n new file mode 100644 index 0000000..fb8756d --- /dev/null +++ b/soar-8.5.2/doc/man/unalias.n @@ -0,0 +1,23 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS unalias soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +unalias \- Remove a Soar alias +.SH SYNOPSIS +\fBunalias\fR \fIname\fR +.BE + +.SH DESCRIPTION +.PP +This command removes an existing alias named \fIname\fR. This +command simply removes the definition of the associated procedure +called \fIname\fR. If no alias named \fIname\fR exists, an error +message is printed. + +.SH SEE ALSO +\fBalias\fR + diff --git a/soar-8.5.2/doc/man/variables.n b/soar-8.5.2/doc/man/variables.n new file mode 100644 index 0000000..21b2a78 --- /dev/null +++ b/soar-8.5.2/doc/man/variables.n @@ -0,0 +1,69 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS variables soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +Soar variables + +.SH DESCRIPTION +.PP +There are a number of Soar variables that influence the +behavior of Soar. These variables are given default values, +which can be changed using the Tcl \fIset\fR command. However, unlike +normal Tcl variables, Soar variables do have an enforced +type and can not be unset. +.PP +The defined Soar variables are: +.RS +.TP +\fBattribute_preferences_mode\fR [0|1|2] +The "attribute_preferences_mode" variable is used to control the +handling of preferences (other than acceptable and reject preferences). +.TP +\fBdefault_wme_depth\fR [0|1|2] +The "default_wme_depth" variable is used to control the +default printing depth of the \fBprint\fR command. +.TP +\fBmax_chunks\fR [positive integer] +The "max_chunks" variable controls the maximum number of chunks +that can be created in a single decision cycle. +.TP +\fBmax_elaborations\fR [positive integer] +The "max_elaborations" variable controls the maximum number of +elaborations allowed in a single decision cycle. +.TP +\fBmax_nil_output_cycles\fR [positive integer] +The "max_nil_output_cycles" variable controls the maximum number of +consecutive nil output cycles allowed when run-til-output-generated +(or \fIrun out\fR) is used. +.TP +\fBo_support_mode\fR [0|1|2] +The "o_support_mode" variable is used to control the +way o-support calculations are done for the agent. +.TP +\fBreal_time_per_decision\fR [positive integer] +The "real_time_per_decision" variable controls the minumum amount +of time that Soar will take to complete a decision cycle (in milliseconds). +A decision cycle may take longer if Soar is still working. +The compiler option REAL_TIME_BEHAVIOR must be enabled for this variable. +.TP +\fBsave_backtraces\fR (boolean) +The "save_backtraces" variable enables and disables the saving +of backtracing information. It must be on for the \fIexplain-backtraces\fR +command to provide backtracing information. +.TP +\fBwarnings\fR (boolean) +This "warnings" variable enables and disables the printing of +warning messages. +.PP +.RE + +.SH SEE ALSO +\fBset\fR \fB attribute_preferences_mode\fR \fBdefault_wme_depth\fR +\fBmax_chunks\fR \fBmax_elaborations\fR \fBmax_nil_output_cycles\fR +\fBo_support_mode\fR \fBreal_time_per_decision\fR \fBsave_backtraces\fR +\fBwarnings\fR + diff --git a/soar-8.5.2/doc/man/version.n b/soar-8.5.2/doc/man/version.n new file mode 100644 index 0000000..5a9f17c --- /dev/null +++ b/soar-8.5.2/doc/man/version.n @@ -0,0 +1,26 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS version soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +version \- Soar version +.SH SYNOPSIS +\fBversion\fR +.BE + +.SH DESCRIPTION +.PP +This command gives information about the current Soar version +being run. It returns the version number itself, which can +then be used in any Tcl expression. + +.SH EXAMPLE +The following is a test that will be true for any version of Soar +that is at least 8.0 or higher. +.DS +\fBif {[version] > 8.0} {\fR ... +.DE + diff --git a/soar-8.5.2/doc/man/viSTEAM.n b/soar-8.5.2/doc/man/viSTEAM.n new file mode 100644 index 0000000..db58f38 --- /dev/null +++ b/soar-8.5.2/doc/man/viSTEAM.n @@ -0,0 +1,16 @@ +'\" +'\" Soar man page +'\" In prep....copy new versions to ~/soar-7.0.4/doc/man/ +'\" +.so man.macros +.HS viSTEAM soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +viSTEAM \- Embryonic visual environment for developing Soar productions +.SH SYNOPSIS +\fBviSTEAM\fR +.BE + +.SH DESCRIPTION +.PP diff --git a/soar-8.5.2/doc/man/vt.n b/soar-8.5.2/doc/man/vt.n new file mode 100644 index 0000000..3d6df68 --- /dev/null +++ b/soar-8.5.2/doc/man/vt.n @@ -0,0 +1,151 @@ +'\" +'\" Soar man page +'\" In prep....copy new versions to ~/soar-7.0.4/doc/man/ +'\" +.so man.macros +.HS vt soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +vt.tcl \- Embryonic visual environment for developing Soar productions +.SH SYNOPSIS +\fBsource vt.tcl\fR +.BE + +.SH DESCRIPTION +.PP +By sourcing \fIvt.tcl\fR in wish or a soartk environment, a visual environment +for writing Soar productions is launched. The intention is to provide a set of +useful tools for writing syntactically correct productions, for example by +providing a suite of tools dedicated to bracket checking. Compatability with +other productions in a ruleset is provided by automatically parsing a sourced +ruleset and producing a navigable tree of attribute value pairs. Such a +facility also supports a user attempting to trace the 'execution path' through +a ruleset. +.PP +In addition to primitive and general tools, a set of extensions are provided +for writing STEAM compatible productions. +.PP +.SH USAGE +.PP +The best way into the environment is to start a \fIsoartk\fR shell in the +viSTEAM directory and type \fBsource vt.tcl\fR. The user will then be +lead through a series of dialogues that reflect the base interpreter. +A quick tutorial through the main features of viSTEAM can be found in the man +page \fBvtutor\fR. +.PP +The viSTEAM environment is based around a text editor. The top menu-bar +provides usual options as regards file, editing and Help options, as well as +options that are specific to the environment (Soar, Builder and Components). +Directly below the menu bar is a toolbar with options to clear the text +window, search for text within the text window or send the code within the +text window to a Soar interpreter for validation. Underneath the text window +is a second toolbar that implements the bracket checking facilities: +.PP +.SH MENUBAR OPTIONS +.PP +\fISoar\fR - this menu is used to open a window onto a Soar interpreter. +.PP +\fIBuilder\fR - this menu is used to select application specific, menu driven +code generators. +.PP +\fIComponents\fR - this menu is used to select typical, frequently encountered +Soar code structures (\fBSkeletons\fR) or project specific attribute-value +structures (\fBa-v pairs\fR - NB this needs overhauling and is currently a +throwback to some test code in an earlier version of this environment...). +.PP +.SH BRACKET CHECKING +.PP +The Bracket-checking toolbar offers several options: +.PP +\fIDoCount\fR - applies bracket-checking...mismatched or unclosed/unopened +brackets will be highlighted individually in pink, and the line in which they +appear will be highlighted in yellow. +.PP +\fIComplement\fR - by selecting a single bracket of a well formed pair, use of +the Complement option will highlight the contents of the pair in pink. +.PP +\fIPairedBy\fR - similar to Complement, altough any bracket (paired or +mismatched) may be selected and complement will find the first bracket that +matches it, highlighting all text in between in pink. +.PP +\fINext\fR - extends PairedBy; after choosing PairedBy, Next will identify +the next, next but one etc matching bracket. +.PP +.SH Soar OPTIONS +.PP +The interface to a Soar intepreter is provided by a \fIProduction Inspector\fR +window. The Production Inspector code may be loaded independently of viSTEAM +into a Soar interpreter, but it also forms an integral part of the viSTEAM +environment. For example, pull down the Soar menu and select \fIagSTEAM...\fR. +This launches the Production Inspector within the automatically launched Soar +agent interpreter, agSTEAM. (NB ideally, the Production Inspector should be +able to inspect the contents of an arbitrarily selected interpreter). +The Production Inspector lists all the productions loaded in an interpreter in +a scrollable listbox. Clicking on a produciton name highlights it, and its code +may then be viewed in the Production Inspector text window by clicking on the +\fBView Selected Production\fR button. The code that appears in this window +may be sent to the text editor of the main viSTEAM window for editing +(although note that at the moment code in the viSTEAM text editor may only be +sent to the testbed interpreter). Additional files may be sourced into the +interpreter overlooked by the Production Inspector using the +\fBSource *.soar\fR button. +.PP +\fBHealthcheck\fR launches another window that provides a set of tools for +analysing the structure of the attribute-value pairs of the loaded ruleset. +.PP +\fBA-V count\fR has a go at building the attribute-value tree that is +described implicitly within the loaded ruleset. Once this command has been +issued, it is possible to employ the extracted information in several ways: +.PP +\fBView A-V\fR - allows the user to view the attributes or values that appear +as instances in the ruleset less than or equal to the number of times on the +button; \fIall\fR allows all attributes, or values, to be viewed. +.PP +\fBMore\fR - having displayed a list of attributes or values, one may be +highlighted and by selecting the More option, the productions in which it +appears (whether on the lhs or rhs) may be identified. Recall that selecting +the appropriate production in the Production Inspector window allows its code +to be displayed there. +.PP +\fBAV Tree\fR - this option produces a cascded series of tear off menus that +correspond to the attribute value tree extracted from the ruleset. This may be +very deep so an alternative way of navigating is also provided - +.PP +\fBAV list\fR - launches a window to allow navigation of an attribute-value +tree using a listbox. This code is still a bit dodgy, but it's a start...(e.g. +Add attribute/value haven't been implemented yet, tree climbing is a bit iffy). +Selecting an item in the list box and pressing \fBView Selected\fR displays +the child attributes (or value options) of an attribute. Viewing \fB..\fR goes +back up to the parent. The descent of the tree should be displayed in the +bottom list box. The intention is that 'Use Selection' will allow a selected +element of the lower listbox to be pasted into the viSTEAM text editor window. +.PP +.SH Builder OPTIONS +.PP +The Builder options are used to launch guis that accelerate the production of +frequently encountered code constructs in STEAM. +.PP +\fBAgents\fR - used to launch GUIs for constructing either single agents or a +team of uniform (individual) agents. Following either selection, the user is +prompted for an agent name. A dialogue is then provided for setting various +attributes of the agent. +Under the \fICreate Team\fR option, the user may specify how many team members +are required (currently limited to the range (2..4 for no good reason). By +issuing the \fIBuild team\fR command, a team is constructed and the defining +code may then be produced automatically. An option to save the code that +defines individual team-members to separate files is then provided, (although +at the moment all that happens here is the generation of sample code for a +single agent within a dedicated text window). +\fBOperators\fR - used to elaborate an operator with a functional model +(although at the moment it only really supports the production of actual +models). +\fBComms\fR - used to generate certain characteristics of a selected comms +channel. + + + + + + + diff --git a/soar-8.5.2/doc/man/vtutor.n b/soar-8.5.2/doc/man/vtutor.n new file mode 100644 index 0000000..211a3cc --- /dev/null +++ b/soar-8.5.2/doc/man/vtutor.n @@ -0,0 +1,115 @@ +'\" +'\" Soar man page +'\" In prep....copy new versions to ~/soar-7.0.4/doc/man/ +'\" +.so man.macros +.HS vtutor soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +viSTEAM (Tutorial) \- A quick run through the major features of an embryonic +visual environment for developing Soar productions and essential STEAM rules. +.SH SYNOPSIS +\fBsource vt.tcl\fR +.BE +.PP +.SH TUTORIAL +.PP +.TP +1. Set pathnames as required in prefs.tcl. Only the VS_DIR variable is essential. +.TP +2. cd to the directory containing the viSTEAM code and launch soartk; when in Soar, source vt.tcl +.TP +3. If Soar is not v7.0.4 you should be prompted about whether Soar is available - hit \fBYes\fR. +.TP +4. If a STEAM directory path is provided, a prompt to load STEAM extensions is now offered. This starts a Soar interpreter and loads the STEAM rules into it from a user specified directory - if it does appear (i.e. you have set env(STEAM_1pt1_DIR)), hit \fBNo\fR. +.TP +5. You are now asked whether STEAM prototypes are required - hit \fBYes\fR. +.TP +6. The viSTEAM main window (the \fIEditSoar\fR)should now have appeared, with some familiar and not so familiar menu bar options. There are also two toolbars, one directly above and one directly below the main text editing window (the \fIcode window\fR). (Some info about what's what appears in the man page \fBvt\fR - the purpose here is to provide a quick run through, so there'll only be a minimum of explanation...;-). +.TP +7. Goto \fBBuilder\fR on the menu bar and select \fBAgents\fR. +.TP +8. Select \fBCreate Team...\fR. +.TP +9. You will now be prompted for a team-name - choose one (testteam herein). +.TP +10. A team builder dialogue is now presented. Play with the settings (note that the characteristics of the chosen comms channel may be manipulated via the \fBDetails...\fR option of the comms channel selection or the \fBComms...\fR option of the \fBBuilder\fR menu). When playing's done, hit \fBBuild team...\fR. This creates a team based on the information provided. +.TP +11. You are now in a position to automatically generate some code - hit \fBGenerate Soar Code...\fR. The code window should be filled with Soar code... +.TP +12. A prompt appears to \fISave agent code?\fR - hit \fBYes\fR. A sample of the code for a single team agent is presented in a new text window. Appropriate code for each team member may be saved to independent files by pressing \fBSave agent code\fR; this has a side effect of closing the example agent code window. +.TP +13. Save the code appearing in the code window by using the \fBSave\fR option of the \fBFile\fR menu. Close the teambuilder window (\fBClose\fR). Now build an operator from the \fBOperators\fR option of the \fBBuilder\fR menu, and generate the soar code. +.TP +14. To prove the code is valid, we'll now send it to a soar agent interpreter (in this case agTestbed, which is provided as a default). This may be directly by dropping down the \fBSend code to...\fR menu and choosing \fBagTestbed\fR. This launches a Production Inspector window. +.TP +15. The name of the production sent to agTestbed should appear in the Production Inspector listbox. (The listbox contains a list of Soar productions in the interpreter, so if the name appars there, the production is well formed). Selecting the production name and clicking on \fIView Selected sp\fR will display the production code. Code for a selected production by be sent to the \fIEditSoar\fR by means of the \fBCopy code to viSTEAM\fR button (clear the text in the \fIEditSoar\fR by clicking on \fBClear\fR in the top toolbar of that main window, and then send code to it from the Production Inspector...) +.TP +16. .soar rulefiles may be loaded directly into the current interpreter from the \fBFile\fR menu (\fBSource *.soar\fR). If several files are to be sourced, and a load.soar, soar.soar or {current-interpreter}.soar file exists in a directory in order to manage the sourcing of files within that directory, it may sourced automatically by selecting \fBFile.Source ruleset\fR and entering the appropriate directory path. +.TP +17. Now for something that helps with debugging if the ruleset isn't too large, but is large enough to be interesting ;-). From the Production Inspector menubar, select \fBView\fR and thence \fBHealthcheck\fR. Yet another window appears, in which we can look at the attribute-value structure of the loaded ruleset. +.TP +18. Goto the \fBOptions\fR menu and choose \fBA-V count\fR. (If TSI is available, it may be launched in the current interpreter from the \fBTSI\fR option). A bit of chugging ensues as the loaded productions are (badly) parsed; a shortform version of the avtree is automatically saved as a \fB.avp\fR file. Lots of options are now available from the \fBView\fR menu. +.TP +19. Goto the \fBView\fR menu and select the \fBView A_V\fR option. This allows you to look at the attributes or values that appear in the loaded ruleset less than or equal to a user selected number of times; the idea is to try and track down typos by identifying attributes or values that only appear once or twice in the whole ruleset. Select \fBAttr\fR. +.TP +20. Having loaded a list of attributes, the productions in which they appear may now be identified. Select an item in the listbox and press the \fBRelated sp...\fR button. By selecting one of the production names, its code may be viewed with the \fBView Production\fR button on the toolbar at the bottom of the window. +.TP +21. Particular \fIproblem-spaces\fR and \fIoperators\fR used within the ruleset may be identified directly using the appropriate options from the \fBView\fR menu. Selecting a particular \fIproblem-space\fR or \fIoperator\fR name and clicking on \fBRelated sp...\fR identifies the productions which propose and exploit (and terminate in the case of \fIoperators\fR) the name. For the single production example used here, this is not very interesting. +.TP +22. From the menubar select \fBAV Tree\fR. This depicts the full \fIavtree\fR of the loaded ruleset as a series of cascaded menus. Wander up and down the tree. This structure (hopefully) reflects the structure inherent within the loaded productions. +.TP +23. Using \fBAV Tree\fR from the menu bar can be quite scary when the ruleset is large, so an alternative way of viewing the \fIavtree\fR is using the \fBAV Tree\fR option from the \fBView\fR menu. This opens a text window (and also saves a tabulated .avt file) containing the \fIavtree\fR. The tree may be searched for particular attributes/values using the toolbar at the bottom of the window. Close the \fBAV Tree Viewer\fR window. A related tool, OpHelia, (available from the \fIHealthcheck\fR menu \fBView.Operator Hierarchy\fR) tries to generate an operator hierarchy based on analysis of operator.names that appear in the rhs of a production whose lhs contains a specific operator or problem-space name. Again, for the single production example used here, this is not very interesting/ +.TP +24. Rather more flexibility in navigating the \fIavtree\fR is provided from the \fBAV List\fR option of the \fBView\fR menu: the screen gets ever more cluttered with a \fBNavigate Project\fR window. Select the item \fIcommand\fR in the list box of this window and hit \fBTraverse Path\fR. Do the same for \fIgroup\fR. In this way the avtree may be scaled and a history appears in the middle frame; selecting one of these items (for example, \fI^command.group\fR) and pressing \fBUse Selection\fR pastes the selected item at the current cursor position in the main \fIEditSoar\fR code window (the idea is to minimise the likelihood of generating typos whilst writing Soar productions; a similar facility is available in the \fEditSoar\fR directly, as will be demonstrated later). The avtree may be climbed by selecting \fI..\fR and traversing the path. +.TP +25. With \fI^command.group\fR still selected, click on \fBIdentify Prods\fR. In the lower frame appears the names of all productions that include the selected structure, distributed howsoever throughout the production (so for example, a search on \fI^a.b c\fR would actually be made over \fI^a.b.c d -->\fR, \fI^a.b --> ^c d\fR, \fI^a --> ^b.c d\fR and \fI --> ^a.b.c d\fR, appropriately formed of course. +.TP +26. Click on \fBAdvanced Search\fR. The new window may be used to filter the productions identified as containing \fI^command.group\fR with respect to particular \fI^operator.name\fR or \fI^problem-space.name\fR values. So for example, if you want to know whether \fI^command.group\fR appears in a production associated with a particular operator, click on the operator in the left hand box of the operator frame of the \fBFiltered Search\fR window, \fBAdd\fR it to the filter set, reselect \fI^command.group\fR in the \fBNavigate\fR window, then press \fBIdentify Prods\fR in the \fBFiltered Search\fR window. NB operators are selected for filtered search via listboxes; problem spaces are selected using checkbuttons. This reflects an assumption that there will be few problem spaces and many operators. Cancel the \fBFiltered Search\fR window and close the \fBNavigator\fR window. +.TP +27. \fBClose\fR the Production Healthcheck window. \fBClose\fR the Production Inspector window. In the main viSTEAM window, clear the code window (\fBClear\fR on the toolbar directly above the code window. +.TP +28. Drop the \fBComponents\fR menu and and goto \fBav-pairs\fR; this leads to a series of cascded menus that allows you to exploit an avtree. Only take \fIcascade\fR options at this point. Note that two projects are available from the \fBav-pairs\fR menu, soar (a default) and (a reduced form of) STEAM (which was loaded). Goto \fBFile\fR, \fBProject\fR, \fBLoad *.avp\fR and hit return when presented with the request for a filename, taking the default (agTestbed.avp, which we previously saved). Returing to \fBav-pairs\fR, there is now an \fBagTestbed\fR option, which cascades into the avtree for the production we generated earlier. +.TP +29. Withing the first \fBav-pairs\fR cascade is an option to \fBAdd project...\fR. Take it and accept the default name. It should now appear as an option on the \fBav-pairs\fR menu. +.TP +30. The current project in the \fIEditSoar\fR is given by the menu in the top left hand corner of the window (it should be set to \fBsoar\fR. Change this to \fBtestproj\fR. ***at the moment, agTestbed is not a viable option because its avtree lacks 2 essential branches - \fIproblem-space.name\fR and \fIoperator.name\fR; these may, however, be added by the user as we shall see*** +.TP +31. Goto \fBComponents\fR on the menubar and select \fBSkeletons\fR, then \fBPropose op...\fR. Give it a name (no angle brackets), such as \fBtestop\fR.\fBCore lhs...\fR. Give the production a name and hit return. Core code for this production appears in the text window, and the operator name is appended to the list of possible name values within the av-pairs.testproj.operator.name menu. +.TP +32. Place the cursor between \fI\fR) and \fI^problem-space\fR. Goto \fBComponents\fR, \fBav-pairs\fR, \fBsteam\fR, \fB^agent\fR, \fBapproach-to-coordination\fR, \fB*cautious*\fR, \fBg.parent\fR, (a bit laborious, I know). This inserts the code for \fI^agent.approach-to-coordination *cautious*\fR. Play at will...(the sense is that \fBparent\fR would give \fI^approach-to-coordination *cautious*\fR, \fB*cautious*\fR would print \fI*cautious*\fR, \fBg.g.parent\fR would give \fI^great.grand.parent me\fR etc. +.TP +33. Attributes and values may be added as required (\fBAdd...\fR) to particular avtrees from within the av-pairs.whatever-proj cascade. For example, goto \fBav-pairs.testproj.Add ^attr \fR, and name the attribute \fItestattribute\fR(or whatever). This means we want to add an attribute that will point to other attributes. Goto \fBav-pairs.testproj.^testattribute.Add ^attr const...\fR and name this one \fItest2attribute\fR (or whatever). Finally, goto \fBav-pairs.testproj.^testattribute.test2attribute.Add value...\fR to add constant values. The new avtree may be saved from the \fBFile.Project.Save a-v\fR menu, as a \fI.av\fR file. +.TP +34. Now for the bracket checking tools (NB a colour monitor is required)... Delete a single bracket somewhere in the production code (NB the delete key removes stuff to the *right* of the cursor...). On the toolbar below the code window, press \fBDoCount\fR...chug, chug, chug...The line containing the unmatched bracket will be highlighted, as will the unmatched bracket. +.TP +35. Select the unmatched bracket, and press \fBPaired By\fR. The first bracket that complements the unmatched one will be highlighted, as will all the intervening characters. Pressing \fBNext\fR goes to the next complementary braket etc. Replace the missing bracket. +.TP +36. Select a matched bracket and press \fBComplement\fR. This highlights the code within the well formed pair. \fBClear\fR the code window. If \fBSoar extensions\fR are enabled (via the \fBPreferences\fR menu on the bottom toolbar) then some additional checks are made to the Soar code (e.g. (^attr val) would be signalled as an error because of touching >^). +.TP +37. Goto \fBFile\fR and select \fBExit\fR. + +.PP +Here ends the quick run through the major features of viSTEAM. Comments, project funding etc to \fBTony.Hirst@port.ac.uk\fR please. See also \fIhttp://www.dcs.port.ac.uk/~hirsta"\fR + +You may want to have another run through now using a ruleset (100 to 200 prods, say) of your own: +.TP +a) Launch visteam in its home directory, refusing steam options; +.TP +b) Goto \fBSoar-->New..." and give it a name (\fImyproj\fB); +.TP +c) Goto \fBSoar-->myproj\fR; +.TP +d) From the \fIProduction Viewer\fR menubar, goto \fBFile-->Source ruleset\fR and give it the name of a directory that contains a load.soar file to manage the loading of lots of soar files within that directory; +.TP +e) Goto \fBView-->Healthcheck\fR; +.TP +f) From the \fIHealthcheck\fR menubar, goto \fBOptions-->A-V Count\fR; +.TP +g) Play with the options from the \fBView\fR menu. + +.PP +Mail me with questions, suggestions, bugs etc. +Tony.Hirst@port.ac.uk + diff --git a/soar-8.5.2/doc/man/wake-from-attention-lapse.n b/soar-8.5.2/doc/man/wake-from-attention-lapse.n new file mode 100644 index 0000000..879aaf6 --- /dev/null +++ b/soar-8.5.2/doc/man/wake-from-attention-lapse.n @@ -0,0 +1,30 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS wake-from-attention-lapse +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +wake-from-attention-lapse \- primarily intended to be called from the RHS of a production rule +.SH SYNOPSIS +\fBwake-from-attention-lapse +.BE + +.SH DESCRIPTION +.PP +This command is primarily intended to be called from the RHS of a +production rule. This sets the "attention-lapsing" variable to FALSE (0), +and starts tracking the amount of real time that has passed since +the last lapse. + +.PP +.SH WARNINGS +The compile time options \fR REAL_TIME_BEHAVIOR\fI and \fRATTENTION_LAPSE\fI +must be enabled for this functionality. +.PP + + + +.SH SEE ALSO +\fRattention-lapse\fI \fRstart-attention-lapse\fI \fBvariables\fR diff --git a/soar-8.5.2/doc/man/warnings.n b/soar-8.5.2/doc/man/warnings.n new file mode 100644 index 0000000..81e5257 --- /dev/null +++ b/soar-8.5.2/doc/man/warnings.n @@ -0,0 +1,35 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS warnings soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +warnings \- Enable/Disable Soar warnings +.SH SYNOPSIS +\fBset warnings \fR[\fBon\fR | \fBoff\fR] +.BE + +.SH DESCRIPTION +.PP +\fBwarnings\fR is a Soar variable which through the Tcl \fIset\fR command, +enables and disables the printing of warning messages. +If an enabling or disabling \fIstatus\fR of \fBon\fR or \fBoff\fR +is given, then the warnings are +set to that state. If no \fIstatus\fR is given, then the current +warnings status is printed. At startup, warnings are initially +enabled. If warnings are disabled using this command, then \fImost\fR +warnings are supressed since some are considered too important to +ignore. + +.SH OPTIONS +.TP +\fBon | 1\fR +Turns on all warnings (initial default) +.TP +\fBoff | 0\fR +Turns off all but critical warnings + +.SH SEE ALSO +\fBvariables\fR diff --git a/soar-8.5.2/doc/man/watch.n b/soar-8.5.2/doc/man/watch.n new file mode 100644 index 0000000..c6cc7c6 --- /dev/null +++ b/soar-8.5.2/doc/man/watch.n @@ -0,0 +1,193 @@ +'\" +'\" Soar man page +'\" +.so man.macros +.HS watch soar +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +watch \- Run-time tracing of Soar +.SH SYNOPSIS +\fBwatch\fR [\fIlevel\fR*] [-on | -off | -inc[lusive]] +.br +\fBwatch wmes\fR [-on | -off | -inc[lusive] | filter-options] +.br +\fBwatch\fR [ aliases | backtracing | loading ] [-on | -off ] +.br +\fBwatch\fR [ learning ] [-noprint | -print | -fullprint ] +.BE +.SH DESCRIPTION +.PP +The \fBwatch\fR command controls run-time tracing of Soar. +With no arguments, this command prints out the current watch +status. +The various \fIlevel\fRs are used to modify the current watch +settings. Each \fIlevel\fR can be indicated with either a number or a +named flag as follows: +.DS +0 none +1 decisions +2 phases +3 productions +4 wmes +5 preferences +.DE +.PP +The numerical arguments (0 - 5) do not take any arguments or modifiers. +They inclusively turn on all levels up to the number specified. To use +numerical arguments to turn off a level, specify a number which is +less than the level to be turned off. For instance, to turn off watching +of productions, specify "watch 2" (or 1 or 0). Numerical arguments are +provided for shorthand convenience. For more detailed control over +the watch settings, the named arguments should be used. +.PP +For the named arguments, +setting either the -\fBon\fR or -\fBoff\fR switch selectively turns on or +off only that setting. Setting the -\fBinclusive\fR switch (which can be +abbreviated as -inc) or setting no flag at all has the effect of setting +all levels up to and including the level specified. +For example, \fBwatch productions -on\fR selectively turns +on the +tracing of production firings/retractions; \fBwatch productions -off\fR +selectively turns it off again. \fBwatch productions [-inc]\fR turns on the +tracing of productions and also turns on tracing of all levels below +productions: decisions and phases, too. Individual watch parameters may +be used to modify the inclusive settings as well, selectively turning on +or off any levels outside or inside the inclusive range. + + +.SH OPTIONS +.PP +The following options are allowed (\fIstatus\fR is given as either +-\fBon\fR, -\fBoff\fR, or -\fBinclusive\fR, -\fBinc\fR is the default): +.TP +0 | \fBnone\fR +turns off all printing about Soar's internals +.TP +1 | \fBdecisions\fR \fIstatus\fR +controls whether state and operator decisions are printed as they are made +.TP +2 | \fBphases\fR \fIstatus\fR +controls whether decisions cycle phase names are printed as Soar executes. +.TP +3 | \fBproductions\fR \fIstatus\fR +\fRcontrols whether the names of +productions are printed as they fire and retract. See the +optional arguments below [-all|-chunks|-defaults|-justifications|-user] +which specify which types of productions the \fIstatus\fR argument refers to. +.TP +4 | \fBwmes\fR +controls the printing of working memory elements that are added and deleted as +productions are fired and retracted. +.PP +.DS +To improve state tracing, the following filter-options +are available to \fBwatch wmes\fR for monitoring a specified +object-attribute-value triplet: +.DS +{-add-filter \fItype filter\fR} | +{-remove-filter \fItype filter\fR} | +{-reset-filter \fItype\fR } | +{-list-filter \fItype\fR } +.DE +.PP +where: +.DS +\fItype\fR = -adds | -removes | -both +\fIfilter\fR = {\fIid\fR|*} {\fIattribute\fR|*} {\fIvalue\fR|*} +.DE +.DE +.PP +.TP +5 | \fBpreferences\fR \fIstatus\fR +controls whether the preferences +generated by the traced productions are printed when +those productions fire or retract. When a production +fires, all the preferences it generates are printed. +When it retracts, only the ones being removed from +preference memory are printed (i.e., the i-supported ones). +.TP +\fB-nowmes | -timetags | -fullwmes\fR +controls the level of detail given about the wmes matched by productions +whose firings and retractions are being traced. Level 0|-nowmes means no +information about the wmes is printed. Level 1|-timetags means the wme +timetags are printed. Level 2|-fullwmes means the whole wmes are printed. +.TP +\fB-all|-default|-user|-chunks|-justifications\fR \fI[modifier]\fR +allows user to selectively control printing by production *type* +as they fire and retract, instead of having to watch ALL productions +or none. (NOTE: these args can be abbreviated by the first +char ONLY, otherwise the full arg must be specified.) +The modifier can be one of: +.DS +\fB-noprint|-print|-fullprint\fR +.DE +.PP +.DS +-noprint prints nothing, +-print prints the production name, +-fullprint prints the entire production. (not done as of 8.2) +.DE +.PP +.PP +The following options control printing of other Soar parameters and are +not part of the above set of levels which can be controlled as a group. +.TP +\fBaliases -on | -off\fR +controls the echoing of aliases as they are defined. +.TP +\fBbacktracing -on | -off\fR +controls the printing of backtracing information when a chunk or +justification is created. +.TP +\fBloading -on | -off \fR +controls the printing of '*' for each production loaded and a '#' for +each production excised +.TP +\fBlearning -noprint | -print | -fullprint +controls the printing of +chunks/justifications as they are created. -noprint is +don't print anything, -print prints just the names, +-fullprint prints the entire chunk/justification. +.PP + +.SH EXAMPLES +The most common uses of \fBwatch\fR are by using the numeric arguments +which indicate \fBwatch\fR levels: +.DS +\fBwatch 0\fR +.DE +which turns off all printing of Soar internals (same as watch none), or +.DS +\fBwatch 3\fR +.DE +which turns on printing of decisions, phases and productions (same as +watch productions). +Of course, individual options can be changed as well: +.DS +\fBwatch 1 wmes -on +.DE +turns on printing of decisions and wmes, but not phases and productions. +While +.DS +\fBwatch 4 phases -off +.DE +turns on printing of decisions, productions and wmes, and turns phases off. +.PP +To watch the firing and retraction of only USER productions: +.DS +\fBwatch productions -user -print\fR +.DE +.PP +whereas this command would watch decisions, phases and ALL productions: +.DS +\fBwatch productions\fR +.DE + + +.SH NOTE +The pwatch command is used to watch named productions. + +.SH SEE ALSO +\fBpwatch\fR, \fBprint\fR + diff --git a/soar-8.5.2/doc/man2html b/soar-8.5.2/doc/man2html new file mode 100644 index 0000000..b70810b --- /dev/null +++ b/soar-8.5.2/doc/man2html @@ -0,0 +1,44 @@ +#!/bin/sh +# filter to convert Tk and Tcl man pages to html equivalents +# does not do any linking !!!! +# +# This code taken from Mike Hopkirk's (hops@x.co.uk) w3get package, +# -- the file tk2html. + +TOP=. +AWK=/bin/nawk + +cat $1 | + sed -e 's/\\-/-/g' \ + -e 's/\\[0&]/ /g' \ + -e 's/&/\&/g' \ + -e 's//\>/g' \ + -e 's/\\|//g' \ + -e 's/\\e/\\/g' | + ${AWK} -f ${TOP}/man2html.awk | + sed -e 's^\\fB\([^\\]*\)\\fR^\1^g' \ + -e 's^\\fI\(.[^\\]*\)\\fR^\1^g' \ + -e 's^\\fB^^g' \ + -e 's^\\fI^^g' \ + -e 's^\\f[RP]^^g' \ + -e 's/^.[LP]P/

                                                                                                                                    /' \ + -e 's/^.br/
                                                                                                                                    /' \ + -e 's/^\.DS.*/

                                                                                                                                    /' \
                                                                                                                                    +        -e 's$^\.DE.*$
                                                                                                                                    $' \ + -e 's/^\.nf */
                                                                                                                                    /' \
                                                                                                                                    +        -e 's$^\.fi *$
                                                                                                                                    $' \ + -e 's$^\.BE *$
                                                                                                                                    $' \ + -e 's/^\.RS.*/
                                                                                                                                      /' \ + -e 's$^\.RE.*$
                                                                                                                                    $' \ + -e 's^\.SH *"*\([^"]*\)"*^

                                                                                                                                    \1

                                                                                                                                    ^' \ + -e 's/^\.[a-zA-Z]*.*//' + +# The above handling for font mapping to html works correctly in about 95% of +# the cases, the others turn out stacking the font setting so you get the +# font bleeding since it isn't being turned off in the correct places. +# To correct we would have to record the current ( non-default) font and +# explicitly turn it off when another font change is detected. +# Which would make multiple styles impossible concurrently which seems to +# be the case anyway.... + diff --git a/soar-8.5.2/doc/man2html.awk b/soar-8.5.2/doc/man2html.awk new file mode 100644 index 0000000..54137a0 --- /dev/null +++ b/soar-8.5.2/doc/man2html.awk @@ -0,0 +1,111 @@ +#!//bin/nawk + + +$0 ~ /'[\/\\]"/ || $1 == "'" { next } # eat [nt]roff comments + +# defining macros - eat them +/^\.de.*/ { + getline + while ( $0 !~ "^\.\.$" ) + { + getline + } + getline + } + +$1 == ".VS" || $1 == ".VE" || $1 == ".AS" { next } + + +# Convert .IP Paragraphs upto next .cmd to hanging indents +# using
                                                                                                                                      pairs without intervening
                                                                                                                                    • + +/^\.IP */ { + if ( inIP > 0 ) + { + print "" + } + inIP = 1 + print "
                                                                                                                                        " + match($0, /".*"/ ) + if ( RSTART > 0 ) + { + arg = substr( $0, RSTART+1, RLENGTH-2) + + print arg "
                                                                                                                                        " + } + else if ( length( $2 ) > 0 ) + { + print $2 "
                                                                                                                                        " + } + next + } + +$0 ~ /^\.[a-zA-Z]*/ && inIP > 0 { + inIP = 0 + print "
                                                                                                                                      " + } + +# Convert +# .TP +# Line1 +# line 2 - n +# .Any +# +# to +#
                                                                                                                                      +#
                                                                                                                                      Line1 +#
                                                                                                                                      lines 2 - n +#
                                                                                                                                      + +/^\.TP */ { + if ( inTP > 0 ) + { + print "
                                                                                                                                      " + } + inTP = 1 + print "
                                                                                                                                      " + next + } + +inTP == 1 && $1 !~ /\.[a-zA-Z]*/ { + print "
                                                                                                                                      " $0 + inTP = 2 + next + } + +inTP == 2 && $1 !~ /\.[a-zA-Z]*/{ + print "" # Belt and suspenders + print "
                                                                                                                                      " $0 + inTP = 3 + next + } + +$0 ~ /^\.[a-zA-Z]*/ && inTP > 0 { + inTP = 0 + print "
                                                                                                                                      " + } + + + +$1 == ".AP" { + $1="" + print "
                                                                                                                                      " + print "
                                                                                                                                      " $2 "\t\t" $3 "\t\t("$4")" + inTP = 2 + next + } + +# make a blank line +$1 == ".sp" { + print "
                                                                                                                                      " + next # print "
                                                                                                                                      " + } + + +$1 == ".ta" { next } + +# just pass everything else on + + { print $0 } + + diff --git a/soar-8.5.2/doc/readme b/soar-8.5.2/doc/readme new file mode 100644 index 0000000..a6286ff --- /dev/null +++ b/soar-8.5.2/doc/readme @@ -0,0 +1,28 @@ +This directory contains all the Help documention on Soar. + +To add the Soar man pages to your MANPATH, add the following command +to the end of your .cshrc file: + + setenv MANPATH ${MANPATH}:/man + +where is the full directory pathname that this +README file resides in. + +The man pages are the source for all documentation. New pages should +be added to the man directory only. The cat pages are formed by +passing each man page through "nroff -man". The html pages are formed +by passing each man page through "man2html", a program obtained from +the main Tcl Archive as tk2html. Postscript pages can be formed by +passing the man pages through "psroff". The only exception to this +translation procedure is that the file html/soar_man.html must be +updated manually for now since it is an HTML file listing the +available commands. + +The program update-man-page takes two arguments -- a conversion format +(-cat or -html) and a man page name (e.g., "sp"). It runs the above +translators to update the cat and html directories. The Perl script +"make_doc_from_C_file.pl" runs over a C file with Tcl formatted +comments and produces a set of files that contain header documentation +for functions. The script was run over an early version of the +"soarCommands.c" file to generate a set of files from which the man +pages were derived. diff --git a/soar-8.5.2/doc/update-man-page b/soar-8.5.2/doc/update-man-page new file mode 100644 index 0000000..0c4cc89 --- /dev/null +++ b/soar-8.5.2/doc/update-man-page @@ -0,0 +1,35 @@ +#!/bin/sh + +if test -n "$2"; then + files="$2" +else + files=`(cd man;ls | grep .n | sed s/\\\.n//g)` +fi + +echo Updating $files + +if [ "$1" = "-cat" ]; then + for f in $files + do + echo Updating cat form of $f + rm -f cat/$f.n + + cd man + + nroff -man $f.n > ../cat/$f.n + cd .. + done +fi + +if [ "$1" = "-html" ]; then + for f in $files + do + echo Updating html form of $f + rm -f html/$f.html + + man2html man/$f.n > html/$f.html + done +fi + + + diff --git a/soar-8.5.2/init-soar-auto-create-agent.tcl b/soar-8.5.2/init-soar-auto-create-agent.tcl new file mode 100755 index 0000000..85b6658 --- /dev/null +++ b/soar-8.5.2/init-soar-auto-create-agent.tcl @@ -0,0 +1,54 @@ +#!/usr/bin/wish + +# If you are not on a Unix system, you can ignore this block of comments. +# +# The first line of this file invokes wish on unix systems. If you +# are running Soar on a Unix system, you must edit the above line to +# reflect the full pathname of your Wish executable if it is not in +# the default location /usr/bin. +# +# If you installed ActiveTcl to its default location, the first line +# of this file should change to: +#!/usr/local/ActiveTcl/bin/wish + +# This next line is revision information for this file and can be ignored. +# $Id: init-soar-auto-create-agent.tcl,v 1.3 2004/06/28 21:51:18 rmarinie Exp $ + +## The next two lines are needed to be able to load Soar into the +## wish executable. + +set soar_library [file join [pwd] library] +set env(SOAR_LIBRARY) $soar_library + +### The next line sets the location of the Tcl-Soar Interface library. +### If you are not using the TSI, you can comment this line. +set tsi_library [file join [file join [pwd] ..] tsi-4.0.1] + +#### This line tells Tcl where it can find the Soar sharable library. +#### It also indicates where the TSI is, you can leave $tsi_library off +#### if you are not using the TSI. +lappend auto_path $soar_library $tsi_library + +##### The next line tells Soar where it can find its help files +set soar_doc_dir [file join $soar_library ../doc] + +##### This line invokes the TSI. You could invoke your own application +##### instead. If you don't want to run the TSI, and you want to +##### start a single agent, change "tsi" to "package require Soar" + +if { ![info exists batchMode] } { set batchMode off } + +if { [llength $argv] > 0 } { + set batchMode on + set batchFile [lindex $argv 1] +} + +#tsi 0 -batchMode $batchMode +tsi + +if { [string match "on" $batchMode] } { + source $batchFile + +} + +createNewAgent "" [pwd] "" \ No newline at end of file diff --git a/soar-8.5.2/init-soar.tcl b/soar-8.5.2/init-soar.tcl new file mode 100755 index 0000000..fe80879 --- /dev/null +++ b/soar-8.5.2/init-soar.tcl @@ -0,0 +1,52 @@ +#!/usr/bin/wish + +# If you are not on a Unix system, you can ignore this block of comments. +# +# The first line of this file invokes wish on unix systems. If you +# are running Soar on a Unix system, you must edit the above line to +# reflect the full pathname of your Wish executable if it is not in +# the default location /usr/bin. +# +# If you installed ActiveTcl to its default location, the first line +# of this file should change to: +#!/usr/local/ActiveTcl/bin/wish + +# This next line is revision information for this file and can be ignored. +# $Id: init-soar.tcl,v 1.9 2004/06/28 21:51:18 rmarinie Exp $ + +## The next two lines are needed to be able to load Soar into the +## wish executable. + +set soar_library [file join [pwd] library] +set env(SOAR_LIBRARY) $soar_library + +### The next line sets the location of the Tcl-Soar Interface library. +### If you are not using the TSI, you can comment this line. +set tsi_library [file join [file join [pwd] ..] tsi-4.0.1] + +#### This line tells Tcl where it can find the Soar sharable library. +#### It also indicates where the TSI is, you can leave $tsi_library off +#### if you are not using the TSI. +lappend auto_path $soar_library $tsi_library + +##### The next line tells Soar where it can find its help files +set soar_doc_dir [file join $soar_library ../doc] + +##### This line invokes the TSI. You could invoke your own application +##### instead. If you don't want to run the TSI, and you want to +##### start a single agent, change "tsi" to "package require Soar" + +if { ![info exists batchMode] } { set batchMode off } + +if { [llength $argv] > 0 } { + set batchMode on + set batchFile [lindex $argv 1] +} + +#tsi 0 -batchMode $batchMode +tsi 0 + +if { [string match "on" $batchMode] } { + source $batchFile + +} diff --git a/soar-8.5.2/kernel/.BuildOptions.swp b/soar-8.5.2/kernel/.BuildOptions.swp new file mode 100644 index 0000000..3df0643 Binary files /dev/null and b/soar-8.5.2/kernel/.BuildOptions.swp differ diff --git a/soar-8.5.2/kernel/.cvsignore b/soar-8.5.2/kernel/.cvsignore new file mode 100644 index 0000000..5399abd --- /dev/null +++ b/soar-8.5.2/kernel/.cvsignore @@ -0,0 +1,10 @@ +Kernel.ncb +Kernel.plg +soarkernel.lib +Release +Debug +Makefile +config.cache +config.log +config.status +Kernel.opt \ No newline at end of file diff --git a/soar-8.5.2/kernel/.indent.pro b/soar-8.5.2/kernel/.indent.pro new file mode 100644 index 0000000..fb5067b --- /dev/null +++ b/soar-8.5.2/kernel/.indent.pro @@ -0,0 +1,3 @@ +-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 +-cp33 -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l120 -lp -npcs +-nprs -npsl -saf -sai -saw -nsc -sob -nss -nut diff --git a/soar-8.5.2/kernel/Doxyfile b/soar-8.5.2/kernel/Doxyfile new file mode 100644 index 0000000..1ba91f6 --- /dev/null +++ b/soar-8.5.2/kernel/Doxyfile @@ -0,0 +1,695 @@ +# Doxyfile 1.2.1 + +# This file describes the settings to be used by doxygen for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "The Soar Application Programming Interface" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = "8.4" + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Dutch, French, Italian, Czech, Swedish, German, Finnish, Japanese, +# Spanish, Russian, Croatian, Polish, and Portuguese. + +OUTPUT_LANGUAGE = English + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these class will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. It is allowed to use relative paths in the argument list. + +STRIP_FROM_PATH = + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a class diagram (in Html and LaTeX) for classes with base or +# super classes. Setting the tag to NO turns the diagrams off. + +CLASS_DIAGRAMS = YES + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the CASE_SENSE_NAMES tag is set to NO (the default) then Doxygen +# will only generate file names in lower case letters. If set to +# YES upper case letters are also allowed. This is useful if you have +# classes or files whose names only differ in case and if your file system +# supports case sensitive file names. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the JAVADOC_AUTOBRIEF tag is set to YES (the default) then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the Javadoc-style will +# behave just like the Qt-style comments. + +JAVADOC_AUTOBRIEF = YES + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# reimplements. + +INHERIT_DOCS = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# The ENABLE_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. + +WARN_FORMAT = "$file:$line: $text" + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ./ + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +FILE_PATTERNS = *api*.h \ + README.api \ + README.BuildOptions \ + BuildOptions \ + callback.h + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. + +INPUT_FILTER = ./doxygen_filter.pl + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimised for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = YES + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using a WORD or other. +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assigments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = YES + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. Warning: This feature +# is still experimental and very incomplete. + +GENERATE_XML = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES tag can be used to specify one or more tagfiles. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the ENABLE_PREPROCESSING, INCLUDE_GRAPH, and HAVE_DOT tags are set to +# YES then doxygen will generate a graph for each documented file showing +# the direct and indirect include dependencies of the file with other +# documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, INCLUDED_BY_GRAPH, and HAVE_DOT tags are set to +# YES then doxygen will generate a graph for each documented header file showing +# the documented files that directly or indirectly include this file + +INCLUDED_BY_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found on the path. + +DOT_PATH = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO + +# The CGI_NAME tag should be the name of the CGI script that +# starts the search engine (doxysearch) with the correct parameters. +# A script with this name will be generated by doxygen. + +CGI_NAME = search.cgi + +# The CGI_URL tag should be the absolute URL to the directory where the +# cgi binaries are located. See the documentation of your http daemon for +# details. + +CGI_URL = + +# The DOC_URL tag should be the absolute URL to the directory where the +# documentation is located. If left blank the absolute path to the +# documentation, with file:// prepended to it, will be used. + +DOC_URL = + +# The DOC_ABSPATH tag should be the absolute path to the directory where the +# documentation is located. If left blank the directory on the local machine +# will be used. + +DOC_ABSPATH = + +# The BIN_ABSPATH tag must point to the directory where the doxysearch binary +# is installed. + +BIN_ABSPATH = /usr/local/bin/ + +# The EXT_DOC_PATHS tag can be used to specify one or more paths to +# documentation generated for other projects. This allows doxysearch to search +# the documentation for these projects as well. + +EXT_DOC_PATHS = diff --git a/soar-8.5.2/kernel/Kernel.dsp b/soar-8.5.2/kernel/Kernel.dsp new file mode 100644 index 0000000..d8cbaeb --- /dev/null +++ b/soar-8.5.2/kernel/Kernel.dsp @@ -0,0 +1,332 @@ +# Microsoft Developer Studio Project File - Name="kernel" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=kernel - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Kernel.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Kernel.mak" CFG="kernel - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kernel - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "kernel - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "kernel - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir ".\Release" +# PROP BASE Intermediate_Dir ".\Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir ".\Release" +# PROP Intermediate_Dir ".\Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MT /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "USE_TCL" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:".\soarkernel.lib" + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir ".\Debug" +# PROP BASE Intermediate_Dir ".\Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir ".\Debug" +# PROP Intermediate_Dir ".\Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /MTd /W4 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "USE_TCL" /D "WINDOWS" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 +# ADD RSC /l 0x409 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:".\soarkernel.lib" + +!ENDIF + +# Begin Target + +# Name "kernel - Win32 Release" +# Name "kernel - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" +# Begin Source File + +SOURCE=.\agent.c +# End Source File +# Begin Source File + +SOURCE=.\backtrace.c +# End Source File +# Begin Source File + +SOURCE=.\callback.c +# End Source File +# Begin Source File + +SOURCE=.\chunk.c +# End Source File +# Begin Source File + +SOURCE=.\consistency.c +# End Source File +# Begin Source File + +SOURCE=.\debugutil.c +# End Source File +# Begin Source File + +SOURCE=.\decide.c +# End Source File +# Begin Source File + +SOURCE=.\explain.c +# End Source File +# Begin Source File + +SOURCE=.\init_soar.c +# End Source File +# Begin Source File + +SOURCE=.\io.c +# End Source File +# Begin Source File + +SOURCE=.\legacy.c +# End Source File +# Begin Source File + +SOURCE=.\lexer.c +# End Source File +# Begin Source File + +SOURCE=.\mem.c +# End Source File +# Begin Source File + +SOURCE=.\osupport.c +# End Source File +# Begin Source File + +SOURCE=.\parser.c +# End Source File +# Begin Source File + +SOURCE=.\prefmem.c +# End Source File +# Begin Source File + +SOURCE=.\print.c +# End Source File +# Begin Source File + +SOURCE=.\production.c +# End Source File +# Begin Source File + +SOURCE=.\recmem.c +# End Source File +# Begin Source File + +SOURCE=.\reorder.c +# End Source File +# Begin Source File + +SOURCE=.\rete.c +# End Source File +# Begin Source File + +SOURCE=.\rhsfun.c +# End Source File +# Begin Source File + +SOURCE=.\rhsfun_examples.c +# End Source File +# Begin Source File + +SOURCE=.\rhsfun_math.c +# End Source File +# Begin Source File + +SOURCE=.\scheduler.c +# End Source File +# Begin Source File + +SOURCE=.\soar_core_api.c +# End Source File +# Begin Source File + +SOURCE=.\soar_core_utils.c +# End Source File +# Begin Source File + +SOURCE=.\soar_ecore_api.c +# End Source File +# Begin Source File + +SOURCE=.\soar_ecore_utils.c +# End Source File +# Begin Source File + +SOURCE=.\soarapi.c +# End Source File +# Begin Source File + +SOURCE=.\soarapi_datatypes.c +# End Source File +# Begin Source File + +SOURCE=.\soarapiCallbacks.c +# End Source File +# Begin Source File + +SOURCE=.\soarapiUtils.c +# End Source File +# Begin Source File + +SOURCE=.\soarBuildInfo.c +# End Source File +# Begin Source File + +SOURCE=.\symtab.c +# End Source File +# Begin Source File + +SOURCE=.\sysdep.c +# End Source File +# Begin Source File + +SOURCE=.\tempmem.c +# End Source File +# Begin Source File + +SOURCE=.\timers.c +# End Source File +# Begin Source File + +SOURCE=.\trace.c +# End Source File +# Begin Source File + +SOURCE=.\wmem.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" +# Begin Source File + +SOURCE=.\callback.h +# End Source File +# Begin Source File + +SOURCE=.\debugutil.h +# End Source File +# Begin Source File + +SOURCE=.\explain.h +# End Source File +# Begin Source File + +SOURCE=.\rete.h +# End Source File +# Begin Source File + +SOURCE=.\rhsfun.h +# End Source File +# Begin Source File + +SOURCE=.\rhsfun_examples.h +# End Source File +# Begin Source File + +SOURCE=.\rhsfun_math.h +# End Source File +# Begin Source File + +SOURCE=.\scheduler.h +# End Source File +# Begin Source File + +SOURCE=.\soar_core_api.h +# End Source File +# Begin Source File + +SOURCE=.\soar_core_utils.h +# End Source File +# Begin Source File + +SOURCE=.\soar_ecore_api.h +# End Source File +# Begin Source File + +SOURCE=.\soar_ecore_utils.h +# End Source File +# Begin Source File + +SOURCE=.\soarapi.h +# End Source File +# Begin Source File + +SOURCE=.\soarapi_datatypes.h +# End Source File +# Begin Source File + +SOURCE=.\soarapiCallbacks.h +# End Source File +# Begin Source File + +SOURCE=.\soarapiUtils.h +# End Source File +# Begin Source File + +SOURCE=.\soarBuildOptions.h +# End Source File +# Begin Source File + +SOURCE=.\soarkernel.h +# End Source File +# Begin Source File + +SOURCE=.\sysdep.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/soar-8.5.2/kernel/Kernel.dsw b/soar-8.5.2/kernel/Kernel.dsw new file mode 100644 index 0000000..37887ec --- /dev/null +++ b/soar-8.5.2/kernel/Kernel.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "kernel"=".\Kernel.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/soar-8.5.2/kernel/Kernel.mak b/soar-8.5.2/kernel/Kernel.mak new file mode 100644 index 0000000..edf02ef --- /dev/null +++ b/soar-8.5.2/kernel/Kernel.mak @@ -0,0 +1,1302 @@ +# Microsoft Developer Studio Generated NMAKE File, Format Version 40001 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +!IF "$(CFG)" == "" +CFG=kernel - Win32 Debug +!MESSAGE No configuration specified. Defaulting to kernel - Win32 Debug. +!ENDIF + +!IF "$(CFG)" != "kernel - Win32 Release" && "$(CFG)" != "kernel - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE on this makefile +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Kernel.mak" CFG="kernel - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "kernel - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "kernel - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF +################################################################################ +# Begin Project +# PROP Target_Last_Scanned "kernel - Win32 Debug" +CPP=cl.exe + +!IF "$(CFG)" == "kernel - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "$(OUTDIR)\soarkernel.lib" + +CLEAN : + -@erase ".\soarkernel.lib" + -@erase ".\Release\trace.obj" + -@erase ".\Release\print.obj" + -@erase ".\Release\chunk.obj" + -@erase ".\Release\tempmem.obj" + -@erase ".\Release\symtab.obj" + -@erase ".\Release\ma_interface.obj" + -@erase ".\Release\mem.obj" + -@erase ".\Release\lexer.obj" + -@erase ".\Release\decide.obj" + -@erase ".\Release\io.obj" + -@erase ".\Release\backtrace.obj" + -@erase ".\Release\main.obj" + -@erase ".\Release\interface.obj" + -@erase ".\Release\parser.obj" + -@erase ".\Release\rete.obj" + -@erase ".\Release\init_soar.obj" + -@erase ".\Release\reorder.obj" + -@erase ".\Release\callback.obj" + -@erase ".\Release\recmem.obj" + -@erase ".\Release\rhsfun_math.obj" + -@erase ".\Release\production.obj" + -@erase ".\Release\agent.obj" + -@erase ".\Release\wmem.obj" + -@erase ".\Release\explain.obj" + -@erase ".\Release\rhsfun.obj" + -@erase ".\Release\osupport.obj" + -@erase ".\Release\tilde.obj" + -@erase ".\Release\prefmem.obj" + -@erase ".\Release\scheduler.obj" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "USE_TCL" /YX /c +CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "USE_TCL"\ + /Fp"$(INTDIR)/Kernel.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Release/ +CPP_SBRS= +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/Kernel.bsc" +BSC32_SBRS= +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"soarkernel.lib" +LIB32_FLAGS=/nologo /out:"soarkernel.lib" +LIB32_OBJS= \ + "$(INTDIR)/trace.obj" \ + "$(INTDIR)/print.obj" \ + "$(INTDIR)/chunk.obj" \ + "$(INTDIR)/tempmem.obj" \ + "$(INTDIR)/symtab.obj" \ + "$(INTDIR)/ma_interface.obj" \ + "$(INTDIR)/mem.obj" \ + "$(INTDIR)/lexer.obj" \ + "$(INTDIR)/decide.obj" \ + "$(INTDIR)/io.obj" \ + "$(INTDIR)/backtrace.obj" \ + "$(INTDIR)/main.obj" \ + "$(INTDIR)/interface.obj" \ + "$(INTDIR)/parser.obj" \ + "$(INTDIR)/rete.obj" \ + "$(INTDIR)/init_soar.obj" \ + "$(INTDIR)/reorder.obj" \ + "$(INTDIR)/callback.obj" \ + "$(INTDIR)/recmem.obj" \ + "$(INTDIR)/rhsfun_math.obj" \ + "$(INTDIR)/production.obj" \ + "$(INTDIR)/agent.obj" \ + "$(INTDIR)/wmem.obj" \ + "$(INTDIR)/explain.obj" \ + "$(INTDIR)/rhsfun.obj" \ + "$(INTDIR)/osupport.obj" \ + "$(INTDIR)/tilde.obj" \ + "$(INTDIR)/prefmem.obj" \ + "$(INTDIR)/scheduler.obj" + +"$(OUTDIR)\soarkernel.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +OUTDIR=.\Debug +INTDIR=.\Debug + +ALL : "$(OUTDIR)\soarkernel.lib" "$(OUTDIR)\Debug\Kernel.bsc" + +CLEAN : + -@erase ".\Debug\Kernel.bsc" + -@erase ".\Debug\agent.sbr" + -@erase ".\Debug\interface.sbr" + -@erase ".\Debug\recmem.sbr" + -@erase ".\Debug\main.sbr" + -@erase ".\Debug\rhsfun.sbr" + -@erase ".\Debug\ma_interface.sbr" + -@erase ".\Debug\reorder.sbr" + -@erase ".\Debug\init_soar.sbr" + -@erase ".\Debug\rete.sbr" + -@erase ".\Debug\callback.sbr" + -@erase ".\Debug\io.sbr" + -@erase ".\Debug\print.sbr" + -@erase ".\Debug\osupport.sbr" + -@erase ".\Debug\wmem.sbr" + -@erase ".\Debug\scheduler.sbr" + -@erase ".\Debug\lexer.sbr" + -@erase ".\Debug\decide.sbr" + -@erase ".\Debug\tempmem.sbr" + -@erase ".\Debug\production.sbr" + -@erase ".\Debug\mem.sbr" + -@erase ".\Debug\tilde.sbr" + -@erase ".\Debug\trace.sbr" + -@erase ".\Debug\rhsfun_math.sbr" + -@erase ".\Debug\explain.sbr" + -@erase ".\Debug\parser.sbr" + -@erase ".\Debug\prefmem.sbr" + -@erase ".\Debug\symtab.sbr" + -@erase ".\Debug\chunk.sbr" + -@erase ".\Debug\backtrace.sbr" + -@erase ".\soarkernel.lib" + -@erase ".\Debug\rhsfun_math.obj" + -@erase ".\Debug\explain.obj" + -@erase ".\Debug\parser.obj" + -@erase ".\Debug\prefmem.obj" + -@erase ".\Debug\symtab.obj" + -@erase ".\Debug\chunk.obj" + -@erase ".\Debug\backtrace.obj" + -@erase ".\Debug\agent.obj" + -@erase ".\Debug\interface.obj" + -@erase ".\Debug\recmem.obj" + -@erase ".\Debug\main.obj" + -@erase ".\Debug\rhsfun.obj" + -@erase ".\Debug\ma_interface.obj" + -@erase ".\Debug\reorder.obj" + -@erase ".\Debug\init_soar.obj" + -@erase ".\Debug\rete.obj" + -@erase ".\Debug\callback.obj" + -@erase ".\Debug\io.obj" + -@erase ".\Debug\print.obj" + -@erase ".\Debug\osupport.obj" + -@erase ".\Debug\wmem.obj" + -@erase ".\Debug\scheduler.obj" + -@erase ".\Debug\lexer.obj" + -@erase ".\Debug\decide.obj" + -@erase ".\Debug\tempmem.obj" + -@erase ".\Debug\production.obj" + -@erase ".\Debug\mem.obj" + -@erase ".\Debug\tilde.obj" + -@erase ".\Debug\trace.obj" + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c +# ADD CPP /nologo /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "USE_TCL" /FR /YX /c +CPP_PROJ=/nologo /MLd /W3 /GX /Z7 /Od /D "_DEBUG" /D "WIN32" /D "USE_TCL"\ + /FR"$(INTDIR)/" /Fp"$(INTDIR)/Kernel.pch" /YX /Fo"$(INTDIR)/" /c +CPP_OBJS=.\Debug/ +CPP_SBRS=.\Debug/ +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +BSC32_FLAGS=/nologo /o"$(OUTDIR)/Kernel.bsc" +BSC32_SBRS= \ + "$(INTDIR)/agent.sbr" \ + "$(INTDIR)/interface.sbr" \ + "$(INTDIR)/recmem.sbr" \ + "$(INTDIR)/main.sbr" \ + "$(INTDIR)/rhsfun.sbr" \ + "$(INTDIR)/ma_interface.sbr" \ + "$(INTDIR)/reorder.sbr" \ + "$(INTDIR)/init_soar.sbr" \ + "$(INTDIR)/rete.sbr" \ + "$(INTDIR)/callback.sbr" \ + "$(INTDIR)/io.sbr" \ + "$(INTDIR)/print.sbr" \ + "$(INTDIR)/osupport.sbr" \ + "$(INTDIR)/wmem.sbr" \ + "$(INTDIR)/scheduler.sbr" \ + "$(INTDIR)/lexer.sbr" \ + "$(INTDIR)/decide.sbr" \ + "$(INTDIR)/tempmem.sbr" \ + "$(INTDIR)/production.sbr" \ + "$(INTDIR)/mem.sbr" \ + "$(INTDIR)/tilde.sbr" \ + "$(INTDIR)/trace.sbr" \ + "$(INTDIR)/rhsfun_math.sbr" \ + "$(INTDIR)/explain.sbr" \ + "$(INTDIR)/parser.sbr" \ + "$(INTDIR)/prefmem.sbr" \ + "$(INTDIR)/symtab.sbr" \ + "$(INTDIR)/chunk.sbr" \ + "$(INTDIR)/backtrace.sbr" + +"$(OUTDIR)\Debug\Kernel.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"soarkernel.lib" +LIB32_FLAGS=/nologo /out:"soarkernel.lib" +LIB32_OBJS= \ + "$(INTDIR)/rhsfun_math.obj" \ + "$(INTDIR)/explain.obj" \ + "$(INTDIR)/parser.obj" \ + "$(INTDIR)/prefmem.obj" \ + "$(INTDIR)/symtab.obj" \ + "$(INTDIR)/chunk.obj" \ + "$(INTDIR)/backtrace.obj" \ + "$(INTDIR)/agent.obj" \ + "$(INTDIR)/interface.obj" \ + "$(INTDIR)/recmem.obj" \ + "$(INTDIR)/main.obj" \ + "$(INTDIR)/rhsfun.obj" \ + "$(INTDIR)/ma_interface.obj" \ + "$(INTDIR)/reorder.obj" \ + "$(INTDIR)/init_soar.obj" \ + "$(INTDIR)/rete.obj" \ + "$(INTDIR)/callback.obj" \ + "$(INTDIR)/io.obj" \ + "$(INTDIR)/print.obj" \ + "$(INTDIR)/osupport.obj" \ + "$(INTDIR)/wmem.obj" \ + "$(INTDIR)/scheduler.obj" \ + "$(INTDIR)/lexer.obj" \ + "$(INTDIR)/decide.obj" \ + "$(INTDIR)/tempmem.obj" \ + "$(INTDIR)/production.obj" \ + "$(INTDIR)/mem.obj" \ + "$(INTDIR)/tilde.obj" \ + "$(INTDIR)/trace.obj" + +"$(OUTDIR)\soarkernel.lib" : "$(OUTDIR)" $(DEF_FILE) $(LIB32_OBJS) + $(LIB32) @<< + $(LIB32_FLAGS) $(DEF_FLAGS) $(LIB32_OBJS) +<< + +!ENDIF + +.c{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_OBJS)}.obj: + $(CPP) $(CPP_PROJ) $< + +.c{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cpp{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +.cxx{$(CPP_SBRS)}.sbr: + $(CPP) $(CPP_PROJ) $< + +################################################################################ +# Begin Target + +# Name "kernel - Win32 Release" +# Name "kernel - Win32 Debug" + +!IF "$(CFG)" == "kernel - Win32 Release" + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + +!ENDIF + +################################################################################ +# Begin Source File + +SOURCE=.\wmem.c +DEP_CPP_WMEM_=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_WMEM_=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\wmem.obj" : $(SOURCE) $(DEP_CPP_WMEM_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\wmem.obj" : $(SOURCE) $(DEP_CPP_WMEM_) "$(INTDIR)" + +"$(INTDIR)\wmem.sbr" : $(SOURCE) $(DEP_CPP_WMEM_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\backtrace.c +DEP_CPP_BACKT=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\explain.h"\ + ".\callback.h"\ + +NODEP_CPP_BACKT=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\backtrace.obj" : $(SOURCE) $(DEP_CPP_BACKT) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\backtrace.obj" : $(SOURCE) $(DEP_CPP_BACKT) "$(INTDIR)" + +"$(INTDIR)\backtrace.sbr" : $(SOURCE) $(DEP_CPP_BACKT) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\callback.c +DEP_CPP_CALLB=\ + ".\soarkernel.h"\ + ".\callback.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + +NODEP_CPP_CALLB=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\callback.obj" : $(SOURCE) $(DEP_CPP_CALLB) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\callback.obj" : $(SOURCE) $(DEP_CPP_CALLB) "$(INTDIR)" + +"$(INTDIR)\callback.sbr" : $(SOURCE) $(DEP_CPP_CALLB) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\chunk.c +DEP_CPP_CHUNK=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\explain.h"\ + ".\callback.h"\ + +NODEP_CPP_CHUNK=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\chunk.obj" : $(SOURCE) $(DEP_CPP_CHUNK) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\chunk.obj" : $(SOURCE) $(DEP_CPP_CHUNK) "$(INTDIR)" + +"$(INTDIR)\chunk.sbr" : $(SOURCE) $(DEP_CPP_CHUNK) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\decide.c +DEP_CPP_DECID=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_DECID=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\decide.obj" : $(SOURCE) $(DEP_CPP_DECID) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\decide.obj" : $(SOURCE) $(DEP_CPP_DECID) "$(INTDIR)" + +"$(INTDIR)\decide.sbr" : $(SOURCE) $(DEP_CPP_DECID) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\explain.c +DEP_CPP_EXPLA=\ + ".\soarkernel.h"\ + ".\explain.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_EXPLA=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\explain.obj" : $(SOURCE) $(DEP_CPP_EXPLA) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\explain.obj" : $(SOURCE) $(DEP_CPP_EXPLA) "$(INTDIR)" + +"$(INTDIR)\explain.sbr" : $(SOURCE) $(DEP_CPP_EXPLA) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\init_soar.c +DEP_CPP_INIT_=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_INIT_=\ + ".\Menus.h"\ + ".\TextEdit.h"\ + ".\Dialogs.h"\ + ".\Fonts.h"\ + ".\Events.h"\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\init_soar.obj" : $(SOURCE) $(DEP_CPP_INIT_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\init_soar.obj" : $(SOURCE) $(DEP_CPP_INIT_) "$(INTDIR)" + +"$(INTDIR)\init_soar.sbr" : $(SOURCE) $(DEP_CPP_INIT_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\interface.c +DEP_CPP_INTER=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\scheduler.h"\ + ".\callback.h"\ + +NODEP_CPP_INTER=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\interface.obj" : $(SOURCE) $(DEP_CPP_INTER) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\interface.obj" : $(SOURCE) $(DEP_CPP_INTER) "$(INTDIR)" + +"$(INTDIR)\interface.sbr" : $(SOURCE) $(DEP_CPP_INTER) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\io.c +DEP_CPP_IO_C10=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_IO_C10=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\io.obj" : $(SOURCE) $(DEP_CPP_IO_C10) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\io.obj" : $(SOURCE) $(DEP_CPP_IO_C10) "$(INTDIR)" + +"$(INTDIR)\io.sbr" : $(SOURCE) $(DEP_CPP_IO_C10) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\lexer.c +DEP_CPP_LEXER=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_LEXER=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\lexer.obj" : $(SOURCE) $(DEP_CPP_LEXER) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\lexer.obj" : $(SOURCE) $(DEP_CPP_LEXER) "$(INTDIR)" + +"$(INTDIR)\lexer.sbr" : $(SOURCE) $(DEP_CPP_LEXER) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\ma_interface.c +DEP_CPP_MA_IN=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\scheduler.h"\ + ".\callback.h"\ + +NODEP_CPP_MA_IN=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\ma_interface.obj" : $(SOURCE) $(DEP_CPP_MA_IN) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\ma_interface.obj" : $(SOURCE) $(DEP_CPP_MA_IN) "$(INTDIR)" + +"$(INTDIR)\ma_interface.sbr" : $(SOURCE) $(DEP_CPP_MA_IN) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\main.c +DEP_CPP_MAIN_=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_MAIN_=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)" + +"$(INTDIR)\main.sbr" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\mem.c +DEP_CPP_MEM_C=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_MEM_C=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\mem.obj" : $(SOURCE) $(DEP_CPP_MEM_C) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\mem.obj" : $(SOURCE) $(DEP_CPP_MEM_C) "$(INTDIR)" + +"$(INTDIR)\mem.sbr" : $(SOURCE) $(DEP_CPP_MEM_C) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\osupport.c +DEP_CPP_OSUPP=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_OSUPP=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\osupport.obj" : $(SOURCE) $(DEP_CPP_OSUPP) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\osupport.obj" : $(SOURCE) $(DEP_CPP_OSUPP) "$(INTDIR)" + +"$(INTDIR)\osupport.sbr" : $(SOURCE) $(DEP_CPP_OSUPP) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\parser.c +DEP_CPP_PARSE=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_PARSE=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\parser.obj" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\parser.obj" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)" + +"$(INTDIR)\parser.sbr" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\prefmem.c +DEP_CPP_PREFM=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_PREFM=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\prefmem.obj" : $(SOURCE) $(DEP_CPP_PREFM) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\prefmem.obj" : $(SOURCE) $(DEP_CPP_PREFM) "$(INTDIR)" + +"$(INTDIR)\prefmem.sbr" : $(SOURCE) $(DEP_CPP_PREFM) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\print.c +DEP_CPP_PRINT=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_PRINT=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\print.obj" : $(SOURCE) $(DEP_CPP_PRINT) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\print.obj" : $(SOURCE) $(DEP_CPP_PRINT) "$(INTDIR)" + +"$(INTDIR)\print.sbr" : $(SOURCE) $(DEP_CPP_PRINT) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\production.c +DEP_CPP_PRODU=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_PRODU=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\production.obj" : $(SOURCE) $(DEP_CPP_PRODU) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\production.obj" : $(SOURCE) $(DEP_CPP_PRODU) "$(INTDIR)" + +"$(INTDIR)\production.sbr" : $(SOURCE) $(DEP_CPP_PRODU) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\recmem.c +DEP_CPP_RECME=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_RECME=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\recmem.obj" : $(SOURCE) $(DEP_CPP_RECME) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\recmem.obj" : $(SOURCE) $(DEP_CPP_RECME) "$(INTDIR)" + +"$(INTDIR)\recmem.sbr" : $(SOURCE) $(DEP_CPP_RECME) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\reorder.c +DEP_CPP_REORD=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_REORD=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\reorder.obj" : $(SOURCE) $(DEP_CPP_REORD) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\reorder.obj" : $(SOURCE) $(DEP_CPP_REORD) "$(INTDIR)" + +"$(INTDIR)\reorder.sbr" : $(SOURCE) $(DEP_CPP_REORD) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\rete.c +DEP_CPP_RETE_=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_RETE_=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\rete.obj" : $(SOURCE) $(DEP_CPP_RETE_) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\rete.obj" : $(SOURCE) $(DEP_CPP_RETE_) "$(INTDIR)" + +"$(INTDIR)\rete.sbr" : $(SOURCE) $(DEP_CPP_RETE_) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\rhsfun.c +DEP_CPP_RHSFU=\ + ".\soarkernel.h"\ + ".\rhsfun_math.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_RHSFU=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\rhsfun.obj" : $(SOURCE) $(DEP_CPP_RHSFU) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\rhsfun.obj" : $(SOURCE) $(DEP_CPP_RHSFU) "$(INTDIR)" + +"$(INTDIR)\rhsfun.sbr" : $(SOURCE) $(DEP_CPP_RHSFU) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\rhsfun_math.c +DEP_CPP_RHSFUN=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_RHSFUN=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\rhsfun_math.obj" : $(SOURCE) $(DEP_CPP_RHSFUN) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\rhsfun_math.obj" : $(SOURCE) $(DEP_CPP_RHSFUN) "$(INTDIR)" + +"$(INTDIR)\rhsfun_math.sbr" : $(SOURCE) $(DEP_CPP_RHSFUN) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\scheduler.c +DEP_CPP_SCHED=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_SCHED=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\scheduler.obj" : $(SOURCE) $(DEP_CPP_SCHED) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\scheduler.obj" : $(SOURCE) $(DEP_CPP_SCHED) "$(INTDIR)" + +"$(INTDIR)\scheduler.sbr" : $(SOURCE) $(DEP_CPP_SCHED) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\symtab.c +DEP_CPP_SYMTA=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_SYMTA=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\symtab.obj" : $(SOURCE) $(DEP_CPP_SYMTA) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\symtab.obj" : $(SOURCE) $(DEP_CPP_SYMTA) "$(INTDIR)" + +"$(INTDIR)\symtab.sbr" : $(SOURCE) $(DEP_CPP_SYMTA) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\tempmem.c +DEP_CPP_TEMPM=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_TEMPM=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\tempmem.obj" : $(SOURCE) $(DEP_CPP_TEMPM) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\tempmem.obj" : $(SOURCE) $(DEP_CPP_TEMPM) "$(INTDIR)" + +"$(INTDIR)\tempmem.sbr" : $(SOURCE) $(DEP_CPP_TEMPM) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\tilde.c +DEP_CPP_TILDE=\ + {$(INCLUDE)}"\sys\Types.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\tilde.obj" : $(SOURCE) $(DEP_CPP_TILDE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\tilde.obj" : $(SOURCE) $(DEP_CPP_TILDE) "$(INTDIR)" + +"$(INTDIR)\tilde.sbr" : $(SOURCE) $(DEP_CPP_TILDE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\trace.c +DEP_CPP_TRACE=\ + ".\soarkernel.h"\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\callback.h"\ + +NODEP_CPP_TRACE=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\trace.obj" : $(SOURCE) $(DEP_CPP_TRACE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\trace.obj" : $(SOURCE) $(DEP_CPP_TRACE) "$(INTDIR)" + +"$(INTDIR)\trace.sbr" : $(SOURCE) $(DEP_CPP_TRACE) "$(INTDIR)" + + +!ENDIF + +# End Source File +################################################################################ +# Begin Source File + +SOURCE=.\agent.c +DEP_CPP_AGENT=\ + {$(INCLUDE)}"\sys\Types.h"\ + ".\soarkernel.h"\ + ".\scheduler.h"\ + ".\callback.h"\ + +NODEP_CPP_AGENT=\ + ".\ThinkCPosix.h"\ + ".\sys\times.h"\ + ".\soar_mpw.h"\ + ".\..\pc_support\gui\winstubs.h"\ + + +!IF "$(CFG)" == "kernel - Win32 Release" + + +"$(INTDIR)\agent.obj" : $(SOURCE) $(DEP_CPP_AGENT) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "kernel - Win32 Debug" + + +"$(INTDIR)\agent.obj" : $(SOURCE) $(DEP_CPP_AGENT) "$(INTDIR)" + +"$(INTDIR)\agent.sbr" : $(SOURCE) $(DEP_CPP_AGENT) "$(INTDIR)" + + +!ENDIF + +# End Source File +# End Target +# End Project +################################################################################ diff --git a/soar-8.5.2/kernel/Kernel.mdp b/soar-8.5.2/kernel/Kernel.mdp new file mode 100644 index 0000000..b6e0cb8 Binary files /dev/null and b/soar-8.5.2/kernel/Kernel.mdp differ diff --git a/soar-8.5.2/kernel/Makefile.in b/soar-8.5.2/kernel/Makefile.in new file mode 100644 index 0000000..440e0e7 --- /dev/null +++ b/soar-8.5.2/kernel/Makefile.in @@ -0,0 +1,270 @@ +# +# Makefile.in for Soar kernel of Soar 8.4 +# +# This makefile template is in two sections. The first specifies +# a set of variables whose values are defined by the configure +# script. The values found by that script are substituted in the +# placeholders which are indicated by the @...@ sequences (e.g., +# @CC@ for the C compiler). This template file is used to +# generate "Makefile" after performing the indicated substitutions. +# [If you are trying to compile this on a non-Unix system, then you +# can make the relevant substitutions without using the configure +# program.] The configure script is generated by the GNU autoconf +# utility. +# +# The second part of this makefile defines the rules for building +# the Soar kernel. +# +#----------------------------------------------------------------- +# +# Things you can change to personalize the Makefile for your own +# site (you can make these changes in either Makefile.in or +# Makefile, but changes to Makefile will get lost if you re-run +# the configuration script). +# +#================================================================= +# +# VARIABLES SET BY CONFIGURE +# +# This section of switches is defined by substitution from the +# configure script. If you are building Soar on a non-Unix +# platform, then substitute the desired switch settings for the +# @...@ placeholders. +# +# The comments for each switch are retained here to clarify their +# meanings. The example switch settings are for a sun4 w/ gcc +# compiler. + +# Set this to your favorite C Compiler that understands ANSI. +# +# CC = gcc + +CC = @CC@ + +# Set these to be whatever flags you want to pass to your compiler. +# If the flags define ANSI C behavior, be sure to set them. +CFLAGS = @CFLAGS@ -g @TCL_SHLIB_CFLAGS@ @ANSI_FLAGS@ + +# Select desired debugging and option flags. These include: +# +# -DUSE_TCL -- build Tcl/Tk version. +# -DUNIX -- compiling on UNIX system. +# -DUSE_X_DISPLAY -- use X interface to multiple agents. Use +# only if -DMULTI_AGENT_ENABLED selected +# and -DUSE_TCL NOT selected. +# +# If you don't select USE_X_DISPLAY then standard I/O will be used. +# in the soar6 binary. +# +# DFLAGS = -DUSE_TCL -DUNIX + +DFLAGS = -DUNIX @DEFS@ + +# Library entry randomizer. Not needed if using certain new +# versions of ar. +# +# RANLIB = ranlib + +RANLIB = @RANLIB@ + +#================================================================= +# +# OTHER VARIABLES +# +# SGI's make, among others, use the SHELL variable to decide +# what shell to use when executing commands in a Makefile. The +# commands below assume the Bourne shell, sh. + +SHELL = /bin/sh + +# set this to the AR flags as appropriate for your system + +AR = ar +ARFLAGS = r + + +# This contains the list of all object files in the soar library + + + +#================================================================= +# +# LIBRARIES +# + +OBJS = agent.o\ + backtrace.o\ + callback.o\ + chunk.o\ + consistency.o\ + decide.o\ + explain.o\ + init_soar.o\ + io.o\ + lexer.o\ + mem.o\ + osupport.o\ + parser.o\ + prefmem.o\ + print.o\ + production.o\ + recmem.o\ + reorder.o\ + rete.o\ + rhsfun.o\ + rhsfun_examples.o\ + rhsfun_math.o\ + symtab.o\ + tempmem.o\ + trace.o\ + wmem.o\ + debugutil.o\ + scheduler.o\ + timers.o\ + soarapi.o\ + soar_core_api.o\ + soar_core_utils.o\ + soarapi_datatypes.o\ + soar_ecore_api.o\ + soar_ecore_utils.o\ + soarapiUtils.o\ + soarapiCallbacks.o\ + soarBuildInfo.o\ + sysdep.o + +#================================================================= +# +# PRIMARY TARGETS: +# +# Pick the latter option if you wish to link with soar code via a library. + +all: lib +devel: soarBuildInfo lib +version: soarBuildOptions soarBuildInfo lib + +soarBuildInfo: soarBuildInfo.tmp + ./make-soar-build-info + + +soarBuildOptions: soarBuildOptions.tmp + ./make-soar-build-options + +docs: soarBuildInfo + doxygen + + +lib: libsoarkernel.a + +# The IBM RS/6000 C compiler doesn't handle the -o switch properly: +# it ignores the path and uses only the filename component. Hence, +# to make compiles portable across a wider set of platforms, we +# compile in the current directory and move the resulting object +# or executable file to its intended destination. + + +libsoarkernel.a: ${OBJS} + ${AR} ${ARFLAGS} libsoarkernel.a ${OBJS} + ${RANLIB} libsoarkernel.a + + + +#================================================================= +# +# C FILES +# +# How we compile a file: + +### HAVE TO CHANGE THIS BECAUSE IT DEPENDS ON GNU MAKE..COMPILE.c +### doesn't work for other makes RMJ +# COMPILE.c = ${CC} ${CFLAGS} ${DFLAGS} ${IFLAGS} -c + +COMPILE.c = ${CC} ${CFLAGS} ${DFLAGS} -c + +# The dependencies of objects on sources/headers: +# (The targets were explicitly listed because make was broken +# under CMU's Mach OS. However, since users should be using +# GNU gmake under Mach, perhaps this can be shorted using +# file extension rules now? We need to check if other makes +# are broken in this way before converting to the more +# consise method.) + + +agent.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h scheduler.h +backtrace.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h explain.h +callback.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +callback.o: soar_core_api.h soarapi_datatypes.h +chunk.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +chunk.o: soar_core_utils.h soar_core_api.h soarapi_datatypes.h +chunk.o: soar_ecore_utils.h explain.h +consistency.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +debugutil.o: debugutil.h soarkernel.h soarBuildOptions.h sysdep.h callback.h +decide.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +decide.o: soarapi_datatypes.h +explain.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h explain.h +init_soar.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +io.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h soarapiUtils.h +io.o: soarapi.h soar_core_api.h soarapi_datatypes.h soar_ecore_api.h +io.o: soar_ecore_utils.h soar_core_utils.h +legacy.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h soar_core_api.h +legacy.o: soarapi_datatypes.h +lexer.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +mem.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +osupport.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +parser.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +prefmem.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +print.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +production.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +recmem.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +reorder.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +rete.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h rete.h +rhsfun.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h rhsfun_math.h +rhsfun.o: rhsfun.h +rhsfun_math.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +scheduler.o: scheduler.h soarkernel.h soarBuildOptions.h sysdep.h callback.h +soarBuildInfo.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +soarBuildInfo.o: soar_ecore_api.h soar_ecore_utils.h soar_core_utils.h +soarBuildInfo.o: soar_core_api.h soarapi_datatypes.h +soar_core_api.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +soar_core_api.o: soar_core_api.h soarapi_datatypes.h soar_core_utils.h +soar_core_api.o: soar_ecore_utils.h scheduler.h +soar_core_utils.o: soar_core_utils.h soarkernel.h soarBuildOptions.h sysdep.h +soar_core_utils.o: callback.h soar_core_api.h soarapi_datatypes.h +soar_core_utils.o: soar_ecore_utils.h rhsfun.h +soar_ecore_api.o: soar_ecore_api.h soarkernel.h soarBuildOptions.h sysdep.h +soar_ecore_api.o: callback.h soar_ecore_utils.h soar_core_utils.h +soar_ecore_api.o: soar_core_api.h soarapi_datatypes.h rete.h +soar_ecore_utils.o: soar_ecore_utils.h soarkernel.h soarBuildOptions.h +soar_ecore_utils.o: sysdep.h callback.h soar_core_utils.h soar_core_api.h +soar_ecore_utils.o: soarapi_datatypes.h +soarapi.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h soarapi.h +soarapi.o: soar_core_api.h soarapi_datatypes.h soar_ecore_api.h +soarapi.o: soar_ecore_utils.h soar_core_utils.h soarapiUtils.h +soarapi.o: soarapiCallbacks.h scheduler.h +soarapiCallbacks.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +soarapiCallbacks.o: soarapi.h soar_core_api.h soarapi_datatypes.h +soarapiCallbacks.o: soar_ecore_api.h soar_ecore_utils.h soar_core_utils.h +soarapiUtils.o: soarapi.h soarkernel.h soarBuildOptions.h sysdep.h callback.h +soarapiUtils.o: soar_core_api.h soarapi_datatypes.h soar_ecore_api.h +soarapiUtils.o: soar_ecore_utils.h soar_core_utils.h soarapiUtils.h +soarapi_datatypes.o: soarapi_datatypes.h soarkernel.h soarBuildOptions.h +soarapi_datatypes.o: sysdep.h callback.h +symtab.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +sysdep.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +tempmem.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +timers.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +trace.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h +wmem.o: soarkernel.h soarBuildOptions.h sysdep.h callback.h + + +#================================================================= +# +# CLEANUP +# + + +clean: + rm -rf *.o *.a core *~ + +distclean: clean + rm -rf Makefile config.cache config.log config.status + diff --git a/soar-8.5.2/kernel/README.BuildOptions b/soar-8.5.2/kernel/README.BuildOptions new file mode 100644 index 0000000..6f04f10 --- /dev/null +++ b/soar-8.5.2/kernel/README.BuildOptions @@ -0,0 +1,542 @@ + +/** + * \file BuildOptions + * + * \brief Soar's compile time options. + * + * + * All compile time options described in this document should + * be defined prior to compilation in a file called + * "soarBuildOptions.h". This file is included by all of + * soar's kernel files. Once a build is completed, you may + * determine the options it was built with using the two core api + * commands "soar_ecBuildInfo" and "soar_ecExcludedBuildInfo" + * it is expected that some compile time flags will be more informative + * than others. These are listed in using the first command. All + * remaining compile time flags have been explicitly hidden using + * comments in the source code. It is expected that they will be of + * no particular use, but for completeness, they can be view using the + * second command (soar_ecExcludedBuildInfo) + * + * + * + * + * \par About the Options: + * + * The compile time options described below can all be used to modify + * the resulting Soar application. Some of these options have only + * subtle effects, while others are much more overt. To those getting + * started down this path, you might want to consider using one of + * the high level build options: + * + * STD - make a "normal" version of Soar. + * do not include Detailed Timers, or + * debugging facilities + * + * + * HEAVY - make a "heavy" version of Soar. + * include Detailed Timers + * + * + * LITE - make a "lite" version of Soar. + * do not include many of the callbacks + * do not include support for learning + * perform special optimizations when possible + * + * \see STD + * \see HEAVY + * \see LITE + * + */ + +/** + * + * + * + * \def ALLOW_I_SUPPORTED_SUBGOAL_RESULTS_WITH_THIN_JUSTS + * Requires: THIN_JUSTIFICATIONS + * + * When used with THIN_JUSTIFICATIONS + * (or SINGLE_THIN_JUSTIFICATION), this option overrides the + * default behvaior which is to force O-support for subgoal + * results. With this option, support for preferences from + * subgoal results is calculated in the normal fashion. NOTE: + * using this option will often result in memory leaks, because + * instantiations which support subgoal results will never be + * deallocated. + * + * \see WARN_IF_RESULT_IS_I_SUPPORTED + */ + +/** + * \def COUNT_KERNEL_TIMER_STOPS + * Requires: KERNEL_TIME_ONLY + * + * Setting this option instructs Soar + * to keep track of how many times the timers have been toggled. + * This is especially useful when highly accurate benchmarking data + * is needed and the cost of system timing calls must be estimated. + */ + +/** + * \def DC_HISTOGRAM + * + * With this option defined, Soar will keep track of the time + * spent on sets of decision cycles. In systems with poor timer + * resolution, this can potentially be used to provide more accurate + * timing information. Unlike Soar's normal timers which are turned + * on many times per decision cycle (even when DETAILED_TIMERS is not + * defined, and even if KERNEL_TIME_ONLY is defined), DC_HISTOGRAM + * uses its own timer which is started every nth decision + * cycle. The timer continues throughout all operation and measures + * the USER time (as do all Soar timers) spent in each section of + * n consecutive decision cycles. This means that the timer is turned + * on and off only infrequently (and the rate can be set dynamcally) + * so that it can be guarenteed that this rate is much larger than + * the timer's granularity. (See also KT_HISTOGRAM) + */ + +/** + * \def DEBUG_CHUNK_NAMES + * + * Setting this option spams some marginally useful messages about + * creating chunk names. It may come in handy for certain debugging + * situations, but is not recommended for normal users. + */ + + + +/** + * \def DEBUG_MEMORY + * + * Enables extended debugging of Soar's internal memory allocation + * system. This is not recomende except for debugging the Soar + * kernel itself. + */ + + + +/** + * \def DETAILED_TIMING_STATS + * Requires: not( NO_TIMING_STUFF ) + * + * Without this defined, Soar will keep track of time spent in + * only a small number of areas. Most important among them are + * the time spent in the kernel itself; in input and output + * functions and the total cput time of the entire operation. + * With this defined, Soar keeps track of time at a much more + * refined level of detail. Note that this is not always a great + * idea. First of all, this option will slow down the overall + * operating speed of Soar. Secondly the times reported by the + * timers (especially the subtimers) may be misleading becuase + * the timers are turned on and off within a time frame that is + * on par with the resolution of the timer itself. + * + */ + +/** + * \def DONT_ALLOW_VARIABLIZATION - highly suggested for soar-lite + * + * this option prevents chunks/justifications from being + * variablized, and in doing so removes a small amount of code + * from being executed. As a result, however, learning is not + * effective, so this option should only be used in those + * situations in which learning is profitable. (As in the + * situations which soar-lite is targeted for). + */ + +/** + * \def DONT_CALC_GDS_OR_BT + * + * This option prevents backtracing as well as refrains from + * calculating any goal dependency sets. Note that depending + * on the productions, the behavior of Soar using this build + * option may differ from the original Soar8 version. Initial + * tests suggest that using this option does not result in + * a significantly faster kernel. + */ + +/** + * \def DONT_DO_IO_CYCLES + * + * This options prevents Soar from performing the input and + * output cycle. Although, Soar will still enter both + * phases, calls to do_input_cycle are removed as well as some + * minor additional streamlining. + * + */ + +/** + * \def FEW_CALLBACKS - suggested + * + * strips out many of the callbacks which are routinely + * invoked during execution. Some critical callbacks + * remain, as do those which are executed only before + * and after execution. A complete list of the + * callbacks which remain usable if this option is invoked + * follows: + * + * \arg AFTER_INIT_AGENT_CALLBACK (may be removed) + * \arg SYSTEM_STARTUP_CALLBACK + * \arg AFTER_DECISION_CYCLE_CALLBACK + * \arg SYSTEM_TERMINATION_CALLBACK + * \arg SYSTEM_PARAMETER_CHANGED_CALLBACK + * \arg BEFORE_INIT_SOAR_CALLBACK + * \arg AFTER_INIT_SOAR_CALLBACK + * \arg AFTER_HALT_SOAR_CALLBACK + * \arg PRINT_CALLBACK + * \arg LOG_CALLBACK + * \arg RECORD_CALLBACK + * \arg INPUT_CYCLE_CALLBACK + * \arg OUTPUT_CYCLE_CALLBACK + * \arg all global callbacks + */ + +/** + * \def HEAVY + * + * This is not a real build option in itself, but an agglomerate + * of other build options. It is specified only in the file + * soarBuildOptions.h, and defines a \b heavy build of Soar + * which includes a large amount of functionality. + * + * \see LITE + * \see STD + */ + + +/** + * \def KERNEL_TIME_ONLY + * + * with this option set, soar only keeps track of the kernel time + * which has been used. This is in contrast to building without + * any flags or with the \c DETAILED_TIMING_STATS flag. In + * either of those cases, more timers are used for tracking Soar's + * performance. In some systems, setting this option may improve + * performance significantly. + */ + +/** + * \def KT_HISTOGRAM + * + * Like the \c DC_HISTOGRAM option, this option keeps track of the + * time spent in individual decision cycles. Unlike + * \c DC_HISTOGRAM, however, \c KT_HISTOGRAM does not use its own + * timer. Instead, it relys on Soar's decision cycle timer. + * Whenever the kernel timer is stopped, the acrued time is + * added not only to the total kernel time, but also to the slot + * in the kt_histogram for the current decision cycle. This means + * that the sum of the bins in the kt_histogram will sum up to + * exactly the kernel time. But it also means that these results + * will be misleading if the granulairty of the timers is relatively + * high. In such cases it is better to use the \c DC_HISTOGRAM with + * a frequency of many decision cycles. When the timers have low + * granularity, however, this function will produce good results, and + * may be more interesting than using the \c DC_HISTOGRAM with frequency + * of 1 decision cycle since these timers do not include time spent + * in the input/output functions. + * + */ + + +/** + * \def LITE + * + * This is not a real build option in itself, but an agglomerate + * of other build options. It is specified only in the file + * soarBuildOptions.h, and defines a \b lite build of Soar + * which reduces Soar's functionality to a realitve minimum + * + * \see HEAVY + * \see STD + */ + + +/** + * \def NO_TOP_LEVEL_REFS - suggested (buggy?) + * + * without this options, reference counts on data structures + * which reside in the top state (i.e. level 1) are incremented + * just as those which correspond to any other data structure. + * However, this method of reference counting results in many + * (perhaps all?) of these top level data structures to remain + * in the memory pools, never to be deallocated. Programs which + * operate mainly on the top state (such as a flattened version of + * towers of hanoi) suffer huge memory leaks. It is possible that + * without these references, your program could behave differently, + * or possibly crash, but if you are intending to run for long + * periods of time, where memory may become an issue, it is worth + * testing your system with this option + */ + +/** + * \def MEMORY_POOL_STATS + * + * Use this build option if you want Soar to keep statistics about + * its usage of the interal memory pools. Do not define this option + * if you would prefer to avoid this overhead. + */ + + +/** + * \def MAKE_PRODUCTION_FOR_THIN_JUSTS + * Requires: THIN_JUSTIFICATIONS + * + * This option, when used in conjuction with THIN_JUSTIFICATIONS + * (and possibly SINGLE_THIN_JUSTIFICATION) allows the justification + * to be created, but still refrains from adding it to the rete. + * The only reason this is at all useful is for debugging purposes + * where it can be useful to see such structures as they are created + * and examine their conditions and actions. + */ + +/** + * \def MAX_SIMULTANEOUS_AGENTS + * + * This options specifies the number of maximum simultaneous + * agents for any particular individual soar instantiation. + * Typically, this is set at 128, much greater than required + * for the typical user. Agent ids are assigned from the range + * (\c 0, \c MAX_SIMULATANEOUS_AGENTS \c - \c 1). This ensures + * that external code which invokes Soar functionality (such as + * the Tcl interface) can quickly associate externally defined + * data (such as a Tcl interpreter) with an agent by placing + * such data into an array of size \c MAX_SIMULTANEOUS_AGENTS. + * Agent ids are assigned in pseudo increasing order, so that + * an id will not be reused until all other ids have been used at + * least once. + * + */ + +/** + * + * \def MHZ + * + * This option is used to specify the clock speed (in megahertz) + * of the platform on which soar is both compiled and used. It + * only needs to be defined if you are also using \c PII_TIMERS, an + * option which may be important in some research situations, + * but will be unwarrented for most users. + * + * \see PII_TIMERS + * + */ + +/** + * + * \def NO_ADC_CALLBACK + * + * this option removes the AFTER_DECISION_CYCLE_CALLBACK which + * is probably one of the most useful callbacks. It doesn't make + * much sense to use this without FEW_CALLBACKS + * + */ + + +/** + * \def NO_TOP_JUST - highly suggested + * + * this option prevents justifications from being built at the top + * level. Since they serve no purpose there anyway, this provides + * a performance gain with no negative tradeoffs, thus it is + * suggested for all builds. + * + */ + + +/** + * + * \def OPTIMIZE_TOP_LEVEL_RESULTS + * Requires: NO_TOP_JUST + * + * results which are retured solely to the top level can be + * optimized even beyond the point which SINGLE_THIN_JUSTIFICAITON + * provides. This is due largely to the fact that there is on + * GDS for the top state and so no backtracing needs to be done. + * Although it seems this option avoids a large portion of code + * which is necessary for learning. Therefore, it is probably most + * useful when used in conjunction with SINGLE_THIN_JUSTIFICATION. + * + * \see NO_TOP_JUST + * + */ + +/** + * \def PII_TIMERS + * Requires: MHZ + * + * This option is only valid on machines which use an Intel + * Pentium II or higher processor. Builds with this option + * defined do not use the timers provided by the system, but + * instead use a timer on-board the PII itself to perform + * timing operations. Using this option, there is can be no + * distinction between different processes which may be sharing + * the CPU, this is in contrast to the system timers which measure + * only the time used by the Soar process itself. However, in + * a lightly loaded machine, Soar may well be the dominating process + * if this is true, then the advantage of these timers is their + * exteremly fine granularity which is unmatched. System timers + * operate at the rate of the scheduler (typically 10ms) and thus + * have a relatively large granularity. The PII timers update once + * a clock cycle, thus providing a granularity of well under 1us. + * + * \see MHZ + */ + +/** + * \def REMOVE_INSTS_WITH_O_PREFS + * + * Instantiations with all O-supported results don't really need + * to stick around in memory after their preferences have been + * asserted so long as no learning (or backtracing) will take + * place. (At least as far as I understand). In a normal build + * of Soar, however, they do stick around and after a long + * period of time (sometimes forever!), can take up a lot of + * space. This build option removes such instantiations after + * their preferences have been asserted. + * + */ + +/** + * \def SINGLE_THIN_JUSTIFICATION + * Requires: THIN_JUSTIFICATIONS + * + * This option makes returning from a subgoal even less expensive + * than THIN_JUSTIFICATIONS alone. The reason is that only a single + * instantiation is created (as opposed to one for each level in the + * subgoal stack). As with THIN_JUSTIFICATIONS, all results are + * forced to become O-supported. + * + * \see THIN_JUSTIFICATIONS + * \see WARN_IF_RESULT_IS_I_SUPPORTED + * + * \par Note: + * + * When using \c THIN_JUSTIFICATIONS or \c SINGLE_THIN_JUSTIFICATION, + * instantiations are built to support the results of subgoals, + * but there is no p node in the rete associated with these + * instantiations. This means that Soar's native mechanism for + * garbage collecting won't work on these things, and they will + * stick around forever (which they shouldn't do). Although this + * has no effect on the system's behavior, it is a memory leak + * that we would like to avoid. Therefore, a work around has been + * created. The basis for this change is the fact that O-supported + * preferences stick around regardless of whether or not their + * associated instantiation is there. This means that instantiations + * created for subgoal results can be removed as soon as their + * preferences have been asserted so long as they have only + * O-supported results. So, after these preferences are asserted, + * we check each instaniation to see if it has all O-supported + * results. If this is the case, and if the production pointer of + * this instantiation is NULL, we know we are looking at a \b Thin + * \b Justification (and that \c MAKE_PRODUCTION_FOR_THIN_JUSTS is + * not defined) and we can remove the inst. If + * \c MAKE_PRODUCTION_FOR_THIN_JUSTS + * is defined, an additional boolean value in the instantiation + * structure allows us to determine if this is a \c THIN JUSTIFICATION + * or not. Finally, if + * \c ALLOW_I_SUPPORTED_SUBGOAL_RESULTS_WITH_THIN_JUSTS + * is defined, there may exist some \c THIN JUSTIFICATIONS with I supported + * results. In such cases these instantiations cannot be removed, + * and a memory leak will ensue. + * + * + * + * + */ + +/** + * \def STD + * + * This is not a real build option in itself, but an agglomerate + * of other build options. It is specified only in the file + * soarBuildOptions.h, and defines a \b standard build of Soar + * which includes similar build options to previously released + * Soar kernels. + * + * \see LITE + * \see HEAVY + */ + +/** + * \def THIN_JUSTIFICATIONS + * + * In a normal version of Soar, chunks/justifications are built in + * a recursive manner. When a subgoal returns results to the top + * level, for example, a chunk/justification is built for every + * intermediate level in the subgoal stack. Adding the chunk + * or justification to the rete is a potential time sink, and when + * learning is off, there is no need for any of these productions + * to be added at all. This build option circumvents this problem + * by refraining from building any production at all. At the same + * time, it forces all subgoal results to beome O-supported, so that + * memory leaks (caused by having lingering instantiations with no + * associated production {Note: 1}) will not occur. + * + * \see WARN_IF_RESULT_IS_I_SUPPORTED + */ + +/** + * + * \def SOAR_8_ONLY + * + * make soar 8 a compile time option as opposed to a run time option. + */ + +/** + * + * \def TRACE_CONTEXT_DECISIONS_ONLY + * + * allows only minimal support for tracing, such as the effects which + * would generally be provided by issuing a "watch 1" command in the + * TSI. + */ + + +/** + * \def USE_STDARGS + * + * This build option should be used when you compile with the + * ANSI stdarg facility. (This will be most users). + */ + +/** + * + * + * \def WARN_IF_RESULT_IS_I_SUPPORTED + * + * this option prints a warning if the result of a subgoal is + * I-supported. It is mainly useful to help determine whether + * using \c THIN_JUSTIFICATIONS (and possbiy \c + * SINGLE_THIN_JUSTIFICATIONS) will change the agent's behavior. + * + */ + +/** + * + * \def WARN_IF_TIMERS_REPORT_ZERO + * + * this option will print a warning if any of Soar's timers report + * zero time. In such cases, there is a high likely hood that the + * timing data will misrepresent the truth because of abnormally high + * granularity. Using this option may slow the system down slightly + * (only slightly it adds approx 10 lines of code to the timing + * functions), however, two builds which differ only in their use + * of this option should similarly have equally fast (or slow) timer + * responses. Thus, if consistently no warnings are generated, it + * should be safe to run the version withou this option and have full + * confidence of the results. + * + */ + + + + + + + + + + + + diff --git a/soar-8.5.2/kernel/README.api b/soar-8.5.2/kernel/README.api new file mode 100644 index 0000000..95bfced --- /dev/null +++ b/soar-8.5.2/kernel/README.api @@ -0,0 +1,148 @@ +/** + +\mainpage The Soar API + +\section overview API Overview + + For most people, interaction with Soar begins with using the +standard interface and a simple environment such as those which come +along with the tutorial. Soar can be instructed to load productions, +run, add-wme and such all via easy interaction with the user at some +prompt. For some people, this is their only requirement for Soar: to +execute some productions within a (relatively) simple environment which +can easily be integrated with Soar's current interface. + + Obviously, this is a limitation that we would like to avoid. +In an ideal world, people who were framiliar with interacting with +Soar through its stardard interface would also be use Soar with a +multitude of different environments, regardless of their +implementation language. Unfortunately, in the past this meant looking +deep inside of the Soar source code, and picking out (with relatively +little guidence) the key set of functions which would allow an +appropriate interaction to take place. + + The primary goal of the Soar API is to provide a C based +interface which has a high degree of correspondence with the standard +Soar interface (Tcl) that users begin their interaction to Soar with. +The anticipated result of this is that it will be easier to interface +other applications with Soar becuase the requred C function calls will +be more intuitive. Moreover, it is likely that this will also help +everyone because documentation at all levels of interaction (from the +C based API to the high level interface in Tcl) will be relatively +similar. + + The secondary goal of the Soar API is to remove all interface +dependencies from the Soar kernel. In the past, when a new interface +was used the kernel was modified (often only slightly) to provide some +degree of support for the particularities of the interface. The new +paradigm is to enforce a strict distinction between interface and +kernel. As a result the kernel is implemented in ansi C. Interface +specific functionality should be handled via callbacks from the Soar +kernel. Examples of this can be seen in both the new-unix-interface +and the tcl-interface. By maintaining a strict distinction between +kernel and interface, it should be easier for users to embed soar in +ther application or build a new interface for it, without understaning +all the details of the kernel itself. + + Now that you are convinced that the API represents forward +progress for the Soar community :), I will give a brief overview of +the components that make up the API, and how they are organized. + +\subsection hlapi High Level: Soar API + + The Soar API exists at two distinct levels of abstraction. +The job of the highest layer is to provide abstract functions which +can easily be called from the end user interface (e.g. something the +user types into). Each of its functions provide a method for parsing +command arguments so that this tedium need not be done by the +developers of end user interfaces. Moreover, all of the functions in +this layer have the similar arguments and return values, so that a +function pointer can be used to invoke any of them. + + The currently implemented version of the Soar API (soarapi.h) +requires only that the end user interface parse commands into argc, +argv style arguments (in a manner similar to what is done in the Tcl +shell). The Soar API then does context dependent parsing and calls +lower level functions in the Soar core (or extended core) API. + + + +\subsection llapi Low Level: Soar Core API and Extended Soar Core API + + Together, the Core API and the Extended Core API comprise the +functionality of the low level Soar API. These functions (described in +soar_core_api.h and soar_ecore_api.h) provide common ancestors for the +more abstract functions in the high level api (soarapi.h). The +difference between this level and the higher level is that these +functions use typed arguments, so that minimal string parsing is +required, and more static type checking can be done. Interaction with +Soar at this level of abstraction is most appropriate when Soar is +embedded within another application, and is not controlled by a user +typing specific commands. + + + The distinction between Core and Extended Core functions is less +important than the distinction between the high and low level +API. However, the Core API (soar_core_api.h), provides all the minimum +functionality that would be required for an embeddable system. Using +it alone, allows a (much?) smaller footprint than would be possible +otherwise because functionality such as printing and parsing are +minimized (in the future it is likely that they will be removed +altogether). The Extended Core API (soar_ecore_api.h), completes the +functionality provided in the higher level Soar API, but requires more +code to be included in the end applciation. Moreover, many of its +functions make the assumption that there is some mechanism to display +output to the user in a pseudo-interactive manner. + +\subsection choosing Which API is for me? + + The following questions may be useful in helping you determine +which api functions you should be examining: +-# If you want to interact with Soar from the command line, or with a GUI look at soarapi.h (The High Level API) +-# If you want your agent to interact directly with C routines whose functionality is known at compile time, look at soar_ecore_api.h and soar_core_api.h (The Low Level API) +-# If you want to keep memory usage as low as possible, and don't mind giving up some useful features (such as the ability to watch what the agent is doing), stick solely to the soar_core_api.h +-# If you want to maximize performance (at the cost of development effort) and are not afraid of void pointers, or getting your hands really dirty, you might consider going beyond the current api into the soar kernel functions. + + Once you have made your initial decision, you should begin purusing the documentation for the corresponding files. + + +*/ + + + + + + + + + + + +TODO: + + Finish Core api, make sure that none of these functions rely on + the parser, or the lexer, or do any printing. + + Finish Extended Core API + + Add a tokenizer which tokenizes a string, and evokes + functions + + Add a NO_PRINT_CALLBACK flag. This won't really save a whole + lot, except maybe a little space + + Add a High Level API which uses the alternate_input_string + mechanism + + Add a tokenizer for that API + + + + +THINGS TO THINK ABOUT: + + some agent data structures which may be removable: + all the stuf related to running (i.e. go_*) + as far as I can tell, its all currently + unnecessary, but it might be useful for + MT-Safe Soar diff --git a/soar-8.5.2/kernel/agent.c b/soar-8.5.2/kernel/agent.c new file mode 100644 index 0000000..d043dfe --- /dev/null +++ b/soar-8.5.2/kernel/agent.c @@ -0,0 +1,180 @@ +/************************************************************************* + * + * file: agent.c + * + * ======================================================================= + * Initialization for the agent structure. Also the cleanup routine + * when an agent is destroyed. These routines are usually replaced + * by the same-named routines in the Tcl interface file soarAgent.c + * The versions in this file are used only when not linking in Tcl. + * HOWEVER, this code should be maintained, and the agent structure + * must be kept up to date. + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ +/* =================================================================== + Agent-related functions + =================================================================== */ + +#include "soarkernel.h" +#include "scheduler.h" +#include "sysdep.h" +#include "rhsfun_examples.h" + +agent *soar_agent; + +list *all_soar_agents = NIL; + +int agent_counter = -1; +int agent_count = -1; + +char *soar_version_string; + +extern int soar_agent_ids[]; + +/* + Try to assign a unique and previously unassigned id. If none are + available, assign a unique, but previously assigned id. +*/ +int next_available_agent_id() +{ + int i; + + for (i = 0; i < MAX_SIMULTANEOUS_AGENTS; i++) { + if (soar_agent_ids[i] == UNTOUCHED) { + soar_agent_ids[i] = ALLOCATED; + return i; + } + } + for (i = 0; i < MAX_SIMULTANEOUS_AGENTS; i++) { + if (soar_agent_ids[i] == TOUCHED) { + soar_agent_ids[i] = ALLOCATED; + return i; + } + } + { + char msg[MESSAGE_SIZE]; + snprintf(msg, MESSAGE_SIZE, "agent.c: Error: Too many simultaneous agents (> %d\n", MAX_SIMULTANEOUS_AGENTS); + msg[MESSAGE_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ + + abort_with_fatal_error(msg); + } + return -1; /* To placate compilier */ +} + +#ifdef ATTENTION_LAPSE +/* RMJ; + When doing attentional lapsing, we need a function that determines + when (and for how long) attentional lapses should occur. This + will normally be provided as a user-defined TCL procedure. +*/ + +long init_lapse_duration(TIMER_VALUE * tv) +{ + int ret; + long time_since_last_lapse; + char buf[128]; + + start_timer(current_real_time); + timersub(current_real_time, tv, current_real_time); + time_since_last_lapse = (long) (1000 * timer_value(tv)); + + if (soar_exists_callback(soar_agent, INIT_LAPSE_DURATION_CALLBACK)) { + + /* SW 11.07.00 + * + * Modified this to use the generic soar interface, as opposed + * to being Tcl specific. This requires a new callback + * in particular, here the callback receives the value + * time_since_last_lapse, and must RESET this value to + * the appropriate number + */ + soar_invoke_callback(soar_agent, INIT_LAPSE_DURATION_CALLBACK, (void *) &time_since_last_lapse); + + return time_since_last_lapse; + } + return 0; +} + +#endif + +/* =================================================================== + + Initialization Function + +=================================================================== */ + +void init_soar_agent(void) +{ + + /* --- initialize everything --- */ + init_memory_utilities(); + init_symbol_tables(); + create_predefined_symbols(); + init_production_utilities(); + init_built_in_rhs_functions(); + /*add_bot_rhs_functions (soar_agent); */ + add_bot_rhs_functions(); + init_rete(); + init_lexer(); + init_firer(); + init_decider(); + init_soar_io(); + init_chunker(); + init_sysparams(); + init_tracing(); + init_explain(); /* AGR 564 */ +#ifdef REAL_TIME_BEHAVIOR + /* RMJ */ + init_real_time(); +#endif +#ifdef ATTENTION_LAPSE + /* RMJ */ + init_attention_lapse(); +#endif + + /* --- add default object trace formats --- */ + add_trace_format(FALSE, FOR_ANYTHING_TF, NIL, "%id %ifdef[(%v[name])]"); + add_trace_format(FALSE, FOR_STATES_TF, NIL, "%id %ifdef[(%v[attribute] %v[impasse])]"); + { + Symbol *evaluate_object_sym; + evaluate_object_sym = make_sym_constant("evaluate-object"); + add_trace_format(FALSE, FOR_OPERATORS_TF, evaluate_object_sym, "%id (evaluate-object %o[object])"); + symbol_remove_ref(evaluate_object_sym); + } + /* --- add default stack trace formats --- */ + add_trace_format(TRUE, FOR_ANYTHING_TF, NIL, "%right[6,%dc]: %rsd[ ]==>S: %id %ifdef[(%v[name])]"); + add_trace_format(TRUE, FOR_STATES_TF, NIL, "%right[6,%dc]: %rsd[ ]==>S: %cs"); + add_trace_format(TRUE, FOR_OPERATORS_TF, NIL, "%right[6,%dc]: %rsd[ ] O: %co"); + reset_statistics(); +} diff --git a/soar-8.5.2/kernel/backtrace.c b/soar-8.5.2/kernel/backtrace.c new file mode 100644 index 0000000..d7731a4 --- /dev/null +++ b/soar-8.5.2/kernel/backtrace.c @@ -0,0 +1,695 @@ +/************************************************************************* + * + * file: backtrace.c + * + * ======================================================================= + * + * Backtracing structures and routines. See also explain.c + * + * + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* ==================================================================== + Backtracing routines + ==================================================================== */ + +#include "soarkernel.h" + +#include + +#include "explain.h" + +/* ==================================================================== + + Backtracing + + Four sets of conditions are maintained during backtracing: locals, + grounds, positive potentials, and negateds. Negateds are really + potentials, but we keep them separately throughout backtracing, and + ground them at the very end. Note that this means during backtracing, + the grounds, positive potentials, and locals are all instantiated + top-level positive conditions, so they all have a bt.wme on them. + + In order to avoid backtracing through the same instantiation twice, + we mark each instantiation as we BT it, by setting + inst->backtrace_number = backtrace_number (this is a global variable + which gets incremented each time we build a chunk). + + Locals, grounds, and positive potentials are kept on lists (see the + global variables below). These are consed lists of the conditions + (that is, the original instantiated conditions). Furthermore, + we mark the bt.wme's on each condition so we can quickly determine + whether a given condition is already in a given set. The "grounds_tc", + "potentials_tc", "locals_tc", and "chunker_bt_pref" fields on wme's + are used for this. Wmes are marked as "in the grounds" by setting + wme->grounds_tc = grounds_tc. For potentials and locals, we also + must set wme->chunker_bt_pref: if the same wme was tested by two + instantiations created at different times--times at which the wme + was supported by two different preferences--then we really need to + BT through *both* preferences. Marking the wmes with just "locals_tc" + or "potentials_tc" alone would prevent the second preference from + being BT'd. + + The add_to_grounds(), add_to_potentials(), and add_to_locals() + macros below are used to add conditions to these sets. The negated + conditions are maintained in the chunk_cond_set "negated_set." + + As we backtrace, each instantiation that has some Nots is added to + the list instantiations_with_nots. We have to go back afterwards + and figure out which Nots are between identifiers that ended up in + the grounds. +==================================================================== */ + +#define add_to_grounds(cond) { \ + if ((cond)->bt.wme->grounds_tc != current_agent(grounds_tc)) { \ + (cond)->bt.wme->grounds_tc = current_agent(grounds_tc); \ + push ((cond), current_agent(grounds)); } } + +#define add_to_potentials(cond) { \ + if ((cond)->bt.wme->potentials_tc != current_agent(potentials_tc)) { \ + (cond)->bt.wme->potentials_tc = current_agent(potentials_tc); \ + (cond)->bt.wme->chunker_bt_pref = (cond)->bt.trace; \ + push ((cond), current_agent(positive_potentials)); \ + } else if ((cond)->bt.wme->chunker_bt_pref != (cond)->bt.trace) { \ + push ((cond), current_agent(positive_potentials)); } } + +#define add_to_locals(cond) { \ + if ((cond)->bt.wme->locals_tc != current_agent(locals_tc)) { \ + (cond)->bt.wme->locals_tc = current_agent(locals_tc); \ + (cond)->bt.wme->chunker_bt_pref = (cond)->bt.trace; \ + push ((cond), current_agent(locals)); \ + } else if ((cond)->bt.wme->chunker_bt_pref != (cond)->bt.trace) { \ + push ((cond), current_agent(locals)); } } + +/* ------------------------------------------------------------------- + Backtrace Through Instantiation + + This routine BT's through a given instantiation. The general method + is as follows: + + 1. If we've already BT'd this instantiation, then skip it. + 2. Mark the TC (in the instantiated conditions) of all higher goal + ids tested in top-level positive conditions + 3. Scan through the instantiated conditions; add each one to the + appropriate set (locals, positive_potentials, grounds, negated_set). + 4. If the instantiation has any Nots, add this instantiation to + the list of instantiations_with_nots. +------------------------------------------------------------------- */ + +/* mvp 5-17-94 */ +void print_consed_list_of_conditions(list * c, int indent) +{ + for (; c != NIL; c = c->rest) { + if (get_printer_output_column() >= COLUMNS_PER_LINE - 20) + print("\n "); + + /* mvp 5-17-94 */ + print_spaces(indent); + print_condition(c->first); + } +} + +/* mvp 5-17-94 */ +void print_consed_list_of_condition_wmes(list * c, int indent) +{ + for (; c != NIL; c = c->rest) { + if (get_printer_output_column() >= COLUMNS_PER_LINE - 20) + print("\n "); + + /* mvp 5-17-94 */ + print_spaces(indent); + print(" "); + print_wme(((condition *) (c->first))->bt.wme); + } +} + +/* This is the wme which is causing this production to be backtraced through. + It is NULL when backtracing for a result preference. */ + +/* mvp 5-17-94 */ +void backtrace_through_instantiation(instantiation * inst, + goal_stack_level grounds_level, condition * trace_cond, int indent) +{ + + tc_number tc; /* use this to mark ids in the ground set */ + tc_number tc2; /* use this to mark other ids we see */ + condition *c; + list *grounds_to_print, *pots_to_print, *locals_to_print, *negateds_to_print; + bool need_another_pass; + backtrace_str temp_explain_backtrace; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + + /* mvp 5-17-94 */ + print_spaces(indent); + print("... BT through instantiation of "); + if (inst->prod) + print_with_symbols("%y\n", inst->prod->name); + else + print_string("[dummy production]\n"); + } +#endif + + /* --- if the instantiation has already been BT'd, don't repeat it --- */ + if (inst->backtrace_number == current_agent(backtrace_number)) { + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + + /* mvp 5-17-94 */ + print_spaces(indent); + print_string("(We already backtraced through this instantiation.)\n"); + } +#endif + + return; + } + inst->backtrace_number = current_agent(backtrace_number); + + /* Record information on the production being backtraced through */ + /* if (current_agent(explain_flag)) { */ + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) { + temp_explain_backtrace.trace_cond = trace_cond; /* Not copied yet */ + if (trace_cond == NULL) /* Backtracing for a result */ + temp_explain_backtrace.result = TRUE; + else + temp_explain_backtrace.result = FALSE; + + temp_explain_backtrace.grounds = NIL; + temp_explain_backtrace.potentials = NIL; + temp_explain_backtrace.locals = NIL; + temp_explain_backtrace.negated = NIL; + + if (inst->prod) { + strncpy(temp_explain_backtrace.prod_name, inst->prod->name->sc.name, PROD_NAME_SIZE); + } else { + strncpy(temp_explain_backtrace.prod_name, "Dummy production", PROD_NAME_SIZE); + } + temp_explain_backtrace.prod_name[PROD_NAME_SIZE - 1] = 0; /* in case the strncpy truncated the string */ + + temp_explain_backtrace.next_backtrace = NULL; + } + + /* --- check okay_to_variablize flag --- */ + if (!inst->okay_to_variablize) + current_agent(variablize_this_chunk) = FALSE; + + /* --- mark transitive closure of each higher goal id that was tested in + the id field of a top-level positive condition --- */ + tc = get_new_tc_number(); + tc2 = get_new_tc_number(); + need_another_pass = FALSE; + + for (c = inst->top_of_instantiated_conditions; c != NIL; c = c->next) { + Symbol *id, *value; + + if (c->type != POSITIVE_CONDITION) + continue; + id = referent_of_equality_test(c->data.tests.id_test); + + if (id->id.tc_num == tc) { + /* --- id is already in the TC, so add in the value --- */ + value = referent_of_equality_test(c->data.tests.value_test); + if (value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) { + /* --- if we already saw it before, we're going to have to go back + and make another pass to get the complete TC --- */ + if (value->id.tc_num == tc2) + need_another_pass = TRUE; + value->id.tc_num = tc; + } + } else if ((id->id.isa_goal) && (c->bt.level <= grounds_level)) { + /* --- id is a higher goal id that was tested: so add id to the TC --- */ + id->id.tc_num = tc; + value = referent_of_equality_test(c->data.tests.value_test); + if (value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) { + /* --- if we already saw it before, we're going to have to go back + and make another pass to get the complete TC --- */ + if (value->id.tc_num == tc2) + need_another_pass = TRUE; + value->id.tc_num = tc; + } + } else { + /* --- as far as we know so far, id shouldn't be in the tc: so mark it + with number "tc2" to indicate that it's been seen already --- */ + id->id.tc_num = tc2; + } + } + + /* --- if necessary, make more passes to get the complete TC through the + top-level positive conditions (recall that they're all super-simple + wme tests--all three fields are equality tests --- */ + while (need_another_pass) { + Symbol *value; + + need_another_pass = FALSE; + for (c = inst->top_of_instantiated_conditions; c != NIL; c = c->next) { + if (c->type != POSITIVE_CONDITION) + continue; + if (referent_of_equality_test(c->data.tests.id_test)->id.tc_num != tc) + continue; + value = referent_of_equality_test(c->data.tests.value_test); + if (value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) + if (value->id.tc_num != tc) { + value->id.tc_num = tc; + need_another_pass = TRUE; + } + } /* end of for loop */ + } /* end of while loop */ + + /* --- scan through conditions, collect grounds, potentials, & locals --- */ + grounds_to_print = NIL; + pots_to_print = NIL; + locals_to_print = NIL; + negateds_to_print = NIL; + + /* Record the conds in the print_lists even if not going to be printed */ + + for (c = inst->top_of_instantiated_conditions; c != NIL; c = c->next) { + if (c->type == POSITIVE_CONDITION) { + + /* REW: begin 11.22.97 */ + /* print ("\n Checking...");print_wme(c->bt.wme); + if (c->bt.trace) print ("c->bt.trace exists..."); else print("\n no c->bt.trace..."); + if (c->bt.wme) { + print ("c->bt.wme...."); + if (c->bt.wme->preference) + print("c->bt.wme->preference"); + else + print("\n no c->bt.wme->preference"); + } else + print ("\nNo WME No Preference!!!!!!"); + print("\n"); + if ((c->bt.trace) && (c->bt.wme->preference)){ + if (c->bt.trace != c->bt.wme->preference) { + print("\n bt.trace and WME preferences not equal:\n"); + print("\nWME:"); print_wme(c->bt.wme); + print("\n bt.trace:"); + if (c->bt.trace) print_preference(c->bt.trace); else print(" NIL\n"); + print("\n bt.wme->preference:"); + if (c->bt.wme->preference) print_preference(c->bt.wme->preference); + else print(" NIL\n"); + c->bt.trace = c->bt.wme->preference; + c->bt.level = c->bt.wme->id->id.level; + } + } */ + /* REW: end 11.22.97 */ + /* --- positive cond's are grounds, potentials, or locals --- */ + if (referent_of_equality_test(c->data.tests.id_test)->id.tc_num == tc) { + add_to_grounds(c); + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM] || current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#else + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#endif + push(c, grounds_to_print); + } else if (c->bt.level <= grounds_level) { + add_to_potentials(c); + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM] || current_agent(sysparams)[EXPLAIN_SYSPARAM]) + push(c, pots_to_print); + } else { + add_to_locals(c); +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM] || current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#else + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#endif + push(c, locals_to_print); + } + } else { + /* --- negative or nc cond's are either grounds or potentials --- */ + add_to_chunk_cond_set(¤t_agent(negated_set), make_chunk_cond_for_condition(c)); +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM] || current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#else + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) +#endif + push(c, negateds_to_print); + } + } /* end of for loop */ + + /* --- add new nots to the not set --- */ + if (inst->nots) + push(inst, current_agent(instantiations_with_nots)); + + /* Now record the sets of conditions. Note that these are not necessarily */ + /* the final resting place for these wmes. In particular potentials may */ + /* move over to become grounds, but since all we really need for explain is */ + /* the list of wmes, this will do as a place to record them. */ + + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) + explain_add_temp_to_backtrace_list(&temp_explain_backtrace, grounds_to_print, + pots_to_print, locals_to_print, negateds_to_print); + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + /* --- if tracing BT, print the resulting conditions, etc. --- */ + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + not *not1; + + /* mvp 5-17-94 */ + print_spaces(indent); + print_string(" -->Grounds:\n"); + print_consed_list_of_condition_wmes(grounds_to_print, indent); + print("\n"); + print_spaces(indent); + print_string("\n -->Potentials:\n"); + print_consed_list_of_condition_wmes(pots_to_print, indent); + print("\n"); + print_spaces(indent); + print_string(" -->Locals:\n"); + print_consed_list_of_condition_wmes(locals_to_print, indent); + print("\n"); + print_spaces(indent); + print_string(" -->Negated:\n"); + print_consed_list_of_conditions(negateds_to_print, indent); + print("\n"); + print_spaces(indent); + print_string(" -->Nots:\n"); + /* mvp done */ + + for (not1 = inst->nots; not1 != NIL; not1 = not1->next) + print_with_symbols(" %y <> %y\n", not1->s1, not1->s2); + } +#endif + + /* Moved these free's down to here, to ensure they are cleared even if we're + not printing these lists */ + + free_list(grounds_to_print); + free_list(pots_to_print); + free_list(locals_to_print); + free_list(negateds_to_print); +} + +/* --------------------------------------------------------------- + Trace Locals + + This routine backtraces through locals, and keeps doing so until + there are no more locals to BT. +--------------------------------------------------------------- */ + +void trace_locals(goal_stack_level grounds_level) +{ + + /* mvp 5-17-94 */ + cons *c, *prohibits; + condition *cond; + preference *bt_pref, *p; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string("\n\n*** Tracing Locals ***\n"); +#endif + + while (current_agent(locals)) { + c = current_agent(locals); + current_agent(locals) = current_agent(locals)->rest; + cond = c->first; + free_cons(c); + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\nFor local "); + print_wme(cond->bt.wme); + print_string(" "); + } +#endif + + bt_pref = find_clone_for_level(cond->bt.trace, (goal_stack_level) (grounds_level + 1)); + /* --- if it has a trace at this level, backtrace through it --- */ + if (bt_pref) { + +#ifdef NO_TOP_JUST + if (bt_pref->inst) { + + /* mvp 5-17-94 */ + backtrace_through_instantiation(bt_pref->inst, grounds_level, cond, 0); + + /* check if any prohibit preferences */ + if (cond->bt.prohibits) { + for (prohibits = cond->bt.prohibits; prohibits != NIL; prohibits = prohibits->rest) { + p = prohibits->first; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string(" For prohibit preference: "); + print_preference(p); + } +#endif + if (p->inst) + backtrace_through_instantiation(p->inst, grounds_level, cond, 6); + } + } + /* mvp done */ + } +#else + + /* mvp 5-17-94 */ + backtrace_through_instantiation(bt_pref->inst, grounds_level, cond, 0); + + /* check if any prohibit preferences */ + if (cond->bt.prohibits) { + for (prohibits = cond->bt.prohibits; prohibits != NIL; prohibits = prohibits->rest) { + p = prohibits->first; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string(" For prohibit preference: "); + print_preference(p); + } +#endif + backtrace_through_instantiation(p->inst, grounds_level, cond, 6); + } + } + /* mvp done */ + +#endif + continue; + } +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string("...no trace, can't BT"); +#endif + + /* --- for augmentations of the local goal id, either handle the + "^quiescence t" test or discard it --- */ + if (referent_of_equality_test(cond->data.tests.id_test)->id.isa_goal) { + if ((referent_of_equality_test(cond->data.tests.attr_test) == + current_agent(quiescence_symbol)) && + (referent_of_equality_test(cond->data.tests.value_test) == + current_agent(t_symbol)) && (!cond->test_for_acceptable_preference)) { + current_agent(variablize_this_chunk) = FALSE; + current_agent(quiescence_t_flag) = TRUE; + } + continue; + } + + /* --- otherwise add it to the potential set --- */ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string(" --> make it a potential."); +#endif + add_to_potentials(cond); + + } /* end of while locals loop */ +} + +/* --------------------------------------------------------------- + Trace Grounded Potentials + + This routine looks for positive potentials that are in the TC + of the ground set, and moves them over to the ground set. This + process is repeated until no more positive potentials are in + the TC of the grounds. +--------------------------------------------------------------- */ + +void trace_grounded_potentials(void) +{ + tc_number tc; + cons *c, *next_c, *prev_c; + condition *pot; + bool need_another_pass; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string("\n\n*** Tracing Grounded Potentials ***\n"); +#endif + + /* --- setup the tc of the ground set --- */ + tc = get_new_tc_number(); + for (c = current_agent(grounds); c != NIL; c = c->rest) + add_cond_to_tc(c->first, tc, NIL, NIL); + + need_another_pass = TRUE; + while (need_another_pass) { + need_another_pass = FALSE; + /* --- look for any potentials that are in the tc now --- */ + prev_c = NIL; + for (c = current_agent(positive_potentials); c != NIL; c = next_c) { + next_c = c->rest; + pot = c->first; + if (cond_is_in_tc(pot, tc)) { + /* --- pot is a grounded potential, move it over to ground set --- */ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\n-->Moving to grounds: "); + print_wme(pot->bt.wme); + } +#endif + if (prev_c) + prev_c->rest = next_c; + else + current_agent(positive_potentials) = next_c; + if (pot->bt.wme->grounds_tc != current_agent(grounds_tc)) { /* add pot to grounds */ + pot->bt.wme->grounds_tc = current_agent(grounds_tc); + c->rest = current_agent(grounds); + current_agent(grounds) = c; + add_cond_to_tc(pot, tc, NIL, NIL); + need_another_pass = TRUE; + } else { /* pot was already in the grounds, do don't add it */ + free_cons(c); + } + } else { + prev_c = c; + } + } /* end of for c */ + } /* end of while need_another_pass */ +} + +/* --------------------------------------------------------------- + Trace Ungrounded Potentials + + This routine backtraces through ungrounded potentials. At entry, + all potentials must be ungrounded. This BT's through each + potential that has some trace (at the right level) that we can + BT through. Other potentials are left alone. TRUE is returned + if anything was BT'd; FALSE if nothing changed. +--------------------------------------------------------------- */ + +bool trace_ungrounded_potentials(goal_stack_level grounds_level) +{ + + /* mvp 5-17-94 */ + cons *c, *next_c, *prev_c, *prohibits; + cons *pots_to_bt; + condition *potential; + preference *bt_pref, *p; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string("\n\n*** Tracing Ungrounded Potentials ***\n"); +#endif + + /* --- scan through positive potentials, pick out the ones that have + a preference we can backtrace through --- */ + pots_to_bt = NIL; + prev_c = NIL; + for (c = current_agent(positive_potentials); c != NIL; c = next_c) { + next_c = c->rest; + potential = c->first; + bt_pref = find_clone_for_level(potential->bt.trace, (goal_stack_level) (grounds_level + 1)); + if (bt_pref) { + if (prev_c) + prev_c->rest = next_c; + else + current_agent(positive_potentials) = next_c; + c->rest = pots_to_bt; + pots_to_bt = c; + } else { + prev_c = c; + } + } + + /* --- if none to BT, exit --- */ + if (!pots_to_bt) + return FALSE; + + /* --- backtrace through each one --- */ + while (pots_to_bt) { + c = pots_to_bt; + pots_to_bt = pots_to_bt->rest; + potential = c->first; + free_cons(c); + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\nFor ungrounded potential "); + print_wme(potential->bt.wme); + print_string(" "); + } +#endif + + bt_pref = find_clone_for_level(potential->bt.trace, (goal_stack_level) (grounds_level + 1)); + +#ifdef NO_TOP_JUST + if (bt_pref->inst) + backtrace_through_instantiation(bt_pref->inst, grounds_level, potential, 0); +#else + + /* mvp 5-17-94 */ + backtrace_through_instantiation(bt_pref->inst, grounds_level, potential, 0); +#endif + + if (potential->bt.prohibits) { + for (prohibits = potential->bt.prohibits; prohibits != NIL; prohibits = prohibits->rest) { + p = prohibits->first; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string(" For prohibit preference: "); + print_preference(p); + } +#endif + +#ifdef NO_TOP_JUST + if (p->inst) + backtrace_through_instantiation(p->inst, grounds_level, potential, 6); +#else + backtrace_through_instantiation(p->inst, grounds_level, potential, 6); +#endif + + } + } + /* mvp done */ + } + return TRUE; +} diff --git a/soar-8.5.2/kernel/callback.c b/soar-8.5.2/kernel/callback.c new file mode 100644 index 0000000..f09b628 --- /dev/null +++ b/soar-8.5.2/kernel/callback.c @@ -0,0 +1,495 @@ +/************************************************************************* + * + * file: callback.c + * + * ======================================================================= + * + * Description: This file contains the callback facility processing. + * + * Exported functions: + * soar_add_callback + * soar_invoke_callbacks + * soar_remove_callback + * + * soar_callback_data_free_string + * soar_callback_enum_to_name + * + * Each agent has a separate callback table. The table has one entry + * per callback type and the entry is a pointer to a list. The list + * contains installed callbacks, one callback per list cons cell. + * + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +#include "soarkernel.h" +#include "soar_core_api.h" +#include "callback.h" + +extern soar_global_callback_array soar_global_callbacks; +extern unsigned long soar_global_callback_error; + +char *soar_callback_names[] = { /* Must match order of */ + "none", /* SOAR_CALLBACK_TYPE */ + "system-startup", + "system-termination", + "before-init-soar", + "after-init-soar", + "after-halt-soar", + "before-schedule-cycle", + "after-schedule-cycle", + "before-decision-cycle", + "after-decision-cycle", + "before-input-phase", + "input-phase-cycle", + "after-input-phase", + "before-preference-phase-cycle", + "after-preference-phase-cycle", + "before-wm-phase-cycle", + "after-wm-phase-cycle", + "before-output-phase", + "output-phase", + "after-output-phase", + "before-decision-phase-cycle", + "after-decision-phase-cycle", + "wm-changes", + "create-new-context", + "pop-context-stack", + "create-new-attribute-impasse", + "remove-attribute-impasse", + "production-just-added", + "production-just-about-to-be-excised", + "firing", + "retraction", + "system-parameter-changed", + "print", + "log", + "ask" +#ifdef ATTENTION_LAPSE + "init-lapse-duration" +#endif + /* "read", *//* kjh CUSP B10 */ + /* "record", *//* kjh CUSP B10 */ + /* Nothing corresponds to NUMBER_OF_CALLBACKS */ +}; + +void soar_init_callbacks(soar_callback_agent the_agent) +{ + SOAR_CALLBACK_TYPE ct; + + for (ct = 1; ct < NUMBER_OF_CALLBACKS; ct++) { + ((agent *) the_agent)->soar_callbacks[ct] = (list *) NIL; + } + ((agent *) the_agent)->callback_error = 0; +} + +void soar_init_global_callbacks(void) +{ + SOAR_GLOBAL_CALLBACK_TYPE gct; + + for (gct = 1; gct < NUMBER_OF_GLOBAL_CALLBACKS; gct++) { + soar_global_callbacks[gct] = (list *) NIL; + } +} + +void soar_callback_data_free_string(soar_callback_data data) +{ + free((char *) data); +} + +char *soar_callback_enum_to_name(SOAR_CALLBACK_TYPE i, bool monitorable_only) +{ + int limit; + + if (monitorable_only) { + limit = NUMBER_OF_MONITORABLE_CALLBACKS; + } else { + limit = NUMBER_OF_CALLBACKS; + } + + if ((0 < i) && (i < limit)) { + return soar_callback_names[i]; + } + return NULL; +} + +bool soar_exists_callback(soar_callback_agent the_agent, SOAR_CALLBACK_TYPE callback_type) +{ + list *cb_cons; + + if ((agent *) the_agent == NULL) + return FALSE; + + cb_cons = ((agent *) the_agent)->soar_callbacks[callback_type]; + + if (cb_cons == NULL) { + return FALSE; + } + + return TRUE; +} + +soar_callback *soar_exists_callback_id(soar_callback_agent the_agent, + SOAR_CALLBACK_TYPE callback_type, soar_callback_id id) +{ + cons *c; + + if ((agent *) the_agent == NULL) + return FALSE; + + for (c = ((agent *) the_agent)->soar_callbacks[callback_type]; c != NIL; c = c->rest) { + soar_callback *cb; + + cb = (soar_callback *) c->first; + + if (!strcmp(cb->id, id)) { + return cb; + } + } + + return NULL; +} + +void soar_destroy_callback(soar_callback * cb) +{ + if (cb->id) { + free((char *) cb->id); + } + if (cb->free_function) { + cb->free_function(cb->data); + } + free((void *) cb); +} + +void soar_invoke_callbacks(soar_callback_agent the_agent, SOAR_CALLBACK_TYPE callback_type, soar_call_data call_data) +{ + cons *c; + +/* REW: begin 28.07.96 */ + /* We want to stop the Soar kernel timers whenever a callback is initiated and + keep track of how much time the callbacks take cumulatively. This + switch doesn't include every pre-defined callback -- however, it should + provide a good "ballpark" estimate because it is focused on all those + that occur doing do_one_top_level_phase in init_soar.c. + + Note that this case will only be compiled if NO_TIMING_STUFF is not + defined. So, if you are worried about the performance costs of this case, + you can always get rid of it by not including the timing code. */ + +#ifndef NO_TIMING_STUFF + switch (callback_type) { + /* This case is necssary to make sure we are in one of the decision cycle + monitors when the routine is invoked. If so, then we want to turn off + the current timers and turn on the appropriate monitor timers. The + 'appropriate' timer is determined by the current phase. */ + +#ifndef FEW_CALLBACKS + + case BEFORE_DECISION_CYCLE_CALLBACK: + case BEFORE_INPUT_PHASE_CALLBACK: + case AFTER_INPUT_PHASE_CALLBACK: + /* for these three: current_agent(current_phase) = INPUT_PHASE */ + case BEFORE_OUTPUT_PHASE_CALLBACK: + case AFTER_OUTPUT_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = OUTPUT_PHASE */ + case BEFORE_PREFERENCE_PHASE_CALLBACK: + case AFTER_PREFERENCE_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = PREFERENCE_PHASE */ + case BEFORE_WM_PHASE_CALLBACK: + case AFTER_WM_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = WM_PHASE */ + case BEFORE_DECISION_PHASE_CALLBACK: + case AFTER_DECISION_PHASE_CALLBACK: +#endif + +#ifndef NO_ADC_CALLBACK + case AFTER_DECISION_CYCLE_CALLBACK: + +#ifndef KERNEL_TIME_ONLY + /* for these three: current_agent(current_phase) = DECISION_PHASE */ + + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; + +#endif + +#ifndef NO_IO_CALLBACKS + case INPUT_PHASE_CALLBACK: + /* Stop the kernel and phase timers for the input function */ + +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + start_timer(¤t_agent(start_kernel_tv)); + break; +#endif + default: + break; + + } + +#endif + +/* REW: end 28.07.96 */ + for (c = ((agent *) the_agent)->soar_callbacks[callback_type]; c != NIL; c = c->rest) { + soar_callback *cb; + + cb = (soar_callback *) c->first; + cb->function(the_agent, cb->data, call_data); + } + +/* REW: begin 28.07.96 */ + +#ifndef NO_TIMING_STUFF + switch (callback_type) { + +#ifndef FEW_CALLBACKS + + case BEFORE_DECISION_CYCLE_CALLBACK: + case BEFORE_INPUT_PHASE_CALLBACK: + case AFTER_INPUT_PHASE_CALLBACK: + case BEFORE_OUTPUT_PHASE_CALLBACK: + case AFTER_OUTPUT_PHASE_CALLBACK: + case BEFORE_PREFERENCE_PHASE_CALLBACK: + case AFTER_PREFERENCE_PHASE_CALLBACK: + case BEFORE_WM_PHASE_CALLBACK: + case AFTER_WM_PHASE_CALLBACK: + case BEFORE_DECISION_PHASE_CALLBACK: + case AFTER_DECISION_PHASE_CALLBACK: +#endif + +#ifndef NO_ADC_CALLBACK + + case AFTER_DECISION_CYCLE_CALLBACK: + +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(monitors_cpu_time[current_agent(current_phase)])); +#endif + + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; + +#endif + +#ifndef NO_IO_CALLBACKS + case INPUT_PHASE_CALLBACK: + /* Stop input_function_cpu_time timer. Restart kernel and phase timers */ + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(input_function_cpu_time)); + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; +#endif + default: + break; + + } + +#endif + +/* REW: end 28.07.96 */ + +} + +void soar_invoke_first_callback(soar_callback_agent the_agent, + SOAR_CALLBACK_TYPE callback_type, soar_call_data call_data) +{ + list *head; + +/* REW: begin 28.07.96 */ + +#ifndef NO_TIMING_STUFF + switch (callback_type) { + +#ifndef FEW_CALLBACKS + + case BEFORE_DECISION_CYCLE_CALLBACK: + case BEFORE_INPUT_PHASE_CALLBACK: + case AFTER_INPUT_PHASE_CALLBACK: + /* for these three: current_agent(current_phase) = INPUT_PHASE */ + case BEFORE_OUTPUT_PHASE_CALLBACK: + case AFTER_OUTPUT_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = OUTPUT_PHASE */ + case BEFORE_PREFERENCE_PHASE_CALLBACK: + case AFTER_PREFERENCE_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = PREFERENCE_PHASE */ + case BEFORE_WM_PHASE_CALLBACK: + case AFTER_WM_PHASE_CALLBACK: + /* for these two: current_agent(current_phase) = WM_PHASE */ + case BEFORE_DECISION_PHASE_CALLBACK: + case AFTER_DECISION_PHASE_CALLBACK: + +#endif + +#ifndef NO_ADC_CALLBACK + case AFTER_DECISION_CYCLE_CALLBACK: + /* for these three: current_agent(current_phase) = DECISION_PHASE */ + +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; +#endif + +#ifndef NO_IO_CALLBACKS + case INPUT_PHASE_CALLBACK: + /* Stop the kernel and phase timers for the input function */ + +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + start_timer(¤t_agent(start_kernel_tv)); + break; +#endif + default: + break; + + } + +#endif +/* REW: end 28.07.96 */ + + head = ((agent *) the_agent)->soar_callbacks[callback_type]; + + if (head != NULL) { + soar_callback *cb; + + cb = (soar_callback *) head->first; + cb->function(the_agent, cb->data, call_data); + } + +/* REW: begin 28.07.96 */ + +#ifndef NO_TIMING_STUFF + switch (callback_type) { + +#ifndef FEW_CALLBACKS + + case BEFORE_DECISION_CYCLE_CALLBACK: + case BEFORE_INPUT_PHASE_CALLBACK: + case AFTER_INPUT_PHASE_CALLBACK: + case BEFORE_OUTPUT_PHASE_CALLBACK: + case AFTER_OUTPUT_PHASE_CALLBACK: + case BEFORE_PREFERENCE_PHASE_CALLBACK: + case AFTER_PREFERENCE_PHASE_CALLBACK: + case BEFORE_WM_PHASE_CALLBACK: + case AFTER_WM_PHASE_CALLBACK: + case BEFORE_DECISION_PHASE_CALLBACK: + case AFTER_DECISION_PHASE_CALLBACK: + +#endif +#ifndef NO_ADC_CALLBACK + case AFTER_DECISION_CYCLE_CALLBACK: +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(monitors_cpu_time[current_agent(current_phase)])); +#endif + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; +#endif + +#ifndef NO_IO_CALLBACKS + case INPUT_PHASE_CALLBACK: + /* Stop input_function_cpu_time timer. Restart kernel and phase timers */ + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(input_function_cpu_time)); + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif + break; +#endif + default: + break; + + } + +#endif + +/* REW: end 28.07.96 */ + +} + +bool soar_exists_global_callback(SOAR_GLOBAL_CALLBACK_TYPE callback_type) +{ + list *cb_cons; + + cb_cons = soar_global_callbacks[callback_type]; + + if (cb_cons == NULL) { + return FALSE; + } + + return TRUE; +} + +void soar_invoke_global_callbacks(soar_callback_agent a, SOAR_CALLBACK_TYPE callback_type, soar_call_data call_data) +{ + cons *c; + + /* So far, there's no need to mess with the timers, becuase + * we have only implemented function which get called at + * agent creation and destruction + */ + + for (c = soar_global_callbacks[callback_type]; c != NIL; c = c->rest) { + soar_callback *cb; + + cb = (soar_callback *) c->first; + cb->function(a, cb->data, call_data); + } + +} diff --git a/soar-8.5.2/kernel/callback.h b/soar-8.5.2/kernel/callback.h new file mode 100644 index 0000000..1f5d63b --- /dev/null +++ b/soar-8.5.2/kernel/callback.h @@ -0,0 +1,448 @@ +/** + * + * \file callback.h + * + * Soar Callbacks + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + * + * + * $Id: callback.h,v 1.4 2004/06/04 00:13:49 rmarinie Exp $ + * + * + * Each agent has a separate callback table. The table has one entry + * per callback type and the entry is a pointer to a list. The list + * contains installed callbacks, one callback per list cons cell. + * + */ + + /* Two points about this enumeration: a) The first entry is not */ + /* a valid callback because 0 is used to indicate an invalid or */ + /* missing callback and b) The last entry in the enum list */ + /* indicates how many enums are defined. */ + +#ifndef CALLBACK_H_INCLUDED /* Avoid duplicate includes */ +#define CALLBACK_H_INCLUDED /* excludeFromBuildInfo */ + + /* First we define the possible callbacks in an enum. Then we */ + /* describe how each one will be called in user code. */ + +typedef enum { + NO_CALLBACK, /* Used for missing callback */ + SYSTEM_STARTUP_CALLBACK, + SYSTEM_TERMINATION_CALLBACK, + BEFORE_INIT_SOAR_CALLBACK, + AFTER_INIT_SOAR_CALLBACK, + AFTER_HALT_SOAR_CALLBACK, + BEFORE_SCHEDULE_CYCLE_CALLBACK, + AFTER_SCHEDULE_CYCLE_CALLBACK, + BEFORE_DECISION_CYCLE_CALLBACK, + AFTER_DECISION_CYCLE_CALLBACK, + BEFORE_INPUT_PHASE_CALLBACK, + INPUT_PHASE_CALLBACK, + AFTER_INPUT_PHASE_CALLBACK, + BEFORE_PREFERENCE_PHASE_CALLBACK, + AFTER_PREFERENCE_PHASE_CALLBACK, + BEFORE_WM_PHASE_CALLBACK, + AFTER_WM_PHASE_CALLBACK, + BEFORE_OUTPUT_PHASE_CALLBACK, + OUTPUT_PHASE_CALLBACK, + AFTER_OUTPUT_PHASE_CALLBACK, + BEFORE_DECISION_PHASE_CALLBACK, + AFTER_DECISION_PHASE_CALLBACK, + WM_CHANGES_CALLBACK, + CREATE_NEW_CONTEXT_CALLBACK, + POP_CONTEXT_STACK_CALLBACK, + CREATE_NEW_ATTRIBUTE_IMPASSE_CALLBACK, + REMOVE_ATTRIBUTE_IMPASSE_CALLBACK, + PRODUCTION_JUST_ADDED_CALLBACK, + PRODUCTION_JUST_ABOUT_TO_BE_EXCISED_CALLBACK, + FIRING_CALLBACK, + RETRACTION_CALLBACK, + SYSTEM_PARAMETER_CHANGED_CALLBACK, + PRINT_CALLBACK, + LOG_CALLBACK, + ASK_CALLBACK, + WAIT_CALLBACK, +#ifdef ATTENTION_LAPSE + INIT_LAPSE_DURATION_CALLBACK, +#endif + /* READ_CALLBACK, *//* kjh CUSP B10 */ + /* RECORD_CALLBACK, *//* kjh CUSP B10 */ + NUMBER_OF_CALLBACKS /* Not actually a callback */ + /* type. Used to indicate */ + /* list size and MUST ALWAYS */ + /* BE LAST. */ +} SOAR_CALLBACK_TYPE; + +#define NUMBER_OF_MONITORABLE_CALLBACKS (NUMBER_OF_CALLBACKS - 2) + +typedef enum { + NO_GLOBAL_CALLBACK, + GLB_CREATE_AGENT, + GLB_AGENT_CREATED, + GLB_DESTROY_AGENT, + NUMBER_OF_GLOBAL_CALLBACKS +} SOAR_GLOBAL_CALLBACK_TYPE; + +typedef list *soar_global_callback_array[NUMBER_OF_GLOBAL_CALLBACKS]; + +/*! + + \enum SOAR_CALLBACK_TYPE + + Standard (Agent Specific) Callbacks + + All callback functions installed by the user must use the function + soar_add_callback. The type signature of all callback functions is + the same and has the following form: + + my_callback_fn(agent * a, + soar_callback_data scd, + soar_call_data call_data); + + where "a" is a pointer to the agent structure for the agent in which + the callback was invoked, "scd" is the data structure given in the + installation when soar_add_callback was called, and "call_data" is + the data relevant to this particular call. To use the "call_data" + parameter, it should first be cast to the appropriate type, which + is mentioned below. Since only the "call_data" argument varies for + all callbacks, only that argument will be mentioned in the following. + + \par SYSTEM_STARTUP_CALLBACK + + This function is called only once, at system startup time. It can + be used to set up any Soar I/O routines and install any interface + commands. This function is called after most of the system has been + initialized, but before any agent initialization file is loaded. + The "call_data" argument is given as NULL. + + \par SYSTEM_TERMINATION_CALLBACK + + This function is called only once, just before the system exits back + to the shell. The "call_data" parameter is of type "bool" which is + TRUE if the system is exiting normally, and FALSE if the exit is + happening because some fatal error situation was detected. Typically, + this routine should do any final cleanup (closing files, etc.) + necessary. + + \par BEFORE_INIT_SOAR_CALLBACK + + This function is called just before any init-soar is done. (This + includes not only the init-soar command, but also excise-task and + excise-all, which do an init-soar.) The "call_data" argument is + given as NULL. + + \par AFTER_INIT_SOAR_CALLBACK + + This function is called just after any init-soar is done. (This + includes not only the init-soar command, but also excise-task and + excise-all, which do an init-soar.) The "call_data" argument is + given as NULL. + + \par AFTER_HALT_SOAR_CALLBACK + + This function is called after Soar halts; i.e., after the preference + phase in which the RHS function "halt" is executed. The "call_data" + argument is given as NULL. + + \par BEFORE_SCHEDULE_CYCLE_CALLBACK + + This function is called just before the agent is scheduled. The + "call_data" argument is given as NULL. + + \par AFTER_SCHEDULE_CYCLE_CALLBACK + + This function is called just after the agent is scheduled. The + "call_data" argument is given as NULL. + + \par BEFORE_DECISION_CYCLE_CALLBACK + + This function is called at the start of each decision cycle. The + "call_data" argument is given as NULL. + + \par AFTER_DECISION_CYCLE_CALLBACK + + This function is called at the end of each decision cycle. The + "call_data" argument is given as NULL. + + \par BEFORE_INPUT_PHASE_CALLBACK + + This function is called at the start of each input phase. This + is called even if the input cycle is effectively null because + there is no top state. The "call_data" argument is given as NULL. + + \par INPUT_PHASE_CALLBACK + + This function is called during each input phase. The "call_data" + argument contains the input mode currently being used. + + \par AFTER_INPUT_PHASE_CALLBACK + + This function is called at the end of each input phase. This + is called even if the input cycle is effectively null because + there is no top state. The "call_data" argument is given as NULL. + + \par BEFORE_PREFERENCE_PHASE_CALLBACK + + This function is called at the start of each preference phase. + The "call_data" argument is given as NULL. + + \par AFTER_PREFERENCE_PHASE_CALLBACK + + This function is called at the end of each preference phase. + The "call_data" argument is given as NULL. + + \par BEFORE_WM_PHASE_CALLBACK + + This function is called at the start of each working memory phase. + The "call_data" argument is given as NULL. + + \par AFTER_WM_PHASE_CALLBACK + + This function is called at the end of each working memory phase. + The "call_data" argument is given as NULL. + + \par BEFORE_OUTPUT_PHASE_CALLBACK + + This function is called at the start of each Soar output cycle. + This is called even if the output cycle is effectively null because + there is no top state. The "call_data" argument is given as NULL. + + \par OUTPUT_PHASE_CALLBACK + + This function is called during each Soar output cycle. The "call_data" + argument is a structure which contains both the output mode being + used and the list of output wmes. + + \par AFTER_OUTPUT_PHASE_CALLBACK + + This function is called at the end of each Soar output cycle. + This is called even if the output cycle is effectively null because + there is no top state. The "call_data" argument is given as NULL. + + \par BEFORE_DECISION_PHASE_CALLBACK + + This function is called at the start of each decision phase. + The "call_data" argument is given as NULL. + + \par AFTER_DECISION_PHASE_CALLBACK + + This function is called at the end of each decision phase. + The "call_data" argument is given as NULL. + + \par WM_CHANGES_CALLBACK + + This function is called just before changes are made to working + memory. The pre-callback hook function passed two arguments to + the corresponding hook function. However, the "call_data" + argument is given as NULL, in this callback. The wmes_being_added + and wmes_being_removed can be retrieved from the agent structure + already being passed. + + \par CREATE_NEW_CONTEXT_CALLBACK + + This function is called after a new goal context is created. The + "call_data" argument is a pointer to a "Symbol" which is the new + goal identifier. This goal identifier is equal to the agent + variable bottom_goal. + + \par POP_CONTEXT_STACK_CALLBACK + + This function is called just before the context stack is popped. + The "call_data" argument is a pointer to a "Symbol" which is the + identifier of the goal about to be removed. This goal identifier + is equal to the aget variable bottom_goal. If the stack is popped + k levels at once, this routine is called k times in bottom-up order. + + \par CREATE_NEW_ATTRIBUTE_IMPASSE_CALLBACK + + This function is called just after an attribute impasse is created. + The "call_data" argument is a pointer to a "slot" which is the + impassed slot. + + \par REMOVE_ATTRIBUTE_IMPASSE_CALLBACK + + This function is called just before an attribute impasse is removed. + The "call_data" argument is a pointer to a "slot" which is the + impassed slot. + + \par PRODUCTION_JUST_ADDED_CALLBACK + + This function is called just after a production (including chunks + and justifications) is added to the system. The "call_data" argument + is a pointer to a "production" which is the production just added. + + \par PRODUCTION_JUST_ABOUT_TO_BE_EXCISED_CALLBACK + + This function is called just before a production (including chunks + and justifications) is excised from the system. The "call_data" + argument is a pointer to a "production" which is the production + just about to be removed. + + \par FIRING_CALLBACK + + This function is called after every production firing. The + "call_data" argument is a pointer to an "instantiation" which + is the newly created instantiation. + + \par RETRACTION_CALLBACK + + This function is called before every production retraction. The + "call_data" argument is a pointer to an "instantiation" which + is the instantiation about to be retracted. + + \par SYSTEM_PARAMETER_CHANGED_CALLBACK + + This function is called after any change to one of the agent system + parameters (e.g., learn on/off). See soarkernel.h for a list of these + system parameters. The "call_data" argument is an "int" which + indicates which system parameter is being changed. This function + should examine the new value of the parameter by looking at the + appropriate agent variable. (For most parameters, this means + looking at the sysparams[] array.) + + \par INIT_LAPSE_DURATION_CALLBACK + + This function is called upon agent (re-initialization). + The "call_data" argument is a "long" which indicates the time + since the last lapse. It should be modified by the callback + to indicate how long of an attention lapse should occur. + +*/ + +/*! + + \enum SOAR_GLOBAL_CALLBACK_TYPE + + Global (Agent Independent) Callbacks + + All global callback functions installed by the user must use the + function soar_add_global_callback. The type signature of all + callback functions is the same as that used for agent-dependent + callbacks and has the following form: + + my_callback_fn(agent * a, + soar_callback_data scd, + soar_call_data call_data); + + however, in some situations, the argument "a" may be NULL, whereas + this will never be a case in a normal (agent-dependent) callback. + All other parameter, mock those in a normal callback function. + Below, arguments are specified for each global callback type: + + + \par GLB_CREATE_AGENT + + This function is called just prior to the creation of a new agent. + Because this is global becuase it is obviously impossible to register + a normal callback with an agent which has not yet been created. + The parameters passed to the callback function are: + a --> NULL + call_data --> (char *) agent_name + + \par GLB_AGENT_CREATED + + This function is called just after the creation of a new agent. + The parameters passed to the callback function are: + a --> a pointer to the new agent + call_data --> the same as above, a pointer to the new agent + + + \par GLB_DESTROY_AGENT + + This function is called just before an agent is destroyed. + The parameters passed to the callback function are: + a --> a pointer to the agent to be destroyed + call_data --> the same as above, a pointer to the + agent to be destroyed + +*/ + +typedef list *soar_callback_array[NUMBER_OF_CALLBACKS]; + +/** + * The agent upon which the callback is invoked. + * Directly castable to either \b agent \b * or \b psoar_agent + */ +typedef void *soar_callback_agent; + +/** + * A callback id is also a string + */ +typedef const char *soar_callback_id; + +/** + * Data sent to the callback function each time it is invoked. + * This data is available at the time the user + * registers the callback, and has nothing to do + * with Soar's internals whatsoever. + */ +typedef void *soar_callback_data; + +/** + * Data sent to the callback function. This content + * of this data is determined solely by the type of + * callback and the internals of Soar + */ +typedef const void *soar_call_data; + +/** + * Any callback registered with Soar, must be in + * this format. + */ +typedef void (*soar_callback_fn) (soar_callback_agent, soar_callback_data, soar_call_data); + +typedef void (*soar_callback_free_fn) (soar_callback_data); + +typedef struct callback_struct { + soar_callback_id id; + soar_callback_fn function; + soar_callback_data data; + soar_callback_free_fn free_function; +} soar_callback; + +extern void soar_callback_data_free_string(soar_callback_data); +extern char *soar_callback_enum_to_name(SOAR_CALLBACK_TYPE, bool); +extern void soar_destroy_callback(soar_callback *); +extern bool soar_exists_callback(soar_callback_agent, SOAR_CALLBACK_TYPE); +extern soar_callback *soar_exists_callback_id(soar_callback_agent the_agent, + SOAR_CALLBACK_TYPE callback_type, soar_callback_id id); +extern void soar_init_callbacks(soar_callback_agent); +extern void soar_init_global_callbacks(void); + +extern void soar_invoke_callbacks(soar_callback_agent, SOAR_CALLBACK_TYPE, soar_call_data); +extern void soar_invoke_global_callbacks(soar_callback_agent, SOAR_CALLBACK_TYPE, soar_call_data); +extern void soar_invoke_first_callback(soar_callback_agent, SOAR_CALLBACK_TYPE, soar_call_data); +extern bool soar_exists_global_callback(SOAR_GLOBAL_CALLBACK_TYPE); + +#endif diff --git a/soar-8.5.2/kernel/chunk.c b/soar-8.5.2/kernel/chunk.c new file mode 100644 index 0000000..c3d1582 --- /dev/null +++ b/soar-8.5.2/kernel/chunk.c @@ -0,0 +1,2266 @@ +/************************************************************************* + * + * file: chunk.c + * + * ======================================================================= + * Supports the learning mechanism in Soar. Learning can be set + * on | off | only | except (for other choices see soarCommands.c: learn). + * If set to "only" | "except" users must specify rhs functions in + * productions: dont-learn | force-learn. See rhsfun.c + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* ==================================================================== + + Chunking Routines + + ==================================================================== */ + +#include "soarkernel.h" +#include +#include "soar_core_utils.h" +#include "explain.h" + +extern byte type_of_existing_impasse(Symbol * goal); +extern wme *find_impasse_wme(Symbol * id, Symbol * attr); +extern void find_match_goal(instantiation * inst); + +/* ===================================================================== + + Results Calculation + + Get_results_for_instantiation() finds and returns the result preferences + for a given instantiation. This is the main routine here. + + The results are accumulated in the list "results," linked via the + "next_result" field of the preference structures. (BUGBUG: to save + space, just use conses for this.) + + Add_pref_to_results() adds a preference to the results. + Add_results_for_id() adds any preferences for the given identifier. + Identifiers are marked with results_tc_number as they are added. +===================================================================== */ + +void add_results_for_id(Symbol * id); +#ifdef DONT_CALC_GDS_OR_BT +static void add_named_superstate_attribute_to_grounds(instantiation * inst, char *name); +#endif + +#ifdef SINGLE_THIN_JUSTIFICATION +void deallocate_inst_members_to_be_rewritten(instantiation * inst); +void second_stage_chunk_instantiation(instantiation * inst); +void re_fill_in_instantiation_stuff_for_modified_lhs(instantiation * inst, bool need_to_do_support_calculations); + +#endif /* SINGLE_THIN_JUSTIFICATION */ + +#define add_results_if_needed(sym) \ + { if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \ + if ( ((sym)->id.level >= current_agent(results_match_goal_level)) && \ + ((sym)->id.tc_num != current_agent(results_tc_number)) ) \ + add_results_for_id(sym); } + +void add_pref_to_results(preference * pref) +{ + preference *p; + + /* --- if an equivalent pref is already a result, don't add this one --- */ + for (p = current_agent(results); p != NIL; p = p->next_result) { + if (p->id != pref->id) + continue; + if (p->attr != pref->attr) + continue; + if (p->value != pref->value) + continue; + if (p->type != pref->type) + continue; + if (preference_is_unary(pref->type)) + return; + if (p->referent != pref->referent) + continue; + return; + } + +#ifdef NO_TOP_JUST + /* --- if pref isn't at the right level, find a clone that is --- */ + if (pref->match_goal_level != current_agent(results_match_goal_level)) { + for (p = pref->next_clone; p != NIL; p = p->next_clone) + if (p->match_goal_level == current_agent(results_match_goal_level)) + break; + if (!p) + for (p = pref->prev_clone; p != NIL; p = p->prev_clone) + if (p->match_goal_level == current_agent(results_match_goal_level)) + break; + if (!p) + return; /* if can't find one, it isn't a result */ + pref = p; + } +#else + + /* --- if pref isn't at the right level, find a clone that is --- */ + if (pref->inst->match_goal_level != current_agent(results_match_goal_level)) { + for (p = pref->next_clone; p != NIL; p = p->next_clone) + if (p->inst->match_goal_level == current_agent(results_match_goal_level)) + break; + if (!p) + for (p = pref->prev_clone; p != NIL; p = p->prev_clone) + if (p->inst->match_goal_level == current_agent(results_match_goal_level)) + break; + if (!p) + return; /* if can't find one, it isn't a result */ + pref = p; + } +#endif + + /* --- add this preference to the result list --- */ + pref->next_result = current_agent(results); + current_agent(results) = pref; + + /* --- follow transitive closuse through value, referent links --- */ + add_results_if_needed(pref->value); + if (preference_is_binary(pref->type)) + add_results_if_needed(pref->referent); +} + +void add_results_for_id(Symbol * id) +{ + slot *s; + preference *pref; + wme *w; + + id->id.tc_num = current_agent(results_tc_number); + + /* --- scan through all preferences and wmes for all slots for this id --- */ + for (w = id->id.input_wmes; w != NIL; w = w->next) + add_results_if_needed(w->value); + for (s = id->id.slots; s != NIL; s = s->next) { + for (pref = s->all_preferences; pref != NIL; pref = pref->all_of_slot_next) + add_pref_to_results(pref); + for (w = s->wmes; w != NIL; w = w->next) + add_results_if_needed(w->value); + } /* end of for slots loop */ + /* --- now scan through extra prefs and look for any with this id --- */ + for (pref = current_agent(extra_result_prefs_from_instantiation); pref != NIL; pref = pref->inst_next) { + if (pref->id == id) + add_pref_to_results(pref); + } +} + +preference *get_results_for_instantiation(instantiation * inst) +{ + preference *pref; + + current_agent(results) = NIL; + current_agent(results_match_goal_level) = inst->match_goal_level; + current_agent(results_tc_number) = get_new_tc_number(); + current_agent(extra_result_prefs_from_instantiation) = inst->preferences_generated; + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) + if ((pref->id->id.level < current_agent(results_match_goal_level)) && + (pref->id->id.tc_num != current_agent(results_tc_number))) { + add_pref_to_results(pref); + + } + return current_agent(results); +} + +/* ===================================================================== + + Variablizing Conditions and Results + + Variablizing of conditions is done by walking over a condition list + and destructively modifying it, replacing tests of identifiers with + tests of tests of variables. The identifier-to-variable mapping is + built as we go along: identifiers that have already been assigned + a variablization are marked with id.tc_num==variablization_tc, and + id.variablization points to the corresponding variable. + + Variablizing of results can't be done destructively because we need + to convert the results--preferences--into actions. This is done + by copy_and_variablize_result_list(), which takes the result preferences + and returns an action list. + + The global variable "variablize_this_chunk" indicates whether to + variablize at all. This flag is set to TRUE or FALSE before and during + backtracing. FALSE means the new production will become a justification; + TRUE means it will be a chunk. +===================================================================== */ + +void variablize_symbol(Symbol ** sym) +{ + char prefix[2]; + Symbol *var; + + if ((*sym)->common.symbol_type != IDENTIFIER_SYMBOL_TYPE) + return; + if (!current_agent(variablize_this_chunk)) + return; + + if ((*sym)->id.tc_num == current_agent(variablization_tc)) { + /* --- it's already been variablized, so use the existing variable --- */ + var = (*sym)->id.variablization; + symbol_remove_ref(*sym); + *sym = var; + symbol_add_ref(var); + return; + } + + /* --- need to create a new variable --- */ + (*sym)->id.tc_num = current_agent(variablization_tc); + prefix[0] = (char) tolower((*sym)->id.name_letter); + prefix[1] = 0; + var = generate_new_variable(prefix); + (*sym)->id.variablization = var; + symbol_remove_ref(*sym); + *sym = var; +} + +void variablize_test(test * t) +{ + cons *c; + complex_test *ct; + + if (test_is_blank_test(*t)) + return; + if (test_is_blank_or_equality_test(*t)) { + variablize_symbol((Symbol **) t); + /* Warning: this relies on the representation of tests */ + return; + } + + ct = complex_test_from_test(*t); + + switch (ct->type) { + case GOAL_ID_TEST: + case IMPASSE_ID_TEST: + case DISJUNCTION_TEST: + return; + case CONJUNCTIVE_TEST: + for (c = ct->data.conjunct_list; c != NIL; c = c->rest) + variablize_test((test *) (&(c->first))); + return; + default: /* relational tests other than equality */ + variablize_symbol(&(ct->data.referent)); + return; + } +} + +void variablize_condition_list(condition * cond) +{ + for (; cond != NIL; cond = cond->next) { + switch (cond->type) { + case POSITIVE_CONDITION: + case NEGATIVE_CONDITION: + variablize_test(&(cond->data.tests.id_test)); + variablize_test(&(cond->data.tests.attr_test)); + variablize_test(&(cond->data.tests.value_test)); + break; + case CONJUNCTIVE_NEGATION_CONDITION: + variablize_condition_list(cond->data.ncc.top); + break; + } + } +} + +action *copy_and_variablize_result_list(preference * pref) +{ + action *a; + Symbol *temp; + + if (!pref) + return NIL; + allocate_with_pool(¤t_agent(action_pool), &a); + a->type = MAKE_ACTION; + + temp = pref->id; + symbol_add_ref(temp); + variablize_symbol(&temp); + a->id = symbol_to_rhs_value(temp); + + temp = pref->attr; + symbol_add_ref(temp); + variablize_symbol(&temp); + a->attr = symbol_to_rhs_value(temp); + + temp = pref->value; + symbol_add_ref(temp); + variablize_symbol(&temp); + a->value = symbol_to_rhs_value(temp); + + a->preference_type = pref->type; + + if (preference_is_binary(pref->type)) { + temp = pref->referent; + symbol_add_ref(temp); + variablize_symbol(&temp); + a->referent = symbol_to_rhs_value(temp); + } + + a->next = copy_and_variablize_result_list(pref->next_result); + return a; +} + +/* ==================================================================== + + Chunk Conditions, and Chunk Conditions Set Manipulation Routines + + These structures have two uses. First, for every ground condition, + one of these structures maintains certain information about it-- + pointers to the original (instantiation's) condition, the chunks's + instantiation's condition, and the variablized condition, etc. + + Second, for negated conditions, these structures are entered into + a hash table with keys hash_condition(this_cond). This hash table + is used so we can add a new negated condition to the set of negated + potentials quickly--we don't want to add a duplicate of a negated + condition that's already there, and the hash table lets us quickly + determine whether a duplicate is already there. + + I used one type of structure for both of these uses, (1) for simplicity + and (2) to avoid having to do a second allocation when we move + negated conditions over to the ground set. +==================================================================== */ + +/* -------------------------------------------------------------------- + Chunk Cond Set Routines + + Init_chunk_cond_set() initializes a given chunk_cond_set to be empty. + + Make_chunk_cond_for_condition() takes a condition and returns a + chunk_cond for it, for use in a chunk_cond_set. This is used only + for the negated conditions, not grounds. + + Add_to_chunk_cond_set() adds a given chunk_cond to a given chunk_cond_set + and returns TRUE if the condition isn't already in the set. If the + condition is already in the set, the routine deallocates the given + chunk_cond and returns FALSE. + + Remove_from_chunk_cond_set() removes a given chunk_cond from a given + chunk_cond_set, but doesn't deallocate it. +-------------------------------------------------------------------- */ + + /* set of all negated conditions we encounter + during backtracing--these are all potentials + and (some of them) are added to the grounds + in one pass at the end of the backtracing */ + +void init_chunk_cond_set(chunk_cond_set * set) +{ + int i; + + set->all = NIL; + for (i = 0; i < CHUNK_COND_HASH_TABLE_SIZE; i++) + set->table[i] = NIL; +} + +chunk_cond *make_chunk_cond_for_condition(condition * cond) +{ + chunk_cond *cc; + unsigned long remainder, hv; + + allocate_with_pool(¤t_agent(chunk_cond_pool), &cc); + cc->cond = cond; + cc->hash_value = hash_condition(cond); + remainder = cc->hash_value; + hv = 0; + while (remainder) { + hv ^= (remainder & masks_for_n_low_order_bits[LOG_2_CHUNK_COND_HASH_TABLE_SIZE]); + remainder = remainder >> LOG_2_CHUNK_COND_HASH_TABLE_SIZE; + } + cc->compressed_hash_value = hv; + return cc; +} + +bool add_to_chunk_cond_set(chunk_cond_set * set, chunk_cond * new_cc) +{ + chunk_cond *old; + + for (old = set->table[new_cc->compressed_hash_value]; old != NIL; old = old->next_in_bucket) + if (old->hash_value == new_cc->hash_value) + if (conditions_are_equal(old->cond, new_cc->cond)) + break; + if (old) { + /* --- the new condition was already in the set; so don't add it --- */ + free_with_pool(¤t_agent(chunk_cond_pool), new_cc); + return FALSE; + } + /* --- add new_cc to the table --- */ + insert_at_head_of_dll(set->all, new_cc, next, prev); + insert_at_head_of_dll(set->table[new_cc->compressed_hash_value], new_cc, next_in_bucket, prev_in_bucket); + return TRUE; +} + +void remove_from_chunk_cond_set(chunk_cond_set * set, chunk_cond * cc) +{ + remove_from_dll(set->all, cc, next, prev); + remove_from_dll(set->table[cc->compressed_hash_value], cc, next_in_bucket, prev_in_bucket); +} + +/* ==================================================================== + + Other Miscellaneous Chunking Routines + +==================================================================== */ + +/* -------------------------------------------------------------------- + Build Chunk Conds For Grounds And Add Negateds + + This routine is called once backtracing is finished. It goes through + the ground conditions and builds a chunk_cond (see above) for each + one. The chunk_cond includes two new copies of the condition: one + to be used for the initial instantiation of the chunk, and one to + be (variablized and) used for the chunk itself. + + This routine also goes through the negated conditions and adds to + the ground set (again building chunk_cond's) any negated conditions + that are connected to the grounds. + + At exit, the "dest_top" and "dest_bottom" arguments are set to point + to the first and last chunk_cond in the ground set. The "tc_to_use" + argument is the tc number that this routine will use to mark the + TC of the ground set. At exit, this TC indicates the set of identifiers + in the grounds. (This is used immediately afterwards to figure out + which Nots must be added to the chunk.) +-------------------------------------------------------------------- */ + +void build_chunk_conds_for_grounds_and_add_negateds(chunk_cond ** dest_top, + chunk_cond ** dest_bottom, tc_number tc_to_use) +{ + cons *c; + condition *ground; + chunk_cond *cc, *first_cc, *prev_cc; + + first_cc = NIL; /* unnecessary, but gcc -Wall warns without it */ + + /* --- build instantiated conds for grounds and setup their TC --- */ + prev_cc = NIL; + while (current_agent(grounds)) { + c = current_agent(grounds); + current_agent(grounds) = current_agent(grounds)->rest; + ground = c->first; + free_cons(c); + /* --- make the instantiated condition --- */ + allocate_with_pool(¤t_agent(chunk_cond_pool), &cc); + cc->cond = ground; + cc->instantiated_cond = copy_condition(cc->cond); + cc->variablized_cond = copy_condition(cc->cond); + if (prev_cc) { + prev_cc->next = cc; + cc->prev = prev_cc; + cc->variablized_cond->prev = prev_cc->variablized_cond; + prev_cc->variablized_cond->next = cc->variablized_cond; + } else { + first_cc = cc; + cc->prev = NIL; + cc->variablized_cond->prev = NIL; + } + prev_cc = cc; + /* --- add this in to the TC --- */ + add_cond_to_tc(ground, tc_to_use, NIL, NIL); + } + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + /* --- scan through negated conditions and check which ones are connected + to the grounds --- */ + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) + print_string("\n\n*** Adding Grounded Negated Conditions ***\n"); +#endif + + while (current_agent(negated_set).all) { + cc = current_agent(negated_set).all; + remove_from_chunk_cond_set(¤t_agent(negated_set), cc); + if (cond_is_in_tc(cc->cond, tc_to_use)) { + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + /* --- negated cond is in the TC, so add it to the grounds --- */ + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\n-->Moving to grounds: "); + print_condition(cc->cond); + } +#endif + + cc->instantiated_cond = copy_condition(cc->cond); + cc->variablized_cond = copy_condition(cc->cond); + if (prev_cc) { + prev_cc->next = cc; + cc->prev = prev_cc; + cc->variablized_cond->prev = prev_cc->variablized_cond; + prev_cc->variablized_cond->next = cc->variablized_cond; + } else { + first_cc = cc; + cc->prev = NIL; + cc->variablized_cond->prev = NIL; + } + prev_cc = cc; + } else { + /* --- not in TC, so discard the condition --- */ + free_with_pool(¤t_agent(chunk_cond_pool), cc); + } + } + + if (prev_cc) { + prev_cc->next = NIL; + prev_cc->variablized_cond->next = NIL; + } else { + first_cc = NIL; + } + + *dest_top = first_cc; + *dest_bottom = prev_cc; +} + +/* -------------------------------------------------------------------- + Get Nots For Instantiated Conditions + + This routine looks through all the Nots in the instantiations in + instantiations_with_nots, and returns copies of the ones involving + pairs of identifiers in the grounds. Before this routine is called, + the ids in the grounds must be marked with "tc_of_grounds." +-------------------------------------------------------------------- */ + +not *get_nots_for_instantiated_conditions(list * instantiations_with_nots, tc_number tc_of_grounds) +{ + cons *c; + instantiation *inst; + not *n1, *n2, *new_not, *collected_nots; + + /* --- collect nots for which both id's are marked --- */ + collected_nots = NIL; + while (instantiations_with_nots) { + c = instantiations_with_nots; + instantiations_with_nots = c->rest; + inst = c->first; + free_cons(c); + for (n1 = inst->nots; n1 != NIL; n1 = n1->next) { + /* --- Are both id's marked? If no, goto next loop iteration --- */ + if (n1->s1->id.tc_num != tc_of_grounds) + continue; + if (n1->s2->id.tc_num != tc_of_grounds) + continue; + /* --- If the pair already in collected_nots, goto next iteration --- */ + for (n2 = collected_nots; n2 != NIL; n2 = n2->next) { + if ((n2->s1 == n1->s1) && (n2->s2 == n1->s2)) + break; + if ((n2->s1 == n1->s2) && (n2->s2 == n1->s1)) + break; + } + if (n2) + continue; + /* --- Add the pair to collected_nots --- */ + allocate_with_pool(¤t_agent(not_pool), &new_not); + new_not->next = collected_nots; + collected_nots = new_not; + new_not->s1 = n1->s1; + symbol_add_ref(new_not->s1); + new_not->s2 = n1->s2; + symbol_add_ref(new_not->s2); + } /* end of for n1 */ + } /* end of while instantiations_with_nots */ + + return collected_nots; +} + +/* -------------------------------------------------------------------- + Variablize Nots And Insert Into Conditions + + This routine goes through the given list of Nots and, for each one, + inserts a variablized copy of it into the given condition list at + the earliest possible location. (The given condition list should + be the previously-variablized condition list that will become the + chunk's LHS.) The given condition list is destructively modified; + the given Not list is unchanged. +-------------------------------------------------------------------- */ + +void variablize_nots_and_insert_into_conditions(not * nots, condition * conds) +{ + not *n; + Symbol *var1, *var2; + test t; + complex_test *ct; + condition *c; + bool added_it; + + /* --- don't bother Not-ifying justifications --- */ + if (!current_agent(variablize_this_chunk)) + return; + + for (n = nots; n != NIL; n = n->next) { + var1 = n->s1->id.variablization; + var2 = n->s2->id.variablization; + /* --- find where var1 is bound, and add "<> var2" to that test --- */ + allocate_with_pool(¤t_agent(complex_test_pool), &ct); + t = make_test_from_complex_test(ct); + ct->type = NOT_EQUAL_TEST; + ct->data.referent = var2; + symbol_add_ref(var2); + added_it = FALSE; + for (c = conds; c != NIL; c = c->next) { + if (c->type != POSITIVE_CONDITION) + continue; + if (test_includes_equality_test_for_symbol(c->data.tests.id_test, var1)) { + add_new_test_to_test(&(c->data.tests.id_test), t); + added_it = TRUE; + break; + } + if (test_includes_equality_test_for_symbol(c->data.tests.attr_test, var1)) { + add_new_test_to_test(&(c->data.tests.attr_test), t); + added_it = TRUE; + break; + } + if (test_includes_equality_test_for_symbol(c->data.tests.value_test, var1)) { + add_new_test_to_test(&(c->data.tests.value_test), t); + added_it = TRUE; + break; + } + } + if (!added_it) { + char msg[MESSAGE_SIZE]; + strncpy(msg, "chunk.c: Internal error: couldn't add Not test to chunk\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + } /* end of for n=nots */ +} + +/* -------------------------------------------------------------------- + Add Goal or Impasse Tests + + This routine adds goal id or impasse id tests to the variablized + conditions. For each id in the grounds that happens to be the + identifier of a goal or impasse, we add a goal/impasse id test + to the variablized conditions, to make sure that in the resulting + chunk, the variablization of that id is constrained to match against + a goal/impasse. (Note: actually, in the current implementation of + chunking, it's impossible for an impasse id to end up in the ground + set. So part of this code is unnecessary.) +-------------------------------------------------------------------- */ + +void add_goal_or_impasse_tests(chunk_cond * all_ccs) +{ + chunk_cond *cc; + tc_number tc; /* mark each id as we add a test for it, so we don't add + a test for the same id in two different places */ + Symbol *id; + test t; + complex_test *ct; + + tc = get_new_tc_number(); + for (cc = all_ccs; cc != NIL; cc = cc->next) { + if (cc->instantiated_cond->type != POSITIVE_CONDITION) + continue; + id = referent_of_equality_test(cc->instantiated_cond->data.tests.id_test); + if ((id->id.isa_goal || id->id.isa_impasse) && (id->id.tc_num != tc)) { + allocate_with_pool(¤t_agent(complex_test_pool), &ct); + ct->type = (char) ((id->id.isa_goal) ? GOAL_ID_TEST : IMPASSE_ID_TEST); + t = make_test_from_complex_test(ct); + add_new_test_to_test(&(cc->variablized_cond->data.tests.id_test), t); + id->id.tc_num = tc; + } + } +} + +/* -------------------------------------------------------------------- + Reorder Instantiated Conditions + + The Rete routines require the instantiated conditions (on the + instantiation structure) to be in the same order as the original + conditions from which the Rete was built. This means that the + initial instantiation of the chunk must have its conditions in + the same order as the variablized conditions. The trouble is, + the variablized conditions get rearranged by the reorderer. So, + after reordering, we have to rearrange the instantiated conditions + to put them in the same order as the now-scrambled variablized ones. + This routine does this. + + Okay, so the obvious way is to have each variablized condition (VCond) + point to the corresponding instantiated condition (ICond). Then after + reordering the VConds, we'd scan through the VConds and say + VCond->Icond->next = VCond->next->Icond + VCond->Icond->prev = VCond->prev->Icond + (with some extra checks for the first and last VCond in the list). + + The problem with this is that it takes an extra 4 bytes per condition, + for the "ICond" field. Conditions were taking up a lot of memory in + my test cases, so I wanted to shrink them. This routine avoids needing + the 4 extra bytes by using the following trick: first "swap out" 4 + bytes from each VCond; then use that 4 bytes for the "ICond" field. + Now run the above algorithm. Finally, swap those original 4 bytes + back in. +-------------------------------------------------------------------- */ + +void reorder_instantiated_conditions(chunk_cond * top_cc, condition ** dest_inst_top, condition ** dest_inst_bottom) +{ + chunk_cond *cc; + + /* --- Step 1: swap prev pointers out of variablized conds into chunk_conds, + and swap pointer to the corresponding instantiated conds into the + variablized conds' prev pointers --- */ + for (cc = top_cc; cc != NIL; cc = cc->next) { + cc->saved_prev_pointer_of_variablized_cond = cc->variablized_cond->prev; + cc->variablized_cond->prev = cc->instantiated_cond; + } + + /* --- Step 2: do the reordering of the instantiated conds --- */ + for (cc = top_cc; cc != NIL; cc = cc->next) { + if (cc->variablized_cond->next) { + cc->instantiated_cond->next = cc->variablized_cond->next->prev; + } else { + cc->instantiated_cond->next = NIL; + *dest_inst_bottom = cc->instantiated_cond; + } + + if (cc->saved_prev_pointer_of_variablized_cond) { + cc->instantiated_cond->prev = cc->saved_prev_pointer_of_variablized_cond->prev; + } else { + cc->instantiated_cond->prev = NIL; + *dest_inst_top = cc->instantiated_cond; + } + } + + /* --- Step 3: restore the prev pointers on variablized conds --- */ + for (cc = top_cc; cc != NIL; cc = cc->next) { + cc->variablized_cond->prev = cc->saved_prev_pointer_of_variablized_cond; + } +} + +/* -------------------------------------------------------------------- + Make Clones of Results + + When we build the initial instantiation of the new chunk, we have + to fill in preferences_generated with *copies* of all the result + preferences. These copies are clones of the results. This routine + makes these clones and fills in chunk_inst->preferences_generated. +-------------------------------------------------------------------- */ + +void make_clones_of_results(preference * results, instantiation * chunk_inst) +{ + preference *p, *result_p; + + chunk_inst->preferences_generated = NIL; + for (result_p = results; result_p != NIL; result_p = result_p->next_result) { + /* --- copy the preference --- */ + p = make_preference(result_p->type, result_p->id, result_p->attr, result_p->value, result_p->referent); + symbol_add_ref(p->id); + symbol_add_ref(p->attr); + symbol_add_ref(p->value); + if (preference_is_binary(p->type)) + symbol_add_ref(p->referent); + /* --- put it onto the list for chunk_inst --- */ + p->inst = chunk_inst; + insert_at_head_of_dll(chunk_inst->preferences_generated, p, inst_next, inst_prev); + /* --- insert it into the list of clones for this preference --- */ + p->next_clone = result_p; + p->prev_clone = result_p->prev_clone; + result_p->prev_clone = p; + if (p->prev_clone) + p->prev_clone->next_clone = p; + } +} + +/* kjh (B14) begin */ +Symbol *find_goal_at_goal_stack_level(goal_stack_level level) +{ + Symbol *g; + + for (g = current_agent(top_goal); g != NIL; g = g->id.lower_goal) + if (g->id.level == level) + return (g); + return (NIL); +} + +Symbol *find_impasse_wme_value(Symbol * id, Symbol * attr) +{ + wme *w; + + for (w = id->id.impasse_wmes; w != NIL; w = w->next) + if (w->attr == attr) + return w->value; + return NIL; +} + +#define NAME_SIZE 512 +#define IMPASS_NAME_SIZE 32 +Symbol *generate_chunk_name_sym_constant(instantiation * inst) +{ + char name[NAME_SIZE]; + char impass_name[IMPASS_NAME_SIZE]; + Symbol *generated_name; + Symbol *goal; + byte impasse_type; + preference *p; + goal_stack_level lowest_result_level; + + if (!current_agent(sysparams)[USE_LONG_CHUNK_NAMES]) + return (generate_new_sym_constant(current_agent(chunk_name_prefix), ¤t_agent(chunk_count))); + + lowest_result_level = current_agent(top_goal)->id.level; + for (p = inst->preferences_generated; p != NIL; p = p->inst_next) + if (p->id->id.level > lowest_result_level) + lowest_result_level = p->id->id.level; + + goal = find_goal_at_goal_stack_level(lowest_result_level); + + if (goal) { + impasse_type = type_of_existing_impasse(goal); + + /* Note that in this switch statement we set the impasse_name variable "safely" using strncpy. + strncpy automatically null terminates the copy unless it was truncated. To be safe, then, + we always put a NULL character at the end of the array. In this case, we can do this after + the if/else statements instead of right after every strncpy since the result of every + strncpy gets funneled past there. + */ + switch (impasse_type) { + case NONE_IMPASSE_TYPE: + print("Internal error: impasse_type is NONE_IMPASSE_TYPE during chunk creation.\n"); + strncpy(impass_name, "unknownimpasse", IMPASS_NAME_SIZE); + break; + case CONSTRAINT_FAILURE_IMPASSE_TYPE: + strncpy(impass_name, "cfailure", IMPASS_NAME_SIZE); + break; + case CONFLICT_IMPASSE_TYPE: + strncpy(impass_name, "conflict", IMPASS_NAME_SIZE); + break; + case TIE_IMPASSE_TYPE: + strncpy(impass_name, "tie", IMPASS_NAME_SIZE); + break; + case NO_CHANGE_IMPASSE_TYPE: + { + Symbol *sym; + + if ((sym = find_impasse_wme_value(goal->id.lower_goal, current_agent(attribute_symbol))) == NIL) { +#ifdef DEBUG_CHUNK_NAMES + print("Internal error: Failed to find ^attribute impasse wme.\n"); + do_print_for_identifier(goal->id.lower_goal, 1, 0); +#endif + strncpy(impass_name, "unknownimpasse", IMPASS_NAME_SIZE); + } else if (sym == current_agent(operator_symbol)) { + strncpy(impass_name, "opnochange", IMPASS_NAME_SIZE); + } else if (sym == current_agent(state_symbol)) { + strncpy(impass_name, "snochange", IMPASS_NAME_SIZE); + } else { +#ifdef DEBUG_CHUNK_NAMES + print("Internal error: ^attribute impasse wme has unexpected value.\n"); +#endif + strncpy(impass_name, "unknownimpasse", IMPASS_NAME_SIZE); + } + } + break; + default: + print("Internal error: encountered unknown impasse_type: %d.\n", impasse_type); + strncpy(impass_name, "unknownimpasse", IMPASS_NAME_SIZE); + break; + } + } else { + print("Internal error: Failed to determine impasse type.\n"); + strncpy(impass_name, "unknownimpasse", IMPASS_NAME_SIZE); + } + impass_name[IMPASS_NAME_SIZE - 1] = 0; + + snprintf(name, NAME_SIZE, "%s-%lu*d%lu*%s*%lu", + current_agent(chunk_name_prefix), + current_agent(chunk_count++), current_agent(d_cycle_count), impass_name, current_agent(chunks_this_d_cycle) + ); + name[NAME_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ + + /* Any user who named a production like this deserves to be burned, but we'll have mercy: */ + if (find_sym_constant(name)) { + unsigned long collision_count; + + collision_count = 1; + print("Warning: generated chunk name already exists. Will find unique name.\n"); + do { + snprintf(name, NAME_SIZE, "%s-%lu*d%lu*%s*%lu*%lu", + current_agent(chunk_name_prefix), + current_agent(chunk_count++), + current_agent(d_cycle_count), impass_name, current_agent(chunks_this_d_cycle), collision_count++); + name[NAME_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ + } while (find_sym_constant(name)); + } + + generated_name = make_sym_constant(name); + return generated_name; +} + +/* kjh (B14) end */ + +/* ==================================================================== + + Chunk Instantiation + + This the main chunking routine. It takes an instantiation, and a + flag "allow_variablization"--if FALSE, the chunk will not be + variablized. (If TRUE, it may still not be variablized, due to + chunk-free-problem-spaces, ^quiescence t, etc.) +==================================================================== */ + +void chunk_instantiation(instantiation * inst, bool allow_variablization) +{ + goal_stack_level grounds_level; + preference *results, *pref; + instantiation *chunk_inst; + Symbol *prod_name; + byte prod_type; + bool print_name, print_prod; + + condition *lhs_top, *lhs_bottom; + not *nots; + chunk_cond *top_cc, *bottom_cc; + explain_chunk_str temp_explain_chunk; + +#if !defined(THIN_JUSTIFICATIONS) || defined(MAKE_PRODUCTION_FOR_THIN_JUSTS) + production *prod; + action *rhs; +#endif + +#ifndef THIN_JUSTIFICATIONS + byte rete_addition_result; +#endif + +#if !defined(NO_TIMING_STUFF) && defined(DETAILED_TIMING_STATS) + struct timeval saved_start_tv; +#endif + + /* These two lines quell compiler warnings */ + temp_explain_chunk.conds = NULL; + temp_explain_chunk.actions = NULL; + + /* --- if it only matched an attribute impasse, don't chunk --- */ + if (!inst->match_goal) + return; + +#ifdef WATCH_PREFS_GENERATED + print("\nPreferences Generated for instantiation at top of ci\n"); + print_instantiation_with_wmes(inst, TIMETAG_WME_TRACE); + print("\n Instantiation Match Goal Level = %d", inst->match_goal_level); + print("\n---------------------------------------------\n"); + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + watchful_print_preference(pref); + print("Reference count = %d\n", pref->reference_count); + } + print("\n"); +#endif + + /* --- if no preference is above the match goal level, exit --- */ + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + if (pref->id->id.level < inst->match_goal_level) + break; + } + if (!pref) + return; + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + start_timer(&saved_start_tv); +#endif +#endif + +/* REW: begin 09.15.96 */ + + /* + + in OPERAND, we only wanna built a chunk for the top goal; i.e. no + intermediate chunks are build. we're essentially creating + "top-down chunking"; just the opposite of the "bottom-up chunking" + that is available through a soar prompt-level comand. + + (why do we do this?? i don't remember...) + + we accomplish this by forcing only justifications to be built for + subgoal chunks. and when we're about to build the top level + result, we make a chunk. a cheat, but it appears to work. of + course, this only kicks in if learning is turned on. + + i get the behavior i want by twiddling the allow_variablization + flag. i set it to FALSE for intermediate results. then for the + last (top-most) result, i set it to whatever it was when the + function was called. + + by the way, i need the lower level justificiations because they + support the upper level justifications; i.e. a justification at + level i supports the justification at level i-1. i'm talkin' outa + my butt here since i don't know that for a fact. it's just that + i tried building only the top level chunk and ignored the + intermediate justifications and the system complained. my + explanation seemed reasonable, at the moment. + + */ + +#ifndef DONT_ALLOW_VARIABLIZATION + +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + + if (current_agent(sysparams)[LEARNING_ON_SYSPARAM] == TRUE) { + if (pref->id->id.level < (inst->match_goal_level - 1)) { + allow_variablization = FALSE; + inst->okay_to_variablize = FALSE; + + if (current_agent(soar_verbose_flag) == TRUE) + print("\n in chunk_instantiation: making justification only"); + } + + else { + allow_variablization = (bool) current_agent(sysparams)[LEARNING_ON_SYSPARAM]; + inst->okay_to_variablize = (byte) current_agent(sysparams)[LEARNING_ON_SYSPARAM]; + + if (current_agent(soar_verbose_flag) == TRUE) + print("\n in chunk_instantiation: resetting allow_variablization to %s", + ((allow_variablization) ? "TRUE" : "FALSE")); + } + } + +#ifndef SOAR_8_ONLY + } +#endif + +#else /* DONT_ALLOW_VARIABLIZATION */ + + inst->okay_to_variablize = FALSE; + +#endif /* DONT_ALLOW_VARIABLIZATION */ + +/* REW: end 09.15.96 */ + + results = get_results_for_instantiation(inst); + + if (!results) + goto chunking_done; + +#ifdef OPTIMIZE_TOP_LEVEL_RESULTS + { + preference *the_temp_pref; + bool optimize = TRUE; + Symbol *top_level_goal = NIL; + + for (the_temp_pref = inst->preferences_generated; the_temp_pref != NIL; + the_temp_pref = the_temp_pref->inst_next) { + if (the_temp_pref->id->id.level != 1) { + optimize = FALSE; + } else if (!top_level_goal && the_temp_pref->id->id.isa_goal) { + top_level_goal = the_temp_pref->id; + } + + } + + if (optimize) { + + /* + print( "Optimizing this result.\n" ); + printf( "Optimizing this result.\n" ); + */ + + allocate_with_pool(¤t_agent(instantiation_pool), &chunk_inst); + chunk_inst->prod = NIL; + chunk_inst->top_of_instantiated_conditions = NIL; + chunk_inst->bottom_of_instantiated_conditions = NIL; + chunk_inst->nots = NIL; + chunk_inst->GDS_evaluated_already = FALSE; + chunk_inst->okay_to_variablize = FALSE; + + make_clones_of_results(results, chunk_inst); + fill_in_new_instantiation_stuff(chunk_inst, FALSE); + + for (the_temp_pref = chunk_inst->preferences_generated; + the_temp_pref != NIL; the_temp_pref = the_temp_pref->inst_next) { + /* + if ( the_temp_pref->o_supported == FALSE ) { + printf( "Warning: Optimizing a result with I-supported results.\n" ); + } + */ + the_temp_pref->o_supported = TRUE; + the_temp_pref->match_goal_level = 1; + the_temp_pref->match_goal = top_level_goal; + + } + /* + printf( "Inst = %p\n", inst ); + printf( "Setting Chunk_inst (%p) match goal to 1\n", chunk_inst ); + */ + chunk_inst->match_goal = top_level_goal; + chunk_inst->match_goal_level = 1; + chunk_inst->in_ms = TRUE; + chunk_inst->next = current_agent(newly_created_instantiations); + current_agent(newly_created_instantiations) = chunk_inst; + + goto chunking_done; + + } + } +#endif + +#ifdef WATCH_RESULTS + { + preference *the_temp_pref; + + print("\nResults for instantiaition:\n"); + print_instantiation_with_wmes(inst, TIMETAG_WME_TRACE); + print("\n---------------------------\n"); + for (the_temp_pref = results; the_temp_pref != NIL; the_temp_pref = the_temp_pref->next_result) { + watchful_print_preference(the_temp_pref); + print("References for id at top of chunk_inst = %d\n", the_temp_pref->id->common.reference_count); + + } + print("\n"); + } +#endif + +#ifdef WATCH_INST_CONDS + print_with_symbols("\nIn chunk_instantiation.\nInst which will be chunked is: %y -- conditions:\n", + inst->prod->name); + print("Address %p\n", inst); + print_condition_list(inst->top_of_instantiated_conditions, 2, TRUE); + if (inst->top_of_instantiated_conditions == NIL) { + print("There are no pointers here...\n"); + } +#endif + + /* --- update flags on goal stack for bottom-up chunking --- */ + { + Symbol *g; + for (g = inst->match_goal->id.higher_goal; g && g->id.allow_bottom_up_chunks; g = g->id.higher_goal) + g->id.allow_bottom_up_chunks = FALSE; + } + + grounds_level = (short) (inst->match_goal_level - 1); + + current_agent(backtrace_number)++; + if (current_agent(backtrace_number) == 0) + current_agent(backtrace_number) = 1; + current_agent(grounds_tc)++; + if (current_agent(grounds_tc) == 0) + current_agent(grounds_tc) = 1; + current_agent(potentials_tc)++; + if (current_agent(potentials_tc) == 0) + current_agent(potentials_tc) = 1; + current_agent(locals_tc)++; + if (current_agent(locals_tc) == 0) + current_agent(locals_tc) = 1; + current_agent(grounds) = NIL; + current_agent(positive_potentials) = NIL; + current_agent(locals) = NIL; + current_agent(instantiations_with_nots) = NIL; + +#ifndef DONT_ALLOW_VARIABLIZATION + + if (allow_variablization && (!current_agent(sysparams)[LEARNING_ALL_GOALS_SYSPARAM])) + allow_variablization = inst->match_goal->id.allow_bottom_up_chunks; + +#endif /* DONT_ALLOW_VARIABLIZATION */ + + /* DJP : Need to initialize chunk_free_flag to be FALSE, as default before + looking for problem spaces and setting the chunk_free_flag below */ + + current_agent(chunk_free_flag) = FALSE; + /* DJP : Noticed this also isn't set if no ps_name */ + current_agent(chunky_flag) = FALSE; + +#ifndef DONT_ALLOW_VARIABLIZATION + + /* --- check whether ps name is in chunk_free_problem_spaces --- */ + if (allow_variablization) { + + /* KJC new implementation of learn cmd: old SPECIFY ==> ONLY, + * old ON ==> EXCEPT, now ON is just ON always + * checking if state is chunky or chunk-free... + */ + if (current_agent(sysparams)[LEARNING_EXCEPT_SYSPARAM]) { + if (member_of_list(inst->match_goal, current_agent(chunk_free_problem_spaces))) { + allow_variablization = FALSE; + current_agent(chunk_free_flag) = TRUE; + } + } else if (current_agent(sysparams)[LEARNING_ONLY_SYSPARAM]) { + if (member_of_list(inst->match_goal, current_agent(chunky_problem_spaces))) { + allow_variablization = TRUE; + current_agent(chunky_flag) = TRUE; + } else { + allow_variablization = FALSE; + current_agent(chunky_flag) = FALSE; + } + } + } + /* end KJC mods */ + current_agent(variablize_this_chunk) = allow_variablization; + +#else /* DONT_ALLOW_VARIABLIZATION */ + + current_agent(variablize_this_chunk) = FALSE; +#endif /* DONT_ALLOW_VARIABLIZATION */ + +#ifndef THIN_JUSTIFICATIONS + + /* Start a new structure for this potential chunk */ + + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) { + temp_explain_chunk.conds = NULL; + temp_explain_chunk.actions = NULL; + temp_explain_chunk.backtrace = NULL; + temp_explain_chunk.name[0] = '\0'; + temp_explain_chunk.all_grounds = NIL; + temp_explain_chunk.next_chunk = NULL; + reset_backtrace_list(); + } +#endif /* !THIN_JUSTIFICATIONS */ + +#ifndef NO_BACKTRACING +#ifndef DONT_CALC_GDS_OR_BT + + /* --- backtrace through the instantiation that produced each result --- */ + for (pref = results; pref != NIL; pref = pref->next_result) { + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\nFor result preference "); + print_preference(pref); + print_string(" "); + } +#endif + +#ifdef NO_TOP_JUST + if (pref->inst) + backtrace_through_instantiation(pref->inst, grounds_level, NULL, 0); + +#else + backtrace_through_instantiation(pref->inst, grounds_level, NULL, 0); + +#endif + + } + +#else + add_named_superstate_attribute_to_grounds(inst, "superstate"); +#endif + +#endif /* NO_BACKTRACING */ + + current_agent(quiescence_t_flag) = FALSE; + + for (;;) { + trace_locals(grounds_level); + trace_grounded_potentials(); + if (!trace_ungrounded_potentials(grounds_level)) + break; + } + free_list(current_agent(positive_potentials)); + + /* --- backtracing done; collect the grounds into the chunk --- */ + { + tc_number tc_for_grounds; + tc_for_grounds = get_new_tc_number(); + build_chunk_conds_for_grounds_and_add_negateds(&top_cc, &bottom_cc, tc_for_grounds); + nots = get_nots_for_instantiated_conditions(current_agent(instantiations_with_nots), tc_for_grounds); + } + + /* --- get symbol for name of new chunk or justification --- */ + +#ifndef DONT_ALLOW_VARIABLIZATION + + if (current_agent(variablize_this_chunk)) { + /* kjh (B14) begin */ + current_agent(chunks_this_d_cycle)++; + prod_name = generate_chunk_name_sym_constant(inst); + /* kjh (B14) end */ + + prod_type = CHUNK_PRODUCTION_TYPE; + print_name = (bool) current_agent(sysparams)[TRACE_CHUNK_NAMES_SYSPARAM]; + print_prod = (bool) current_agent(sysparams)[TRACE_CHUNKS_SYSPARAM]; + + } else { + +#endif /* DONT_ALLOW_VARIABLIZATION */ + +#ifdef THIN_JUSTIFICATIONS + prod_name = generate_new_sym_constant("temp-justification-", ¤t_agent(justification_count)); +#else + prod_name = generate_new_sym_constant("justification-", ¤t_agent(justification_count)); +#endif /* THIN_JUSTIFICATIONS */ + + prod_type = JUSTIFICATION_PRODUCTION_TYPE; + print_name = (bool) current_agent(sysparams)[TRACE_JUSTIFICATION_NAMES_SYSPARAM]; + print_prod = (bool) current_agent(sysparams)[TRACE_JUSTIFICATIONS_SYSPARAM]; + +#ifndef DONT_ALLOW_VARIABLIZATION + } +#endif /* DONT_ALLOW_VARIABLIZATION */ + + /* AGR 617/634 begin */ + if (print_name) { + if (get_printer_output_column() != 1) + print("\n"); + print_with_symbols("Building %y", prod_name); + +#if defined(THIN_JUSTIFICATIONS) && !defined(MAKE_PRODUCTION_FOR_THIN_JUSTS) + print("...thin justification, no prod"); +#endif + + } + /* AGR 617/634 end */ + + /* --- if there aren't any grounds, exit --- */ + if (!top_cc) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print_string(" Warning: chunk has no grounds, ignoring it."); + goto chunking_done; + } +#ifndef DONT_ALLOW_VARIABLIZATION + + /* MVP 6-8-94 */ + if (current_agent(chunks_this_d_cycle) > (unsigned long) current_agent(sysparams)[MAX_CHUNKS_SYSPARAM]) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print("\nWarning: reached max-chunks! Halting system."); + current_agent(max_chunks_reached) = TRUE; + goto chunking_done; + } +#endif /* DONT_ALLOW_VARIABLIZATION */ + + /* --- variablize it --- */ + lhs_top = top_cc->variablized_cond; + lhs_bottom = bottom_cc->variablized_cond; + reset_variable_generator(lhs_top, NIL); + current_agent(variablization_tc) = get_new_tc_number(); + variablize_condition_list(lhs_top); + variablize_nots_and_insert_into_conditions(nots, lhs_top); +#if !defined(THIN_JUSTIFICATIONS) || defined(MAKE_PRODUCTION_FOR_THIN_JUSTS) + rhs = copy_and_variablize_result_list(results); +#endif + + /* --- add goal/impasse tests to it --- */ + add_goal_or_impasse_tests(top_cc); + + /* --- reorder lhs and make the production --- */ +#if !defined(THIN_JUSTIFICATIONS) || defined(MAKE_PRODUCTION_FOR_THIN_JUSTS) + + prod = make_production(prod_type, prod_name, &lhs_top, &lhs_bottom, &rhs, FALSE); + + if (!prod) { + print("\nUnable to reorder this chunk:\n "); + print_condition_list(lhs_top, 2, FALSE); + print("\n -->\n "); + print_action_list(rhs, 3, FALSE); + print("\n\n(Ignoring this chunk. Weird things could happen from now on...)\n"); + goto chunking_done; /* this leaks memory but who cares */ + } +#endif /* !THIN_JUSTIFICATIONS || MAKE_PRODUCTION_FOR_THIN_JUSTS */ + + { + condition *inst_lhs_top, *inst_lhs_bottom; + + reorder_instantiated_conditions(top_cc, &inst_lhs_top, &inst_lhs_bottom); + + /* Record the list of grounds in the order they will appear in the chunk */ + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) + temp_explain_chunk.all_grounds = inst_lhs_top; /* Not a copy yet */ + + allocate_with_pool(¤t_agent(instantiation_pool), &chunk_inst); + +#if !defined(THIN_JUSTIFICATIONS) || defined(MAKE_PRODUCTION_FOR_THIN_JUSTS) + chunk_inst->prod = prod; +#else + chunk_inst->prod = NIL; +#endif /* !THIN_JUSTIFICATIONS || MAKE_PRODUCTION_FOR_THIN_JUSTS */ + + chunk_inst->top_of_instantiated_conditions = inst_lhs_top; + +#ifdef WATCH_SSCI_CONDS + + print("\nCreating temp-justification: "); + + if (chunk_inst->prod) + print_with_symbols("%y...conditions:\n", chunk_inst->prod->name); + else + print("(nil) ... conditions:\n"); + + print("Address %p\n", chunk_inst); + print_condition_list(chunk_inst->top_of_instantiated_conditions, 2, TRUE); + if (chunk_inst->top_of_instantiated_conditions == NIL) { + print("There are no pointers here...\n"); + } +#endif + + chunk_inst->bottom_of_instantiated_conditions = inst_lhs_bottom; + chunk_inst->nots = nots; + chunk_inst->GDS_evaluated_already = FALSE; /* REW: 09.15.96 */ + + /* If: + - you don't want to variablize this chunk, and + - the reason is ONLY that it's chunk free, and + - NOT that it's also quiescence, then + it's okay to variablize through this instantiation later. + */ + + /* AGR MVL1 begin */ + if (!current_agent(sysparams)[LEARNING_ONLY_SYSPARAM]) { + if ((!current_agent(variablize_this_chunk)) + && (current_agent(chunk_free_flag)) + && (!current_agent(quiescence_t_flag))) + chunk_inst->okay_to_variablize = TRUE; + else + chunk_inst->okay_to_variablize = current_agent(variablize_this_chunk); + } else { + if ((!current_agent(variablize_this_chunk)) + && (!current_agent(chunky_flag)) + && (!current_agent(quiescence_t_flag))) + chunk_inst->okay_to_variablize = TRUE; + else + chunk_inst->okay_to_variablize = current_agent(variablize_this_chunk); + } + /* AGR MVL1 end */ + + chunk_inst->in_ms = TRUE; /* set TRUE for now, we'll find out later... */ + + /* Increments symbol reference counts */ + make_clones_of_results(results, chunk_inst); + + fill_in_new_instantiation_stuff(chunk_inst, TRUE); + + } /* matches { condition *inst_lhs_top, *inst_lhs_bottom ... */ + +#ifdef WARN_IF_RESULT_IS_I_SUPPORTED + /* + * SW 110499 + * + * When we use the Soar-lite feature of not adding justifications + * to the rete, we bump up against a potential problem: + * Without a production in the rete, there is no way to know + * when an instantiation should be retracted (I think!). As a result, + * we can end up with a huge memory leak. We get around this by assuming + * that subgoal results are o-supported. If this is the case, we + * can safely remove the instantiations once the preferences have been + * asserted. However, this could influence the way certain Soar programs + * run. As a result, it may or may not be desireable to actually force + * subgoal results to be o-supported without telling anyone... + */ + + for (pref = chunk_inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + if (pref->o_supported == FALSE) { + print("Warning: Result is not natively o-supported. "); +#ifdef THIN_JUSTIFICATIONS +#ifdef ALLOW_I_SUPPORTED_SUBGOAL_RESULTS_WITH_THIN_JUSTS + print("This may produce memory leaks.\n"); +#else + print("O-support will be forced.\n"); +#endif +#endif /* THIN_JUSTIFICATIONS */ + + watchful_print_preference(pref); + } + } +#endif /* WARN_IF_RESULT_IS_I_SUPPORTED */ + +#if defined(DONT_CALC_GDS_OR_BT) || (defined(THIN_JUSTIFICATIONS) && !defined(ALLOW_I_SUPPORTED_SUBGOAL_RESULTS_WITH_THIN_JUSTS)) + + /* DJP Now force all results to be o-supported */ + /* Have to wait till the clone preferences are created */ + for (pref = chunk_inst->preferences_generated; pref != NIL; pref = pref->inst_next) + + pref->o_supported = TRUE; /* These preferences are all results */ + +#endif + +#ifndef THIN_JUSTIFICATIONS + + /* RBD 4/6/95 Need to copy cond's and actions for the production here, + otherwise some of the variables might get deallocated by the call to + add_production_to_rete() when it throws away chunk variable names. */ + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) { + condition *new_top, *new_bottom; + copy_condition_list(lhs_top, &new_top, &new_bottom); + temp_explain_chunk.conds = new_top; + temp_explain_chunk.actions = copy_and_variablize_result_list(results); + } + + rete_addition_result = add_production_to_rete(prod, lhs_top, chunk_inst, print_name); + +#ifdef WATCH_CHUNK_INST + if (rete_addition_result == REFRACTED_INST_MATCHED) + print("\nAdded chunk/justification to rete -- result: MATCHED\n"); + else if (rete_addition_result == REFRACTED_INST_DID_NOT_MATCH) + print("\nAdded chunk/justification to rete -- result: DID NOT MATCH\n"); + else + print("\nAdded chunk/justification to rete -- result: DUPLICATE\n"); +#endif + + /* If didn't immediately excise the chunk from the rete net + then record the temporary structure in the list of explained chunks. */ + + if (current_agent(sysparams)[EXPLAIN_SYSPARAM]) { + if ((rete_addition_result != DUPLICATE_PRODUCTION) && + ((prod_type != JUSTIFICATION_PRODUCTION_TYPE) || (rete_addition_result != REFRACTED_INST_DID_NOT_MATCH))) { + strncpy(temp_explain_chunk.name, prod_name->sc.name, PROD_NAME_SIZE); + temp_explain_chunk.name[PROD_NAME_SIZE - 1] = 0; + explain_add_temp_to_chunk_list(&temp_explain_chunk); + } else { + /* RBD 4/6/95 if excised the chunk, discard previously-copied stuff */ + deallocate_condition_list(temp_explain_chunk.conds); + deallocate_action_list(temp_explain_chunk.actions); + } + } + /* --- deallocate chunks conds and variablized conditions --- */ + deallocate_condition_list(lhs_top); + { + chunk_cond *cc; + while (top_cc) { + cc = top_cc; + top_cc = cc->next; + free_with_pool(¤t_agent(chunk_cond_pool), cc); + } + } + + if (print_prod && (rete_addition_result != DUPLICATE_PRODUCTION)) { + print_string("\n"); + print_production(prod, FALSE); + } + + if (rete_addition_result == DUPLICATE_PRODUCTION) { + excise_production(prod, FALSE); + } else if ((prod_type == JUSTIFICATION_PRODUCTION_TYPE) && (rete_addition_result == REFRACTED_INST_DID_NOT_MATCH)) { + excise_production(prod, FALSE); + } + + if (rete_addition_result != REFRACTED_INST_MATCHED) { + /* --- it didn't match, or it was a duplicate production --- */ + /* --- tell the firer it didn't match, so it'll only assert the + o-supported preferences --- */ + chunk_inst->in_ms = FALSE; + } +#else /* THIN_JUSTIFICATIONS */ + + /* I think this will take care of the 102099 Memory Leak */ + /* --- deallocate chunks conds and variablized conditions --- */ + deallocate_condition_list(lhs_top); +#ifdef DONT_CALC_GDS_OR_BT + /* SW NOTE See the note in add_named_superstate_attribute_to_grounds */ + deallocate_condition_list(top_cc->cond); +#endif + { + chunk_cond *cc; + while (top_cc) { + cc = top_cc; + top_cc = cc->next; + free_with_pool(¤t_agent(chunk_cond_pool), cc); + } + } + + if (print_prod) { + print_string("\n -- Justification (not added to rete) -- \n"); + { + preference *the_temp_pref; + + print("\nResults for instantiaition:\n"); + print_instantiation_with_wmes(chunk_inst, FULL_WME_TRACE); + print("\n---------------------------\n"); + for (the_temp_pref = chunk_inst->preferences_generated; + the_temp_pref != NIL; the_temp_pref = the_temp_pref->inst_next) { + watchful_print_preference(the_temp_pref); + } + print("\n"); + } + + } +#endif /* !THIN_JUSTIFICATIONS */ + + /* SW 090799 These two lines of code are necessary for the GDS... */ + /* --- assert the preferences --- */ + chunk_inst->next = current_agent(newly_created_instantiations); + current_agent(newly_created_instantiations) = chunk_inst; + + /* MVP 6-8-94 */ + if (!current_agent(max_chunks_reached)) +#ifndef THIN_JUSTIFICATIONS + chunk_instantiation(chunk_inst, current_agent(variablize_this_chunk)); + +#else /* THIN_JUSTIFICATIONS */ + + if (chunk_inst->isa_ssci_inst != TRUE) { + chunk_inst->isa_ssci_inst = TRUE; + } +#ifdef WATCH_SSCI_INSTS + + print("\nCreating an SSCI instantiation: "); + if (chunk_inst->prod) + print_with_symbols("%y\n", chunk_inst->prod->name); + else + print("(nil)\n"); + +#endif /* WATCH_SSCI_INSTS */ + +#ifdef SINGLE_THIN_JUSTIFICATION + second_stage_chunk_instantiation(chunk_inst); + +#else /* !SINGLE_THIN_JUSTIFICATION --> THIN_JUSTIFICATIONS */ + + /* + * 102699 + * we can use a recursive call to chunk_inst as opposed to ssci + * to avoid the tr.soar memory leak. Today, I will try to fix + * ssci + */ + chunk_instantiation(chunk_inst, FALSE); + +#endif /* SINGLE_THIN_JUSTIFICATION */ + +#endif /* !THIN_JUSTIFICATION */ + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + stop_timer(&saved_start_tv, ¤t_agent(chunking_cpu_time[current_agent(current_phase)])); +#endif +#endif + + return; + + chunking_done:{ + } + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + stop_timer(&saved_start_tv, ¤t_agent(chunking_cpu_time[current_agent(current_phase)])); +#endif +#endif + +} + +#ifdef SINGLE_THIN_JUSTIFICATION + +void second_stage_chunk_instantiation(instantiation * inst) +{ + goal_stack_level grounds_level; + preference *results, *pref; + bool print_name, print_prod; + condition *lhs_top, *lhs_bottom; + not *nots; + chunk_cond *top_cc, *bottom_cc; + + /* --- if it only matched an attribute impasse, don't chunk --- */ + if (!inst->match_goal) + return; + +#ifdef WATCH_PREFS_GENERATED + print("\nPreferences Generated for instantiation at top of sscii\n"); + print_instantiation_with_wmes(inst, TIMETAG_WME_TRACE); + print("\n Instantiation Match Goal Level = %d", inst->match_goal_level); + print("\n---------------------------------------------\n"); + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + watchful_print_preference(pref); + print("Reference count = %d\n", pref->reference_count); + } + print("\n"); +#endif + + /* --- if no preference is above the match goal level, exit --- */ + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + if (pref->id->id.level < inst->match_goal_level) + break; + } + if (!pref) + return; + inst->okay_to_variablize = FALSE; + + results = get_results_for_instantiation(inst); + +#ifdef WATCH_RESULTS + { + preference *the_temp_pref; + + print("\nResults for instantiaition:\n"); + print_instantiation_with_wmes(inst, TIMETAG_WME_TRACE); + print("\n---------------------------\n"); + for (the_temp_pref = results; the_temp_pref != NIL; the_temp_pref = the_temp_pref->next_result) { + watchful_print_preference(the_temp_pref); + + } + print("\n"); + } +#endif + + if (!results) + goto chunking_done; + + /* --- update flags on goal stack for bottom-up chunking --- */ + { + Symbol *g; + for (g = inst->match_goal->id.higher_goal; g && g->id.allow_bottom_up_chunks; g = g->id.higher_goal) + g->id.allow_bottom_up_chunks = FALSE; + } + + grounds_level = inst->match_goal_level - 1; + + current_agent(backtrace_number)++; + if (current_agent(backtrace_number) == 0) + current_agent(backtrace_number) = 1; + current_agent(grounds_tc)++; + if (current_agent(grounds_tc) == 0) + current_agent(grounds_tc) = 1; + current_agent(potentials_tc)++; + if (current_agent(potentials_tc) == 0) + current_agent(potentials_tc) = 1; + current_agent(locals_tc)++; + if (current_agent(locals_tc) == 0) + current_agent(locals_tc) = 1; + current_agent(grounds) = NIL; + current_agent(positive_potentials) = NIL; + current_agent(locals) = NIL; + current_agent(instantiations_with_nots) = NIL; + + /* DJP : Need to initialize chunk_free_flag to be FALSE, as default before + looking for problem spaces and setting the chunk_free_flag below */ + + current_agent(chunk_free_flag) = FALSE; + /* DJP : Noticed this also isn't set if no ps_name */ + current_agent(chunky_flag) = FALSE; + + current_agent(variablize_this_chunk) = FALSE; + +#ifndef NO_BACKTRACING +#ifndef DONT_CALC_GDS_OR_BT + + /* --- backtrace through the instantiation that produced each result --- */ + for (pref = results; pref != NIL; pref = pref->next_result) { + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_BACKTRACING_SYSPARAM]) { + print_string("\nFor result preference "); + print_preference(pref); + print_string(" "); + } +#endif + + if (pref->inst) + backtrace_through_instantiation(pref->inst, grounds_level, NULL, 0); + + } + +#else + add_named_superstate_attribute_to_grounds(inst, "superstate"); +#endif + +#endif /* NO_BACKTRACING */ + + current_agent(quiescence_t_flag) = FALSE; + + while (TRUE) { + trace_locals(grounds_level); + trace_grounded_potentials(); + if (!trace_ungrounded_potentials(grounds_level)) + break; + } + free_list(current_agent(positive_potentials)); + + /* --- backtracing done; collect the grounds into the chunk --- */ + { + tc_number tc_for_grounds; + tc_for_grounds = get_new_tc_number(); + build_chunk_conds_for_grounds_and_add_negateds(&top_cc, &bottom_cc, tc_for_grounds); + nots = get_nots_for_instantiated_conditions(current_agent(instantiations_with_nots), tc_for_grounds); + } + + /* --- get symbol for name of new chunk or justification --- */ +#ifdef MAKE_PRODUCTION_FOR_THIN_JUSTS + if (inst->prod->type != JUSTIFICATION_PRODUCTION_TYPE) { + print("Warning (1)\n"); + } +#endif + + print_name = current_agent(sysparams)[TRACE_JUSTIFICATION_NAMES_SYSPARAM]; + print_prod = current_agent(sysparams)[TRACE_JUSTIFICATIONS_SYSPARAM]; + +#ifdef WATCH_SSCI_INSTS + + print("Rebuiding "); + if (inst->prod) + print_with_symbols("%y\n", inst->prod->name); + else + print("an SSCI inst.\n"); + +#endif + + /* AGR 617/634 begin */ + if (print_name) { + if (get_printer_output_column() != 1) + print("\n"); + print("Rebuiding "); + if (inst->prod) + print_with_symbols("%y\n", inst->prod->name); + else + print("an SSCI inst.\n"); + + } + /* AGR 617/634 end */ + + /* --- if there aren't any grounds, exit --- */ + if (!top_cc) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print_string(" Warning: chunk has no grounds, ignoring it."); + + } + + /* --- variablize it --- */ + lhs_top = top_cc->variablized_cond; + lhs_bottom = bottom_cc->variablized_cond; + reset_variable_generator(lhs_top, NIL); + current_agent(variablization_tc) = get_new_tc_number(); + variablize_condition_list(lhs_top); + variablize_nots_and_insert_into_conditions(nots, lhs_top); + /* + * no need to make a rhs, since there's no justification being + * built + */ + + /* --- add goal/impasse tests to it --- */ + add_goal_or_impasse_tests(top_cc); + + /* --- reorder lhs and make the production --- */ + + { + condition *inst_lhs_top, *inst_lhs_bottom; + + reorder_instantiated_conditions(top_cc, &inst_lhs_top, &inst_lhs_bottom); + deallocate_inst_members_to_be_rewritten(inst); + + /* + * now fill in the new conditions for this level + */ + inst->top_of_instantiated_conditions = inst_lhs_top; + inst->bottom_of_instantiated_conditions = inst_lhs_bottom; + inst->nots = nots; + +#ifdef WATCH_SSCI_CONDS + + print("Rebuiding temp-just: "); + if (inst->prod) + print_with_symbols("%y ... conditions:\n", inst->prod->name); + else + print(" (nil) ... conditions: \n"); + print("Address %p\n", inst); + print_condition_list(inst->top_of_instantiated_conditions, 2, TRUE); + if (inst->top_of_instantiated_conditions == NIL) { + print("There are no pointers here...\n"); + } +#endif + + re_fill_in_instantiation_stuff_for_modified_lhs(inst, TRUE); + + } /* matches { condition *inst_lhs_top, *inst_lhs_bottom ... */ + +#ifdef WARN_IF_RESULT_IS_I_SUPPORTED + /* + * SW 110499 + * See the note with the same date in chunk_instantiation + */ + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + if (pref->o_supported == FALSE) { + print("Warning: Result is not natively o-supported. "); + +#ifdef ALLOW_I_SUPPORTED_SUBGOAL_RESULTS_WITH_THIN_JUSTS + print("This may produce memory leaks.\n"); +#else + print("O-support will be forced.\n"); +#endif + + watchful_print_preference(pref); + } + } +#endif /* WARN_IF_RESULT_IS_I_SUPPORTED */ + + /* --- deallocate chunks conds and variablized conditions --- */ + deallocate_condition_list(lhs_top); +#ifdef DONT_CALC_GDS_OR_BT + /* SW NOTE See the note in add_named_superstate_attribute_to_ground */ + deallocate_condition_list(top_cc->cond); +#endif + + { + chunk_cond *cc; + while (top_cc) { + cc = top_cc; + top_cc = cc->next; + free_with_pool(¤t_agent(chunk_cond_pool), cc); + } + } + + /* finally, recurse... */ + second_stage_chunk_instantiation(inst); + + chunking_done:{ + } + +} + +void deallocate_inst_members_to_be_rewritten(instantiation * inst) +{ + + goal_stack_level level; + condition *cond; + + level = inst->match_goal_level; + + /* SW 102799 -- memory leak fix + * We need to do some freeing of old conditions and such. + * moreover, we need to free up some references to wmes and + * preferences in the backtracing structures. That's + * what's going on here (I stole this code from fill_in_new_inst_stuff) + */ + + for (cond = inst->top_of_instantiated_conditions; cond != NIL; cond = cond->next) + if (cond->type == POSITIVE_CONDITION) { + +#ifdef NO_TOP_LEVEL_REFS + if (level > 1) { + wme_remove_ref(cond->bt.wme); + } +#ifdef DEBUG_NO_TOP_LEVEL_REFS + else { + print("NO_TOP_LEVEL_REFS(4): Not removing reference to tt =%lu ref =%lu\n", + cond->bt.wme->timetag, cond->bt.wme->reference_count); + } +#endif + +#else + wme_remove_ref(cond->bt.wme); +#endif + if (cond->bt.trace) { + +#ifdef NO_TOP_JUST + if (cond->bt.trace->match_goal_level > level) + cond->bt.trace = find_clone_for_level(cond->bt.trace, level); +#else + + if (cond->bt.trace->inst->match_goal_level > level) + cond->bt.trace = find_clone_for_level(cond->bt.trace, level); +#endif + + /* begin SW 7.7.99 */ +#ifdef NO_TOP_LEVEL_REFS + if ((cond->bt.trace) && (level > 1)) { + preference_remove_ref(cond->bt.trace); + } +#ifdef DEBUG_NO_TOP_LEVEL_REFS + else { + print("NO_TOP_LEVEL_REFS (5): Not removing reference to rf = %lu\n", + cond->bt.trace->reference_count); + print("NO_TOP_LEVEL_REFS (5): cond->bt.trace = \n"); + print_preference(cond->bt.trace); + } +#endif + +#else + if (cond->bt.trace) + preference_remove_ref(cond->bt.trace); +#endif + } + + } + + { + preference *pr, *p, *np; + /* + printf( "Trying to remove old preferences generated from match goal\n" ); + */ + if (inst->match_goal) { + for (p = inst->match_goal->id.preferences_from_goal; p != NIL; p = np) { + + np = p->all_of_goal_next; + for (pr = inst->preferences_generated; pr != NIL; pr = pr->inst_next) { + if (p == pr) { + /* + printf ("Found prefernces in old match goal, removing\n"); + */ + remove_from_dll(inst->match_goal->id.preferences_from_goal, + pr, all_of_goal_next, all_of_goal_prev); + break; + } + } + } + } + } + + /* SW 102799 + * now those icky backtracing structures are all been ready + * to be deallocated (we've decremented reference counts) + * and we can free the old conditions (which were valid at + * the previous depth in the goal stack, but probably aren't + * here) + */ + deallocate_condition_list(inst->top_of_instantiated_conditions); + deallocate_list_of_nots(inst->nots); + +} + +/* + * Currently, this is copied directy from + * fill_in_new_instantiation_stuff This can be incorporated into the orig. + */ +void re_fill_in_instantiation_stuff_for_modified_lhs(instantiation * inst, bool need_to_do_support_calculations) +{ + condition *cond; + preference *p; + goal_stack_level level; + +#if 0 +#ifdef TRY_SSCI_PROD_NIL + if (inst->prod) +#endif + production_add_ref(inst->prod); +#endif + + find_match_goal(inst); + + level = inst->match_goal_level; + +#ifdef NO_TOP_JUST + /* Record goal information as we may discard pref->inst later */ + /* This list of preferences will catch the productions results and */ + /* clone preferences (I believe). */ + + for (p = inst->preferences_generated; p != NIL; p = p->inst_next) { + p->match_goal = inst->match_goal; /* NIL if from attribute impasse */ + p->match_goal_level = inst->match_goal_level; + } + + /* This may be a SWBUG. I removed a '}' here. */ +#endif + + /* + + Note: since we'll never backtrace through instantiations at the top + level, it might make sense to not increment the reference counts + on the wmes and preferences here if the instantiation is at the top + level. As it stands now, we could gradually accumulate garbage at + the top level if we have a never-ending sequence of production + firings at the top level that chain on each other's results. (E.g., + incrementing a counter on every decision cycle.) I'm leaving it this + way for now, because if we go to S-Support, we'll (I think) need to + save these around (maybe). + + */ + + for (cond = inst->top_of_instantiated_conditions; cond != NIL; cond = cond->next) + if (cond->type == POSITIVE_CONDITION) { + + /* begin SW 7.7.99 */ + +#ifdef NO_TOP_LEVEL_REFS + if (level > 1) { + wme_add_ref(cond->bt.wme); + } +#ifdef DEBUG_NO_TOP_LEVEL_REFS + else { + print("NO_TOP_LEVEL_REFS (1): Not adding reference to tt =%lu ref =%lu\n", + cond->bt.wme->timetag, cond->bt.wme->reference_count); + } +#endif + +#else + wme_add_ref(cond->bt.wme); +#endif + + /* --- if trace is for a lower level, find one for this level --- */ + if (cond->bt.trace) { + +#ifdef NO_TOP_JUST + if (cond->bt.trace->match_goal_level > level) + cond->bt.trace = find_clone_for_level(cond->bt.trace, level); +#else + + if (cond->bt.trace->inst->match_goal_level > level) + cond->bt.trace = find_clone_for_level(cond->bt.trace, level); +#endif + + /* begin SW 7.7.99 */ +#ifdef NO_TOP_LEVEL_REFS + if ((cond->bt.trace) && (level > 1)) { + preference_add_ref(cond->bt.trace); + } +#ifdef DEBUG_NO_TOP_LEVEL_REFS + else { + print("NO_TOP_LEVEL_REFS (2): Not adding reference to rf = %lu\n", + cond->bt.trace->reference_count); + print("NO_TOP_LEVEL_REFS (2): cond->bt.trace = \n"); + print_preference(cond->bt.trace); + } +#endif + +#else + if (cond->bt.trace) + preference_add_ref(cond->bt.trace); +#endif + } + + } + + /* endif SW 7.7.99 */ + + if (inst->match_goal) { + for (p = inst->preferences_generated; p != NIL; p = p->inst_next) { + insert_at_head_of_dll(inst->match_goal->id.preferences_from_goal, p, all_of_goal_next, all_of_goal_prev); + p->on_goal_list = TRUE; + } + } + + inst->backtrace_number = 0; + + if (current_agent(o_support_calculation_type) == 0) { + /* --- do calc's the normal Soar 6 way --- */ + if (need_to_do_support_calculations) + calculate_support_for_instantiation_preferences(inst); + } else if (current_agent(o_support_calculation_type) == 1) { + if (need_to_do_support_calculations) + calculate_support_for_instantiation_preferences(inst); + /* --- do calc's both ways, warn on differences --- */ + if ((inst->prod->declared_support != DECLARED_O_SUPPORT) && + (inst->prod->declared_support != DECLARED_I_SUPPORT)) { + /* --- At this point, we've done them the normal way. To look for + differences, save o-support flags on a list, then do Doug's + calculations, then compare and restore saved flags. --- */ + list *saved_flags; + preference *pref; + bool difference_found; + saved_flags = NIL; + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) + push((pref->o_supported ? pref : NIL), saved_flags); + saved_flags = destructively_reverse_list(saved_flags); + dougs_calculate_support_for_instantiation_preferences(inst); + difference_found = FALSE; + for (pref = inst->preferences_generated; pref != NIL; pref = pref->inst_next) { + cons *c; + bool b; + c = saved_flags; + saved_flags = c->rest; + b = (c->first ? TRUE : FALSE); + free_cons(c); + if (pref->o_supported != b) + difference_found = TRUE; + pref->o_supported = b; + } + if (difference_found) { + print_with_symbols("\n*** O-support difference found in production %y", inst->prod->name); + } + } + } else { + /* --- do calc's Doug's way --- */ + if ((inst->prod->declared_support != DECLARED_O_SUPPORT) && + (inst->prod->declared_support != DECLARED_I_SUPPORT)) { + dougs_calculate_support_for_instantiation_preferences(inst); + } + } +} + +#endif /* SINGLE_THIN_JUSTIFICATION */ + +/* -------------------------------------------------------------------- + + Chunker Initialization + + Init_chunker() is called at startup time to do initialization here. +-------------------------------------------------------------------- */ + +void init_chunker(void) +{ + init_memory_pool(¤t_agent(chunk_cond_pool), sizeof(chunk_cond), "chunk condition"); + init_chunk_cond_set(¤t_agent(negated_set)); +} + +#ifdef DONT_CALC_GDS_OR_BT + +/* DJP */ +/* We're going to create a dummy justification with just one condition. */ +/* The condition will be the named attribute (usually the problem-space) */ +/* passed to this routine. This function finds the WME in the superstate */ +/* and then builds a condition to match it, as if that condition had come */ +/* through backtracing for a chunk. */ +/* Yes, it's really ugly. */ +/* SW NOTE + * + * This function works by finding the superstate attribute and adding + * it to the grounds of the new instantiation (justification/chunk) + * By doing this, it avoids backtracing altogether, however in this + * routine, unlike within backtrace_through_instantiation, the grounds + * consisits of conditions (actually only one) that are fabricated on + * the spot, as opposed to conditions from other real instantiations + * Therefore, in a normal, backtracing version the grounds are just pointers + * to conditions that some other inst owns, in this case no one else owns + * the conds so we need to do some extra trickery to avoid a memory leak. + * this is done in chunk_instantiation (and second_stage_chunk_instantiation) + */ +static void add_named_superstate_attribute_to_grounds(instantiation * inst, char *name) +{ + Symbol *target; + wme *ps; + slot *the_slot; + condition *ps_cond; + + /* Find the target WME */ + target = find_sym_constant(name); + + if (!target) + target = current_agent(superstate_symbol); + + the_slot = find_slot(inst->match_goal->id.higher_goal, target); + + if (the_slot) { + ps = the_slot->wmes; + } else { + ps = find_impasse_wme(inst->match_goal->id.higher_goal, target); + } + + if (ps == NIL) { + print("\nNo Chunks Hack: Whoops, couldn't find %s in superstate.\n", name); + return; + } + + /* Now try to build a condition for this WME */ + + /* This will be de-alloced when free the grounds list */ + allocate_with_pool(¤t_agent(condition_pool), &ps_cond); + + ps_cond->prev = NIL; + ps_cond->next = NIL; + ps_cond->type = POSITIVE_CONDITION; + + ps_cond->data.tests.id_test = make_equality_test(ps->id); + ps_cond->data.tests.attr_test = make_equality_test(ps->attr); + ps_cond->data.tests.value_test = make_equality_test(ps->value); + ps_cond->test_for_acceptable_preference = ps->acceptable; + + ps_cond->bt.wme = ps; + ps_cond->bt.level = inst->match_goal_level - 1; /* Set to superstate level */ + + ps_cond->bt.trace = NIL; /* Maybe this needs to be a preference for the PS slot ? */ + ps_cond->bt.prohibits = NIL; + + push((ps_cond), current_agent(grounds)); /* Add it to the grounds list */ + +} + +#endif +/* 031799 SW End */ diff --git a/soar-8.5.2/kernel/configure b/soar-8.5.2/kernel/configure new file mode 100755 index 0000000..1150f6d --- /dev/null +++ b/soar-8.5.2/kernel/configure @@ -0,0 +1,2062 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --with-x use the X Window System" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=soarkernel.h + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +#-------------------------------------------------------------------- +# Set up the compiler & other programs +#-------------------------------------------------------------------- + +# The autoconf documentation leads me to believe this has to be here +# (rather than in Makefile.in), or AC_PROG_CC will change it. +#CFLAGS="-O -Werror" +#CFLAGS="-O -Wall" + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:540: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:570: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:621: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:653: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 664 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:695: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:700: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:728: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O -Werror" + else + CFLAGS="-g -Werror" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +# Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:762: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +#-------------------------------------------------------------------- +# Checks for header files. +#-------------------------------------------------------------------- + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:795: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:816: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:833: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:850: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# If we find X, set shell vars x_includes and x_libraries to the +# paths, otherwise set no_x=yes. +# Uses ac_ vars as temps to allow command line to override cache and checks. +# --without-x overrides everything else, but does not touch the cache. +echo $ac_n "checking for X""... $ac_c" 1>&6 +echo "configure:879: checking for X" >&5 + +# Check whether --with-x or --without-x was given. +if test "${with_x+set}" = set; then + withval="$with_x" + : +fi + +# $have_x is `yes', `no', `disabled', or empty when we do not yet know. +if test "x$with_x" = xno; then + # The user explicitly disabled X. + have_x=disabled +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + # Both variables are already set. + have_x=yes + else +if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # One or both of the vars are not set, and there is no cached value. +ac_x_includes=NO ac_x_libraries=NO +rm -fr conftestdir +if mkdir conftestdir; then + cd conftestdir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat > Imakefile <<'EOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +EOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + for ac_extension in a so sl; do + if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && + test -f $ac_im_libdir/libX11.$ac_extension; then + ac_im_usrlibdir=$ac_im_libdir; break + fi + done + # Screen out bogus values from the imake configuration. They are + # bogus both because they are the default anyway, and because + # using them would break gcc on systems where it needs fixed includes. + case "$ac_im_incroot" in + /usr/include) ;; + *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; + esac + case "$ac_im_usrlibdir" in + /usr/lib | /lib) ;; + *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; + esac + fi + cd .. + rm -fr conftestdir +fi + +if test "$ac_x_includes" = NO; then + # Guess where to find include files, by looking for this one X11 .h file. + test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h + + # First, try using that file with no special directory specified. +cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:946: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + # We can compile using X headers with no special include directory. +ac_x_includes= +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + # Look for the header file in a standard set of common directories. +# Check X11 before X11Rn because it is often a symlink to the current release. + for ac_dir in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + ac_x_includes=$ac_dir + break + fi + done +fi +rm -f conftest* +fi # $ac_x_includes = NO + +if test "$ac_x_libraries" = NO; then + # Check for the libraries. + + test -z "$x_direct_test_library" && x_direct_test_library=Xt + test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc + + # See if we find them without any special options. + # Don't add to $LIBS permanently. + ac_save_LIBS="$LIBS" + LIBS="-l$x_direct_test_library $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + LIBS="$ac_save_LIBS" +# We can link X programs with no special library path. +ac_x_libraries= +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +# Check X11 before X11Rn because it is often a symlink to the current release. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11/lib \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11 \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11/lib \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11 \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + /lib/usr/lib/X11 \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + ac_x_libraries=$ac_dir + break 2 + fi + done +done +fi +rm -f conftest* +fi # $ac_x_libraries = NO + +if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then + # Didn't find X anywhere. Cache the known absence of X. + ac_cv_have_x="have_x=no" +else + # Record where we found X for the cache. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi +fi + fi + eval "$ac_cv_have_x" +fi # $with_x != no + +if test "$have_x" != yes; then + echo "$ac_t""$have_x" 1>&6 + no_x=yes +else + # If each of the values was on the command line, it overrides each guess. + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + # Update the cache value to reflect the command line values. + ac_cv_have_x="have_x=yes \ + ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 +fi + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:1113: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:1126: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:1151: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:1192: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +echo "configure:1234: checking for ANSI C header files" >&5 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +#include +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + ac_cv_header_stdc=yes +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "memchr" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +cat > conftest.$ac_ext < +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "free" >/dev/null 2>&1; then + : +else + rm -rf conftest* + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +if test "$cross_compiling" = yes; then + : +else + cat > conftest.$ac_ext < +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } + +EOF +if { (eval echo configure:1314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_header_stdc=no +fi +rm -fr conftest* +fi + +fi +fi + +echo "$ac_t""$ac_cv_header_stdc" 1>&6 +if test $ac_cv_header_stdc = yes; then + cat >> confdefs.h <<\EOF +#define STDC_HEADERS 1 +EOF + +fi + +for ac_hdr in sys/time.h unistd.h limits.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1341: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1351: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + + + +#-------------------------------------------------------------------- +# Checks for typedefs, structures, and compiler characteristics. +#-------------------------------------------------------------------- + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +echo "configure:1384: checking for working const" >&5 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} + +; return 0; } +EOF +if { (eval echo configure:1438: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_c_const=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_c_const=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_c_const" 1>&6 +if test $ac_cv_c_const = no; then + cat >> confdefs.h <<\EOF +#define const +EOF + +fi + +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +echo "configure:1459: checking for size_t" >&5 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#if STDC_HEADERS +#include +#include +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_size_t=yes +else + rm -rf conftest* + ac_cv_type_size_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_size_t" 1>&6 +if test $ac_cv_type_size_t = no; then + cat >> confdefs.h <<\EOF +#define size_t unsigned +EOF + +fi + +echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 +echo "configure:1492: checking whether time.h and sys/time.h may both be included" >&5 +if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#include +int main() { +struct tm *tp; +; return 0; } +EOF +if { (eval echo configure:1506: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_header_time=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_time=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_time" 1>&6 +if test $ac_cv_header_time = yes; then + cat >> confdefs.h <<\EOF +#define TIME_WITH_SYS_TIME 1 +EOF + +fi + +echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 +echo "configure:1527: checking whether struct tm is in sys/time.h or time.h" >&5 +if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { +struct tm *tp; tp->tm_sec; +; return 0; } +EOF +if { (eval echo configure:1540: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_struct_tm=time.h +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_struct_tm=sys/time.h +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_struct_tm" 1>&6 +if test $ac_cv_struct_tm = sys/time.h; then + cat >> confdefs.h <<\EOF +#define TM_IN_SYS_TIME 1 +EOF + +fi + + + +#-------------------------------------------------------------------- +# Figure out how to make the compiler compile ANSI code. +#-------------------------------------------------------------------- + + +# The setting of ANSI_FLAGS is the only real kludge here. Rumor has +# it that the GNU m4 macros has a ANSI test macro. Until we find a +# cleaner way of determining how to turn on ANSI compilation, we'll +# try this hack. + +### RMJ: Will this work without first doing AC_CANONICAL_HOST? + +ANSI_FLAGS="" + +if test "$ac_cv_prog_gcc" = yes; then + ANSI_FLAGS="-ansi -fpcc-struct-return" +else + # No gcc. Test vendor and select native cc ANSI compilation option. + if test "$host_vendor" = hp; then + ANSI_FLAGS="-Aa -D_INCLUDE_POSIX_SOURCE" + fi +fi + + +#-------------------------------------------------------------------- +# Checks for library functions. +#-------------------------------------------------------------------- + +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +echo "configure:1591: checking return type of signal handlers" >&5 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +#ifdef signal +#undef signal +#endif +#ifdef __cplusplus +extern "C" void (*signal (int, void (*)(int)))(int); +#else +void (*signal ()) (); +#endif + +int main() { +int i; +; return 0; } +EOF +if { (eval echo configure:1613: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + ac_cv_type_signal=void +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_type_signal=int +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_type_signal" 1>&6 +cat >> confdefs.h <&6 +echo "configure:1632: checking for vprintf" >&5 +if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char vprintf(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_vprintf) || defined (__stub___vprintf) +choke me +#else +vprintf(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1660: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_vprintf=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_vprintf=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'vprintf`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_VPRINTF 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +if test "$ac_cv_func_vprintf" != yes; then +echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 +echo "configure:1684: checking for _doprnt" >&5 +if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char _doprnt(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub__doprnt) || defined (__stub____doprnt) +choke me +#else +_doprnt(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func__doprnt=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func__doprnt=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'_doprnt`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_DOPRNT 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi + +fi + +for ac_func in gethostname gettimeofday getwd strtol strtoul snprintf +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1739: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1767: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <&6 +fi +done + + +#-------------------------------------------------------------------- +# Use latest Posix standards +#-------------------------------------------------------------------- +cat >> confdefs.h <<\EOF +#define POSIX_C_SOURCE 199506L +EOF + + +#-------------------------------------------------------------------- +# Create the Makefile +#-------------------------------------------------------------------- + + + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@RANLIB@%$RANLIB%g +s%@CPP@%$CPP%g +s%@ANSI_FLAGS@%$ANSI_FLAGS%g +s%@TCL_SHLIB_CFLAGS@%$TCL_SHLIB_CFLAGS%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + diff --git a/soar-8.5.2/kernel/configure.in b/soar-8.5.2/kernel/configure.in new file mode 100644 index 0000000..e0837b7 --- /dev/null +++ b/soar-8.5.2/kernel/configure.in @@ -0,0 +1,85 @@ +# Autoconf configuration file for soar kernel + +AC_INIT(soarkernel.h) + +#-------------------------------------------------------------------- +# Set up the compiler & other programs +#-------------------------------------------------------------------- + +# The autoconf documentation leads me to believe this has to be here +# (rather than in Makefile.in), or AC_PROG_CC will change it. +#CFLAGS="-O -Werror" +if test -z "${CFLAGS}"; then + CFLAGS="-O -w -Wall" +fi + + +AC_PROG_CC +AC_PROG_RANLIB + +#-------------------------------------------------------------------- +# Checks for header files. +#-------------------------------------------------------------------- + +AC_PATH_X +AC_HEADER_DIRENT +AC_HEADER_STDC +AC_CHECK_HEADERS(sys/time.h unistd.h limits.h) + + +#-------------------------------------------------------------------- +# Checks for typedefs, structures, and compiler characteristics. +#-------------------------------------------------------------------- + +AC_C_CONST +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_STRUCT_TM + + +#-------------------------------------------------------------------- +# Figure out how to make the compiler compile ANSI code. +#-------------------------------------------------------------------- + + +# The setting of ANSI_FLAGS is the only real kludge here. Rumor has +# it that the GNU m4 macros has a ANSI test macro. Until we find a +# cleaner way of determining how to turn on ANSI compilation, we'll +# try this hack. + +### RMJ: Will this work without first doing AC_CANONICAL_HOST? + +ANSI_FLAGS="" + +if test "$ac_cv_prog_gcc" = yes; then + ANSI_FLAGS="-ansi -fpcc-struct-return" +else + # No gcc. Test vendor and select native cc ANSI compilation option. + if test "$host_vendor" = hp; then + ANSI_FLAGS="-Aa -D_INCLUDE_POSIX_SOURCE" + fi +fi + + +#-------------------------------------------------------------------- +# Checks for library functions. +#-------------------------------------------------------------------- + +AC_TYPE_SIGNAL +AC_FUNC_VPRINTF +AC_CHECK_FUNCS(gethostname gettimeofday getwd strtol strtoul snprintf) + +#-------------------------------------------------------------------- +# Use latest Posix standards +#-------------------------------------------------------------------- +AC_DEFINE(POSIX_C_SOURCE,199506L) + +#-------------------------------------------------------------------- +# Create the Makefile +#-------------------------------------------------------------------- + +AC_SUBST(ANSI_FLAGS) +AC_SUBST(TCL_SHLIB_CFLAGS) + +AC_OUTPUT(Makefile) + diff --git a/soar-8.5.2/kernel/consistency.c b/soar-8.5.2/kernel/consistency.c new file mode 100644 index 0000000..df8a671 --- /dev/null +++ b/soar-8.5.2/kernel/consistency.c @@ -0,0 +1,1045 @@ +/************************************************************************* + * + * file: consistency.c + * + * ======================================================================= + * + * Source code for Operand2/Waterfall specific functions in the kernel. + * + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + * + * Revision history: + * + * 05 May 97: Created for version 2.0 of Operand2 + * REW + * + * 20 Aug 97: Version 2.1 of Operand2/Waterfall + * Reimplemented the Waterfall functions with a more efficient algorithm + * REW + * + */ + +/* For information on the consistency check routines */ +/* #define DEBUG_CONSISTENCY_CHECK */ + +/* For information on aspects of determining the active level */ +/* #define DEBUG_DETERMINE_LEVEL_PHASE */ + +#include "soarkernel.h" + +/* REW: begin 08.20.97 */ +#define NEW_DECISION 0 +#define SAME_LEVEL 1 +#define HIGHER_LEVEL 2 +#define LOWER_LEVEL 3 +#define NIL_GOAL_RETRACTIONS 4 +/* REW: end 08.20.97 */ + +/* REW: begin 09.15.96 */ +extern void remove_wmes_for_context_slot(slot * s); +extern void remove_existing_context_and_descendents(Symbol * goal); +extern byte type_of_existing_impasse(Symbol * goal); +extern Symbol *attribute_of_existing_impasse(Symbol * goal); +extern byte run_preference_semantics_for_consistency_check(slot * s, preference ** result_candidates); + +void remove_operator_if_necessary(slot * s, wme * w); +bool decision_consistent_with_current_preferences(Symbol * goal, slot * s); +void remove_current_decision(slot * s); +bool check_context_slot_decisions(goal_stack_level level); +/* REW: end 09.15.96 */ + + /* REW: begin 08.20.97 *//* To implement the Waterfall part of Operand2 */ +extern void print_assertion(ms_change * msc); +extern void print_retraction(ms_change * msc); +void initialize_consistency_calculations_for_new_decision(); +void determine_highest_active_production_level_in_stack_apply(); +void determine_highest_active_production_level_in_stack_propose(); +bool goal_stack_consistent_through_goal(Symbol * goal); +bool i_activity_at_goal(Symbol * goal); +bool minor_quiescence_at_goal(Symbol * goal); +int active_production_type_at_goal(Symbol * goal); +Symbol *highest_active_goal_propose(); +Symbol *highest_active_goal_apply(); +/* REW: end 08.20.97 */ + +void remove_operator_if_necessary(slot * s, wme * w) +{ + + /* REW: begin 11.25.96 */ +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + start_timer(¤t_agent(start_gds_tv)); +#endif +#endif + /* REW: end 11.25.96 */ + + /* print("Examining slot (next)\n"); + for (next = s; next; next=next->next){ + print_with_symbols("Slot ID: [%y]\n", next->id); + print_with_symbols("Slot Attr: [%y]\n", next->attr); + } + + print("Examining slot (prev)\n"); + for (prev = s->prev; prev; prev=prev->prev){ + print_with_symbols("Slot ID: [%y]\n", prev->id); + print_with_symbols("Slot Attr: [%y]\n", prev->attr); + } + + print("Examining slot WMEs\n"); + for (slot_wmes=s->wmes; slot_wmes; slot_wmes=slot_wmes->next){ + print_wme(slot_wmes); + } + + print("Examining acceptable preference WMEs\n"); + for (slot_wmes=s->acceptable_preference_wmes; slot_wmes; slot_wmes=slot_wmes->next){ + print_wme(slot_wmes); + } + + if (current_agent(highest_goal_whose_context_changed)) print_with_symbols("Highest goal with changed context: [%y]\n", current_agent(highest_goal_whose_context_changed)); + + print_with_symbols("Slot ID: [%y]\n", s->id); + print_with_symbols("Slot Attr: [%y]\n", s->attr); + if (s->isa_context_slot) print("this is a context slot.\n"); + if (s->impasse_id) print_with_symbols("Impasse: [%y]\n", s->impasse_id); + if (s->acceptable_preference_changed) print("Acceptable pref changed\n"); + + print_with_symbols("WME ID: [%y]\n", w->id); + print_with_symbols("WME Attr: [%y]\n", w->attr); + print_with_symbols("WME Value: [%y]\n", w->value); + if (w->value->id.isa_operator) print("This is an operator\n"); + + print_with_symbols("s->id->id.operator_slot->id: [%y]\n", s->id->id.operator_slot->id); */ + + if (s->wmes) { /* If there is something in the context slot */ + if (s->wmes->value == w->value) { /* The WME in the context slot is WME whose pref changed */ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_OPERAND2_REMOVALS_SYSPARAM]) { + print("\n REMOVING: Operator from context slot (proposal no longer matches): "); + print_wme(w); + } +#endif + remove_wmes_for_context_slot(s); + if (s->id->id.lower_goal) + remove_existing_context_and_descendents(s->id->id.lower_goal); + } + } + + /* REW: begin 11.25.96 */ +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + stop_timer(¤t_agent(start_gds_tv), ¤t_agent(gds_cpu_time[current_agent(current_phase)])); +#endif +#endif + /* REW: end 11.25.96 */ +} + +/* This code concerns the implementation of a 'consistency check' following + each IE phase. The basic idea is that we want context decisions to + remain consistent with the current preferences, even if the proposal + for some operator is still acceptable */ + +bool decision_consistent_with_current_preferences(Symbol * goal, slot * s) +{ + byte current_impasse_type, new_impasse_type; + Symbol *current_impasse_attribute; + wme *current_operator; + preference *candidates, *cand; + bool operator_in_slot, goal_is_impassed; + +#ifdef DEBUG_CONSISTENCY_CHECK + if (s->isa_context_slot) { + print(" slot (s) isa context slot: "); + print_with_symbols(" Slot Identifier [%y] and attribute [%y]\n", s->id, s->attr); + } + /* print(" Address of s: %x\n", s); */ + print(" s->impasse_type: %d\n", s->impasse_type); + if (s->impasse_id) + print(" Impasse ID is set (non-NIL)\n"); +#endif + + /* Determine the current operator/impasse in the slot */ + if (goal->id.operator_slot->wmes) { + /* There is an operator in the slot */ + current_operator = goal->id.operator_slot->wmes; + operator_in_slot = TRUE; + } else { + /* There is not an operator in the slot */ + current_operator = NIL; + operator_in_slot = FALSE; + } + + if (goal->id.lower_goal) { + /* the goal is impassed */ + goal_is_impassed = TRUE; + current_impasse_type = type_of_existing_impasse(goal); + current_impasse_attribute = attribute_of_existing_impasse(goal); +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Goal is impassed: Impasse type: %d: ", current_impasse_type); + print_with_symbols(" Impasse attribute: [%y]\n", current_impasse_attribute); +#endif + /* Special case for an operator no-change */ + if ((operator_in_slot) && (current_impasse_type == NO_CHANGE_IMPASSE_TYPE)) { + /* Operator no-change impasse: run_preference_semantics will return 0 + and we only want to blow away this operator if another is better + than it (checked in NONE_IMPASSE_TYPE switch) or if another kind + of impasse would be generated (e.g., OPERATOR_TIE). So, we set + the impasse type here to 0; that way we'll know that we should be + comparing a previous decision for a unique operator against the + current preference semantics. */ +#ifdef DEBUG_CONSISTENCY_CHECK + print(" This is an operator no-change impasse.\n"); +#endif + current_impasse_type = NONE_IMPASSE_TYPE; + } + } else { + goal_is_impassed = FALSE; + current_impasse_type = NONE_IMPASSE_TYPE; + current_impasse_attribute = NIL; +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Goal is not impassed: "); +#endif + } + + /* Determine the new impasse type, based on the preferences that exist now */ + new_impasse_type = run_preference_semantics_for_consistency_check(s, &candidates); + +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Impasse Type returned by run preference semantics: %d\n", new_impasse_type); + + for (cand = candidates; cand; cand = cand->next) { + print(" Preference for slot:"); + print_preference(cand); + } + + for (cand = candidates; cand; cand = cand->next_candidate) { + print("\n Candidate for slot:"); + print_preference(cand); + } +#endif + + if (current_impasse_type != new_impasse_type) { + /* Then there is an inconsistency: no more work necessary */ +#ifdef DEBUG_CONSISTENCY_CHECK + print + (" Impasse types are different: Returning FALSE, preferences are not consistent with prior decision.\n"); +#endif + return FALSE; + } + + /* in these cases, we know that the new impasse and the old impasse *TYPES* are the same. We + just want to check and make the actual impasses/decisions are the same. */ + switch (new_impasse_type) { + + case NONE_IMPASSE_TYPE: + /* There are four cases to consider when NONE_IMPASSE_TYPE is returned: */ + /* 1. Previous operator and operator returned by run_pref_sem are the same. + In this case, return TRUE (decision remains consistent) */ + + /* This next if is meant to test that there actually is something in the slot but + I'm nut quite certain that it will not always be true? */ + if (operator_in_slot) { +#ifdef DEBUG_CONSISTENCY_CHECK + print(" There is a WME in the operator slot:"); + print_wme(current_operator); +#endif + + /* Because of indifferent preferences, we need to compare all possible candidates + with the current decision */ + for (cand = candidates; cand; cand = cand->next_candidate) { + if (current_operator->value == cand->value) { +#ifdef DEBUG_CONSISTENCY_CHECK + print_with_symbols(" Operator slot ID [%y] and candidate ID [%y] are the same.\n", + current_operator->value, cand->value); +#endif + return TRUE; + } + } + + /* 2. A different operator is indicated for the slot than the one that is + currently installed. In this case, we return FALSE (the decision is + not consistent with the preferences). */ + + /* Now we know that the decision is inconsistent */ + return FALSE; + + /* 3. A single operator is suggested when an impasse existed previously. + In this case, return FALSE so that the impasse can be removed. */ + + } else { /* There is no operator in the slot */ + if (goal->id.lower_goal) { /* But there is an impasse */ + if (goal->id.lower_goal->id.isa_impasse) + print("This goal is an impasse\n"); + print(" No Impasse Needed but Impasse exists: remove impasse now\n"); + print("\n\n *************This should never be executed*******************\n\n"); + return FALSE; + } + } + + /* 4. This is the bottom goal in the stack and there is no operator or + impasse for the operator slot created yet. We shouldn't call this + routine in this case (this condition is checked before + decision_consistent_with_current_preferences is called) but, for + completeness' sake, we check this condition and return TRUE + (because no decision has been made at this level, there is no + need to remove anything). */ + print("\n\n *************This should never be executed*******************\n\n"); + return TRUE; + break; + + case CONSTRAINT_FAILURE_IMPASSE_TYPE: +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Constraint Failure Impasse: Returning TRUE\n"); +#endif + return TRUE; + break; + + case CONFLICT_IMPASSE_TYPE: +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Conflict Impasse: Returning TRUE\n"); +#endif + return TRUE; + break; + + case TIE_IMPASSE_TYPE: +#ifdef DEBUG_CONSISTENCY_CHECK + print(" Tie Impasse: Returning TRUE\n"); +#endif + return TRUE; + break; + + case NO_CHANGE_IMPASSE_TYPE: +#ifdef DEBUG_CONSISTENCY_CHECK + print(" No change Impasse: Returning TRUE\n"); +#endif + return TRUE; + break; + } + + print("\n After switch................"); + print("\n\n *************This should never be executed*******************\n\n"); + return TRUE; + +} + +void remove_current_decision(slot * s) +{ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (!s->wmes) + if (current_agent(sysparams)[TRACE_OPERAND2_REMOVALS_SYSPARAM]) + print_with_symbols("\n REMOVING CONTEXT SLOT: Slot Identifier [%y] and attribute [%y]\n", s->id, + s->attr); + + if (s->id) + if (current_agent(sysparams)[TRACE_OPERAND2_REMOVALS_SYSPARAM]) + print_with_symbols("\n Decision for goal [%y] is inconsistent. Replacing it with....\n", s->id); + +#endif + + /* If there is an operator in the slot, remove it */ + remove_wmes_for_context_slot(s); + + /* If there are any subgoals, remove those */ + if (s->id->id.lower_goal) + remove_existing_context_and_descendents(s->id->id.lower_goal); + + do_buffered_wm_and_ownership_changes(); + +} + +/* ------------------------------------------------------------------ + Check Context Slot Decisions + + This scans down the goal stack and checks the consistency of the current + decision versus the current preferences for the slot, if the preferences + have changed. +------------------------------------------------------------------ */ + +bool check_context_slot_decisions(goal_stack_level level) +{ + Symbol *goal; + slot *s; + +#ifdef DEBUG_CONSISTENCY_CHECK + if (current_agent(highest_goal_whose_context_changed)) + print_with_symbols(" Highest goal with changed context: [%y]\n", + current_agent(highest_goal_whose_context_changed)); +#endif + +/* REW: begin 05.05.97 */ + /* Check only those goals where preferences have changes that are at or above the level + of the consistency check */ + for (goal = current_agent(highest_goal_whose_context_changed); goal && goal->id.level <= level; + goal = goal->id.lower_goal) { +/* REW: end 05.05.97 */ +#ifdef DEBUG_CONSISTENCY_CHECK + print_with_symbols(" Looking at goal [%y] to see if its preferences have changed\n", goal); +#endif + s = goal->id.operator_slot; + + if ((goal->id.lower_goal) || (s->wmes)) { /* If we are not at the bottom goal or if there is an operator in the + bottom goal's operator slot */ +#ifdef DEBUG_CONSISTENCY_CHECK + print + (" This is a goal that either has subgoals or, if the bottom goal, has an operator in the slot\n"); +#endif + if (s->changed) { /* Only need to check a goal if its prefs have changed */ +#ifdef DEBUG_CONSISTENCY_CHECK + print(" This goal's preferences have changed.\n"); +#endif + if (!decision_consistent_with_current_preferences(goal, s)) { +#ifdef DEBUG_CONSISTENCY_CHECK + print_with_symbols + (" The current preferences indicate that the decision at [%y] needs to be removed.\n", goal); +#endif + /* This doesn;t seem like it should be necessary but evidently it is: see 2.008 */ + remove_current_decision(s); + return FALSE; + break; /* No need to continue once a decision is removed */ + } + } + } +#ifdef DEBUG_CONSISTENCY_CHECK + else { + printf(" This is a bottom goal with no operator in the slot\n"); + } +#endif + } + + return TRUE; +} + +/* REW: begin 08.20.97 */ + +bool i_activity_at_goal(Symbol * goal) +{ + + /* print_with_symbols("\nLooking for I-activity at goal: %y\n", goal); */ + + if (goal->id.ms_i_assertions) + return TRUE; + + if (goal->id.ms_retractions) + return TRUE; + + /* print("\nNo instantiation found. Returning FALSE\n"); */ + return FALSE; +} + +/* Minor Quiescence at GOAL + + This procedure returns TRUE if the current firing type is IE_PRODS and + there are no i-assertions (or any retractions) ready to fire in the + current GOAL. Else it returns FALSE. */ + +bool minor_quiescence_at_goal(Symbol * goal) +{ + + if ((current_agent(FIRING_TYPE) == IE_PRODS) && (!i_activity_at_goal(goal))) + /* firing IEs but no more to fire == minor quiescence */ + return TRUE; + else + return FALSE; +} + +/* ---------------------------------------------------------------------- */ +/* Find the highest goal of activity among the current assertions and + * retractions */ + +/* We have to start at the top of the goal stack and go down because *any* + * goal in the goal stack could be active (and we want to highest one). + * However, we terminate as soon as a goal with assertions or retractions + * is found. Propose cares only about ms_i_assertions & retractions + */ + +Symbol *highest_active_goal_propose() +{ + + Symbol *goal; + + for (goal = current_agent(top_goal); goal; goal = goal->id.lower_goal) { + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + /* Debugging only */ + print("In highest_active_goal_propose:\n"); + if (goal->id.ms_i_assertions) + print_assertion(goal->id.ms_i_assertions); + if (goal->id.ms_retractions) + print_retraction(goal->id.ms_retractions); +#endif + + /* If there are any active productions at this goal, return the goal */ + if ((goal->id.ms_i_assertions) || (goal->id.ms_retractions)) + return goal; + } + + /* This routine should only be called when !quiescence. However, there is + still the possibility that the only active productions are retractions + that matched in a NIL goal. If so, then we just return the bottom goal. + If not, then all possibilities have been exausted and we have encounted + an unrecoverable error. */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("WARNING: Returning NIL active goal because only NIL goal retractions are active."); +#endif + if (current_agent(nil_goal_retractions)) + return NIL; + { + char msg[MESSAGE_SIZE]; + strncpy(msg, "\n consistency.c: Error: Unable to find an active goal when not at quiescence.\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + return NIL; /* unneeded, but avoids gcc -Wall warning */ +} + +Symbol *highest_active_goal_apply() +{ + + Symbol *goal; + + for (goal = current_agent(top_goal); goal; goal = goal->id.lower_goal) { + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + /* Debugging only */ + print("In highest_active_goal_apply :\n"); + if (goal->id.ms_i_assertions) + print_assertion(goal->id.ms_i_assertions); + if (goal->id.ms_o_assertions) + print_assertion(goal->id.ms_o_assertions); + if (goal->id.ms_retractions) + print_retraction(goal->id.ms_retractions); +#endif + + /* If there are any active productions at this goal, return the goal */ + if ((goal->id.ms_i_assertions) || (goal->id.ms_o_assertions) + || (goal->id.ms_retractions)) + return goal; + } + + /* This routine should only be called when !quiescence. However, there is + still the possibility that the only active productions are retractions + that matched in a NIL goal. If so, then we just return the bottom goal. + If not, then all possibilities have been exausted and we have encounted + an unrecoverable error. */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("WARNING: Returning NIL active goal because only NIL goal retractions are active."); +#endif + if (current_agent(nil_goal_retractions)) + return NIL; + { + char msg[MESSAGE_SIZE]; + strncpy(msg, "\nconsistency.c: Error: Unable to find an active goal when not at quiescence.\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + return NIL; /* unneeded, but avoids gcc -Wall warning */ +} + +/* ---------------------------------------------------------------------- */ + +/* active_production_type_at_goal + + Determines type of productions active at some active level. If + IE PRODS are active, this value is returned (regardless of whether there + are PEs active or not). Note that this procedure will return erroneous + values if there is no activity at the current level. It should only be + called when activity at the active_level has been determined. */ + +int active_production_type_at_goal(Symbol * goal) +{ + + if (i_activity_at_goal(goal)) + return IE_PRODS; + else + return PE_PRODS; +} + +/* ---------------------------------------------------------------------- */ + +bool goal_stack_consistent_through_goal(Symbol * goal) +{ + bool test; + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + start_timer(¤t_agent(start_gds_tv)); +#endif +#endif + +#ifdef DEBUG_CONSISTENCY_CHECK + print("\nStart: CONSISTENCY CHECK at level %d\n", goal->id.level); + + /* Just a bunch of debug stuff for now */ + if (current_agent(highest_goal_whose_context_changed)) { + print_with_symbols("current_agent(highest_goal_whose_context_changed) = [%y]\n", + current_agent(highest_goal_whose_context_changed)); + } else { + print("Evidently, nothing has changed: not checking slots\n"); + } +#endif + + test = check_context_slot_decisions(goal->id.level); + +#ifdef DEBUG_CONSISTENCY_CHECK + print("\nEnd: CONSISTENCY CHECK\n"); +#endif + +#ifdef DETAILED_TIMING_STATS + stop_timer(¤t_agent(start_gds_tv), ¤t_agent(gds_cpu_time[current_agent(current_phase)])); +#endif + + return test; +} + +/* REW: end 08.20.97 */ + +/* ---------------------------------------------------------------------- */ + +/* REW: begin 05.05.97 */ + +void initialize_consistency_calculations_for_new_decision() +{ + + Symbol *goal; + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nInitialize consistency calculations for new decision.\n"); +#endif + + /* No current activity level */ + current_agent(active_level) = 0; + current_agent(active_goal) = NIL; + + /* Clear any interruption flags on the goals.... */ + for (goal = current_agent(top_goal); goal; goal = goal->id.lower_goal) + goal->id.saved_firing_type = NO_SAVED_PRODS; +} + +/* ---------------------------------------------------------------------- */ + + /* determine_highest_active_production_level_in_stack_apply() + + This routine is responsible for implementing the DETERMINE_LEVEL_PHASE. + In the Waterfall version of Soar, the DETERMINE_LEVEL_PHASE makes the + determination of what goal level is active in the stack. Activity + proceeds from top goal to bottom goal so the active goal is the goal + highest in the stack with productions waiting to fire. This procedure + also recognizes quiescence (no productions active anywhere) and + mini-quiescence (no more IE_PRODS are waiting to fire in some goal for a + goal that fired IE_PRODS in the previous elaboration). Mini-quiescence is + followed by a consistency check. */ + +void determine_highest_active_production_level_in_stack_apply() +{ + + Symbol *goal; + int level_change_type, diff; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) + print("\n--- Application Phase ---\n"); +#endif + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nDetermining the highest active level in the stack....\n"); +#endif + + if (!any_assertions_or_retractions_ready()) { + /* This is quiescence */ +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\n(Full) Quiescence has been reached...going to decision\n"); +#endif + + /* Need to determine if this quiescence is also a minor quiescence, + otherwise, an inconsistent decision could get retained here (because + the consistency check was never run). (2.008). Therefore, if + in the previous preference phase, IE_PRODS fired, then force a + consistency check over the entire stack (by checking at the + bottom goal). */ + + if (minor_quiescence_at_goal(current_agent(bottom_goal))) { + goal_stack_consistent_through_goal(current_agent(bottom_goal)); + } + + /* regardless of the outcome, we go to the decision phase */ + + current_agent(current_phase) = OUTPUT_PHASE; + return; + } + + /* Not Quiescence */ + + /* Check for Max ELABORATIONS EXCEEDED */ + + if (current_agent(e_cycles_this_d_cycle) >= (unsigned long) (current_agent(sysparams)[MAX_ELABORATIONS_SYSPARAM])) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print("\nWarning: reached max-elaborations; proceeding to decision phase."); + current_agent(current_phase) = OUTPUT_PHASE; + return; + } + + /* Save the old goal and level (must save level explicitly in case goal is NIL) */ + current_agent(previous_active_goal) = current_agent(active_goal); + current_agent(previous_active_level) = current_agent(active_level); + + /* Determine the new highest level of activity */ + current_agent(active_goal) = highest_active_goal_apply(); + if (current_agent(active_goal)) + current_agent(active_level) = current_agent(active_goal)->id.level; + else + current_agent(active_level) = 0; /* Necessary for get_next_retraction */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nHighest level of activity is....%d", current_agent(active_level)); + print("\n Previous level of activity is....%d", current_agent(previous_active_level)); +#endif + + if (!current_agent(active_goal)) + /* Only NIL goal retractions */ + level_change_type = NIL_GOAL_RETRACTIONS; + else if (current_agent(previous_active_level) == 0) + level_change_type = NEW_DECISION; + else { + diff = current_agent(active_level) - current_agent(previous_active_level); + if (diff == 0) + level_change_type = SAME_LEVEL; + else if (diff > 0) + level_change_type = LOWER_LEVEL; + else + level_change_type = HIGHER_LEVEL; + } + + switch (level_change_type) { + case NIL_GOAL_RETRACTIONS: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nOnly NIL goal retractions are active"); +#endif + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case NEW_DECISION: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThis is a new decision...."); +#endif + current_agent(FIRING_TYPE) = active_production_type_at_goal(current_agent(active_goal)); + + /* in APPLY phase, we can test for ONC here, check ms_o_assertions */ + + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case LOWER_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is lower than the previous level...."); +#endif + /* Is there a minor quiescence at the previous level? */ + if (minor_quiescence_at_goal(current_agent(previous_active_goal))) { +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nMinor quiescence at level %d", current_agent(previous_active_level)); +#endif + if (!goal_stack_consistent_through_goal(current_agent(previous_active_goal))) { + current_agent(current_phase) = OUTPUT_PHASE; + break; + } + } + + /* else: check if return to interrupted level */ + + goal = current_agent(active_goal); + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + if (goal->id.saved_firing_type == IE_PRODS) + print("\nSaved production type: IE _PRODS"); + if (goal->id.saved_firing_type == PE_PRODS) + print("\nSaved production type: PE _PRODS"); + if (goal->id.saved_firing_type == NO_SAVED_PRODS) + print("\nSaved production type: NONE"); +#endif + + if (goal->id.saved_firing_type != NO_SAVED_PRODS) { +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nRestoring production type from previous processing at this level"); +#endif + current_agent(FIRING_TYPE) = goal->id.saved_firing_type; + current_agent(current_phase) = DETERMINE_LEVEL_PHASE; + break; + } + + /* else: just do a preference phase */ + current_agent(FIRING_TYPE) = active_production_type_at_goal(current_agent(active_goal)); + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case SAME_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is the same as the previous level...."); +#endif + if (minor_quiescence_at_goal(current_agent(active_goal))) { +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nMinor quiescence at level %d", current_agent(active_level)); +#endif + if (!goal_stack_consistent_through_goal(current_agent(active_goal))) { + current_agent(current_phase) = OUTPUT_PHASE; + break; + } + } + + current_agent(FIRING_TYPE) = active_production_type_at_goal(current_agent(active_goal)); + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case HIGHER_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is higher than the previous level...."); +#endif + + goal = current_agent(previous_active_goal); + goal->id.saved_firing_type = current_agent(FIRING_TYPE); + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + if (goal->id.saved_firing_type == IE_PRODS) + print("\n Saving current firing type as IE_PRODS"); + else if (goal->id.saved_firing_type == PE_PRODS) + print("\n Saving current firing type as PE_PRODS"); + else if (goal->id.saved_firing_type == NO_SAVED_PRODS) + print("\n Saving current firing type as NO_SAVED_PRODS"); + else + print("\n Unknown SAVED firing type???????"); +#endif + + /* run consistency check at new active level *before* firing any + productions there */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nMinor quiescence at level %d", current_agent(active_level)); +#endif + if (!goal_stack_consistent_through_goal(current_agent(active_goal))) { + current_agent(current_phase) = OUTPUT_PHASE; + break; + } + + /* If the decision is consistent, then just start processing at this level */ + + current_agent(FIRING_TYPE) = active_production_type_at_goal(current_agent(active_goal)); + current_agent(current_phase) = PREFERENCE_PHASE; + break; + } + +} + +/* REW: end 05.05.97 */ + + /* KJC: begin 10.04.98 *//* swiped from REW's determine_highest_active... */ +/* ---------------------------------------------------------------------- */ + + /* determine_highest_active_production_level_in_stack_propose() + + This routine is responsible for implementing the DETERMINE_LEVEL_PHASE + for the Propose Phase under the new reordering of the Decision Cycle. + In the Waterfall version of Soar, the DETERMINE_LEVEL_PHASE makes the + determination of what goal level is active in the stack. Activity + proceeds from top goal to bottom goal so the active goal is the goal + highest in the stack with productions waiting to fire. This procedure + also recognizes quiescence (no productions active anywhere) and + mini-quiescence (no more IE_PRODS are waiting to fire in some goal for a + goal that fired IE_PRODS in the previous elaboration). Mini-quiescence is + followed by a consistency check. */ + +void determine_highest_active_production_level_in_stack_propose() +{ + + Symbol *goal; + int level_change_type, diff; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) + print("\n--- Proposal Phase ---\n"); +#endif + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\n(Propose) Determining the highest active level in the stack....\n"); +#endif + + /* We are only checking for i_assertions, not o_assertions, since we don't + want operators to fire in the proposal phase + */ + if (!(current_agent(ms_retractions) || current_agent(ms_i_assertions))) { + /*if (minor_quiescence_at_goal(current_agent(bottom_goal))) { */ + /* This is minor quiescence */ +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\n Propose Phase Quiescence has been reached...going to decision\n"); +#endif + + /* Force a consistency check over the entire stack (by checking at + the bottom goal). */ + goal_stack_consistent_through_goal(current_agent(bottom_goal)); + + /* Decision phase is always next */ + current_agent(current_phase) = DECISION_PHASE; + return; + } + + /* Not Quiescence */ + + /* Check for Max ELABORATIONS EXCEEDED */ + + if (current_agent(e_cycles_this_d_cycle) >= (unsigned long) (current_agent(sysparams)[MAX_ELABORATIONS_SYSPARAM])) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print("\nWarning: reached max-elaborations; proceeding to decision phase."); + current_agent(current_phase) = DECISION_PHASE; + return; + } + + /* not Max Elaborations */ + + /* Save the old goal and level (must save level explicitly in case + goal is NIL) */ + current_agent(previous_active_goal) = current_agent(active_goal); + current_agent(previous_active_level) = current_agent(active_level); + + /* Determine the new highest level of activity */ + current_agent(active_goal) = highest_active_goal_propose(); + if (current_agent(active_goal)) + current_agent(active_level) = current_agent(active_goal)->id.level; + else + current_agent(active_level) = 0; /* Necessary for get_next_retraction */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nHighest level of activity is....%d", current_agent(active_level)); + print("\n Previous level of activity is....%d", current_agent(previous_active_level)); +#endif + + if (!current_agent(active_goal)) + /* Only NIL goal retractions */ + level_change_type = NIL_GOAL_RETRACTIONS; + else if (current_agent(previous_active_level) == 0) + level_change_type = NEW_DECISION; + else { + diff = current_agent(active_level) - current_agent(previous_active_level); + if (diff == 0) + level_change_type = SAME_LEVEL; + else if (diff > 0) + level_change_type = LOWER_LEVEL; + else + level_change_type = HIGHER_LEVEL; + } + + switch (level_change_type) { + case NIL_GOAL_RETRACTIONS: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nOnly NIL goal retractions are active"); +#endif + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case NEW_DECISION: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThis is a new decision...."); +#endif + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case LOWER_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is lower than the previous level...."); +#endif + /* There is always a minor quiescence at the previous level + in the propose phase, so check for consistency. */ + if (!goal_stack_consistent_through_goal(current_agent(previous_active_goal))) { + current_agent(current_phase) = DECISION_PHASE; + break; + } + + /* else: just do a preference phase */ + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case SAME_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is the same as the previous level...."); +#endif + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + + case HIGHER_LEVEL: +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nThe level is higher than the previous level...."); +#endif + + goal = current_agent(previous_active_goal); + goal->id.saved_firing_type = current_agent(FIRING_TYPE); + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + if (goal->id.saved_firing_type == IE_PRODS) + print("\n Saving current firing type as IE_PRODS"); + else if (goal->id.saved_firing_type == PE_PRODS) + print("\n Saving current firing type as PE_PRODS"); + else if (goal->id.saved_firing_type == NO_SAVED_PRODS) + print("\n Saving current firing type as NO_SAVED_PRODS"); + else + print("\n Unknown SAVED firing type???????"); +#endif + + /* run consistency check at new active level *before* firing any + productions there */ + +#ifdef DEBUG_DETERMINE_LEVEL_PHASE + print("\nMinor quiescence at level %d", current_agent(active_level)); +#endif + if (!goal_stack_consistent_through_goal(current_agent(active_goal))) { + current_agent(current_phase) = DECISION_PHASE; + break; + } + + /* If the decision is consistent, then just start processing + at this level */ + + current_agent(FIRING_TYPE) = IE_PRODS; + current_agent(current_phase) = PREFERENCE_PHASE; + break; + } + +} + +/* KJC: end 10.04.98 */ diff --git a/soar-8.5.2/kernel/debugutil.c b/soar-8.5.2/kernel/debugutil.c new file mode 100644 index 0000000..726fed7 --- /dev/null +++ b/soar-8.5.2/kernel/debugutil.c @@ -0,0 +1,227 @@ +#include "soarkernel.h" +#include "debugutil.h" + +extern void detailed_print_wme(wme * w); +extern void detailed_print_preference(preference * p); + +void examine_memory_pool(memory_pool * p) +{ + + print("Examine Memory Pool:\n"); + print("Free List Head: %p\n", p->free_list); + +#ifdef MEMORY_POOL_STATS + print("Used Count: %ld\n", p->used_count); +#endif +#ifdef TRACE_MEMORY_USAGE + print("Free List Length: %ld\n", p->free_list_length); + print("Pool Size: %ld\n", p->pool_size); +#endif + + print("Item Size: %ld\n", p->item_size); + print("Items / Block: %ld\n", p->items_per_block); + print("Num Blocks: %ld\n", p->num_blocks); + print("First Block: %p\n", p->first_block); + print("Name: %s\n", p->name); + +} + +void print_item_info_header(void) +{ + print("Block Number, Block Address, Next Block, Item Address\n"); +} + +void *get_item_in_pool_block(memory_pool * p, long n, long b, bool p_free) +{ + + char *block_head; + long i; + void *item; + bool in_free_list; + + block_head = p->first_block; + for (i = 0; i < b; i++) { + + /* I think this is right. + What I'm going for, is as follows: + block_head = the first few bytes of the block, cast as a pointer + and then dereferenced. + */ + block_head = *(char **) block_head; + } + + block_head += sizeof(char *); + + if (n > p->items_per_block) { + print("ERROR: The block contains less than %ld items.\n", n); + return NULL; + } + + for (i = 0; i < n; i++) { + block_head += p->item_size; + } + item = block_head; + + in_free_list = (char) check_for_addr_in_free_list(p, block_head); + + if (!in_free_list || p_free) { + print("%ld, %p, %p, ", b, (char *) block_head, *(char **) block_head); + print("%p\n", block_head); + } + if (in_free_list && p_free) { + print("This item is in the free list. \n"); + } + if (in_free_list) + return NULL; + return block_head; + +} + +void print_all_productions_in_block(long b, bool full, bool p_free) +{ + long i; + production *pro; + + print_item_info_header(); + for (i = 0; i < current_agent(production_pool).items_per_block; i++) { + pro = (production *) get_item_in_pool_block(¤t_agent(production_pool), i, b, p_free); + + if (pro) { + if (full) { + print_production(pro, FALSE); + } else { + print_with_symbols("%y\n", pro->name); + } + } + } + +} + +void print_all_identifiers_in_block(long b, bool p_free) +{ + long i; + Symbol *s; + + print_item_info_header(); + for (i = 0; i < current_agent(identifier_pool).items_per_block; i++) { + s = (Symbol *) get_item_in_pool_block(¤t_agent(identifier_pool), i, b, p_free); + + if (s) { + print(symbol_to_string(s, TRUE, NIL, 0)); + print(" reference count: %d\n", s->common.reference_count); + + } + + } + +} + +void print_all_wmes_in_block(long b, bool p_free) +{ + long i; + wme *the_wme; + + print_item_info_header(); + for (i = 0; i < current_agent(wme_pool).items_per_block; i++) { + the_wme = (wme *) get_item_in_pool_block(¤t_agent(wme_pool), i, b, p_free); + + if (the_wme) + detailed_print_wme(the_wme); + } + +} + +void print_all_conditions_in_block(long b, bool p_free) +{ + long i; + condition *the_condition; + + print_item_info_header(); + for (i = 0; i < current_agent(condition_pool).items_per_block; i++) { + the_condition = (condition *) get_item_in_pool_block(¤t_agent(condition_pool), i, b, p_free); + + if (the_condition) + print_condition(the_condition); + } + +} + +void print_all_preferences_in_block(long b, bool p_free) +{ + long i; + preference *the_pref; + + print_item_info_header(); + + for (i = 0; i < current_agent(preference_pool).items_per_block; i++) { + the_pref = (preference *) get_item_in_pool_block(¤t_agent(preference_pool), i, b, p_free); + + if (the_pref) + detailed_print_preference(the_pref); + } + +} + +void print_all_instantiations_in_block(long b, wme_trace_type wtt, bool p_free) +{ + long i; + instantiation *the_inst; + + print_item_info_header(); + for (i = 0; i < current_agent(instantiation_pool).items_per_block; i++) { + the_inst = (instantiation *) get_item_in_pool_block(¤t_agent(instantiation_pool), i, b, p_free); + + if (the_inst) + print_instantiation_with_wmes(the_inst, wtt); + } +} + +int check_for_addr_in_free_list(memory_pool * p, void *addr) +{ + + void *free_block_addr; + + free_block_addr = p->free_list; + + while (free_block_addr != NULL) { + + /* + print( "Looking for %p in List...%p\n", addr, free_block_addr ); + */ + + if (free_block_addr == addr) + return 1; + + free_block_addr = *(void **) free_block_addr; + + } + + return 0; +} + +#ifdef USE_DEBUG_UTILS + +void allocate_with_pool_fn(memory_pool * p, void **dest_item_pointer) +{ + + if (!(p)->free_list) + add_block_to_memory_pool(p); + *(dest_item_pointer) = (p)->free_list; + (p)->free_list = *(void **) (*(dest_item_pointer)); + fill_with_garbage(*(dest_item_pointer), (p)->item_size); + increment_used_count(p); + decrement_free_list_length(p); + +} + +void free_with_pool_fn(memory_pool * p, void *item) +{ + + fill_with_garbage((item), (p)->item_size); + *(void **) (item) = (p)->free_list; + (p)->free_list = (void *) (item); + decrement_used_count(p); + increment_free_list_length(p); + +} +#endif diff --git a/soar-8.5.2/kernel/debugutil.h b/soar-8.5.2/kernel/debugutil.h new file mode 100644 index 0000000..42ddb14 --- /dev/null +++ b/soar-8.5.2/kernel/debugutil.h @@ -0,0 +1,14 @@ + +extern void examine_memory_pool(memory_pool * p); + +extern void *get_item_in_pool_block(memory_pool * p, long item, long block, bool pfr); +extern void print_wme_in_pool(long w, long b); +extern void print_all_wmes_in_block(long b, bool pfree); +extern void print_conditions_in_pool(long w, long b, bool pfree); +extern void print_all_conditions_in_block(long b, bool pfree); +extern void print_all_identifiers_in_block(long b, bool pfree); +extern void print_all_productions_in_block(long b, bool full, bool pfree); +extern int check_for_addr_in_free_list(memory_pool * p, void *addr); +extern void print_all_preferences_in_block(long b, bool p_free); + +extern void print_all_instantiations_in_block(long b, wme_trace_type wtt, bool p_free); diff --git a/soar-8.5.2/kernel/decide.c b/soar-8.5.2/kernel/decide.c new file mode 100644 index 0000000..b423552 --- /dev/null +++ b/soar-8.5.2/kernel/decide.c @@ -0,0 +1,3519 @@ +/* ************************************************************************ + * + * file: decide.c + * + * ======================================================================= + * Decider and Associated Routines for Soar 6 + * + * This file contains the decider as well as routine for managing + * slots, and the garbage collection of disconnected WMEs. + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* Debugging stuff: #define DEBUG_LINKS to get links, gc printouts */ +/* #define DEBUG_SLOTS to get slot printouts */ +/* #define DEBUG_LINKS */ +/* #define DEBUG_SLOTS */ + +/* REW: begin 09.15.96 */ +/* For low-level, detailed information on the processing of the GDS */ +/* #define DEBUG_GDS */ +/* For high-level information on the instantiations that created an + * o-supported element and lead to the elaboration of the GDS */ +/* #define DEBUG_GDS_HIGH */ +/* REW: end 09.15.96 */ + +#include "soarkernel.h" +#include "soarapi_datatypes.h" +#include +#include +#include + +#ifdef NUMERIC_INDIFFERENCE +/* REW: 2003-01-02 Behavior Variability Kernel Experiments */ +preference *probabilistically_select(slot * s, preference * candidates); + +/* REW: 2003-01-06 A temporary helper function */ + +void print_candidates(preference * candidates) +{ + preference *cand = 0; + int max_count = 0; + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + max_count++; + print("\n Candidate %d", cand); + print_with_symbols("\n %y %y %y", cand->id, cand->attr, cand->value); + if (max_count > 10) + break; + } +} + +/* END: 2003-01-02 Behavior Variability Kernel Experiments */ + +#endif + +extern void soar_ecGDSPrint(); + +void remove_existing_attribute_impasse_for_slot(slot * s); +void post_link_addition(Symbol * from, Symbol * to); +void post_link_removal(Symbol * from, Symbol * to); + +/* REW: begin 09.15.96 additions for Soar8 architecture */ +void elaborate_gds(void); +void gds_invalid_so_remove_goal(wme * w); +void free_parent_list(void); +void uniquely_add_to_head_of_dll(instantiation * inst); +void create_gds_for_goal(Symbol * goal); +extern void remove_operator_if_necessary(slot * s, wme * w); + +/* REW: end 09.15.96 */ + +/* ------------------------------------------------------------------------ + Decider Global Variables + + Top_goal and bottom_goal point to the top and bottom goal identifiers, + respectively. (If there is no goal stack at all, they're both NIL.) + Top_state points to the top state (Symbol) if there is a top state, and + is NIL of there isn't any top state selected. + + Highest_goal_whose_context_changed points to the identifier of the highest + goal for which some context slot has changed preferences. If no context + slot has changed preferences, this variable is NIL. This is used by + the decider during decision phase to avoid scanning down the whole + goal stack when (as is the usual case) it really only needs to look at + the lowest context. + + Changed_slots is a dl_list of non-context slots with changed preferences. + This is used by the decider during working memory phase to tell which + slots need to be re-decided. + + Context_slots_with_changed_acceptable_preferences is a dl_list of + context slots for which the set of acceptable or require preferences + has changed. This is used to update the acceptable preference WMEs. +------------------------------------------------------------------------ */ + +/* -------------------------------------------------- + Decider Flags + + The decider often needs to mark symbols with + certain flags, usually to record that the symbols + are in certain sets or have a certain status. + The "common.decider_flag" field on symbols is + used for this, and is set to one of the following + flag values. (Usually only two or three of these + values are used at once, and the meaning should + be clear from the code.) +-------------------------------------------------- */ + +#define NOTHING_DECIDER_FLAG 0 /* Warning: code relies in this being 0 */ +#define CANDIDATE_DECIDER_FLAG 1 +#define CONFLICTED_DECIDER_FLAG 2 +#define FORMER_CANDIDATE_DECIDER_FLAG 3 +#define BEST_DECIDER_FLAG 4 +#define WORST_DECIDER_FLAG 5 +#define UNARY_INDIFFERENT_DECIDER_FLAG 6 +#define ALREADY_EXISTING_WME_DECIDER_FLAG 7 +#define UNARY_PARALLEL_DECIDER_FLAG 8 +/* REW: 2003-01-02 Behavior Variability Kernel Experiments + A new preference type: unary indifferent + constant (probability) value +*/ +#define UNARY_INDIFFERENT_CONSTANT_DECIDER_FLAG 9 + +/* ====================================================================== + + Acceptable Preference WME Routines + + Whenever some acceptable or require preference for a context slot + changes, we call mark_context_slot_as_acceptable_preference_changed(). + + At the end of the phase, do_buffered_acceptable_preference_wme_changes() + is called to update the acceptable preference wmes. This should be + called *before* do_buffered_link_changes() and do_buffered_wm_changes(). +====================================================================== */ + +void mark_context_slot_as_acceptable_preference_changed(slot * s) +{ + dl_cons *dc; + + if (s->acceptable_preference_changed) + return; + allocate_with_pool(¤t_agent(dl_cons_pool), &dc); + dc->item = s; + s->acceptable_preference_changed = dc; + insert_at_head_of_dll(current_agent(context_slots_with_changed_acceptable_preferences), dc, next, prev); +} + +/* --- This updates the acceptable preference wmes for a single slot. --- */ +void do_acceptable_preference_wme_changes_for_slot(slot * s) +{ + wme *w, *next_w; + preference *p; + + /* --- first, reset marks to "NOTHING" --- */ + for (w = s->acceptable_preference_wmes; w != NIL; w = w->next) + w->value->common.decider_flag = NOTHING_DECIDER_FLAG; + + /* --- now mark values for which we WANT a wme as "CANDIDATE" values --- */ + for (p = s->preferences[REQUIRE_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + + /* --- remove any existing wme's that aren't CANDIDATEs; mark the + rest as ALREADY_EXISTING --- */ + + w = s->acceptable_preference_wmes; + while (w) { + next_w = w->next; + if (w->value->common.decider_flag == CANDIDATE_DECIDER_FLAG) { + w->value->common.decider_flag = ALREADY_EXISTING_WME_DECIDER_FLAG; + w->value->common.a.decider_wme = w; + w->preference = NIL; /* we'll update this later */ + } else { + remove_from_dll(s->acceptable_preference_wmes, w, next, prev); +/* REW: begin 09.15.96 */ + /* IF we lose an acceptable preference for an operator, then that + operator comes out of the slot immediately in OPERAND2. + However, if the lost acceptable preference is not for item + in the slot, then we don;t need to do anything special until + mini-quiescence. */ + +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode)) +#endif + remove_operator_if_necessary(s, w); +/* REW: end 09.15.96 */ + remove_wme_from_wm(w); + } + w = next_w; + } + + /* --- add the necessary wme's that don't ALREADY_EXIST --- */ + + for (p = s->preferences[REQUIRE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + if (p->value->common.decider_flag == ALREADY_EXISTING_WME_DECIDER_FLAG) { + /* --- found existing wme, so just update its trace --- */ + w = p->value->common.a.decider_wme; + if (!w->preference) + w->preference = p; + } else { + w = make_wme(p->id, p->attr, p->value, TRUE); + insert_at_head_of_dll(s->acceptable_preference_wmes, w, next, prev); + w->preference = p; + add_wme_to_wm(w); + p->value->common.decider_flag = ALREADY_EXISTING_WME_DECIDER_FLAG; + p->value->common.a.decider_wme = w; + } + } + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + if (p->value->common.decider_flag == ALREADY_EXISTING_WME_DECIDER_FLAG) { + /* --- found existing wme, so just update its trace --- */ + w = p->value->common.a.decider_wme; + if (!w->preference) + w->preference = p; + } else { + w = make_wme(p->id, p->attr, p->value, TRUE); + insert_at_head_of_dll(s->acceptable_preference_wmes, w, next, prev); + w->preference = p; + add_wme_to_wm(w); + p->value->common.decider_flag = ALREADY_EXISTING_WME_DECIDER_FLAG; + p->value->common.a.decider_wme = w; + } + } +} + +void do_buffered_acceptable_preference_wme_changes(void) +{ + dl_cons *dc; + slot *s; + + while (current_agent(context_slots_with_changed_acceptable_preferences)) { + dc = current_agent(context_slots_with_changed_acceptable_preferences); + current_agent(context_slots_with_changed_acceptable_preferences) = dc->next; + s = dc->item; + free_with_pool(¤t_agent(dl_cons_pool), dc); + do_acceptable_preference_wme_changes_for_slot(s); + s->acceptable_preference_changed = NIL; + } +} + +/* ********************************************************************** + + Ownership Calculations + + Whenever a link is added from one identifier to another (i.e., + (I37 ^x R26)), we call post_link_addition(). This records the link + addition and buffers it for later processing. Similarly, whenever a + link is removed, we call post_link_removal(), which buffers the + removal for later processing. At the end of the phase, we call + do_buffered_link_changes() to update the goal stack level of all + identifiers, and garbage collect anything that's now disconnected. + + On each identifier, we maintain a count of how many links there are + to it. If the count is decremented to 0, the id must be disconnected, + so we can GC it. If the count is decremented but nonzero, we have + to walk through WM to see whether it's connected--it could be disconnected + but have a positive link count, if there's a circular structure in WM. + + Goal and impasse identifiers are handled specially. We don't want to + GC these even though WM may not have any pointers to them. So instead + of the normal link count stuff, we use a special "link" to each goal or + impasse id. This special link is added/removed by calling + post_link_addition/removal (NIL, id). +********************************************************************** */ + +/* ====================================================================== + + Promotion (Upgrade) Routines + + The list "promoted_ids" indicates which identifiers need to be + promoted at the end of the current phase. On every id, we have a + "promotion_level" field indicating the new goal_stack_level to which + the id is going to be promoted. When we actually do the promotion, + we set the id's level to promotion_level. We also promote anything + in the id's transitive closure to the same level, if necessary. +====================================================================== */ + +/* ---------------------------------------------- + Post a link addition for later processing. +---------------------------------------------- */ + +void post_link_addition(Symbol * from, Symbol * to) +{ + + /* --- don't add links to goals/impasses, except the special one + (NIL,goal) --- */ + if ((to->id.isa_goal || to->id.isa_impasse) && from) + return; + + to->id.link_count++; + +#ifdef DEBUG_LINKS + if (from) + print_with_symbols("\nAdding link from %y to %y", from, to); + else + print_with_symbols("\nAdding special link to %y", to); + print(" (count=%lu)", to->id.link_count); +#endif + + if (!from) + return; /* if adding a special link, we're done */ + + /* --- if adding link from same level, ignore it --- */ + if (from->id.promotion_level == to->id.promotion_level) + return; + + /* --- if adding link from lower to higher, mark higher accordingly --- */ + if (from->id.promotion_level > to->id.promotion_level) { + to->id.could_be_a_link_from_below = TRUE; + return; + } + + /* --- otherwise buffer it for later --- */ + to->id.promotion_level = from->id.promotion_level; + symbol_add_ref(to); + push(to, current_agent(promoted_ids)); +} + +/* ---------------------------------------------- + Promote an id and its transitive closure. +---------------------------------------------- */ + +#define promote_if_needed(sym) \ + { if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \ + promote_id_and_tc(sym,new_level); } + +void promote_id_and_tc(Symbol * id, goal_stack_level new_level) +{ + slot *s; + preference *pref; + wme *w; + + /* --- if it's already that high, or is going to be soon, don't bother -- */ + if (id->id.level <= new_level) + return; + if (id->id.promotion_level < new_level) + return; + + /* --- update its level, etc. --- */ + id->id.level = new_level; + id->id.promotion_level = new_level; + id->id.could_be_a_link_from_below = TRUE; + + /* --- sanity check --- */ + if (id->id.isa_goal || id->id.isa_impasse) { + char msg[MESSAGE_SIZE]; + strncpy(msg, "decide.c: Internal error: tried to promote a goal or impasse id\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + /* Note--since we can't promote a goal, we don't have to worry about + slot->acceptable_preference_wmes below */ + } + + /* --- scan through all preferences and wmes for all slots for this id -- */ + for (w = id->id.input_wmes; w != NIL; w = w->next) + promote_if_needed(w->value); + for (s = id->id.slots; s != NIL; s = s->next) { + for (pref = s->all_preferences; pref != NIL; pref = pref->all_of_slot_next) { + promote_if_needed(pref->value); + if (preference_is_binary(pref->type)) + promote_if_needed(pref->referent); + } + for (w = s->wmes; w != NIL; w = w->next) + promote_if_needed(w->value); + } /* end of for slots loop */ +} + +/* ---------------------------------------------- + Do all buffered promotions. +---------------------------------------------- */ + +void do_promotion(void) +{ + cons *c; + Symbol *to; + + while (current_agent(promoted_ids)) { + c = current_agent(promoted_ids); + to = c->first; + current_agent(promoted_ids) = current_agent(promoted_ids)->rest; + free_cons(c); + promote_id_and_tc(to, to->id.promotion_level); + symbol_remove_ref(to); + } +} + +/* ====================================================================== + + Demotion (Downgrade) and Garbage Collection Routines + + Demotions happen in stages. Post_link_removal() is called from + various places; this decrements the link count on an identifier and + adds it to the dl_list "ids_with_unknown_level". (While this is going + on, link_update_mode is always set to UPDATE_LINKS_NORMALLY.) + + At the end of the phase, do_demotion() is called. This has three + stages: + (1) the ids with unknown level whose link count is 0 are moved + over to a list of disconnected_ids -- these ids are definitely + disconnected and are going to be GC'd + (2) We GC the disconnected_ids. While doing this GC, more wmes + are removed from WM and more links are removed. For these + link removals, if the link count on an id goes to 0, we put + it onto disconnected_ids (rather than ids_with_unknown_level). + (Here link_update_mode is UPDATE_DISCONNECTED_IDS_LIST.) + We keep GC-ing disconnected_ids until none are left. + (3) Mark & Walk: If there are still remaining ids_with_unknown_level, + we mark each such id and its transitive closure, then walk the + goal stack (or parts of it) to find out what's really still + connected. + (4) For each id now known to be disconnected, we GC it. While doing + this GC, more links are removed, but for those, we merely update + the link count, nothing else--because we already took the TC of + each id in step 3, so we're already certain of what's connected + and what's not. (Here link_update_mode is JUST_UPDATE_COUNT.) +====================================================================== */ + +/* ---------------------------------------------- + Post a link removal for later processing. +---------------------------------------------- */ + +void post_link_removal(Symbol * from, Symbol * to) +{ + dl_cons *dc; + + /* --- don't remove links to goals/impasses, except the special one + (NIL,goal) --- */ + if ((to->id.isa_goal || to->id.isa_impasse) && from) + return; + + to->id.link_count--; + +#ifdef DEBUG_LINKS + if (from) { + print_with_symbols("\nRemoving link from %y to %y", from, to); + print(" (%d to %d)", from->id.level, to->id.level); + } else { + print_with_symbols("\nRemoving special link to %y ", to); + print(" (%d)", to->id.level); + } + print(" (count=%lu)", to->id.link_count); +#endif + + /* --- if a gc is in progress, handle differently --- */ + if (current_agent(link_update_mode) == JUST_UPDATE_COUNT) + return; + + if ((current_agent(link_update_mode) == UPDATE_DISCONNECTED_IDS_LIST) && (to->id.link_count == 0)) { + if (to->id.unknown_level) { + dc = to->id.unknown_level; + remove_from_dll(current_agent(ids_with_unknown_level), dc, next, prev); + insert_at_head_of_dll(current_agent(disconnected_ids), dc, next, prev); + } else { + symbol_add_ref(to); + allocate_with_pool(¤t_agent(dl_cons_pool), &dc); + dc->item = to; + to->id.unknown_level = dc; + insert_at_head_of_dll(current_agent(disconnected_ids), dc, next, prev); + } + return; + } + + /* --- if removing a link from a different level, there must be some other + link at the same level, so we can ignore this change --- */ + if (from && (from->id.level != to->id.level)) + return; + + if (!to->id.unknown_level) { + symbol_add_ref(to); + allocate_with_pool(¤t_agent(dl_cons_pool), &dc); + dc->item = to; + to->id.unknown_level = dc; + insert_at_head_of_dll(current_agent(ids_with_unknown_level), dc, next, prev); + } +} + +/* ---------------------------------------------- + Garbage collect an identifier. This removes + all wmes, input wmes, and preferences for that + id from TM. +---------------------------------------------- */ + +void garbage_collect_id(Symbol * id) +{ + slot *s; + preference *pref, *next_pref; + +#ifdef DEBUG_LINKS + print_with_symbols("\n*** Garbage collecting id: %y", id); +#endif + + /* Note--for goal/impasse id's, this does not remove the impasse wme's. + This is handled by remove_existing_such-and-such... */ + + /* --- remove any input wmes from the id --- */ + remove_wme_list_from_wm(id->id.input_wmes); + id->id.input_wmes = NIL; + + for (s = id->id.slots; s != NIL; s = s->next) { + /* --- remove any existing attribute impasse for the slot --- */ + if (s->impasse_type != NONE_IMPASSE_TYPE) + remove_existing_attribute_impasse_for_slot(s); + /* --- remove all wme's from the slot --- */ + remove_wme_list_from_wm(s->wmes); + s->wmes = NIL; + /* --- remove all preferences for the slot --- */ + pref = s->all_preferences; + while (pref) { + next_pref = pref->all_of_slot_next; + remove_preference_from_tm(pref); + /* Note: the call to remove_preference_from_slot handles the removal + of acceptable_preference_wmes */ + pref = next_pref; + } + mark_slot_for_possible_removal(s); + } /* end of for slots loop */ +} + +/* ---------------------------------------------- + During the mark & walk, these variables keep + track of the highest goal stack level that + any identifier could "fall from" and the lowest + level any could "fall to". These are used to + delimit a range of goal stack levels that + need to be walked. (In many cases, much of + the goal stack can be ignored.) +---------------------------------------------- */ + +/* ---------------------------------------------- + Mark an id and its transitive closure as having + an unknown level. Ids are marked by setting + id.tc_num to mark_tc_number. The starting id's + goal stack level is recorded in + level_at_which_marking_started by the caller. + The marked ids are added to ids_with_unknown_level. +---------------------------------------------- */ + +#define mark_unknown_level_if_needed(sym) \ + { if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \ + mark_id_and_tc_as_unknown_level(sym); } + +void mark_id_and_tc_as_unknown_level(Symbol * id) +{ + slot *s; + preference *pref; + wme *w; + dl_cons *dc; + + /* --- if id is already marked, do nothing --- */ + if (id->id.tc_num == current_agent(mark_tc_number)) + return; + + /* --- don't mark anything higher up as disconnected--in order to be higher + up, it must have a link to it up there --- */ + if (id->id.level < current_agent(level_at_which_marking_started)) + return; + + /* --- mark id, so we won't do it again later --- */ + id->id.tc_num = current_agent(mark_tc_number); + + /* --- update range of goal stack levels we'll need to walk --- */ + if (id->id.level < current_agent(highest_level_anything_could_fall_from)) + current_agent(highest_level_anything_could_fall_from) = id->id.level; + if (id->id.level > current_agent(lowest_level_anything_could_fall_to)) + current_agent(lowest_level_anything_could_fall_to) = id->id.level; + if (id->id.could_be_a_link_from_below) + current_agent(lowest_level_anything_could_fall_to) = LOWEST_POSSIBLE_GOAL_LEVEL; + + /* --- add id to the set of ids with unknown level --- */ + if (!id->id.unknown_level) { + allocate_with_pool(¤t_agent(dl_cons_pool), &dc); + dc->item = id; + id->id.unknown_level = dc; + insert_at_head_of_dll(current_agent(ids_with_unknown_level), dc, next, prev); + symbol_add_ref(id); + } + + /* -- scan through all preferences and wmes for all slots for this id -- */ + for (w = id->id.input_wmes; w != NIL; w = w->next) + mark_unknown_level_if_needed(w->value); + for (s = id->id.slots; s != NIL; s = s->next) { + for (pref = s->all_preferences; pref != NIL; pref = pref->all_of_slot_next) { + mark_unknown_level_if_needed(pref->value); + if (preference_is_binary(pref->type)) + mark_unknown_level_if_needed(pref->referent); + } + if (s->impasse_id) + mark_unknown_level_if_needed(s->impasse_id); + for (w = s->wmes; w != NIL; w = w->next) + mark_unknown_level_if_needed(w->value); + } /* end of for slots loop */ +} + +/* ---------------------------------------------- + After marking the ids with unknown level, + we walk various levels of the goal stack, + higher level to lower level. If, while doing + the walk, we encounter an id marked as having + an unknown level, we update its level and + remove it from ids_with_unknown_level. +---------------------------------------------- */ + +#define update_levels_if_needed(sym) \ + { if ((sym)->common.symbol_type==IDENTIFIER_SYMBOL_TYPE) \ + if ((sym)->id.tc_num!=current_agent(walk_tc_number)) \ + walk_and_update_levels(sym); } + +void walk_and_update_levels(Symbol * id) +{ + slot *s; + preference *pref; + wme *w; + dl_cons *dc; + + /* --- mark id so we don't walk it twice --- */ + id->id.tc_num = current_agent(walk_tc_number); + + /* --- if we already know its level, and it's higher up, then exit --- */ + if ((!id->id.unknown_level) && (id->id.level < current_agent(walk_level))) + return; + + /* --- if we didn't know its level before, we do now --- */ + if (id->id.unknown_level) { + dc = id->id.unknown_level; + remove_from_dll(current_agent(ids_with_unknown_level), dc, next, prev); + free_with_pool(¤t_agent(dl_cons_pool), dc); + symbol_remove_ref(id); + id->id.unknown_level = NIL; + id->id.level = current_agent(walk_level); + id->id.promotion_level = current_agent(walk_level); + } + + /* -- scan through all preferences and wmes for all slots for this id -- */ + for (w = id->id.input_wmes; w != NIL; w = w->next) + update_levels_if_needed(w->value); + for (s = id->id.slots; s != NIL; s = s->next) { + for (pref = s->all_preferences; pref != NIL; pref = pref->all_of_slot_next) { + update_levels_if_needed(pref->value); + if (preference_is_binary(pref->type)) + update_levels_if_needed(pref->referent); + } + if (s->impasse_id) + update_levels_if_needed(s->impasse_id); + for (w = s->wmes; w != NIL; w = w->next) + update_levels_if_needed(w->value); + } /* end of for slots loop */ +} + +/* ---------------------------------------------- + Do all buffered demotions and gc's. +---------------------------------------------- */ + +void do_demotion(void) +{ + Symbol *g, *id; + dl_cons *dc, *next_dc; + + /* --- scan through ids_with_unknown_level, move the ones with link_count==0 + * over to disconnected_ids --- */ + for (dc = current_agent(ids_with_unknown_level); dc != NIL; dc = next_dc) { + next_dc = dc->next; + id = dc->item; + if (id->id.link_count == 0) { + remove_from_dll(current_agent(ids_with_unknown_level), dc, next, prev); + insert_at_head_of_dll(current_agent(disconnected_ids), dc, next, prev); + } + } + + /* --- keep garbage collecting ids until nothing left to gc --- */ + current_agent(link_update_mode) = UPDATE_DISCONNECTED_IDS_LIST; + while (current_agent(disconnected_ids)) { + dc = current_agent(disconnected_ids); + current_agent(disconnected_ids) = current_agent(disconnected_ids)->next; + id = dc->item; + free_with_pool(¤t_agent(dl_cons_pool), dc); + garbage_collect_id(id); + symbol_remove_ref(id); + } + current_agent(link_update_mode) = UPDATE_LINKS_NORMALLY; + + /* --- if nothing's left with an unknown level, we're done --- */ + if (!current_agent(ids_with_unknown_level)) + return; + + /* --- do the mark --- */ + current_agent(highest_level_anything_could_fall_from) = LOWEST_POSSIBLE_GOAL_LEVEL; + current_agent(lowest_level_anything_could_fall_to) = -1; + current_agent(mark_tc_number) = get_new_tc_number(); + for (dc = current_agent(ids_with_unknown_level); dc != NIL; dc = dc->next) { + id = dc->item; + current_agent(level_at_which_marking_started) = id->id.level; + mark_id_and_tc_as_unknown_level(id); + } + + /* --- do the walk --- */ + g = current_agent(top_goal); + for (;;) { + if (!g) + break; + if (g->id.level > current_agent(lowest_level_anything_could_fall_to)) + break; + if (g->id.level >= current_agent(highest_level_anything_could_fall_from)) { + current_agent(walk_level) = g->id.level; + current_agent(walk_tc_number) = get_new_tc_number(); + walk_and_update_levels(g); + } + g = g->id.lower_goal; + } + + /* --- GC anything left with an unknown level after the walk --- */ + current_agent(link_update_mode) = JUST_UPDATE_COUNT; + while (current_agent(ids_with_unknown_level)) { + dc = current_agent(ids_with_unknown_level); + current_agent(ids_with_unknown_level) = current_agent(ids_with_unknown_level)->next; + id = dc->item; + free_with_pool(¤t_agent(dl_cons_pool), dc); + id->id.unknown_level = NIL; /* AGR 640: GAP set to NIL because */ + /* symbol may still have pointers to it */ + garbage_collect_id(id); + symbol_remove_ref(id); + } + current_agent(link_update_mode) = UPDATE_LINKS_NORMALLY; +} + +/* ------------------------------------------------------------------ + Do Buffered Link Changes + + This routine does all the buffered link (ownership) chages, updating + the goal stack level on all identifiers and garbage collecting + disconnected wmes. +------------------------------------------------------------------ */ + +void do_buffered_link_changes(void) +{ + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + struct timeval saved_start_tv; +#endif +#endif + + /* --- if no promotions or demotions are buffered, do nothing --- */ + if (!(current_agent(promoted_ids) || current_agent(ids_with_unknown_level) || current_agent(disconnected_ids))) + return; + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + start_timer(&saved_start_tv); +#endif +#endif + do_promotion(); + do_demotion(); +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + stop_timer(&saved_start_tv, ¤t_agent(ownership_cpu_time[current_agent(current_phase)])); +#endif +#endif +} + +/* ************************************************************************** + + Preference Semantics + + Run_preference_semantics (slot *s, preference **result_candidates) examines + the preferences for a given slot, and returns an impasse type for the + slot. The argument "result_candidates" is set to a list of candidate + values for the slot--if the returned impasse type is NONE_IMPASSE_TYPE, + this is the set of winners; otherwise it is the set of tied, conflicted, + or constraint-failured values. This list of values is a list of preferences + for those values, linked via the "next_candidate" field on each preference + structure. If there is more than one preference for a given value, + only one is returned in the result_candidates, with (first) require + preferences being preferred over acceptable preferences, and (second) + preferences from higher match goals being preferred over those from + lower match goals. + + BUGBUG There is a problem here: since the require/acceptable priority + takes precedence over the match goal level priority, it's possible that + we could return a require preference from lower in the goal stack than + some acceptable preference. If the goal stack gets popped soon + afterwards (i.e., before the next time the slot is re-decided, I think), + we would be left with a WME still in WM (not GC'd, because of the acceptable + preference higher up) but with a trace pointing to a deallocated require + preference. This case is very obsure and unlikely to come up, but it + could easily cause a core dump or worse. + + Require_preference_semantics() is a helper function for + run_preference_semantics() that is used when there is at least one + require preference for the slot. +************************************************************************** */ + +byte require_preference_semantics(slot * s, preference ** result_candidates) +{ + preference *p; + preference *candidates; + Symbol *value; + + /* --- collect set of required items into candidates list --- */ + for (p = s->preferences[REQUIRE_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + candidates = NIL; + for (p = s->preferences[REQUIRE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + if (p->value->common.decider_flag == NOTHING_DECIDER_FLAG) { + p->next_candidate = candidates; + candidates = p; + /* --- unmark it, in order to prevent it from being added twice --- */ + p->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + } + } + *result_candidates = candidates; + + /* --- if more than one required item, we have a constraint failure --- */ + if (candidates->next_candidate) + return CONSTRAINT_FAILURE_IMPASSE_TYPE; + + /* --- just one require, check for require-prohibit impasse --- */ + value = candidates->value; + for (p = s->preferences[PROHIBIT_PREFERENCE_TYPE]; p != NIL; p = p->next) + if (p->value == value) + return CONSTRAINT_FAILURE_IMPASSE_TYPE; + + /* --- the lone require is the winner --- */ + return NONE_IMPASSE_TYPE; +} + +byte run_preference_semantics(slot * s, preference ** result_candidates) +{ + preference *p, *p2, *cand, *prev_cand; + bool match_found, not_all_indifferent, not_all_parallel; + preference *candidates; + + /* --- if the slot has no preferences at all, things are trivial --- */ + if (!s->all_preferences) { + if (!s->isa_context_slot) + mark_slot_for_possible_removal(s); + *result_candidates = NIL; + return NONE_IMPASSE_TYPE; + } + + /* === Requires === */ + if (s->preferences[REQUIRE_PREFERENCE_TYPE]) { + return require_preference_semantics(s, result_candidates); + } + + /* === Acceptables, Prohibits, Rejects === */ + + /* --- mark everything that's acceptable, then unmark the prohibited + and rejected items --- */ + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + for (p = s->preferences[PROHIBIT_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[REJECT_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + + /* --- now scan through acceptables and build the list of candidates --- */ + candidates = NIL; + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + if (p->value->common.decider_flag == CANDIDATE_DECIDER_FLAG) { + p->next_candidate = candidates; + candidates = p; + /* --- unmark it, in order to prevent it from being added twice --- */ + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + } + } + + /* === Handling of attribute_preferences_mode 2 === */ +#ifndef SOAR_8_ONLY + if (((current_agent(attribute_preferences_mode) == 2) || + (current_agent(operand2_mode) == TRUE)) && (!s->isa_context_slot)) { +#else + if (!s->isa_context_slot) { +#endif + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === If there are only 0 or 1 candidates, we're done === */ + if ((!candidates) || (!candidates->next_candidate)) { + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === Better/Worse === */ + if (s->preferences[BETTER_PREFERENCE_TYPE] || s->preferences[WORSE_PREFERENCE_TYPE]) { + Symbol *j, *k; + + /* -------------------- Algorithm to find conflicted set: + conflicted = {} + for each (j > k): + if j is (candidate or conflicted) + and k is (candidate or conflicted) + and at least one of j,k is a candidate + then if (k > j) or (j < k) then + conflicted += j, if not already true + conflicted += k, if not already true + candidate -= j, if not already true + candidate -= k, if not already true + for each (j < k): + if j is (candidate or conflicted) + and k is (candidate or conflicted) + and at least one of j,k is a candidate + then if (k < j) + then + conflicted += j, if not already true + conflicted += k, if not already true + candidate -= j, if not already true + candidate -= k, if not already true + ----------------------- */ + + for (p = s->preferences[BETTER_PREFERENCE_TYPE]; p != NIL; p = p->next) { + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + p->referent->common.decider_flag = NOTHING_DECIDER_FLAG; + } + for (p = s->preferences[WORSE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + p->referent->common.decider_flag = NOTHING_DECIDER_FLAG; + } + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + cand->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + } + for (p = s->preferences[BETTER_PREFERENCE_TYPE]; p != NIL; p = p->next) { + j = p->value; + k = p->referent; + if (j == k) + continue; + if (j->common.decider_flag && k->common.decider_flag) { + if (k->common.decider_flag != CONFLICTED_DECIDER_FLAG) + k->common.decider_flag = FORMER_CANDIDATE_DECIDER_FLAG; + if ((j->common.decider_flag != CONFLICTED_DECIDER_FLAG) || + (k->common.decider_flag != CONFLICTED_DECIDER_FLAG)) { + for (p2 = s->preferences[BETTER_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == k) && (p2->referent == j)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + for (p2 = s->preferences[WORSE_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == j) && (p2->referent == k)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + } + } + } + for (p = s->preferences[WORSE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + j = p->value; + k = p->referent; + if (j == k) + continue; + if (j->common.decider_flag && k->common.decider_flag) { + if (j->common.decider_flag != CONFLICTED_DECIDER_FLAG) + j->common.decider_flag = FORMER_CANDIDATE_DECIDER_FLAG; + if ((j->common.decider_flag != CONFLICTED_DECIDER_FLAG) || + (k->common.decider_flag != CONFLICTED_DECIDER_FLAG)) { + for (p2 = s->preferences[WORSE_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == k) && (p2->referent == j)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + } + } + } + + /* --- now scan through candidates list, look for conflicted stuff --- */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag == CONFLICTED_DECIDER_FLAG) + break; + if (cand) { + /* --- collect conflicted candidates into new candidates list --- */ + prev_cand = NIL; + cand = candidates; + while (cand) { + if (cand->value->common.decider_flag != CONFLICTED_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand->next_candidate; + else + candidates = cand->next_candidate; + } else { + prev_cand = cand; + } + cand = cand->next_candidate; + } + *result_candidates = candidates; + return CONFLICT_IMPASSE_TYPE; + } + /* --- no conflicts found, remove former_candidates from candidates --- */ + prev_cand = NIL; + cand = candidates; + while (cand) { + if (cand->value->common.decider_flag == FORMER_CANDIDATE_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand->next_candidate; + else + candidates = cand->next_candidate; + } else { + prev_cand = cand; + } + cand = cand->next_candidate; + } + } + + /* === Bests === */ + if (s->preferences[BEST_PREFERENCE_TYPE]) { + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[BEST_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = BEST_DECIDER_FLAG; + prev_cand = NIL; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag == BEST_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand; + else + candidates = cand; + prev_cand = cand; + } + if (prev_cand) + prev_cand->next_candidate = NIL; + } + + /* === Worsts === */ + if (s->preferences[WORST_PREFERENCE_TYPE]) { + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[WORST_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = WORST_DECIDER_FLAG; + prev_cand = NIL; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag != WORST_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand; + else + candidates = cand; + prev_cand = cand; + } + if (prev_cand) + prev_cand->next_candidate = NIL; + } + + /* === If there are only 0 or 1 candidates, we're done === */ + if ((!candidates) || (!candidates->next_candidate)) { + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === Indifferents === */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[UNARY_INDIFFERENT_PREFERENCE_TYPE]; p; p = p->next) + p->value->common.decider_flag = UNARY_INDIFFERENT_DECIDER_FLAG; + + #ifdef NUMERIC_INDIFFERENCE + /* REW: 2003-01-02 Behavior Variability Kernel Experiments + We want to treat some binary indifferent prefs as unary indifferents, + the second pref is really an int representing a probability value. + So we identify these preferences here. + */ + for (p=s->preferences[BINARY_INDIFFERENT_PREFERENCE_TYPE]; p; p=p->next) + if((p->referent->fc.common_symbol_info.symbol_type == INT_CONSTANT_SYMBOL_TYPE) || + (p->referent->fc.common_symbol_info.symbol_type == FLOAT_CONSTANT_SYMBOL_TYPE)) + + p->value->common.decider_flag = UNARY_INDIFFERENT_CONSTANT_DECIDER_FLAG; + + /* END: 2003-01-02 Behavior Variability Kernel Experiments */ + + #endif + + not_all_indifferent = FALSE; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /* --- if cand is unary indifferent, it's fine --- */ + if (cand->value->common.decider_flag == UNARY_INDIFFERENT_DECIDER_FLAG) + continue; + + #ifdef NUMERIC_INDIFFERENCE + else if ( cand->value->common.decider_flag==UNARY_INDIFFERENT_CONSTANT_DECIDER_FLAG ) + continue; + #endif + + /* --- check whether cand is binary indifferent to each other one --- */ + for (p = candidates; p != NIL; p = p->next_candidate) { + if (p == cand) + continue; + match_found = FALSE; + for (p2 = s->preferences[BINARY_INDIFFERENT_PREFERENCE_TYPE]; p2 != NIL; p2 = p2->next) + if (((p2->value == cand->value) && (p2->referent == p->value)) || + ((p2->value == p->value) && (p2->referent == cand->value))) { + match_found = TRUE; + break; + } + if (!match_found) { + not_all_indifferent = TRUE; + break; + } + } /* end of for p loop */ + if (not_all_indifferent) + break; + } /* end of for cand loop */ + + if (!not_all_indifferent) { + /* --- items all indifferent, so just pick one of them to return --- */ + /* RBD 4/13/95 Removed code that looked for an existing value already in + working memory for this slot, and returned it if found. This was + apparently an attempt to "stabilize" working memory if attribute + preferences kept changing, but it ended up getting in the way, esp. + with mutually indifferent operators were used with user-select + random. */ + /* --- choose according to user-select --- */ + switch (current_agent(sysparams)[USER_SELECT_MODE_SYSPARAM]) { + case USER_SELECT_FIRST: + *result_candidates = candidates; + break; +/* AGR 615 begin */ + case USER_SELECT_LAST: + /* The test to see if candidates is NIL is done just before the + indifferent preferences processing begins. The only place + between there and here that candidates is changed is immediately + followed by a return statement, so we can assume here that + candidates is not NIL. AGR 94.11.09 */ + for (cand = candidates; cand->next_candidate != NIL; cand = cand->next_candidate); + *result_candidates = cand; + break; +/* AGR 615 end */ + case USER_SELECT_ASK:{ + soar_apiAskCallbackData askd; + + askd.candidates = candidates; + askd.selection = result_candidates; + + if (soar_exists_callback(soar_agent, ASK_CALLBACK)) { + soar_invoke_first_callback(soar_agent, ASK_CALLBACK, (soar_call_data) & askd); + + break; /* ** prevent fallthrough ** */ + } else { + print("\nError: \n"); + print(" User Select ASK failed becuase no ask callback is defined\n"); + print(" Setting to user select RANDOM\n"); + set_sysparam(USER_SELECT_MODE_SYSPARAM, USER_SELECT_RANDOM); + current_agent(stop_soar) = TRUE; + + /* ** intentiaonal fall through here... ** */ + } + + /* ** intentiaonal fall through here... ** */ + } + case USER_SELECT_RANDOM:{ + +#ifdef NUMERIC_INDIFFERENCE + /* REW: 2003-01-02 Behavior Variability Kernel Experiments */ + cand = probabilistically_select(s, candidates); + if (!cand) { + *result_candidates = candidates; + return TIE_IMPASSE_TYPE; + } + *result_candidates = cand; + break; +#else + int num_candidates, chosen_num; + num_candidates = 0; + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + num_candidates++; + + chosen_num = sys_random() % num_candidates; + + cand = candidates; + while (chosen_num) { + cand = cand->next_candidate; + chosen_num--; + } + *result_candidates = cand; + break; +#endif + } + default: + { + char msg[MESSAGE_SIZE]; + snprintf(msg, MESSAGE_SIZE, "decide.c: Error: bad value of user_select_mode: %ld\n", + current_agent(sysparams)[USER_SELECT_MODE_SYSPARAM]); + msg[MESSAGE_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ + abort_with_fatal_error(msg); + } + } + (*result_candidates)->next_candidate = NIL; + return NONE_IMPASSE_TYPE; + } + + /* --- items not all indifferent; for context slots this gives a tie --- */ + if (s->isa_context_slot) { + *result_candidates = candidates; + return TIE_IMPASSE_TYPE; + } + + /* === Parallels === */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[UNARY_PARALLEL_PREFERENCE_TYPE]; p; p = p->next) + p->value->common.decider_flag = UNARY_PARALLEL_DECIDER_FLAG; + not_all_parallel = FALSE; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /* --- if cand is unary parallel, it's fine --- */ + if (cand->value->common.decider_flag == UNARY_PARALLEL_DECIDER_FLAG) + continue; + /* --- check whether cand is binary parallel to each other candidate --- */ + for (p = candidates; p != NIL; p = p->next_candidate) { + if (p == cand) + continue; + match_found = FALSE; + for (p2 = s->preferences[BINARY_PARALLEL_PREFERENCE_TYPE]; p2 != NIL; p2 = p2->next) + if (((p2->value == cand->value) && (p2->referent == p->value)) || + ((p2->value == p->value) && (p2->referent == cand->value))) { + match_found = TRUE; + break; + } + if (!match_found) { + not_all_parallel = TRUE; + break; + } + } /* end of for p loop */ + if (not_all_parallel) + break; + } /* end of for cand loop */ + + *result_candidates = candidates; + + if (!not_all_parallel) { + /* --- items are all parallel, so return them all --- */ + return NONE_IMPASSE_TYPE; + } + + /* --- otherwise we have a tie --- */ + return TIE_IMPASSE_TYPE; +} + +byte run_preference_semantics_for_consistency_check(slot * s, preference ** result_candidates) +{ + preference *p, *p2, *cand, *prev_cand; + bool match_found, not_all_indifferent, not_all_parallel; + preference *candidates; + + /* print("\n Checking the preference semantics for inconsistencies....\n"); */ + /* --- if the slot has no preferences at all, things are trivial --- */ + if (!s->all_preferences) { + if (!s->isa_context_slot) + mark_slot_for_possible_removal(s); + *result_candidates = NIL; + return NONE_IMPASSE_TYPE; + } + + /* === Requires === */ + if (s->preferences[REQUIRE_PREFERENCE_TYPE]) { + return require_preference_semantics(s, result_candidates); + } + + /* === Acceptables, Prohibits, Rejects === */ + + /* --- mark everything that's acceptable, then unmark the prohibited + and rejected items --- */ + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + for (p = s->preferences[PROHIBIT_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[REJECT_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + + /* --- now scan through acceptables and build the list of candidates --- */ + candidates = NIL; + for (p = s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + if (p->value->common.decider_flag == CANDIDATE_DECIDER_FLAG) { + p->next_candidate = candidates; + candidates = p; + /* --- unmark it, in order to prevent it from being added twice --- */ + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + } + } + + /* === Handling of attribute_preferences_mode 2 === */ +#ifndef SOAR_8_ONLY + if (((current_agent(attribute_preferences_mode) == 2) || + (current_agent(operand2_mode) == TRUE)) && (!s->isa_context_slot)) { +#else + if (!s->isa_context_slot) { +#endif + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === If there are only 0 or 1 candidates, we're done === */ + if ((!candidates) || (!candidates->next_candidate)) { + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === Better/Worse === */ + if (s->preferences[BETTER_PREFERENCE_TYPE] || s->preferences[WORSE_PREFERENCE_TYPE]) { + Symbol *j, *k; + + /* -------------------- Algorithm to find conflicted set: + conflicted = {} + for each (j > k): + if j is (candidate or conflicted) + and k is (candidate or conflicted) + and at least one of j,k is a candidate + then if (k > j) or (j < k) then + conflicted += j, if not already true + conflicted += k, if not already true + candidate -= j, if not already true + candidate -= k, if not already true + for each (j < k): + if j is (candidate or conflicted) + and k is (candidate or conflicted) + and at least one of j,k is a candidate + then if (k < j) + then + conflicted += j, if not already true + conflicted += k, if not already true + candidate -= j, if not already true + candidate -= k, if not already true + ----------------------- */ + + for (p = s->preferences[BETTER_PREFERENCE_TYPE]; p != NIL; p = p->next) { + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + p->referent->common.decider_flag = NOTHING_DECIDER_FLAG; + } + for (p = s->preferences[WORSE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + p->value->common.decider_flag = NOTHING_DECIDER_FLAG; + p->referent->common.decider_flag = NOTHING_DECIDER_FLAG; + } + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + cand->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + } + for (p = s->preferences[BETTER_PREFERENCE_TYPE]; p != NIL; p = p->next) { + j = p->value; + k = p->referent; + if (j == k) + continue; + if (j->common.decider_flag && k->common.decider_flag) { + if (k->common.decider_flag != CONFLICTED_DECIDER_FLAG) + k->common.decider_flag = FORMER_CANDIDATE_DECIDER_FLAG; + if ((j->common.decider_flag != CONFLICTED_DECIDER_FLAG) || + (k->common.decider_flag != CONFLICTED_DECIDER_FLAG)) { + for (p2 = s->preferences[BETTER_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == k) && (p2->referent == j)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + for (p2 = s->preferences[WORSE_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == j) && (p2->referent == k)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + } + } + } + for (p = s->preferences[WORSE_PREFERENCE_TYPE]; p != NIL; p = p->next) { + j = p->value; + k = p->referent; + if (j == k) + continue; + if (j->common.decider_flag && k->common.decider_flag) { + if (j->common.decider_flag != CONFLICTED_DECIDER_FLAG) + j->common.decider_flag = FORMER_CANDIDATE_DECIDER_FLAG; + if ((j->common.decider_flag != CONFLICTED_DECIDER_FLAG) || + (k->common.decider_flag != CONFLICTED_DECIDER_FLAG)) { + for (p2 = s->preferences[WORSE_PREFERENCE_TYPE]; p2; p2 = p2->next) + if ((p2->value == k) && (p2->referent == j)) { + j->common.decider_flag = CONFLICTED_DECIDER_FLAG; + k->common.decider_flag = CONFLICTED_DECIDER_FLAG; + break; + } + } + } + } + + /* --- now scan through candidates list, look for conflicted stuff --- */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag == CONFLICTED_DECIDER_FLAG) + break; + if (cand) { + /* --- collect conflicted candidates into new candidates list --- */ + prev_cand = NIL; + cand = candidates; + while (cand) { + if (cand->value->common.decider_flag != CONFLICTED_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand->next_candidate; + else + candidates = cand->next_candidate; + } else { + prev_cand = cand; + } + cand = cand->next_candidate; + } + *result_candidates = candidates; + return CONFLICT_IMPASSE_TYPE; + } + /* --- no conflicts found, remove former_candidates from candidates --- */ + prev_cand = NIL; + cand = candidates; + while (cand) { + if (cand->value->common.decider_flag == FORMER_CANDIDATE_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand->next_candidate; + else + candidates = cand->next_candidate; + } else { + prev_cand = cand; + } + cand = cand->next_candidate; + } + } + + /* === Bests === */ + if (s->preferences[BEST_PREFERENCE_TYPE]) { + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[BEST_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = BEST_DECIDER_FLAG; + prev_cand = NIL; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag == BEST_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand; + else + candidates = cand; + prev_cand = cand; + } + if (prev_cand) + prev_cand->next_candidate = NIL; + } + + /* === Worsts === */ + if (s->preferences[WORST_PREFERENCE_TYPE]) { + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[WORST_PREFERENCE_TYPE]; p != NIL; p = p->next) + p->value->common.decider_flag = WORST_DECIDER_FLAG; + prev_cand = NIL; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + if (cand->value->common.decider_flag != WORST_DECIDER_FLAG) { + if (prev_cand) + prev_cand->next_candidate = cand; + else + candidates = cand; + prev_cand = cand; + } + if (prev_cand) + prev_cand->next_candidate = NIL; + } + + /* === If there are only 0 or 1 candidates, we're done === */ + if ((!candidates) || (!candidates->next_candidate)) { + *result_candidates = candidates; + return NONE_IMPASSE_TYPE; + } + + /* === Indifferents === */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[UNARY_INDIFFERENT_PREFERENCE_TYPE]; p; p = p->next) + p->value->common.decider_flag = UNARY_INDIFFERENT_DECIDER_FLAG; + + #ifdef NUMERIC_INDIFFERENCE + /* REW: 2003-01-26 Behavior Variability Kernel Experiments + We want to treat some binary indifferent prefs as unary indifferents, + the second pref is really an int representing a probability value. + So we identify these preferences here. + -- want to guarantee decision is not interrupted by a new indiff pref + */ + for (p=s->preferences[BINARY_INDIFFERENT_PREFERENCE_TYPE]; p; p=p->next) + if( (p->referent->fc.common_symbol_info.symbol_type == INT_CONSTANT_SYMBOL_TYPE) || + (p->referent->fc.common_symbol_info.symbol_type == FLOAT_CONSTANT_SYMBOL_TYPE)) + + p->value->common.decider_flag = UNARY_INDIFFERENT_CONSTANT_DECIDER_FLAG; + /* END: 2003-01-02 Behavior Variability Kernel Experiments */ +#endif + + not_all_indifferent = FALSE; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /* --- if cand is unary indifferent, it's fine --- */ + if (cand->value->common.decider_flag == UNARY_INDIFFERENT_DECIDER_FLAG) + continue; + + #ifdef NUMERIC_INDIFFERENCE + else if ( cand->value->common.decider_flag==UNARY_INDIFFERENT_CONSTANT_DECIDER_FLAG ) { + /* print("\n Ignoring this candidate because it has a constant value for the second pref"); */ + continue; + } + #endif + + /* --- check whether cand is binary indifferent to each other one --- */ + for (p = candidates; p != NIL; p = p->next_candidate) { + if (p == cand) + continue; + match_found = FALSE; + for (p2 = s->preferences[BINARY_INDIFFERENT_PREFERENCE_TYPE]; p2 != NIL; p2 = p2->next) + if (((p2->value == cand->value) && (p2->referent == p->value)) || + ((p2->value == p->value) && (p2->referent == cand->value))) { + match_found = TRUE; + break; + } + if (!match_found) { + not_all_indifferent = TRUE; + break; + } + } /* end of for p loop */ + if (not_all_indifferent) + break; + } /* end of for cand loop */ + + if (!not_all_indifferent) { + /* --- items all indifferent, so just pick one of them to return --- */ + /* RBD 4/13/95 Removed code that looked for an existing value already in + working memory for this slot, and returned it if found. This was + apparently an attempt to "stabilize" working memory if attribute + preferences kept changing, but it ended up getting in the way, esp. + with mutually indifferent operators were used with user-select + random. */ + /* --- choose according to user-select --- */ + + /* REW: begin 09.15.96 */ + /* We don't care about the User Select mode in Operand2 for the + * consistency check. All we need to do is return the impasse type + * (None because all preferences are indifferent) and return all the + * candidates (rather than just one) because we don;t want to commit + ourselves to single candidate at this point. + */ + + *result_candidates = candidates; + + /* We want the whole list of candidates, not just the one that would + * be chosen FIRST (ie, the head of result_candidates is also first), + * so we comment the next line. */ + /* (*result_candidates)->next_candidate = NIL; */ + return NONE_IMPASSE_TYPE; + + } + + /* --- items not all indifferent; for context slots this gives a tie --- */ + if (s->isa_context_slot) { + *result_candidates = candidates; + return TIE_IMPASSE_TYPE; + } + + /* === Parallels === */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = NOTHING_DECIDER_FLAG; + for (p = s->preferences[UNARY_PARALLEL_PREFERENCE_TYPE]; p; p = p->next) + p->value->common.decider_flag = UNARY_PARALLEL_DECIDER_FLAG; + not_all_parallel = FALSE; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /* --- if cand is unary parallel, it's fine --- */ + if (cand->value->common.decider_flag == UNARY_PARALLEL_DECIDER_FLAG) + continue; + /* --- check whether cand is binary parallel to each other candidate --- */ + for (p = candidates; p != NIL; p = p->next_candidate) { + if (p == cand) + continue; + match_found = FALSE; + for (p2 = s->preferences[BINARY_PARALLEL_PREFERENCE_TYPE]; p2 != NIL; p2 = p2->next) + if (((p2->value == cand->value) && (p2->referent == p->value)) || + ((p2->value == p->value) && (p2->referent == cand->value))) { + match_found = TRUE; + break; + } + if (!match_found) { + not_all_parallel = TRUE; + break; + } + } /* end of for p loop */ + if (not_all_parallel) + break; + } /* end of for cand loop */ + + *result_candidates = candidates; + + if (!not_all_parallel) { + /* --- items are all parallel, so return them all --- */ + return NONE_IMPASSE_TYPE; + } + + /* --- otherwise we have a tie --- */ + return TIE_IMPASSE_TYPE; +} + +/* ************************************************************************** + + Decider and Impasser Routines + +************************************************************************** */ + +/* ------------------------------------------------------------------ + Add Impasse Wme + + This creates a new wme and adds it to the given impasse object. + "Id" indicates the goal/impasse id; (id ^attr value) is the impasse + wme to be added. The "preference" argument indicates the preference + (if non-NIL) for backtracing. +------------------------------------------------------------------ */ + +void add_impasse_wme(Symbol * id, Symbol * attr, Symbol * value, preference * p) +{ + wme *w; + + w = make_wme(id, attr, value, FALSE); + insert_at_head_of_dll(id->id.impasse_wmes, w, next, prev); + w->preference = p; + add_wme_to_wm(w); +} + +/* ------------------------------------------------------------------ + Create New Impasse + + This creates a new impasse, returning its identifier. The caller is + responsible for filling in either id->isa_impasse or id->isa_goal, + and all the extra stuff for goal identifiers. +------------------------------------------------------------------ */ + +Symbol *create_new_impasse(bool isa_goal, Symbol * object, Symbol * attr, byte impasse_type, goal_stack_level level) +{ + Symbol *id; + + id = make_new_identifier((char) (isa_goal ? 'S' : 'I'), level); + post_link_addition(NIL, id); /* add the special link */ + + add_impasse_wme(id, current_agent(type_symbol), + isa_goal ? current_agent(state_symbol) : current_agent(impasse_symbol), NIL); + + if (isa_goal) + add_impasse_wme(id, current_agent(superstate_symbol), object, NIL); + else + add_impasse_wme(id, current_agent(object_symbol), object, NIL); + + if (attr) + add_impasse_wme(id, current_agent(attribute_symbol), attr, NIL); + + switch (impasse_type) { + case NONE_IMPASSE_TYPE: + break; /* this happens only when creating the top goal */ + case CONSTRAINT_FAILURE_IMPASSE_TYPE: + add_impasse_wme(id, current_agent(impasse_symbol), current_agent(constraint_failure_symbol), NIL); + add_impasse_wme(id, current_agent(choices_symbol), current_agent(none_symbol), NIL); + break; + case CONFLICT_IMPASSE_TYPE: + add_impasse_wme(id, current_agent(impasse_symbol), current_agent(conflict_symbol), NIL); + add_impasse_wme(id, current_agent(choices_symbol), current_agent(multiple_symbol), NIL); + break; + case TIE_IMPASSE_TYPE: + add_impasse_wme(id, current_agent(impasse_symbol), current_agent(tie_symbol), NIL); + add_impasse_wme(id, current_agent(choices_symbol), current_agent(multiple_symbol), NIL); + break; + case NO_CHANGE_IMPASSE_TYPE: + add_impasse_wme(id, current_agent(impasse_symbol), current_agent(no_change_symbol), NIL); + add_impasse_wme(id, current_agent(choices_symbol), current_agent(none_symbol), NIL); + break; + } + return id; +} + +/* ------------------------------------------------------------------ + Create/Remove Attribute Impasse for Slot + + These routines create and remove an attribute impasse for a given + slot. +------------------------------------------------------------------ */ + +void create_new_attribute_impasse_for_slot(slot * s, byte impasse_type) +{ + Symbol *id; + + s->impasse_type = impasse_type; + id = create_new_impasse(FALSE, s->id, s->attr, impasse_type, ATTRIBUTE_IMPASSE_LEVEL); + s->impasse_id = id; + id->id.isa_impasse = TRUE; + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, CREATE_NEW_ATTRIBUTE_IMPASSE_CALLBACK, (soar_call_data) s); +#endif + +} + +void remove_existing_attribute_impasse_for_slot(slot * s) +{ + Symbol *id; + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, REMOVE_ATTRIBUTE_IMPASSE_CALLBACK, (soar_call_data) s); + +#endif + + id = s->impasse_id; + s->impasse_id = NIL; + s->impasse_type = NONE_IMPASSE_TYPE; + remove_wme_list_from_wm(id->id.impasse_wmes); + id->id.impasse_wmes = NIL; + post_link_removal(NIL, id); /* remove the special link */ + symbol_remove_ref(id); +} + +/* ------------------------------------------------------------------ + Fake Preferences for Goal ^Item Augmentations + + When we backtrace through a (goal ^item) augmentation, we want + to backtrace to the acceptable preference wme in the supercontext + corresponding to that ^item. A slick way to do this automagically + is to set the backtracing preference pointer on the (goal ^item) + wme to be a "fake" preference for a "fake" instantiation. The + instantiation has as its LHS a list of one condition, which matched + the acceptable preference wme in the supercontext. + + Make_fake_preference_for_goal_item() builds such a fake preference + and instantiation, given a pointer to the supergoal and the + acceptable/require preference for the value, and returns a pointer + to the fake preference. *** for Soar 7.3, we changed the fake + preference to be ACCEPTABLE instead of REQUIRE. This could + potentially break some code, but it avoids the BUGBUG condition + that can occur when you have a REQUIRE lower in the stack than an + ACCEPTABLE but the goal stack gets popped while the WME backtrace + still points to the REQUIRE, instead of the higher ACCEPTABLE. + See the section above on Preference Semantics. It also allows + the GDS to backtrace through ^items properly. + + Remove_fake_preference_for_goal_item() is called to clean up the + fake stuff once the (goal ^item) wme is no longer needed. +------------------------------------------------------------------ */ + +preference *make_fake_preference_for_goal_item(Symbol * goal, preference * cand) +{ + slot *s; + wme *ap_wme; + instantiation *inst; + preference *pref; + condition *cond; + + /* --- find the acceptable preference wme we want to backtrace to --- */ + s = cand->slot; + for (ap_wme = s->acceptable_preference_wmes; ap_wme != NIL; ap_wme = ap_wme->next) + if (ap_wme->value == cand->value) + break; + if (!ap_wme) { + char msg[MESSAGE_SIZE]; + strncpy(msg, "decide.c: Internal error: couldn't find acceptable pref wme\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + /* --- make the fake preference --- */ + /* kjc: here's where we changed REQUIRE to ACCEPTABLE */ + pref = make_preference(ACCEPTABLE_PREFERENCE_TYPE, goal, current_agent(item_symbol), cand->value, NIL); + symbol_add_ref(pref->id); + symbol_add_ref(pref->attr); + symbol_add_ref(pref->value); + insert_at_head_of_dll(goal->id.preferences_from_goal, pref, all_of_goal_next, all_of_goal_prev); + pref->on_goal_list = TRUE; + preference_add_ref(pref); + /* --- make the fake instantiation --- */ + allocate_with_pool(¤t_agent(instantiation_pool), &inst); + pref->inst = inst; + pref->inst_next = pref->inst_prev = NIL; + inst->preferences_generated = pref; + inst->prod = NIL; + inst->next = inst->prev = NIL; + inst->rete_token = NIL; + inst->rete_wme = NIL; + inst->match_goal = goal; + inst->match_goal_level = goal->id.level; + inst->okay_to_variablize = TRUE; + inst->backtrace_number = 0; + inst->in_ms = FALSE; + /* --- make the fake condition --- */ + allocate_with_pool(¤t_agent(condition_pool), &cond); + cond->type = POSITIVE_CONDITION; + cond->next = cond->prev = NIL; + inst->top_of_instantiated_conditions = cond; + inst->bottom_of_instantiated_conditions = cond; + inst->nots = NIL; + cond->data.tests.id_test = make_equality_test(ap_wme->id); + cond->data.tests.attr_test = make_equality_test(ap_wme->attr); + cond->data.tests.value_test = make_equality_test(ap_wme->value); + cond->test_for_acceptable_preference = TRUE; + cond->bt.wme = ap_wme; + wme_add_ref(ap_wme); + cond->bt.level = ap_wme->id->id.level; + cond->bt.trace = NIL; + cond->bt.prohibits = NIL; + + /* --- return the fake preference --- */ + return pref; +} + +void remove_fake_preference_for_goal_item(preference * pref) +{ + preference_remove_ref(pref); /* everything else happens automatically */ +} + +/* ------------------------------------------------------------------ + Update Impasse Items + + This routine updates the set of ^item wmes on a goal or attribute + impasse. It takes the identifier of the goal/impasse, and a list + of preferences (linked via the "next_candidate" field) for the new + set of items that should be there. +------------------------------------------------------------------ */ + +void update_impasse_items(Symbol * id, preference * items) +{ + wme *w, *next_w; + preference *cand; + preference *bt_pref; + + /* --- reset flags on existing items to "NOTHING" --- */ + for (w = id->id.impasse_wmes; w != NIL; w = w->next) + if (w->attr == current_agent(item_symbol)) + w->value->common.decider_flag = NOTHING_DECIDER_FLAG; + + /* --- mark set of desired items as "CANDIDATEs" --- */ + for (cand = items; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + + /* --- for each existing item: if it's supposed to be there still, then + mark it "ALREADY_EXISTING"; otherwise remove it --- */ + w = id->id.impasse_wmes; + while (w) { + next_w = w->next; + if (w->attr == current_agent(item_symbol)) { + if (w->value->common.decider_flag == CANDIDATE_DECIDER_FLAG) { + w->value->common.decider_flag = ALREADY_EXISTING_WME_DECIDER_FLAG; + w->value->common.a.decider_wme = w; /* so we can update the pref later */ + } else { + remove_from_dll(id->id.impasse_wmes, w, next, prev); + if (id->id.isa_goal) + remove_fake_preference_for_goal_item(w->preference); + remove_wme_from_wm(w); + } + } + w = next_w; + } + + /* --- for each desired item: if it doesn't ALREADY_EXIST, add it --- */ + for (cand = items; cand != NIL; cand = cand->next_candidate) { + if (id->id.isa_goal) + bt_pref = make_fake_preference_for_goal_item(id, cand); + else + bt_pref = cand; + if (cand->value->common.decider_flag == ALREADY_EXISTING_WME_DECIDER_FLAG) { + if (id->id.isa_goal) + remove_fake_preference_for_goal_item(cand->value->common.a.decider_wme->preference); + cand->value->common.a.decider_wme->preference = bt_pref; + } else { + add_impasse_wme(id, current_agent(item_symbol), cand->value, bt_pref); + } + } +} + +/* ------------------------------------------------------------------ + Decide Non Context Slot + + This routine decides a given slot, which must be a non-context + slot. It calls run_preference_semantics() on the slot, then + updates the wmes and/or impasse for the slot accordingly. +------------------------------------------------------------------ */ + +void decide_non_context_slot(slot * s) +{ + byte impasse_type; + wme *w, *next_w; + preference *candidates, *cand; +#ifndef DONT_CALC_GDS_OR_BT + preference *pref; +#endif + + impasse_type = run_preference_semantics(s, &candidates); + + if (impasse_type == NONE_IMPASSE_TYPE) { + /* --- no impasse, so remove any existing one and update the wmes --- */ + if (s->impasse_type != NONE_IMPASSE_TYPE) + remove_existing_attribute_impasse_for_slot(s); + /* --- reset marks on existing wme values to "NOTHING" --- */ + for (w = s->wmes; w != NIL; w = w->next) + w->value->common.decider_flag = NOTHING_DECIDER_FLAG; + /* --- set marks on desired values to "CANDIDATES" --- */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + cand->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + /* --- for each existing wme, if we want it there, mark it as + ALREADY_EXISTING; otherwise remove it --- */ + w = s->wmes; + while (w) { + next_w = w->next; + if (w->value->common.decider_flag == CANDIDATE_DECIDER_FLAG) { + w->value->common.decider_flag = ALREADY_EXISTING_WME_DECIDER_FLAG; + w->value->common.a.decider_wme = w; /* so we can set the pref later */ + } else { + remove_from_dll(s->wmes, w, next, prev); + +#ifndef DONT_CALC_GDS_OR_BT + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode)) { +#endif + if (w->gds) { + if (w->gds->goal != NIL) { + /* If the goal pointer is non-NIL, then goal is in the stack */ + if (current_agent(soar_verbose_flag)) { + print("\n Removing goal %d because element in GDS changed.", + w->gds->goal->id.level); + print(" WME: "); + print_wme(w); + } + gds_invalid_so_remove_goal(w); + } + } +#ifndef SOAR_8_ONLY + } +#endif +#endif /* DONT_CALC_GDS_OR_BT */ + /* REW: end 09.15.96 */ + remove_wme_from_wm(w); + } + w = next_w; + } /* end while (W) */ + + /* --- for each desired value, if it's not already there, add it --- */ + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + if (cand->value->common.decider_flag == ALREADY_EXISTING_WME_DECIDER_FLAG) { + /* REW: begin 11.22.97 */ + /* print("\n This WME was marked as already existing...."); print_wme(cand->value->common.a.decider_wme); */ + + /* REW: end 11.22.97 */ + cand->value->common.a.decider_wme->preference = cand; + } else { + w = make_wme(cand->id, cand->attr, cand->value, FALSE); + insert_at_head_of_dll(s->wmes, w, next, prev); + w->preference = cand; + +#ifndef DONT_CALC_GDS_OR_BT + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode)) { +#endif + /* Whenever we add a WME to WM, we also want to check and see if + this new WME is o-supported. If so, then we want to add the + supergoal dependencies of the new, o-supported element to the + goal in which the element was created (as long as the o_supported + element was not created in the top state -- the top goal has + no gds). */ + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + /* REW: begin 11.25.96 */ + start_timer(¤t_agent(start_gds_tv)); + /* REW: end 11.25.96 */ +#endif +#endif + current_agent(parent_list_head) = NIL; + + /* If the working memory element being added is going to have + o_supported preferences and the instantion that created it + is not in the top_level_goal (where there is no GDS), then + loop over the preferences for this WME and determine which + WMEs should be added to the goal's GDS (the goal here being the + goal to which the added memory is attached). */ + +#ifdef NO_TOP_JUST + + if ((w->preference->o_supported == TRUE) && (w->preference->match_goal_level != 1)) { + + if (w->preference->match_goal->id.gds == NIL) { + /* If there is no GDS yet for this goal, + * then we need to create one */ + if (w->preference->match_goal_level == w->preference->id->id.level) { + + create_gds_for_goal(w->preference->match_goal); +#else + if ((w->preference->o_supported == TRUE) && (w->preference->inst->match_goal_level != 1)) { + + if (w->preference->inst->match_goal->id.gds == NIL) { + /* If there is no GDS yet for this goal, + * then we need to create one */ + + if (w->preference->inst->match_goal_level == w->preference->id->id.level) { + + create_gds_for_goal(w->preference->inst->match_goal); +#endif + + /* REW: BUG When chunks and result instantiations both create + * preferences for the same WME, then we only want to create + * the GDS for the highest goal. Right now I ensure that we + * elaborate the correct GDS with the tests in the loop just + * below this code, but the GDS creation above assumes that + * the chunk will be first on the GDS list. This order + * appears to be always true, although I am not 100% certain + * (I think it occurs this way because the chunk is + * necessarily added to the instantiaton list after the + * original instantiation and lists get built such older items + * appear further from the head of the list) . If not true, + * then we need to keep track of any GDS's that get created + * here to remove them later if we find a higher match goal + * for the WME. For now, the program just exits in this + * situation; otherwise, we would build a GDS for the wrong + * level and never elaborate it (resulting in a memory + * leak). + */ + } else { + char msg[MESSAGE_SIZE]; + print_wme(w); + print_preference(w->preference); +#ifdef NO_TOP_JUST + snprintf(msg, MESSAGE_SIZE, + "**** (NO_TOP_JUST) Wanted to create a GDS for a WME level (%d) different from the instantiation level (%d).....Big problems....exiting....(instantiation = %p, inst->match_goal_level = %d)****\n\n", + w->preference->id->id.level, w->preference->match_goal_level, + w->preference->inst, w->preference->inst->match_goal_level); + msg[MESSAGE_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ +#else + snprintf(msg, MESSAGE_SIZE, + "**** Wanted to create a GDS for a WME level (%d) different from the instantiation level (%d).....Big problems....exiting....****\n\n", + w->preference->id->id.level, w->preference->inst->match_goal_level); + msg[MESSAGE_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ +#endif + abort_with_fatal_error(msg); + } + } + + /* end if no GDS yet for goal... */ + /* Loop over all the preferences for this WME: + * If the instantiation that lead to the preference has not + * been already explored; OR + * If the instantiation is not an subgoal instantiation + * for a chunk instantiation we are already exploring + * Then + * Add the instantiation to a list of instantiations that + * will be explored in elaborate_gds(). + */ + for (pref = w->preference; pref != NIL; pref = pref->next) { +#ifdef DEBUG_GDS_HIGH + print("\n\n "); + print_preference(pref); + print(" Goal level of preference: %d\n", pref->id->id.level); +#endif + + if (pref->inst->GDS_evaluated_already == FALSE) { +#ifdef DEBUG_GDS_HIGH + print_with_symbols(" Match goal lev of instantiation %y ", pref->inst->prod->name); + print("is %d\n", pref->inst->match_goal_level); +#endif + if (pref->inst->match_goal_level > pref->id->id.level) { +#ifdef DEBUG_GDS_HIGH + print_with_symbols + (" %y is simply the instantiation that led to a chunk.\n Not adding it the current instantiations.\n", + pref->inst->prod->name); +#endif + + } else { +#ifdef DEBUG_GDS_HIGH + print_with_symbols("\n Adding %y to list of parent instantiations\n", + pref->inst->prod->name); +#endif + uniquely_add_to_head_of_dll(pref->inst); + pref->inst->GDS_evaluated_already = TRUE; + } + } /* end if GDS_evaluated_already is FALSE */ +#ifdef DEBUG_GDS_HIGH + else + print_with_symbols("\n Instantiation %y was already explored; skipping it\n", + pref->inst->prod->name); +#endif + + } /* end of forloop over preferences for this wme */ + +#ifdef DEBUG_GDS_HIGH + print("\n CALLING ELABORATE GDS....\n"); +#endif + elaborate_gds(); + + /* technically, the list should be empty at this point ??? */ + + free_parent_list(); +#ifdef DEBUG_GDS_HIGH + print(" FINISHED ELABORATING GDS.\n\n"); +#endif + } + + /* end if w->preference->o_supported == TRUE ... */ +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + /* REW: begin 11.25.96 */ + stop_timer(¤t_agent(start_gds_tv), + ¤t_agent(gds_cpu_time[current_agent(current_phase)])); + /* REW: end 11.25.96 */ +#endif +#endif +#ifndef SOAR_8_ONLY + } /* end if current_agent(OPERAND2_MODE) ... */ +#endif + +#endif /* DONT_CALC_GDS_OR_BT */ + + /* REW: end 09.15.96 */ + + add_wme_to_wm(w); + } + } + return; + } + + /* end of if impasse type == NONE */ + /* --- impasse type != NONE --- */ + if (s->wmes) { /* --- remove any existing wmes --- */ + remove_wme_list_from_wm(s->wmes); + s->wmes = NIL; + } + /* --- create and/or update impasse structure --- */ + if (s->impasse_type != NONE_IMPASSE_TYPE) { + if (s->impasse_type != impasse_type) { + remove_existing_attribute_impasse_for_slot(s); + create_new_attribute_impasse_for_slot(s, impasse_type); + } + update_impasse_items(s->impasse_id, candidates); + } else { + create_new_attribute_impasse_for_slot(s, impasse_type); + update_impasse_items(s->impasse_id, candidates); + } +} + +/* ------------------------------------------------------------------ + Decide Non Context Slots + + This routine iterates through all changed non-context slots, and + decides each one. +------------------------------------------------------------------ */ + +void decide_non_context_slots(void) +{ + dl_cons *dc; + slot *s; + + while (current_agent(changed_slots)) { + dc = current_agent(changed_slots); + current_agent(changed_slots) = current_agent(changed_slots)->next; + s = dc->item; + decide_non_context_slot(s); + s->changed = NIL; + free_with_pool(¤t_agent(dl_cons_pool), dc); + } +} + +/* ------------------------------------------------------------------ + Context Slot Is Decidable + + This returns TRUE iff the given slot (which must be a context slot) + is decidable. A context slot is decidable if: + - it has an installed value in WM and there is a reconsider + preference for that value, or + - it has no installed value but does have changed preferences +------------------------------------------------------------------ */ + +bool context_slot_is_decidable(slot * s) +{ + Symbol *v; + preference *p; + + if (!s->wmes) + return (bool) (s->changed != NIL); + v = s->wmes->value; + for (p = s->preferences[RECONSIDER_PREFERENCE_TYPE]; p != NIL; p = p->next) + if (v == p->value) + return TRUE; + return FALSE; +} + +/* ------------------------------------------------------------------ + Remove WMEs For Context Slot + + This removes the wmes (there can only be 0 or 1 of them) for the + given context slot. +------------------------------------------------------------------ */ + +void remove_wmes_for_context_slot(slot * s) +{ + wme *w; + + if (!s->wmes) + return; + /* Note that we only need to handle one wme--context slots never have + more than one wme in them */ + w = s->wmes; + preference_remove_ref(w->preference); + remove_wme_from_wm(w); + s->wmes = NIL; +} + +/* ------------------------------------------------------------------ + Remove Existing Context And Descendents + + This routine truncates the goal stack by removing the given goal + and all its subgoals. (If the given goal is the top goal, the + entire context stack is removed.) +------------------------------------------------------------------ */ + +void remove_existing_context_and_descendents(Symbol * goal) +{ + preference *p; + + ms_change *head, *tail; /* REW: 08.20.97 */ + + /* --- remove descendents of this goal --- */ +#ifdef GOAL_SANITY_CHECK + + /* printf ( "Goal id.level = %d\n", (goal->id.level) ); */ + if (goal->id.level < 0 || goal->id.level > 1000) { + print("Warning: goal id is of a bizzare value: %d\n", goal->id.level); + printf("Warning: goal id is of a bizzare value: %d\n", goal->id.level); + } +#endif + if (goal->id.lower_goal) + remove_existing_context_and_descendents(goal->id.lower_goal); + +#ifndef FEW_CALLBACKS + + /* --- invoke callback routine --- */ + soar_invoke_callbacks(soar_agent, POP_CONTEXT_STACK_CALLBACK, (soar_call_data) goal); + +#endif + /* --- disconnect this goal from the goal stack --- */ + if (goal == current_agent(top_goal)) { + current_agent(top_goal) = NIL; + current_agent(bottom_goal) = NIL; + } else { + current_agent(bottom_goal) = goal->id.higher_goal; + current_agent(bottom_goal)->id.lower_goal = NIL; + } + + /* --- remove any preferences supported by this goal --- */ + while (goal->id.preferences_from_goal) { + p = goal->id.preferences_from_goal; + remove_from_dll(goal->id.preferences_from_goal, p, all_of_goal_next, all_of_goal_prev); + p->on_goal_list = FALSE; + if (!remove_preference_from_clones(p)) + if (p->in_tm) + remove_preference_from_tm(p); + } + + /* --- remove wmes for this goal, and garbage collect --- */ + remove_wmes_for_context_slot(goal->id.operator_slot); + update_impasse_items(goal, NIL); /* causes items & fake pref's to go away */ + remove_wme_list_from_wm(goal->id.impasse_wmes); + goal->id.impasse_wmes = NIL; + /* REW: begin 09.15.96 */ + /* If there was a GDS for this goal, we want to set the pointer for the + goal to NIL to indicate it no longer exists. + BUG: We probably also need to make certain that the GDS doesn't need + to be free'd here as well. */ + if (goal->id.gds != NIL) + goal->id.gds->goal = NIL; + /* REW: end 09.15.96 */ + + /* REW: begin 08.20.97 */ + + /* If we remove a goal WME, then we have to transfer any already existing + retractions to the nil-goal list on the current agent. We should be + able to do this more efficiently but the most obvious way (below) still + requires scanning over the whole list (to set the goal pointer of each + msc to NIL); therefore this solution should be acceptably efficient. */ + + if (goal->id.ms_retractions) { /* There's something on the retraction list */ + + head = goal->id.ms_retractions; + tail = head; + + /* find the tail of this list */ + while (tail->next_in_level) { + tail->goal = NIL; /* force the goal to be NIL */ + tail = tail->next_in_level; + } + tail->goal = NIL; + + if (current_agent(nil_goal_retractions)) { + /* There are already retractions on the list */ + + /* Append this list to front of NIL goal list */ + current_agent(nil_goal_retractions)->prev_in_level = tail; + tail->next_in_level = current_agent(nil_goal_retractions); + current_agent(nil_goal_retractions) = head; + + } else { /* If no retractions, make this list the NIL goal list */ + current_agent(nil_goal_retractions) = head; + } + } + + /* REW: BUG + * Tentative assertions can exist for removed goals. However, it looks + * like the removal forces a tentative retraction, which then leads to + * the deletion of the tentative assertion. However, I have not tested + * such cases exhaustively -- I would guess that some processing may be + * necessary for the assertions here at some point? + */ + + /* REW: end 08.20.97 */ + + post_link_removal(NIL, goal); /* remove the special link */ + symbol_remove_ref(goal); +} + +/* ------------------------------------------------------------------ + Create New Context + + This routine creates a new goal context (becoming the new bottom + goal) below the current bottom goal. If there is no current + bottom goal, this routine creates a new goal and makes it both + the top and bottom goal. +------------------------------------------------------------------ */ + +void create_new_context(Symbol * attr_of_impasse, byte impasse_type) +{ + Symbol *id; + + if (current_agent(bottom_goal)) { + id = create_new_impasse(TRUE, current_agent(bottom_goal), attr_of_impasse, impasse_type, (goal_stack_level) + (current_agent(bottom_goal)->id.level + 1)); + id->id.higher_goal = current_agent(bottom_goal); + current_agent(bottom_goal)->id.lower_goal = id; + current_agent(bottom_goal) = id; + add_impasse_wme(id, current_agent(quiescence_symbol), current_agent(t_symbol), NIL); + } else { + id = create_new_impasse(TRUE, current_agent(nil_symbol), NIL, NONE_IMPASSE_TYPE, TOP_GOAL_LEVEL); + current_agent(top_goal) = id; + current_agent(bottom_goal) = id; + current_agent(top_state) = current_agent(top_goal); + id->id.higher_goal = NIL; + id->id.lower_goal = NIL; + } + id->id.isa_goal = TRUE; + id->id.operator_slot = make_slot(id, current_agent(operator_symbol)); + id->id.allow_bottom_up_chunks = TRUE; + +#ifndef FEW_CALLBACKS + + /* --- invoke callback routine --- */ + soar_invoke_callbacks(soar_agent, CREATE_NEW_CONTEXT_CALLBACK, (soar_call_data) id); + +#endif +} + +/* ------------------------------------------------------------------ + Type and Attribute of Existing Impasse + + Given a goal, these routines return the type and attribute, + respectively, of the impasse just below that goal context. It + does so by looking at the impasse wmes for the next lower goal + in the goal stack. +------------------------------------------------------------------ */ + +byte type_of_existing_impasse(Symbol * goal) +{ + wme *w; + char msg[MESSAGE_SIZE]; + + if (!goal->id.lower_goal) + return NONE_IMPASSE_TYPE; + for (w = goal->id.lower_goal->id.impasse_wmes; w != NIL; w = w->next) + if (w->attr == current_agent(impasse_symbol)) { + if (w->value == current_agent(no_change_symbol)) + return NO_CHANGE_IMPASSE_TYPE; + if (w->value == current_agent(tie_symbol)) + return TIE_IMPASSE_TYPE; + if (w->value == current_agent(constraint_failure_symbol)) + return CONSTRAINT_FAILURE_IMPASSE_TYPE; + if (w->value == current_agent(conflict_symbol)) + return CONFLICT_IMPASSE_TYPE; + if (w->value == current_agent(none_symbol)) + return NONE_IMPASSE_TYPE; + strncpy(msg, "decide.c: Internal error: bad type of existing impasse.\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + strncpy(msg, "decide.c: Internal error: couldn't find type of existing impasse.\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + return 0; /* unreachable, but without it, gcc -Wall warns here */ +} + +Symbol *attribute_of_existing_impasse(Symbol * goal) +{ + wme *w; + + if (!goal->id.lower_goal) + return NIL; + for (w = goal->id.lower_goal->id.impasse_wmes; w != NIL; w = w->next) + if (w->attr == current_agent(attribute_symbol)) + return w->value; + { + char msg[MESSAGE_SIZE]; + strncpy(msg, "decide.c: Internal error: couldn't find attribute of existing impasse.\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + return NIL; /* unreachable, but without it, gcc -Wall warns here */ +} + +/* ------------------------------------------------------------------ + Decide Context Slot + + This decides the given context slot. It normally returns TRUE, + but returns FALSE if the ONLY change as a result of the decision + procedure was a change in the set of ^item's on the impasse below + the given slot. +------------------------------------------------------------------ */ + +bool decide_context_slot(Symbol * goal, slot * s) +{ + byte impasse_type; + Symbol *attribute_of_impasse; + wme *w; + preference *candidates; + preference *temp; + + if (!context_slot_is_decidable(s)) { + /* --- the only time we decide a slot that's not "decidable" is when it's + the last slot in the entire context stack, in which case we have a + no-change impasse there --- */ + impasse_type = NO_CHANGE_IMPASSE_TYPE; + candidates = NIL; /* we don't want any impasse ^item's later */ + } else { + /* --- the slot is decidable, so run preference semantics on it --- */ + impasse_type = run_preference_semantics(s, &candidates); + remove_wmes_for_context_slot(s); /* must remove old wme before adding + the new one (if any) */ + if (impasse_type == NONE_IMPASSE_TYPE) { + if (!candidates) { + /* --- no winner ==> no-change impasse on the previous slot --- */ + impasse_type = NO_CHANGE_IMPASSE_TYPE; + } else if (candidates->next_candidate) { + /* --- more than one winner ==> internal error --- */ + char msg[MESSAGE_SIZE]; + strncpy(msg, "decide.c: Internal error: more than one winner for context slot\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + } + } /* end if !context_slot_is_decidable */ + + /* --- mark the slot as not changed --- */ + s->changed = NIL; + + /* --- determine the attribute of the impasse (if there is no impasse, + * this doesn't matter) --- */ + if (impasse_type == NO_CHANGE_IMPASSE_TYPE) { + if (s->wmes) { + attribute_of_impasse = s->attr; + } else { + attribute_of_impasse = current_agent(state_symbol); + } + } else { + /* --- for all other kinds of impasses --- */ + attribute_of_impasse = s->attr; + } + + /* --- remove wme's for lower slots of this context --- */ + if (attribute_of_impasse == current_agent(state_symbol)) { + remove_wmes_for_context_slot(goal->id.operator_slot); + } + + /* --- if we have a winner, remove any existing impasse and install the + new value for the current slot --- */ + if (impasse_type == NONE_IMPASSE_TYPE) { + for (temp = candidates; temp; temp = temp->next_candidate) + preference_add_ref(temp); + if (goal->id.lower_goal) + remove_existing_context_and_descendents(goal->id.lower_goal); + w = make_wme(s->id, s->attr, candidates->value, FALSE); + insert_at_head_of_dll(s->wmes, w, next, prev); + w->preference = candidates; + preference_add_ref(w->preference); + add_wme_to_wm(w); + for (temp = candidates; temp; temp = temp->next_candidate) + preference_remove_ref(temp); + return TRUE; + } + + /* --- no winner; if an impasse of the right type already existed, just + update the ^item set on it --- */ + if ((impasse_type == type_of_existing_impasse(goal)) && + (attribute_of_impasse == attribute_of_existing_impasse(goal))) { + update_impasse_items(goal->id.lower_goal, candidates); + return FALSE; + } + + /* --- no impasse already existed, or an impasse of the wrong type + already existed --- */ + for (temp = candidates; temp; temp = temp->next_candidate) + preference_add_ref(temp); + if (goal->id.lower_goal) + remove_existing_context_and_descendents(goal->id.lower_goal); + + /* REW: begin 10.24.97 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) && current_agent(waitsnc) && + (impasse_type == NO_CHANGE_IMPASSE_TYPE) && (attribute_of_impasse == current_agent(state_symbol))) { +#else + if (current_agent(waitsnc) && + (impasse_type == NO_CHANGE_IMPASSE_TYPE) && (attribute_of_impasse == current_agent(state_symbol))) { +#endif + current_agent(waitsnc_detect) = TRUE; + if (soar_exists_callback(soar_agent, WAIT_CALLBACK)) { + soar_invoke_first_callback(soar_agent, WAIT_CALLBACK, NULL); + } + + } else { + /* REW: end 10.24.97 */ + create_new_context(attribute_of_impasse, impasse_type); + update_impasse_items(goal->id.lower_goal, candidates); + } + + for (temp = candidates; temp; temp = temp->next_candidate) + preference_remove_ref(temp); + return TRUE; +} + +/* ------------------------------------------------------------------ + Decide Context Slots + + This scans down the goal stack and runs the decision procedure on + the appropriate context slots. +------------------------------------------------------------------ */ + +void decide_context_slots(void) +{ + Symbol *goal; + slot *s; + + if (current_agent(highest_goal_whose_context_changed)) { + goal = current_agent(highest_goal_whose_context_changed); + } else + /* no context changed, so jump right to the bottom */ + goal = current_agent(bottom_goal); + + s = goal->id.operator_slot; + + /* --- loop down context stack --- */ + for (;;) { + /* --- find next slot to decide --- */ + for (;;) { + if (context_slot_is_decidable(s)) + break; + + if ((s == goal->id.operator_slot) || (!s->wmes)) { + /* --- no more slots to look at for this goal; have we reached + the last slot in whole stack? --- */ + if (!goal->id.lower_goal) + break; + /* --- no, go down one level --- */ + goal = goal->id.lower_goal; + s = goal->id.operator_slot; + } + } /* end of while (TRUE) find next slot to decide */ + + /* --- now go and decide that slot --- */ + if (decide_context_slot(goal, s)) + break; + + } /* end of while (TRUE) loop down context stack */ + current_agent(highest_goal_whose_context_changed) = NIL; +} + +/* ********************************************************************** + + Top-Level Decider Routines + + Init_decider() should be called at startup time to initialize this + module. + + Do_buffered_wm_and_ownership_changes() does the end-of-phase processing + of WM changes, ownership calculations, garbage collection, etc. + + Do_working_memory_phase() and do_decision_phase() are called from + the top level to run those phases. + + Create_top_goal() creates the top goal in the goal stack. + Clear_goal_stack() wipes out the whole goal stack--this is called + during an init-soar. + + Print_lowest_slot_in_context_stack() is used for the watch 0 trace + to print the context slot that was just decided. +********************************************************************** */ + +void init_decider(void) +{ + init_memory_pool(¤t_agent(slot_pool), sizeof(slot), "slot"); + init_memory_pool(¤t_agent(wme_pool), sizeof(wme), "wme"); + init_memory_pool(¤t_agent(preference_pool), sizeof(preference), "preference"); +} + +void do_buffered_wm_and_ownership_changes(void) +{ + do_buffered_acceptable_preference_wme_changes(); + do_buffered_link_changes(); + do_buffered_wm_changes(); + remove_garbage_slots(); +} + +void do_working_memory_phase(void) +{ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) { +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + switch (current_agent(FIRING_TYPE)) { + case PE_PRODS: + print("\t--- Change Working Memory (PE) ---\n"); + break; + case IE_PRODS: + print("\t--- Change Working Memory (IE) ---\n"); + break; + } +#ifndef SOAR_8_ONLY + } + + else + print("\n--- Working Memory Phase ---\n"); +#endif + } +#endif + + decide_non_context_slots(); + do_buffered_wm_and_ownership_changes(); +} + +void do_decision_phase(void) +{ +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) + print("\n--- Decision Phase ---\n"); + +#endif + + decide_context_slots(); + do_buffered_wm_and_ownership_changes(); + /* + * Bob provided a solution to fix WME's hanging around unsupported + * for an elaboration cycle. + */ + decide_non_context_slots(); + do_buffered_wm_and_ownership_changes(); +} + +void create_top_goal(void) +{ + create_new_context(NIL, NONE_IMPASSE_TYPE); + current_agent(highest_goal_whose_context_changed) = NIL; /* nothing changed yet */ + do_buffered_wm_and_ownership_changes(); +} + +void clear_goal_stack(void) +{ + if (!current_agent(top_goal)) + return; + remove_existing_context_and_descendents(current_agent(top_goal)); + current_agent(highest_goal_whose_context_changed) = NIL; /* nothing changed yet */ + do_buffered_wm_and_ownership_changes(); + current_agent(top_state) = NIL; + do_input_cycle(); /* tell input functions that the top state is gone */ + do_output_cycle(); /* tell output functions that output commands are gone */ +} + +void print_lowest_slot_in_context_stack(void) +{ + + /* REW: begin 10.24.97 */ + /* This doesn't work yet so for now just print the last selection */ + if (current_agent(operand2_mode) && current_agent(waitsnc) && current_agent(waitsnc_detect)) { + + current_agent(waitsnc_detect) = FALSE; + print_stack_trace(current_agent(wait_symbol), current_agent(bottom_goal), FOR_ANYTHING_TF, TRUE); + } else { + + /* REW: end 10.24.97 */ + + if (current_agent(bottom_goal)->id.operator_slot->wmes) + print_stack_trace(current_agent(bottom_goal)->id.operator_slot->wmes->value, + current_agent(bottom_goal), FOR_OPERATORS_TF, TRUE); + + /* RCHONG: begin 10.11 */ + /* + this coded is needed just so that when an ONC is created in OPERAND + (i.e. if the previous goal's operator slot is not empty), it's stack + trace line doesn't get a number. this is done because in OPERAND, + ONCs are detected for "free". + */ + + else { + + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == FALSE) + print_stack_trace(current_agent(bottom_goal), current_agent(bottom_goal), FOR_STATES_TF, TRUE); + /* REW: end 09.15.96 */ + + else { +#endif + if (current_agent(d_cycle_count) == 0) + print_stack_trace(current_agent(bottom_goal), current_agent(bottom_goal), FOR_STATES_TF, TRUE); + else { + if (current_agent(bottom_goal)->id.higher_goal && + current_agent(bottom_goal)->id.higher_goal->id.operator_slot->wmes) { + print_stack_trace(current_agent(bottom_goal), current_agent(bottom_goal), FOR_STATES_TF, FALSE); + } else { + print_stack_trace(current_agent(bottom_goal), current_agent(bottom_goal), FOR_STATES_TF, TRUE); + } + } +#ifndef SOAR_8_ONLY + } +#endif + } + } + /* RCHONG: end 10.11 */ + +} + +/* REW: begin 09.15.96 */ + +void uniquely_add_to_head_of_dll(instantiation * inst) +{ + + parent_inst *new_pi, *curr_pi; + + /* print("UNIQUE DLL: scanning parent list...\n"); */ + + for (curr_pi = current_agent(parent_list_head); curr_pi; curr_pi = curr_pi->next) { + if (curr_pi->inst == inst) { +#ifdef DEBUG_GDS + print_with_symbols("UNIQUE DLL: %y is already in parent list\n", curr_pi->inst->prod->name); +#endif + return; + } +#ifdef DEBUG_GDS + print_with_symbols("UNIQUE DLL: %y\n", curr_pi->inst->prod->name); +#endif + } /* end for loop */ + + new_pi = (parent_inst *) malloc(sizeof(parent_inst)); + new_pi->next = NIL; + new_pi->prev = NIL; + new_pi->inst = inst; + + new_pi->next = current_agent(parent_list_head); + + if (current_agent(parent_list_head) != NIL) + current_agent(parent_list_head)->prev = new_pi; + + current_agent(parent_list_head) = new_pi; +#ifdef DEBUG_GDS + print_with_symbols("UNIQUE DLL: added: %y\n", inst->prod->name); +#endif +} + +void elaborate_gds () { + +wme *wme_matching_this_cond; +goal_stack_level wme_goal_level; +preference *pref_for_this_wme, *pref; +condition *cond; +parent_inst *curr_pi, *temp_pi; +slot *s; +instantiation *inst; + + for (curr_pi=current_agent(parent_list_head); curr_pi; curr_pi=temp_pi) { + + inst = curr_pi->inst; + + #ifdef DEBUG_GDS + print_with_symbols("\n EXPLORING INSTANTIATION: %y\n",curr_pi->inst->prod->name); + print(" "); + print_instantiation_with_wmes( curr_pi->inst , TIMETAG_WME_TRACE); + #endif + + for (cond=inst->top_of_instantiated_conditions; + cond!=NIL; + cond=cond->next) { + + if (cond->type != POSITIVE_CONDITION) continue; + /* We'll deal with negative instantiations after we get the + * positive ones figured out */ + + wme_matching_this_cond = cond->bt.wme; + wme_goal_level = cond->bt.level; + pref_for_this_wme = wme_matching_this_cond->preference; + + #ifdef DEBUG_GDS + print("\n wme_matching_this_cond at goal_level = %d : ", + wme_goal_level); + print_wme(wme_matching_this_cond); + + if (pref_for_this_wme) { + print(" pref_for_this_wme : "); + print_preference(pref_for_this_wme); + } + #endif + + + /* WME is in a supergoal or is arch-supported WME + * (except for fake instantiations, which do have prefs, so + * they get handled under "wme is local and i-supported") + */ + if ((pref_for_this_wme == NIL) || + (wme_goal_level < inst->match_goal_level)) { + + #ifdef DEBUG_GDS + if (pref_for_this_wme == NIL) { + print(" this wme has no preferences (it's an arch-created wme)\n"); + } + else if (wme_goal_level < inst->match_goal_level) { + print(" this wme is in the supergoal\n"); + } + print_with_symbols("inst->match_goal [%y]\n" , inst->match_goal); + #endif + + if (wme_matching_this_cond->gds != NIL){ + /* Then we want to check and see if the old GDS value + * should be changed */ + if (wme_matching_this_cond->gds->goal == NIL) { + /* The goal is NIL: meaning that the goal for the GDS + * is no longer around */ + fast_remove_from_dll(wme_matching_this_cond->gds->wmes_in_gds, \ + wme_matching_this_cond, wme, + gds_next, gds_prev); + + /* We have to check for GDS removal anytime we take a + * WME off the GDS wme list, not just when a WME is + * removed from memory. */ + if (!wme_matching_this_cond->gds->wmes_in_gds) { + free_memory(wme_matching_this_cond->gds, + MISCELLANEOUS_MEM_USAGE); + #ifdef DEBUG_GDS + print("\n REMOVING GDS FROM MEMORY."); + #endif + } + wme_matching_this_cond->gds = inst->match_goal->id.gds; + insert_at_head_of_dll(wme_matching_this_cond->gds->wmes_in_gds, + wme_matching_this_cond, gds_next, + gds_prev); + #ifdef DEBUG_GDS + print("\n .....GDS' goal is NIL so switching from old to new GDS list....\n"); + #endif + + } else if (wme_matching_this_cond->gds->goal->id.level > + inst->match_goal_level) { + /* if the WME currently belongs to the GDS of a goal below + * the current one */ + /* 1. Take WME off old (current) GDS list + * 2. Check to see if old GDS WME list is empty. If so, + * remove(free) it. + * 3. Add WME to new GDS list + * 4. Update WME pointer to new GDS list + */ + if (inst->match_goal_level == 1) + print("\n\n\n HELLO! HELLO! The inst->match_goal_level is 1"); + + fast_remove_from_dll(wme_matching_this_cond->gds->wmes_in_gds, \ + wme_matching_this_cond, wme, + gds_next, gds_prev); + if (!wme_matching_this_cond->gds->wmes_in_gds) { + free_memory(wme_matching_this_cond->gds, + MISCELLANEOUS_MEM_USAGE); + #ifdef DEBUG_GDS + print("\n REMOVING GDS FROM MEMORY."); + #endif + } + wme_matching_this_cond->gds = inst->match_goal->id.gds; + insert_at_head_of_dll(wme_matching_this_cond->gds->wmes_in_gds, + wme_matching_this_cond, gds_next, + gds_prev); + #ifdef DEBUG_GDS + print("\n ....switching from old to new GDS list....\n"); + #endif + wme_matching_this_cond->gds = inst->match_goal->id.gds; + } + } else { + /* We know that the WME should be in the GDS of the current + * goal if the WME's GDS does not already exist. + * (i.e., if NIL GDS) */ + wme_matching_this_cond->gds = inst->match_goal->id.gds; + + insert_at_head_of_dll(wme_matching_this_cond->gds->wmes_in_gds, + wme_matching_this_cond, gds_next, gds_prev); + if (wme_matching_this_cond->gds->wmes_in_gds->gds_prev) + print("\nDEBUG DEBUG : The new header should never have a prev value.\n"); + #ifdef DEBUG_GDS + print_with_symbols("\n ......WME did not have defined GDS. Now adding to goal [%y].\n", wme_matching_this_cond->gds->goal); + #endif + } /* end else clause for "if wme_matching_this_cond->gds != NIL" */ + + + #ifdef DEBUG_GDS + print(" Added WME to GDS for goal = %d", + wme_matching_this_cond->gds->goal->id.level); + print_with_symbols(" [%y]\n", wme_matching_this_cond->gds->goal); + #endif + } /* end "wme in supergoal or arch-supported" */ + + else { + /* wme must be local */ + + /* if wme's pref is o-supported, then just ignore it and + * move to next condition */ + if (pref_for_this_wme->o_supported == TRUE) { + #ifdef DEBUG_GDS + print(" this wme is local and o-supported\n"); + #endif + continue; + } + + else { + /* wme's pref is i-supported, so remember it's instantiation + * for later examination */ + + /* this test avoids "backtracing" through the top state */ + if (inst->match_goal_level == 1) { + #ifdef DEBUG_GDS + print(" don't back up through top state\n"); + if (inst->prod) + if (inst->prod->name) + print_with_symbols(" don't back up through top state for instantiation %y\n", inst->prod->name); + #endif + continue; + } + + else { /* (inst->match_goal_level != 1) */ + #ifdef DEBUG_GDS + print(" this wme is local and i-supported\n"); + print_with_symbols(" ID: %y ATTR: %y \n", pref_for_this_wme->id, pref_for_this_wme->attr); + #endif + s = find_slot (pref_for_this_wme->id, pref_for_this_wme->attr); + if (s == NIL) { + /* this must be an arch-wme from a fake instantiation */ + + #ifdef DEBUG_GDS + print("here's the wme with no slot:\t"); + print_wme(pref_for_this_wme->inst->top_of_instantiated_conditions->bt.wme); + #endif + + /* this is the same code as above, just using the + * differently-named pointer. it probably should + * be a subroutine */ + { + wme *fake_inst_wme_cond; + + fake_inst_wme_cond = + pref_for_this_wme->inst->top_of_instantiated_conditions->bt.wme; + if (fake_inst_wme_cond->gds != NIL){ + /* Then we want to check and see if the old GDS + * value should be changed */ + if (fake_inst_wme_cond->gds->goal == NIL) { + /* The goal is NIL: meaning that the goal for + * the GDS is no longer around */ + + fast_remove_from_dll(fake_inst_wme_cond->gds->wmes_in_gds, + fake_inst_wme_cond, wme, + gds_next, gds_prev); + + /* We have to check for GDS removal anytime we take + * a WME off the GDS wme list, not just when a WME + *is removed from memory. */ + if (!fake_inst_wme_cond->gds->wmes_in_gds) { + free_memory(fake_inst_wme_cond->gds, + MISCELLANEOUS_MEM_USAGE); + #ifdef DEBUG_GDS + print("\n REMOVING GDS FROM MEMORY."); + #endif + } + + fake_inst_wme_cond->gds = inst->match_goal->id.gds; + insert_at_head_of_dll(fake_inst_wme_cond->gds->wmes_in_gds, + fake_inst_wme_cond, gds_next, gds_prev); + #ifdef DEBUG_GDS + print("\n .....GDS' goal is NIL so switching from old to new GDS list....\n"); + #endif + } else if (fake_inst_wme_cond->gds->goal->id.level > + inst->match_goal_level) { + /* if the WME currently belongs to the GDS of a + *goal below the current one */ + /* 1. Take WME off old (current) GDS list + * 2. Check to see if old GDS WME list is empty. + * If so, remove(free) it. + * 3. Add WME to new GDS list + * 4. Update WME pointer to new GDS list + */ + if (inst->match_goal_level == 1) + print("\n\n\n\n\n HELLO! HELLO! The inst->match_goal_level is 1"); + + fast_remove_from_dll(fake_inst_wme_cond->gds->wmes_in_gds, \ + fake_inst_wme_cond, wme, + gds_next, gds_prev); + if (!fake_inst_wme_cond->gds->wmes_in_gds) { + free_memory(fake_inst_wme_cond->gds, + MISCELLANEOUS_MEM_USAGE); + #ifdef DEBUG_GDS + print("\n REMOVING GDS FROM MEMORY."); + #endif + } + + fake_inst_wme_cond->gds = inst->match_goal->id.gds; + insert_at_head_of_dll(fake_inst_wme_cond->gds->wmes_in_gds, \ + fake_inst_wme_cond, gds_next, + gds_prev); + #ifdef DEBUG_GDS + print("\n .....switching from old to new GDS list....\n"); + #endif + fake_inst_wme_cond->gds = inst->match_goal->id.gds; + } + } else { + /* We know that the WME should be in the GDS of + * the current goal if the WME's GDS does not + * already exist. (i.e., if NIL GDS) */ + fake_inst_wme_cond->gds = inst->match_goal->id.gds; + + insert_at_head_of_dll(fake_inst_wme_cond->gds->wmes_in_gds, + fake_inst_wme_cond, + gds_next, gds_prev); + if (fake_inst_wme_cond->gds->wmes_in_gds->gds_prev) + print("\nDEBUG DEBUG : The new header should never have a prev value.\n"); + #ifdef DEBUG_GDS + print_with_symbols("\n ......WME did not have defined GDS. Now adding to goal [%y].\n", fake_inst_wme_cond->gds->goal); + #endif + } + #ifdef DEBUG_GDS + print(" Added WME to GDS for goal = %d", fake_inst_wme_cond->gds->goal->id.level); + print_with_symbols(" [%y]\n", + fake_inst_wme_cond->gds->goal); + #endif + } /* matches { wme *fake_inst_wme_cond */ + } else { + /* this was the original "local & i-supported" action */ + + for (pref=s->preferences[ACCEPTABLE_PREFERENCE_TYPE]; + pref; + pref=pref->next) { + + #ifdef DEBUG_GDS + print(" looking at pref for the wme: "); + print_preference(pref); + + print_wme(wme_matching_this_cond); + print_with_symbols (" pref->value %y wme->value %y \n", pref->value, wme_matching_this_cond->value); + #endif + + /* REW: 2004-05-27: Bug fix + We must check that the value with acceptable pref for the slot + is the same as the value for the wme in the condition, since + operators can have acceptable preferences for values other than + the WME value. We dont want to backtrack thru acceptable prefs + for other operators */ + + if (pref->value == wme_matching_this_cond->value) { + + /* REW BUG: may have to go over all insts regardless + of this visited_already flag... */ + + if (pref->inst->GDS_evaluated_already == FALSE) { + + #ifdef DEBUG_GDS + print_with_symbols("\n adding inst that produced the pref to GDS: %y\n",pref->inst->prod->name); + #endif + + /* REW: 2003-12-07 */ + /* If the preference comes from a lower level, then ignore it. */ + /* Preferences from lower levels must come from result instantiations, + we just want to use the justification/chunk instantiations */ + if (pref->inst->match_goal_level <= inst->match_goal_level) { + uniquely_add_to_head_of_dll(pref->inst); + pref->inst->GDS_evaluated_already = TRUE; + } else { + #ifdef DEBUG_GDS + print_with_symbols("\n ignoring inst %y because it is at a lower level than the GDS\n",pref->inst->prod->name); + #endif + + /* Dont set the flag to TRUE in case there is a local result as well */ + /* pref->inst->GDS_evaluated_already = TRUE; */ + } + + + } else { + #ifdef DEBUG_GDS + print(" the inst producing this pref was already explored; skipping it\n"); + #endif + } + } else { /* pref->value != wme->value REW: 2004-05-27 */ + #ifdef DEBUG_GDS + print(" this inst is for a pref with a different value than the condition WME; skipping it\n"); + #endif + } /* pref->value != wme->value REW: 2004-05-27 */ + } /* for pref = s->pref[ACCEPTABLE_PREF ...*/ + } + } + } + } + + } /* for (cond = inst->top_of_instantiated_cond ... *;'/ + + + /* remove just used instantiation from list */ + + #ifdef DEBUG_GDS + print_with_symbols("\n removing instantiation: %y\n", + curr_pi->inst->prod->name); + #endif + + if (curr_pi->next != NIL) curr_pi->next->prev = curr_pi->prev; + if (curr_pi->prev != NIL) curr_pi->prev->next = curr_pi->next; + + if (current_agent(parent_list_head) == curr_pi) + current_agent(parent_list_head) = curr_pi->next; + + temp_pi = curr_pi->next; + free(curr_pi); + + } /* end of "for (curr_pi = current_agent(parent_list_head) ... */ + + + if (current_agent(parent_list_head) != NIL) { + #ifdef DEBUG_GDS + print("\n RECURSING using these parents:\n"); + for (curr_pi = current_agent(parent_list_head); + curr_pi; + curr_pi = curr_pi->next) { + print_with_symbols(" %y\n",curr_pi->inst->prod->name); + } + #endif + + /* recursively explore the parents of all the instantiations */ + + elaborate_gds(); + + /* free the parent instantiation list. technically, the list + * should be empty at this point ??? */ + free_parent_list(); + } + +} /* end of elaborate_gds */ + + + + +/* REW BUG: this needs to be smarter to deal with wmes that get support from +multiple instantiations. for example ^enemy-out-there could be made by 50 +instantiations. if one of those instantiations goes, should the goal be +killed???? This routine says "yes" -- anytime a dependent item gets changed, +we're gonna yank out the goal -- even when that i-supported element itself +may not be removed (due to multiple preferences). So, we'll say that this is +a "twitchy" version of OPERAND2, and leave open the possibility that other +approaches may be better */ + +void gds_invalid_so_remove_goal(wme * w) +{ +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + /* REW: begin 11.25.96 */ + start_timer(¤t_agent(start_gds_tv)); + /* REW: end 11.25.96 */ +#endif +#endif + + if (current_agent(soar_verbose_flag)) + soar_ecGDSPrint(); + + /* REW: BUG. I have no idea right now if this is a terrible hack or + * actually what we want to do. The idea here is that the context of + * the immediately higher goal above a retraction should be marked as + * having its context changed in order that the architecture doesn't + * look below this level for context changes. I think it's a hack b/c + * it seems like there should aready be mechanisms for doing this in + * the architecture but I couldn't find any. + */ + /* Note: the inner 'if' is correct -- we only want to change + * highest_goal_whose_context_changed if the pointer is currently at + * or below (greater than) the goal which we are going to retract. + * However, I'm not so sure about the outer 'else.' If we don't set + * this to the goal above the retraction, even if the current value + * is NIL, we still seg fault in certain cases. But setting it as we do + * in the inner 'if' seems to clear up the difficulty. + */ + + if (current_agent(highest_goal_whose_context_changed)) { + if (current_agent(highest_goal_whose_context_changed)->id.level >= w->gds->goal->id.level) { + current_agent(highest_goal_whose_context_changed) = w->gds->goal->id.higher_goal; + } + } else { + /* If nothing has yet changed (highest_ ... = NIL) then set + * the goal automatically */ + current_agent(highest_goal_whose_context_changed) = w->gds->goal->id.higher_goal; + } + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + if (current_agent(sysparams)[TRACE_OPERAND2_REMOVALS_SYSPARAM]) { + print_with_symbols("\n REMOVING GOAL [%y] due to change in GDS WME ", w->gds->goal); + print_wme(w); + } +#endif + + remove_existing_context_and_descendents(w->gds->goal); + /* BUG: Need to reset highest_goal here ??? */ + + /* usually, we'd call do_buffered_wm_and_ownership_changes() here, but + * we don't need to because it will be done at the end of the working + * memory phase; cf. the end of do_working_memory_phase(). + */ + +#ifndef NO_TIMING_STUFF +#ifdef DETAILED_TIMING_STATS + /* REW: begin 11.25.96 */ + stop_timer(¤t_agent(start_gds_tv), ¤t_agent(gds_cpu_time[current_agent(current_phase)])); + /* REW: end 11.25.96 */ +#endif +#endif +} + +void free_parent_list() +{ + parent_inst *curr_pi; + + for (curr_pi = current_agent(parent_list_head); curr_pi; curr_pi = curr_pi->next) + free(curr_pi); + + current_agent(parent_list_head) = NIL; +} + +void create_gds_for_goal(Symbol * goal) +{ + goal_dependency_set *gds; + + gds = allocate_memory(sizeof(goal_dependency_set), MISCELLANEOUS_MEM_USAGE); + gds->goal = goal; + gds->wmes_in_gds = NIL; + goal->id.gds = gds; +#ifdef DEBUG_GDS + print_with_symbols("\nCreated GDS for goal [%y].\n", gds->goal); +#endif +} + +#ifdef NUMERIC_INDIFFERENCE + +/* REW: 2003-01-06 */ +/* This a helper function that sets the decider flag to candidate for + all the items on the candidate list and initializes the counters + that will track the total probability distributions to zero. + + It's okay to muck with the + decider flags here because this will be called after the decision + has been determined to be a choice among indifferent candidates. + + Note: the slot is only needed for debugging/data verification + + Note: slot parameter removed by voigtjr to quell compiler warnings +*/ + +/* SAN: 2003-10-30 */ +/* Revised - this function also initializes candidate's value to default value for + appropriate numeric-indifferent-mode +*/ + +/*void initialize_indifferent_candidates_for_probability_selection(slot *s, preference *candidates)*/ +void initialize_indifferent_candidates_for_probability_selection(preference * candidates) +{ + preference *cand = 0; + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /* print_with_symbols("\nInitializing candidate %y",cand->value); + */ + cand->value->common.decider_flag = CANDIDATE_DECIDER_FLAG; + cand->total_preferences_for_candidate = 0; + cand->sum_of_probability = 0; + + } +} + +/*unsigned int count_candidates(slot *s, preference *candidates)*/ +unsigned int count_candidates(preference * candidates) +{ + unsigned int numCandidates = 0; + preference *cand = 0; + + /* + Count up the number of candidates + REW: 2003-01-06 + I'm assuming that all of the candidates have unary or + unary+value (binary) indifferent preferences at this point. + So we loop over the candidates list and count the number of + elements in the list. + */ + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) + numCandidates++; + + return numCandidates; +} + +/* Below is the Temperature, used to keep summed indifferent + preferences within a reasonable range, since they will be used as + an exponent to the number 10, and must be stored in a 64 bit double +*/ +#define TEMPERATURE 25.0 + +preference *probabilistically_select(slot * s, preference * candidates) +{ + preference *cand = 0; + preference *pref = 0; + double total_probability = 0; + unsigned int numCandidates = 0; + double selectedProbability = 0; + double currentSumOfValues = 0; + static int initialized_rand = 0; + unsigned long rn = 0; + double default_ni; + + /* initialized, but not referenced, so i commented them out: + preference* selectedCandidate=0; + unsigned int currentCandidate=0; */ + + assert(s != 0); + assert(candidates != 0); + + if (!initialized_rand) { + srand((unsigned) time(NULL)); + initialized_rand = 1; + } + /* + print("\nCandidates at top of probabilistically_select"); + print_candidates(candidates); + */ + + /* s param uneccesary, commented out to quell compiler warning. see comment + block above the following function definitions + initialize_indifferent_candidates_for_probability_selection(s, candidates); + numCandidates = count_candidates(s,candidates); */ + + initialize_indifferent_candidates_for_probability_selection(candidates); + numCandidates = count_candidates(candidates); + + /* + print("\n numCandidates = %d", numCandidates); + print("\nCandidates before unary indifferent loop"); + print_candidates(candidates); + */ + + + switch (current_agent(numeric_indifferent_mode)) { + case NUMERIC_INDIFFERENT_MODE_AVG: + default_ni = 50; + break; + + case NUMERIC_INDIFFERENT_MODE_SUM: + default: + default_ni = 0; + break; + } + /* + BUGBUGBUG + Next some error checking here to ensure that the binary preference + is indeed really an indifferent+value preference.... + someday. + + also, precision loss (long to float conversion) here: + value = (float)pref->referent->ic.value; + */ + + for (pref = s->preferences[BINARY_INDIFFERENT_PREFERENCE_TYPE]; pref != NIL; pref = pref->next) { + /*print_with_symbols("\nPreference for %y", pref->value); */ + float value; + if (pref->referent->common.symbol_type == FLOAT_CONSTANT_SYMBOL_TYPE) { + value = pref->referent->fc.value; + } else if (pref->referent->common.symbol_type == INT_CONSTANT_SYMBOL_TYPE) { + value = (float) pref->referent->ic.value; + } else + continue; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + /*print_with_symbols("\nConsidering candidate %y", cand->value); */ + + if (cand->value == pref->value) { + cand->total_preferences_for_candidate += 1; + cand->sum_of_probability += value; + } + } + } + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + if (cand->total_preferences_for_candidate == 0) { + cand->sum_of_probability = default_ni; + cand->total_preferences_for_candidate = 1; + } + } + + if (current_agent(numeric_indifferent_mode) == NUMERIC_INDIFFERENT_MODE_SUM) { + + total_probability = 0.0; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + + if (current_agent(sysparams)[TRACE_INDIFFERENT_SYSPARAM]){ + print_with_symbols("\n Candidate %y: ", cand->value); + print("Value (Sum) = %f", exp(cand->sum_of_probability / TEMPERATURE)); + } + /* Total Probability represents the range of values, we expect + * the use of negative valued preferences, so its possible the + * sum is negative, here that means a fractional probability + */ + total_probability += exp(cand->sum_of_probability / TEMPERATURE); + /* print("\n Total (Sum) Probability = %f", total_probability ); */ + } + + /* Now select the candidate */ + + /*print("\n");*/ /* removed to fix bugzilla bug 311 */ + rn = rand(); + selectedProbability = ((double) rn / (double) RAND_MAX) * total_probability; + currentSumOfValues = 0; + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + + currentSumOfValues += exp(cand->sum_of_probability / TEMPERATURE); + + if (selectedProbability <= currentSumOfValues) { + /* + print_with_symbols("\n Returning (Sum) candidate %y", cand->value); + */ + + return cand; + } + } + + } else if (current_agent(numeric_indifferent_mode) == NUMERIC_INDIFFERENT_MODE_AVG) { + + total_probability = 0.0; + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + + if (current_agent(sysparams)[TRACE_INDIFFERENT_SYSPARAM]) { + print_with_symbols("\n Candidate %y: ", cand->value); + print("Value (Avg) = %f", fabs(cand->sum_of_probability / cand->total_preferences_for_candidate)); + } + /* Total probability represents the range of values that + * we'll map into for selection. Here we don't expect the use + * of negative values, so we'll warn when we see one. + */ + + total_probability += fabs(cand->sum_of_probability / cand->total_preferences_for_candidate); + + if (cand->sum_of_probability < 0.0) { + print_with_symbols + ("WARNING: Candidate %y has a negative value, which is unexpected with 'numeric-indifferent-mode -avg'", + cand->value); + } + /* print("\n Total (Avg) Probability = %f", total_probability ); */ + } + + /* Now select the candidate */ + + /*print("\n");*/ /* removed to fix bugzilla bug 311 */ + rn = rand(); + selectedProbability = ((double) rn / (double) RAND_MAX) * total_probability; + currentSumOfValues = 0; + + for (cand = candidates; cand != NIL; cand = cand->next_candidate) { + + currentSumOfValues += fabs(cand->sum_of_probability / cand->total_preferences_for_candidate); + + if (selectedProbability <= currentSumOfValues) { + /* + print_with_symbols("\n Returning (Avg) candidate %y", cand->value); + */ + + return cand; + } + } + + } else { + print("\nERROR: Invalid Numeric Indifferent Mode!\n"); + } + + print("\nERROR: Probability Selection failed. This should never happen.\n"); + return NIL; + +} + +#endif diff --git a/soar-8.5.2/kernel/doxygen_filter.pl b/soar-8.5.2/kernel/doxygen_filter.pl new file mode 100644 index 0000000..e46e94c --- /dev/null +++ b/soar-8.5.2/kernel/doxygen_filter.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl + + +$file = $ARGV[0]; +if ( $ARGV[0] =~ /(.*)soarBuildOptions\.h$/ ) { + $file = "$1BuildOptions"; +} + +#print stderr "FILTERING --> $ARGV[0] --> $file\n"; + +open( INP, "<$file" ); +while( ) { print "$_"; } +close( INP ); diff --git a/soar-8.5.2/kernel/explain.c b/soar-8.5.2/kernel/explain.c new file mode 100644 index 0000000..34e739f --- /dev/null +++ b/soar-8.5.2/kernel/explain.c @@ -0,0 +1,505 @@ +/************************************************************************* + * + * file: explain.c + * + * ======================================================================= + * Description : To provide a function which at the least can do : + * (explain chunk-1) + * lists conditions -- given one can list the productions + * which fired & caused it to be in the chunk. + * + * (It would only run AFTER backtracing). + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* + NOTES : + 1) Explain search just finds ANY path--should be shortest. +*/ + +#include "soarkernel.h" /* Condition type defs */ +#include "soar_ecore_api.h" +#include "explain.h" + +/* Define the "local" globals if that makes sense. + (Only accessed in this file) + The backtrace_list is built up until a call is made to create a new + entry in the chunk_list. At that time the current backtrace list is + included in that structure and a new backtrace list begun. */ + +/* static explain_chunk_str *explain_chunk_list; + static backtrace_str *explain_backtrace_list; + static char explain_chunk_name[256] = { '\0' }; + AGR 564 */ + +/* AGR 564 This bug report came complete with fixes from Frank Koss. + So, I just implemented the fixes. The files with changes in them + for this bug are explain.c, explain.h, + init_soar.c, interface.c, and soarkernel.h. AGR 564 2-May-94 */ + +/*************************************************************************** + * Function : init_explain + **************************************************************************/ + +void init_explain(void) +{ + +/* "AGR 564" applies to this whole function */ + + current_agent(explain_chunk_name[0]) = '\0'; + current_agent(explain_chunk_list) = NULL; + current_agent(explain_backtrace_list) = NULL; + /* added in this initialization, not sure why removed... KJC 7/96 */ + /* current_agent(explain_flag) = FALSE; + */ + /* should we be re-initializing here?? */ + set_sysparam(EXPLAIN_SYSPARAM, FALSE); + +/* + * add_help("explain",help_on_explain); + * add_command("explain",explain_interface_routine); + * + * explain_chunk_list = NULL; + * explain_backtrace_list = NULL; + * current_agent(explain_flag) = FALSE; + */ +} + +/*************************************************************************** + * Function : free_backtrace_list + **************************************************************************/ + +void free_backtrace_list(backtrace_str * prod) +{ + + backtrace_str *next_prod; + + while (prod != NULL) { + next_prod = prod->next_backtrace; + deallocate_condition_list(prod->trace_cond); + deallocate_condition_list(prod->grounds); + deallocate_condition_list(prod->potentials); + deallocate_condition_list(prod->locals); + deallocate_condition_list(prod->negated); + free((void *) prod); + prod = next_prod; + } +} + +/*************************************************************************** + * Function : reset_backtrace_list + **************************************************************************/ + +void reset_backtrace_list(void) +{ + + free_backtrace_list(current_agent(explain_backtrace_list)); + current_agent(explain_backtrace_list) = NULL; +/* AGR 564 In both statements, the current_agent(...) was added. 2-May-94 */ + +} + +/*************************************************************************** + * Function : copy_cond_list + **************************************************************************/ + +condition *copy_cond_list(condition * top_list) +{ + + condition *new_top, *new_bottom; + + copy_condition_list(top_list, &new_top, &new_bottom); + return (new_top); +} + +/*************************************************************************** + * Function : copy_conds_from_list + **************************************************************************/ + +condition *copy_conds_from_list(cons * top_list) +{ + + condition *top, *cond, *prev, *next; + cons *cc; + + prev = next = top = NIL; + + for (cc = top_list; cc != NIL; cc = cc->rest) { + cond = copy_condition(cc->first); + cond->prev = prev; + cond->next = NIL; + + if (prev == NIL) + top = cond; + else + prev->next = cond; + + prev = cond; + } + return (top); +} + +/*************************************************************************** + * Function : explain_add_temp_to_backtrace_list + **************************************************************************/ + +void explain_add_temp_to_backtrace_list + (backtrace_str * temp, cons * grounds, cons * pots, cons * locals, cons * negateds) { + + backtrace_str *back; + + back = (backtrace_str *) malloc(sizeof(backtrace_str)); + back->result = temp->result; + back->trace_cond = copy_condition(temp->trace_cond); + if (back->trace_cond != NULL) + back->trace_cond->next = NULL; + strncpy(back->prod_name, temp->prod_name, PROD_NAME_SIZE); + back->prod_name[PROD_NAME_SIZE - 1] = 0; + + back->grounds = copy_conds_from_list(grounds); + back->potentials = copy_conds_from_list(pots); + back->locals = copy_conds_from_list(locals); + back->negated = copy_conds_from_list(negateds); + + back->next_backtrace = current_agent(explain_backtrace_list); + current_agent(explain_backtrace_list) = back; +/* AGR 564 In last 2 statements, current_agent(...) was added. 2-May-94 */ + +} + +/*************************************************************************** +* Function : explain_add_temp_to_chunk_list +* Description : Allocate a new chunk structure and copy the information in +* the temp structure to it. Also copy in the current +* "explain_backtrace_list" and reset that list. +* We want to copy all the information in the chunk/justification +* in case it is excised or retracted later on and you still +* want an explanation. Therefore each item used is carefully +* copied, rather than just keeping a pointer. +**************************************************************************/ + +void explain_add_temp_to_chunk_list(explain_chunk_str * temp) +{ + + explain_chunk_str *chunk; + + chunk = (explain_chunk_str *) malloc(sizeof(explain_chunk_str)); + chunk->conds = temp->conds; + chunk->actions = temp->actions; + strncpy(chunk->name, temp->name, PROD_NAME_SIZE); + chunk->name[PROD_NAME_SIZE - 1] = 0; + + chunk->backtrace = current_agent(explain_backtrace_list); + current_agent(explain_backtrace_list) = NULL; +/* AGR 564 In last 2 statements, current_agent(...) was added. 2-May-94 */ + + chunk->all_grounds = copy_cond_list(temp->all_grounds); + + chunk->next_chunk = current_agent(explain_chunk_list); + current_agent(explain_chunk_list) = chunk; +/* AGR 564 In last 2 statements, current_agent(...) was added. 2-May-94 */ + +} + +/*************************************************************************** + * Function : free_explain_chunk + **************************************************************************/ + +/* Note - the calling procedure must ensure that the list which "chunk" is + a part of is correctly updated to allow for its removal. */ + +void free_explain_chunk(explain_chunk_str * chunk) +{ + + /* First free up all the traced productions */ + free_backtrace_list(chunk->backtrace); + + deallocate_condition_list(chunk->conds); + deallocate_action_list(chunk->actions); + deallocate_condition_list(chunk->all_grounds); + + /* Then free up this structure */ + free((void *) chunk); +} + +/*************************************************************************** + * Function : reset_explain + **************************************************************************/ + +void reset_explain(void) +{ + + explain_chunk_str *top, *chunk; + + top = current_agent(explain_chunk_list); +/* AGR 564 In previous statement, current_agent(...) was added. 2-May-94 */ + + while (top != NULL) { + chunk = top; + top = top->next_chunk; + free_explain_chunk(chunk); + } + + current_agent(explain_chunk_list) = NULL; +/* AGR 564 In previous statement, current_agent(...) was added. 2-May-94 */ + + reset_backtrace_list(); +} + +/*************************************************************************** + * Function : find_chunk + * Description : Find the data structure associated with an explain chunk by + * searching for its name. + **************************************************************************/ + +explain_chunk_str *find_chunk(explain_chunk_str * chunk, char *name) +{ + + while (chunk != NULL) { + if (strcmp(chunk->name, name) == 0) + return (chunk); + chunk = chunk->next_chunk; + } + + print("Could not find the chunk. Maybe explain was not on when it was created."); + /* BUGBUG *** shouldn't have user interface stuff in kernel!! */ + print("\nFor Soar 7: set save_backtraces 1 before the chunk is created.\n"); + + return (NULL); +} + +/*************************************************************************** + * Function : find_ground + * Description : Find the numbered condition in the chunk. + **************************************************************************/ + +condition *find_ground(explain_chunk_str * chunk, int number) +{ + + condition *ground, *cond; + + ground = NIL; /* unnecessary, but gcc -Wall warns without it */ + for (cond = chunk->all_grounds; cond != NIL; cond = cond->next) { + number--; + if (number == 0) + ground = cond; + } + if (number > 0) { + print("Could not find this condition.\n"); + return (NIL); + } + return (ground); +} + +/*************************************************************************** + * Function : explain_trace_chunk + **************************************************************************/ + +void explain_trace_chunk(explain_chunk_str * chunk) +{ + + backtrace_str *prod; + + print("Chunk : %s\n", chunk->name); + prod = chunk->backtrace; + while (prod != NULL) { + print("Backtrace production : %s\n", prod->prod_name); + print("Result : %d\n", prod->result); + if (prod->trace_cond != NULL) { + print("Trace condition : "); + print_condition(prod->trace_cond); + } else + print("The result preference is not stored, sorry.\n"); + print_string("\nGrounds:\n"); + print_list_of_conditions(prod->grounds); + print_string("\nPotentials:\n"); + print_list_of_conditions(prod->potentials); + print_string("\nLocals:\n"); + print_list_of_conditions(prod->locals); + print_string("\nNegateds:\n"); + print_list_of_conditions(prod->negated); + prod = prod->next_backtrace; + print("\n\n"); + } +} + +/*************************************************************************** + * Function : explain_find_cond + * Description : Return the matching condition from the list, NULL if no match. + **************************************************************************/ + +condition *explain_find_cond(condition * target, condition * cond_list) +{ + + condition *cond, *match; + + match = NULL; + for (cond = cond_list; cond != NULL; cond = cond->next) { + if (conditions_are_equal(target, cond)) + match = cond; + } + return (match); +} + +/*************************************************************************** + * Function : explain_trace + * Description : Search the backtrace structures to explain why the given + * condition appeared in the chunk. + **************************************************************************/ + +void explain_trace(char *chunk_name, backtrace_str * prod_list, condition * ground) +{ + + int count; + condition *match, *target; + backtrace_str *prod; + + /* Find which prod. inst. tested the ground originally to get + it included in the chunk. + Need to check potentials too, in case they got included + later on. */ + + prod = prod_list; + match = NULL; + while (prod != NULL && match == NULL) { + match = explain_find_cond(ground, prod->potentials); + if (match == NULL) + match = explain_find_cond(ground, prod->grounds); + if (match == NULL) + match = explain_find_cond(ground, prod->negated); + if (match == NULL) + prod = prod->next_backtrace; + } + + if (match == NULL) { + print("EXPLAIN: Error, couldn't find the ground condition\n"); + return; + } + + print("Explanation of why condition "); + print_condition(ground); + print(" was included in %s\n\n", chunk_name); + + print("Production %s matched\n ", prod->prod_name); + print_condition(match); + print(" which caused\n"); + + /* Trace back the series of productions to find which one + caused the matched condition to be created. + Build in a safety limit of tracing 50 productions before cancelling. + This is in case there is a loop in the search procedure somehow or + a really long sequence of production firings. Either way you probably + don't want to see more than 50 lines of junk.... */ + + target = prod->trace_cond; + count = 0; + + while (prod->result == FALSE && count < 50 && match != NULL) { + prod = prod_list; + match = NULL; + count++; + while (prod != NULL && match == NULL) { + match = explain_find_cond(target, prod->locals); + /* Going to check all the other lists too just to be sure */ + if (match == NULL) + match = explain_find_cond(target, prod->negated); + if (match == NULL) + match = explain_find_cond(target, prod->potentials); + if (match == NULL) + match = explain_find_cond(target, prod->grounds); + if (match == NULL) + prod = prod->next_backtrace; + } + + if (match == NULL) { + print("EXPLAIN : Unable to find which production matched condition "); + print_condition(target); + print("\nTo help understand what happened here and help debug this\n"); + print("here is all of the backtracing information stored for this chunk.\n"); + print("\n"); + soar_ecExplainChunkTrace(chunk_name); + } else { + print("production %s to match\n ", prod->prod_name); + print_condition(match); + print(" which caused\n"); + target = prod->trace_cond; + } + } + + if (prod->result == TRUE) + print("A result to be generated.\n"); + if (count >= 50) + print("EXPLAIN: Exceeded 50 productions traced through, so terminating now.\n"); +} + +/*************************************************************************** + * Function : explain_list_chunks + **************************************************************************/ + +void explain_list_chunks(void) +{ + + explain_chunk_str *chunk; + + chunk = current_agent(explain_chunk_list); +/* AGR 564 In previous statement, current_agent(...) was added. 2-May-94 */ + + if (!chunk) + print("No chunks/justifications built yet!\n"); + else { + print("List of all explained chunks/justifications:\n"); + while (chunk != NULL) { + print("Have explanation for %s\n", chunk->name); + chunk = chunk->next_chunk; + } + } +} + +/*************************************************************************** + * Function : explain_full_trace + **************************************************************************/ + +void explain_full_trace(void) +{ + + explain_chunk_str *chunk; + + chunk = current_agent(explain_chunk_list); +/* AGR 564 In previous statement, current_agent(...) was added. 2-May-94 */ + + while (chunk != NULL) { + explain_trace_chunk(chunk); + chunk = chunk->next_chunk; + } +} diff --git a/soar-8.5.2/kernel/explain.h b/soar-8.5.2/kernel/explain.h new file mode 100644 index 0000000..116b894 --- /dev/null +++ b/soar-8.5.2/kernel/explain.h @@ -0,0 +1,48 @@ +/************************************************************************* + * + * file: explain.h + * + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* we really only needs these for interface.c, so maybe just + * explicitly include them there and get rid of this file... kjc */ + +/* About 80 lines of stuff deleted. AGR 564 2-May-94 */ + +/* KBS commented this out -- redundant with agent variable */ +/* extern bool explain_flag; Flag for whether we're explaining or not */ + +extern bool explain_interface_routine(void); +extern char *help_on_explain[]; diff --git a/soar-8.5.2/kernel/init_soar.c b/soar-8.5.2/kernel/init_soar.c new file mode 100644 index 0000000..65ee11a --- /dev/null +++ b/soar-8.5.2/kernel/init_soar.c @@ -0,0 +1,1287 @@ +/************************************************************************* + * + * file: init_soar.c + * + * ======================================================================= + * Routines for initializing Soar, signal handling (ctrl-c interrupt), + * exiting Soar (cleanup and error msgs), setting sysparams, and + * the core routines for "running" Soar (do_one_top_level_phase, etc.) + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +#include "soarkernel.h" +#include /* used for control-c handler */ + +#if !defined(__SC__) && !defined(THINK_C) && !defined(WIN32) && !defined(MACINTOSH) +#include /* used for timing stuff */ +#include /* used for timing stuff */ +#endif /* !__SC__ && !THINK_C && !WIN32 */ + +/* REW: begin 08.20.97 these defined in consistency.c */ +extern void determine_highest_active_production_level_in_stack(); +extern void determine_highest_active_production_level_in_stack_apply(); +extern void determine_highest_active_production_level_in_stack_propose(); +extern void initialize_consistency_calculations_for_new_decision(); + +/* REW: end 08.20.97 */ + +int soar_agent_ids[MAX_SIMULTANEOUS_AGENTS]; +soar_global_callback_array soar_global_callbacks; +unsigned long soar_global_callback_error; + +#if (defined(REAL_TIME_BEHAVIOR) || defined(ATTENTION_LAPSE)) +/* RMJ; just a temporary variable, but we don't want to + reallocate it every time we process a phase, so we make it global + and allocate memory for it in init_soar() (init agent.c) */ +struct timeval *current_real_time; +#endif + +#ifdef ATTENTION_LAPSE +/* RMJ; just a temporary variable, but we don't want to + reallocate it every time we process a phase, so we make it global */ +long lapse_duration; +#endif + +/* =================================================================== + + Exiting Soar + + Exit_soar() and abort_with_fatal_error(msg) both terminate Soar, closing + the log file before exiting. Abort_with_fatal_error(msg) also prints + an error message and tries to write a file before exiting. +=================================================================== */ + +void just_before_exit_soar(void) +{ + cons *c; + + /* + * This function should now deal with multiple agents + * as well as no agents. + */ + for (c = all_soar_agents; c != NULL; c = c->rest) { + soar_invoke_callbacks((agent *) c->first, SYSTEM_TERMINATION_CALLBACK, (soar_call_data) TRUE); + + if (((agent *) c->first)->logging_to_file) + stop_log_file(); + } +} + +void exit_soar(void) +{ + + just_before_exit_soar(); + exit(0); + +} + +void abort_with_fatal_error(char *msg) +{ + FILE *f; + + print("%s", msg); + print("Soar cannot recover from this error. Aborting...\n"); + fprintf(stderr, "%s", msg); + fprintf(stderr, "Soar cannot recover from this error. Aborting...\n"); + f = fopen("soarerror", "w"); + fprintf(f, "%s", msg); + fprintf(f, "Soar cannot recover from this error. Aborting...\n"); + fclose(f); + + soar_invoke_callbacks(soar_agent, SYSTEM_TERMINATION_CALLBACK, (soar_call_data) FALSE); + + if (current_agent(logging_to_file)) + stop_log_file(); + + sys_abort(); + +} + +#ifdef REAL_TIME_BEHAVIOR +/* RMJ */ +void init_real_time(void) +{ + current_agent(real_time_tracker) = (struct timeval *) malloc(sizeof(struct timeval)); + timerclear(current_agent(real_time_tracker)); + current_agent(real_time_idling) = FALSE; + current_real_time = (struct timeval *) malloc(sizeof(struct timeval)); +} +#endif + +#ifdef ATTENTION_LAPSE +/* RMJ */ + +void wake_from_attention_lapse(void) +{ + /* Set tracker to last time we woke up */ + start_timer(current_agent(attention_lapse_tracker)); + current_agent(attention_lapsing) = FALSE; +} + +void init_attention_lapse(void) +{ + current_agent(attention_lapse_tracker) = (struct timeval *) malloc(sizeof(struct timeval)); + wake_from_attention_lapse(); +#ifndef REAL_TIME_BEHAVIOR + current_real_time = (struct timeval *) malloc(sizeof(struct timeval)); +#endif +} + +void start_attention_lapse(long duration) +{ + /* Set tracker to time we should wake up */ + start_timer(current_agent(attention_lapse_tracker)); + current_agent(attention_lapse_tracker)->tv_usec += 1000 * duration; + if (current_agent(attention_lapse_tracker)->tv_usec >= 1000000) { + current_agent(attention_lapse_tracker)->tv_sec += current_agent(attention_lapse_tracker)->tv_usec / 1000000; + current_agent(attention_lapse_tracker)->tv_usec %= 1000000; + } + current_agent(attention_lapsing) = TRUE; +} + +#endif + +/* =================================================================== + + Sysparams + +=================================================================== */ + +void init_sysparams(void) +{ + int i; + + for (i = 0; i < HIGHEST_SYSPARAM_NUMBER + 1; i++) + current_agent(sysparams)[i] = 0; + + /* --- set all params to zero, except the following: --- */ + current_agent(sysparams)[TRACE_CONTEXT_DECISIONS_SYSPARAM] = TRUE; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + + current_agent(sysparams)[TRACE_FIRINGS_OF_CHUNKS_SYSPARAM] = TRUE; + current_agent(sysparams)[TRACE_FIRINGS_WME_TRACE_TYPE_SYSPARAM] = NONE_WME_TRACE; + current_agent(sysparams)[TRACE_CHUNK_NAMES_SYSPARAM] = TRUE; + current_agent(sysparams)[TRACE_JUSTIFICATION_NAMES_SYSPARAM] = TRUE; + +#endif + current_agent(sysparams)[TRACE_LOADING_SYSPARAM] = TRUE; /* KJC 8/96 */ + + current_agent(sysparams)[MAX_ELABORATIONS_SYSPARAM] = 100; + current_agent(sysparams)[MAX_CHUNKS_SYSPARAM] = 50; + + current_agent(sysparams)[RESPOND_TO_LOAD_ERRORS_SYSPARAM] = TRUE; + +#ifdef ATTENTION_LAPSE + /* RMJ */ + current_agent(sysparams)[ATTENTION_LAPSE_ON_SYSPARAM] = FALSE; +#endif /* ATTENTION_LAPSE */ + + current_agent(sysparams)[LEARNING_ON_SYSPARAM] = FALSE; /* bugzilla bug 338 */ + current_agent(sysparams)[LEARNING_ONLY_SYSPARAM] = FALSE; /* AGR MVL1 */ + current_agent(sysparams)[LEARNING_EXCEPT_SYSPARAM] = FALSE; /* KJC 8/96 */ + current_agent(sysparams)[LEARNING_ALL_GOALS_SYSPARAM] = TRUE; + current_agent(sysparams)[USER_SELECT_MODE_SYSPARAM] = USER_SELECT_RANDOM; + current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM] = TRUE; + current_agent(sysparams)[PRINT_ALIAS_SYSPARAM] = TRUE; /* AGR 627 */ + current_agent(sysparams)[EXPLAIN_SYSPARAM] = FALSE; /* KJC 7/96 */ + current_agent(sysparams)[USE_LONG_CHUNK_NAMES] = TRUE; /* kjh(B14) */ + current_agent(sysparams)[TRACE_OPERAND2_REMOVALS_SYSPARAM] = FALSE; +} + +/* =================================================================== + + Adding and Removing Pwatchs + + Productions_being_traced is a (consed) list of all productions + on which a pwatch has been set. Pwatchs are added/removed via + calls to add_pwatch() and remove_pwatch(). +=================================================================== */ +/* list of production structures */ + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + +void add_pwatch(production * prod) +{ + if (prod->trace_firings) + return; + prod->trace_firings = TRUE; + push(prod, current_agent(productions_being_traced)); +} + +production *prod_to_remove_pwatch_of; + +bool remove_pwatch_test_fn(cons * c) +{ + return (bool) (c->first == prod_to_remove_pwatch_of); +} + +void remove_pwatch(production * prod) +{ + if (!prod->trace_firings) + return; + prod->trace_firings = FALSE; + prod_to_remove_pwatch_of = prod; + free_list(extract_list_elements(¤t_agent(productions_being_traced), remove_pwatch_test_fn)); +} + +#endif + +/* =================================================================== + + Reinitializing Soar + + Reset_statistics() resets all the statistics (except the firing counts + on each individual production). Reinitialize_soar() does all the + work for an init-soar. +=================================================================== */ + +void reset_production_firing_counts(void) +{ + int t; + production *p; + + for (t = 0; t < NUM_PRODUCTION_TYPES; t++) { + for (p = current_agent(all_productions_of_type)[t]; p != NIL; p = p->next) + p->firing_count = 0; + } +} + +void reset_statistics(void) +{ + + current_agent(d_cycle_count) = 0; + current_agent(e_cycle_count) = 0; + current_agent(e_cycles_this_d_cycle) = 0; + current_agent(chunks_this_d_cycle) = 0; + current_agent(production_firing_count) = 0; + current_agent(wme_addition_count) = 0; + current_agent(wme_removal_count) = 0; + current_agent(max_wm_size) = 0; + current_agent(cumulative_wm_size) = 0.0; + current_agent(num_wm_sizes_accumulated) = 0; +/* REW: begin 09.15.96 */ + current_agent(pe_cycle_count) = 0; + current_agent(pe_cycles_this_d_cycle) = 0; +/* REW: end 09.15.96 */ + + reset_production_firing_counts(); + +#ifndef NO_TIMING_STUFF + reset_timer(¤t_agent(total_cpu_time)); + +/* REW: begin 28.07.96 */ + + reset_timer(¤t_agent(total_kernel_time)); + + reset_timer(¤t_agent(input_function_cpu_time)); + reset_timer(¤t_agent(output_function_cpu_time)); + +#ifndef KERNEL_TIME_ONLY + + reset_timer(¤t_agent(decision_cycle_phase_timers[INPUT_PHASE])); + reset_timer(¤t_agent(decision_cycle_phase_timers[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(decision_cycle_phase_timers[PREFERENCE_PHASE])); + reset_timer(¤t_agent(decision_cycle_phase_timers[WM_PHASE])); + reset_timer(¤t_agent(decision_cycle_phase_timers[OUTPUT_PHASE])); + reset_timer(¤t_agent(decision_cycle_phase_timers[DECISION_PHASE])); + + reset_timer(¤t_agent(monitors_cpu_time[INPUT_PHASE])); + reset_timer(¤t_agent(monitors_cpu_time[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(monitors_cpu_time[PREFERENCE_PHASE])); + reset_timer(¤t_agent(monitors_cpu_time[WM_PHASE])); + reset_timer(¤t_agent(monitors_cpu_time[OUTPUT_PHASE])); + reset_timer(¤t_agent(monitors_cpu_time[DECISION_PHASE])); + +#ifdef DETAILED_TIMING_STATS + reset_timer(¤t_agent(match_cpu_time[INPUT_PHASE])); + reset_timer(¤t_agent(match_cpu_time[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(match_cpu_time[PREFERENCE_PHASE])); + reset_timer(¤t_agent(match_cpu_time[WM_PHASE])); + reset_timer(¤t_agent(match_cpu_time[OUTPUT_PHASE])); + reset_timer(¤t_agent(match_cpu_time[DECISION_PHASE])); + + reset_timer(¤t_agent(ownership_cpu_time[INPUT_PHASE])); + reset_timer(¤t_agent(ownership_cpu_time[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(ownership_cpu_time[PREFERENCE_PHASE])); + reset_timer(¤t_agent(ownership_cpu_time[WM_PHASE])); + reset_timer(¤t_agent(ownership_cpu_time[OUTPUT_PHASE])); + reset_timer(¤t_agent(ownership_cpu_time[DECISION_PHASE])); + + reset_timer(¤t_agent(chunking_cpu_time[INPUT_PHASE])); + reset_timer(¤t_agent(chunking_cpu_time[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(chunking_cpu_time[PREFERENCE_PHASE])); + reset_timer(¤t_agent(chunking_cpu_time[WM_PHASE])); + reset_timer(¤t_agent(chunking_cpu_time[OUTPUT_PHASE])); + reset_timer(¤t_agent(chunking_cpu_time[DECISION_PHASE])); + +/* REW: begin 11.25.96 */ + reset_timer(¤t_agent(total_gds_time)); + + reset_timer(¤t_agent(gds_cpu_time[INPUT_PHASE])); + reset_timer(¤t_agent(gds_cpu_time[DETERMINE_LEVEL_PHASE])); + reset_timer(¤t_agent(gds_cpu_time[PREFERENCE_PHASE])); + reset_timer(¤t_agent(gds_cpu_time[WM_PHASE])); + reset_timer(¤t_agent(gds_cpu_time[OUTPUT_PHASE])); + reset_timer(¤t_agent(gds_cpu_time[DECISION_PHASE])); +/* REW: end 11.25.96 */ +#endif +#endif +#ifdef DC_HISTOGRAM + { + int i; + for (i = 0; i < current_agent(dc_histogram_sz); i++) { + reset_timer(¤t_agent(dc_histogram_tv)[i]); + } + } +#endif /* DC_HISTOGRAM */ +#ifdef KT_HISTOGRAM + { + int i; + for (i = 0; i < current_agent(kt_histogram_sz); i++) { + reset_timer(¤t_agent(kt_histogram_tv)[i]); + } + } +#endif /* KT_HISTOGRAM */ + +#endif +/* REW: end 28.07.96 */ +#ifdef COUNT_KERNEL_TIMER_STOPS + current_agent(kernelTimerStops) = 0; + current_agent(nonKernelTimerStops) = 0; +#endif + +} + +/* =================================================================== + + Running Soar + + Do_one_top_level_phase() runs Soar one top-level phase. Note that + this does not start/stop the total_cpu_time timer--the caller must + do this. + + Each of the following routines runs Soar for a certain duration, + or until stop_soar gets set to TRUE. + - Run_forever() runs Soar forever. + - Run_for_n_phases() runs Soar for a given number (n) of top-level + phases. (If n==-1, it runs forever.) + - Run_for_n_elaboration_cycles() runs Soar for a given number (n) + of elaboration cycles. (Here, decision phase is counted as + an elaboration cycle.) (If n==-1, it runs forever.) + - Run_for_n_decision_cycles() runs Soar for a given number (n) of + decision cycles. (If n==-1, it runs forever.) + - Run_for_n_selections_of_slot (long n, Symbol *attr_of_slot): this + runs Soar until the nth time a selection is made for a given + type of slot. Attr_of_slot should be either state_symbol or + operator_symbol. + - Run_for_n_selections_of_slot_at_level (long n, Symbol *attr_of_slot, + goal_stack_level level): this runs Soar for n selections of the + given slot at the given level, or until the goal stack is popped + so that level no longer exists. +=================================================================== */ + +void do_one_top_level_phase(void) +{ + + if (current_agent(system_halted)) { + print("\nSystem halted. Use (init-soar) before running Soar again."); + current_agent(stop_soar) = TRUE; + current_agent(reason_for_stopping) = "System halted."; + return; + } + + if (!current_agent(top_goal)) { + create_top_goal(); + if (current_agent(sysparams)[TRACE_CONTEXT_DECISIONS_SYSPARAM]) { + print_string("\n"); + print_lowest_slot_in_context_stack(); + } + current_agent(current_phase) = INPUT_PHASE; + +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode)) +#endif + /* + * SW 112999 was: + * current_agent(d_cycle_count)++; + */ + increment_current_agent_d_cycle_count; +#ifdef DC_HISTOGRAM + /* SW NOTE + * I beleive this is executed for the very first decision cycle only. + * Assuming this holds true, then this should be right. We start + * the dc_histogram timer here, and we will stop it every + * dc_histogram_freq decision cycles when dc_histogram_now is TRUE + * when it is stopped (at the end of OUTPUT) it will also be restarted + * thus, we only need to bootstrap for the 1st dc. + */ + start_timer(¤t_agent(start_dc_tv)); +#endif + + } + + switch (current_agent(current_phase)) { + + case INPUT_PHASE: +#ifdef REAL_TIME_BEHAVIOR + /* RMJ; For real-time behavior, don't start any new decision phase + until the specified "artificial" time step has passed */ + start_timer(current_real_time); + if (timercmp(current_real_time, current_agent(real_time_tracker), <)) { + if (!(current_agent(real_time_idling))) { + current_agent(real_time_idling) = TRUE; + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) { + print("\n--- Real-time Idle Phase ---\n"); + } + } + break; + } + + /* Artificial time delay has passed. Reset new delay and start the + decision phase with input */ + current_agent(real_time_tracker)->tv_sec = current_real_time->tv_sec; + current_agent(real_time_tracker)->tv_usec = + current_real_time->tv_usec + 1000 * current_agent(sysparams)[REAL_TIME_SYSPARAM]; + if (current_agent(real_time_tracker)->tv_usec >= 1000000) { + current_agent(real_time_tracker)->tv_sec += current_agent(real_time_tracker)->tv_usec / 1000000; + current_agent(real_time_tracker)->tv_usec %= 1000000; + } + current_agent(real_time_idling) = FALSE; +#endif + +#ifdef ATTENTION_LAPSE + /* RMJ; decide whether to start or finish an attentional lapse */ + if (current_agent(sysparams)[ATTENTION_LAPSE_ON_SYSPARAM]) { + if (current_agent(attention_lapsing)) { + /* If lapsing, is it time to stop? */ + start_timer(current_real_time); + if (timercmp(current_real_time, current_agent(attention_lapse_tracker), >)) { + wake_from_attention_lapse(); + } + } else { + /* If not lapsing, should we start? */ + lapse_duration = init_lapse_duration(current_agent(attention_lapse_tracker)); + if (lapse_duration > 0) { + start_attention_lapse(lapse_duration); + } + } + } +#endif + +#ifndef KERNEL_TIME_ONLY +#ifndef NO_TIMING_STUFF /* REW: begin 28.07.96 */ + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + + /* for Operand2 mode using the new decision cycle ordering, + we need to do some initialization in the INPUT PHASE, which + now comes first. e_cycles are also zeroed before the APPLY Phase. + */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + current_agent(chunks_this_d_cycle) = 0; + current_agent(e_cycles_this_d_cycle) = 0; +#ifndef SOAR_8_ONLY + } +#endif + +#ifndef FEW_CALLBACKS + + if (current_agent(e_cycles_this_d_cycle) == 0) { + soar_invoke_callbacks(soar_agent, BEFORE_DECISION_CYCLE_CALLBACK, (soar_call_data) NULL); + } +#endif + +#ifndef DONT_DO_IO_CYCLES + + if (current_agent(input_cycle_flag) == TRUE) { /* AGR REW1 */ + +#ifndef FEW_CALLBACKS + + soar_invoke_callbacks(soar_agent, BEFORE_INPUT_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + + /* SW : 120199 timer bug fix */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + /* SW : 120199 end */ + + do_input_cycle(); + + /* SW : 120199 timer bug fix */ +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(input_function_cpu_time)); + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + /* SW : 120199 end */ + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, AFTER_INPUT_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + if (current_agent(input_period)) + current_agent(input_cycle_flag) = FALSE; + } + /* AGR REW1 this line and 1 previous line */ +#endif /* DONT_DO_IO_CYCLES */ + + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + /* REW: begin 05.05.97 */ + current_agent(current_phase) = DETERMINE_LEVEL_PHASE; + current_agent(FIRING_TYPE) = IE_PRODS; + /* Pref and WM are now done twice: for propose and apply. + We always need to know which "superphase" we are in. */ + current_agent(applyPhase) = FALSE; + /* We now do input only once per decision so we can 'prime' the + decision for a new round of production firings at the end of + the input phase */ + initialize_consistency_calculations_for_new_decision(); + /* REW: end 05.05.97 */ +#ifndef SOAR_8_ONLY + } else { + if (any_assertions_or_retractions_ready()) + current_agent(current_phase) = PREFERENCE_PHASE; + else + current_agent(current_phase) = DECISION_PHASE; + } +#endif + + /* REW: end 09.15.96 */ + + /* SW : 120199 timer bug fix */ + /* REW: begin 28.07.96 */ +#ifndef KERNEL_TIME_ONLY +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[INPUT_PHASE])); +#endif +#endif + /* REW: end 28.07.96 */ + /* SW 120199 End */ + + break; + + case DETERMINE_LEVEL_PHASE: + +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + + /* Still need to register callbacks for both before and after + the determine_level procedure call. */ + + if (current_agent(applyPhase)) + determine_highest_active_production_level_in_stack_apply(); + else + determine_highest_active_production_level_in_stack_propose(); +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[DETERMINE_LEVEL_PHASE])); +#endif +#endif + + break; + + case PREFERENCE_PHASE: + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + /* REW: end 28.07.96 */ + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, BEFORE_PREFERENCE_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + do_preference_phase(); + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, AFTER_PREFERENCE_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + current_agent(current_phase) = WM_PHASE; + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[PREFERENCE_PHASE])); +#endif +#endif + /* REW: end 28.07.96 */ + +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == FALSE) + break; +#endif + /* if we're in Soar8, then go right to WM_PHASE without stopping */ + + case WM_PHASE: + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + /* REW: end 28.07.96 */ + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, BEFORE_WM_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + do_working_memory_phase(); + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, AFTER_WM_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + /* KJC - New Order: Always follow WM PHASE with DETERMINE_LEVEL_PHASE */ + current_agent(current_phase) = DETERMINE_LEVEL_PHASE; + + /* Update accounting. Moved here by KJC 10-02-98 */ + current_agent(e_cycle_count)++; + current_agent(e_cycles_this_d_cycle)++; + + if (current_agent(FIRING_TYPE) == PE_PRODS) { + /* Keep track of each pe_phase for reporting in stats */ + current_agent(pe_cycle_count)++; + current_agent(pe_cycles_this_d_cycle)++; + } +#ifndef SOAR_8_ONLY + } +#endif + /* REW: end 10.29.97 */ + + else + + current_agent(current_phase) = OUTPUT_PHASE; + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[WM_PHASE])); +#endif +#endif + /* REW: end 28.07.96 */ + break; + + case OUTPUT_PHASE: + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + /* REW: end 28.07.96 */ + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, BEFORE_OUTPUT_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + +#ifndef DONT_DO_IO_CYCLES + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), + ¤t_agent(decision_cycle_phase_timers[current_agent(current_phase)])); +#endif + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + /* REW: end 28.07.96 */ + + do_output_cycle(); + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(output_function_cpu_time)); + start_timer(¤t_agent(start_kernel_tv)); +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + +#endif /* DONT_DO_IO_CYCLES */ + + /* REW: end 28.07.96 */ + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, AFTER_OUTPUT_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + /* After each OUTPUT_PHASE in Operand2/Waterfall, always return to the + DETERMINE_LEVEL_PHASE */ + /* changed to INPUT LEVEL. KJC 10-04-98 */ + current_agent(current_phase) = INPUT_PHASE; + +#ifdef DC_HISTOGRAM + if (current_agent(dc_histogram_now)) { + /* We check this value /before/ incrementing the d_cycle_count + * because we want to know when we have /finished/ the dc + * which is amultiple of dc_histogram_freq. + * now, we store that value, restart the timer, and incr the d.c. count + */ + stop_timer(¤t_agent(start_dc_tv), + ¤t_agent(dc_histogram_tv)[(current_agent(d_cycle_count) / + current_agent(dc_histogram_freq)) - 1]); + start_timer(¤t_agent(start_dc_tv)); + current_agent(dc_histogram_now) = FALSE; + } +#endif /* DC_HISTOGRAM */ + + /* + * SW 112999 was: + * current_agent(d_cycle_count)++; + */ + increment_current_agent_d_cycle_count; + + /* timers stopped KJC 10-04-98 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[OUTPUT_PHASE])); +#endif +#endif + break; + +#ifndef SOAR_8_ONLY + } +#endif + /* REW: end 09.15.96 */ + + /* otherwise we're in Soar7 mode ... */ + + current_agent(e_cycle_count)++; + current_agent(e_cycles_this_d_cycle)++; + + /* MVP 6-8-94 */ + if (current_agent(e_cycles_this_d_cycle) >= (unsigned long) current_agent(sysparams)[MAX_ELABORATIONS_SYSPARAM]) { + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) + print("\nWarning: reached max-elaborations; proceeding to decision phase."); + current_agent(current_phase) = DECISION_PHASE; + } else + current_agent(current_phase) = INPUT_PHASE; + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[OUTPUT_PHASE])); +#endif +#endif + /* REW: end 28.07.96 */ + break; + + case DECISION_PHASE: + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + start_timer(¤t_agent(start_phase_tv)); +#endif +#endif + /* REW: end 28.07.96 */ + + /* d_cycle_count moved to input phase for Soar 8 new decision cycle */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == FALSE) { + /* + * SW 11299 was: + * current_agent(d_cycle_count)++; + */ + increment_current_agent_d_cycle_count; + } +#endif + +/* AGR REW1 begin */ + if (!current_agent(input_period)) + current_agent(input_cycle_flag) = TRUE; + else if ((current_agent(d_cycle_count) % current_agent(input_period)) == 0) + current_agent(input_cycle_flag) = TRUE; + +#ifndef FEW_CALLBACKS +/* AGR REW1 end */ + soar_invoke_callbacks(soar_agent, BEFORE_DECISION_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + do_decision_phase(); + +#ifndef NO_ADP_CALLBACK + soar_invoke_callbacks(soar_agent, AFTER_DECISION_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + +#ifndef NO_ADC_CALLBACK + soar_invoke_callbacks(soar_agent, AFTER_DECISION_CYCLE_CALLBACK, (soar_call_data) NULL); +#endif + + if (current_agent(sysparams)[TRACE_CONTEXT_DECISIONS_SYSPARAM]) { + + /* + The following statement was previously used only in conjunction + with the TCL interface, however, the new formating is valid + for all Soar8 derivitives, and thus we will use this, + as opposed to the next (commented out) block. + 081699 SW + */ + print_string("\n"); + + /* Unnecessary as of 081699 SW change */ + /* + if(current_agent(printer_output_column) != 1) + print_string ("\n"); + */ + + print_lowest_slot_in_context_stack(); + } +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == FALSE) { + current_agent(chunks_this_d_cycle) = 0; + } +#endif + + current_agent(e_cycles_this_d_cycle) = 0; + current_agent(current_phase) = INPUT_PHASE; + + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) == TRUE) { +#endif + +#ifdef AGRESSIVE_ONC + /* test for ONC, if TRUE, generate substate and go to OUTPUT */ + if ((current_agent(ms_o_assertions) == NIL) && (current_agent(bottom_goal)->id.operator_slot->wmes != NIL)) { + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, BEFORE_DECISION_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + do_decision_phase(); + +#ifndef FEW_CALLBACKS + soar_invoke_callbacks(soar_agent, AFTER_DECISION_PHASE_CALLBACK, (soar_call_data) NULL); +#endif + + if (current_agent(sysparams)[TRACE_CONTEXT_DECISIONS_SYSPARAM]) { + /* + The following statement was previously used only in conjunction + with the TCL interface, however, the new formating is valid + for all Soar8 derivitives, and thus we will use this, + as opposed to the next (commented out) block. + 081699 SW + */ + print_string("\n"); + + /* Unneeded as of 081699 SW changes */ + /* + if(current_agent(printer_output_column) != 1) print_string ("\n"); + */ + + print_lowest_slot_in_context_stack(); + } + + /* set phase to OUTPUT */ + current_agent(current_phase) = OUTPUT_PHASE; + + /* REW: begin 28.07.96 */ +#ifndef NO_TIMING_STUFF +#ifndef KERNEL_TIME_ONLY + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[DECISION_PHASE])); +#endif +#endif + /* REW: end 28.07.96 */ + + break; + + } else +/* end AGRESSIVE_ONC */ +#endif + + { + /* print("\nSetting next phase to APPLY following a decision...."); */ + current_agent(applyPhase) = TRUE; + current_agent(FIRING_TYPE) = PE_PRODS; + current_agent(current_phase) = DETERMINE_LEVEL_PHASE; + /* 'prime' the cycle for a new round of production firings + in the APPLY (pref/wm) phase */ + initialize_consistency_calculations_for_new_decision(); + } +#ifndef SOAR_8_ONLY + } +#endif + + /* REW: begin 28.07.96 */ +#if !defined(NO_TIMING_STUFF) && !defined(KERNEL_TIME_ONLY) + stop_timer(¤t_agent(start_phase_tv), ¤t_agent(decision_cycle_phase_timers[DECISION_PHASE])); +#endif + /* REW: end 28.07.96 */ + + break; /* end DECISION phase */ + + } /* end switch stmt for current_phase */ + + /* --- update WM size statistics --- */ + if (current_agent(num_wmes_in_rete) > current_agent(max_wm_size)) + current_agent(max_wm_size) = current_agent(num_wmes_in_rete); + current_agent(cumulative_wm_size) += current_agent(num_wmes_in_rete); + current_agent(num_wm_sizes_accumulated)++; + + if (current_agent(system_halted)) { + current_agent(stop_soar) = TRUE; + current_agent(reason_for_stopping) = "System halted."; + + soar_invoke_callbacks(soar_agent, AFTER_HALT_SOAR_CALLBACK, (soar_call_data) NULL); + } + + if (current_agent(stop_soar)) { + + /* (voigtjr) + this old test is nonsense, it compares pointers: + + if (current_agent(reason_for_stopping) != "") + + what really should happen here is reason_for_stopping should be + set to NULL in the cases where nothing should be printed, instead + of being assigned a pointer to a zero length (NULL) string, then + we could simply say: + + if (current_agent(reason_for_stopping)) + */ + if (current_agent(reason_for_stopping)) { + if (strcmp(current_agent(reason_for_stopping), "") != 0) { + print("\n%s", current_agent(reason_for_stopping)); + } + } + } +} + +void run_forever(void) +{ +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + while (!current_agent(stop_soar)) { + do_one_top_level_phase(); + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); +#endif +} + +void run_for_n_phases(long n) +{ + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + while (!current_agent(stop_soar) && n) { + do_one_top_level_phase(); + n--; + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#endif +} + +void run_for_n_elaboration_cycles(long n) +{ + long e_cycles_at_start, d_cycles_at_start, elapsed_cycles; + + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + e_cycles_at_start = current_agent(e_cycle_count); + d_cycles_at_start = current_agent(d_cycle_count); + /* need next line or runs only the input phase for "d 1" after init-soar */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) && (d_cycles_at_start == 0)) +#else + if (d_cycles_at_start == 0) +#endif + d_cycles_at_start++; + while (!current_agent(stop_soar)) { + elapsed_cycles = (current_agent(d_cycle_count) - d_cycles_at_start) + + (current_agent(e_cycle_count) - e_cycles_at_start); + if (n == elapsed_cycles) + break; + do_one_top_level_phase(); + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#endif +} + +void run_for_n_modifications_of_output(long n) +{ + bool was_output_phase; + long count = 0; + + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + + while (!current_agent(stop_soar) && n) { + was_output_phase = (bool) (current_agent(current_phase) == OUTPUT_PHASE); + do_one_top_level_phase(); + + if (was_output_phase) { + if (current_agent(output_link_changed)) { + + n--; + } else { + count++; + } + } + if (count > 15) { + current_agent(stop_soar) = TRUE; + current_agent(reason_for_stopping) = "exceeded 15 cycles with no output"; + } + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); +#endif +} + +void run_for_n_decision_cycles(long n) +{ + long d_cycles_at_start; + + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + d_cycles_at_start = current_agent(d_cycle_count); + /* need next line or runs only the input phase for "d 1" after init-soar */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode) && (d_cycles_at_start == 0)) +#else + if (d_cycles_at_start == 0) +#endif + d_cycles_at_start++; + while (!current_agent(stop_soar)) { + if (n == (long) (current_agent(d_cycle_count) - d_cycles_at_start)) + break; + do_one_top_level_phase(); + } + current_agent(stop_soar) = TRUE; /* fix for bugzilla bug #353 */ +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#endif +} + +Symbol *attr_of_slot_just_decided(void) +{ + if (current_agent(bottom_goal)->id.operator_slot->wmes) + return current_agent(operator_symbol); + return current_agent(state_symbol); +} + +void run_for_n_selections_of_slot(long n, Symbol * attr_of_slot) +{ + long count; + bool was_decision_phase; + + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + count = 0; + while (!current_agent(stop_soar) && (count < n)) { + was_decision_phase = (bool) (current_agent(current_phase) == DECISION_PHASE); + do_one_top_level_phase(); + if (was_decision_phase) + if (attr_of_slot_just_decided() == attr_of_slot) + count++; + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#endif +} + +void run_for_n_selections_of_slot_at_level(long n, Symbol * attr_of_slot, goal_stack_level level) +{ + long count; + bool was_decision_phase; + + if (n == -1) { + run_forever(); + return; + } + if (n < -1) + return; +#ifndef NO_TIMING_STUFF + start_timer(¤t_agent(start_total_tv)); + start_timer(¤t_agent(start_kernel_tv)); +#endif + current_agent(stop_soar) = FALSE; + current_agent(reason_for_stopping) = ""; + count = 0; + while (!current_agent(stop_soar) && (count < n)) { + was_decision_phase = (bool) (current_agent(current_phase) == DECISION_PHASE); + do_one_top_level_phase(); + if (was_decision_phase) { + if (current_agent(bottom_goal)->id.level < level) + break; + if (current_agent(bottom_goal)->id.level == level) { + if (attr_of_slot_just_decided() == attr_of_slot) + count++; + } + } + } +#ifndef NO_TIMING_STUFF + stop_timer(¤t_agent(start_total_tv), ¤t_agent(total_cpu_time)); + stop_timer(¤t_agent(start_kernel_tv), ¤t_agent(total_kernel_time)); +#endif +} + +/* =================================================================== + + Print the Startup Banner + +=================================================================== */ + +char *soar_news_string = "\ +General questions and topics for discussion should be sent to\n\ +soar-group@umich.edu. Bug reports should be sent to soar-bugs@umich.edu\n\ +The current bug-list may be obtained by sending mail to\n\ +soar-bugs@umich.edu with the Subject: line \"bug list\".\n\ +The Soar Home Page URL is: http://ai.eecs.umich.edu/soar\n\ +\n\ +Copyright (c) 1995-1999 Carnegie Mellon University,\n\ + University of Michigan,\n\ + University of Southern California/Information\n\ + Sciences Institute. All rights reserved.\n\ +The Soar consortium proclaims this software is in the public domain, and\n\ +is made available AS IS. Carnegie Mellon University, The University of \n\ +Michigan, and The University of Southern California/Information Sciences \n\ +Institute make no warranties about the software or its performance,\n\ +implied or otherwise.\n\ +\n\ +Type \"help\" for information on various topics.\n\ +Type \"quit\" to exit Soar. Use ctrl-c to stop a Soar run.\n\ +Type \"soarnews\" to repeat this information.\n\ +Type \"version\" for Soar version information.\ +"; + +void print_startup_banner(void) +{ + print(soar_version_string); + print(soar_news_string); +} + +/* =================================================================== + + Loading the Initialization File ".init.soar" + + This routine looks for a file ".init.soar" in either the current + directory or $HOME, and if found, loads it. +=================================================================== */ + +extern char *getenv(); + +int terminate_soar(void) +{ + /* Shouldn't we free *all* agents here? */ + free((void *) soar_agent); + + exit_soar(); + return 0; /* unreachable, but without it, gcc -Wall warns here */ +} diff --git a/soar-8.5.2/kernel/io.c b/soar-8.5.2/kernel/io.c new file mode 100644 index 0000000..d6307ad --- /dev/null +++ b/soar-8.5.2/kernel/io.c @@ -0,0 +1,852 @@ +/************************************************************************* + * + * file: io.c + * + * ======================================================================= + * + * + * General Soar I/O System Routines + * + * User-defined Soar I/O routines should be added at system startup time + * via calls to add_input_function() and add_output_function(). These + * calls add things to the system's list of (1) functions to be called + * every input cycle, and (2) symbol-to-function mappings for output + * commands. File io.c contains the system I/O mechanism itself (i.e., + * the stuff that calls the input and output functions), plus the text + * I/O routines. + * + * Init_soar_io() does what it says. Do_input_cycle() and do_output_cycle() + * perform the entire input and output cycles -- these routines are called + * once per elaboration cycle. (once per Decision cycle in Soar 8). + * The output module is notified about WM changes via a call to + * inform_output_module_of_wm_changes(). + * + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ + +/* ================================================================== + I/O Code for Soar 6 + + General Soar I/O System Routines, and Text I/O Routines + + See comments in soarkernel.h for more information. + ================================================================== */ + +#include "soarkernel.h" +#include +#include +#include "soarapiUtils.h" + +#ifdef _AIX /* excludeFromBuildInfo */ +#include +#endif + +extern void gds_invalid_so_remove_goal(wme * w); +void calculate_output_link_tc_info(output_link * ol); + +/* ==================================================================== + Input Routines + + Get_new_io_identifier(), get_io_sym_constant(), get_io_int_constant(), + and get_io_float_constant() just call the appropriate symbol table + routines. This has the effect of incrementing the reference count + on the symbol (or creating one with a reference count of 1). + Release_io_symbol() just decrements the reference count. + + Add_input_wme() and remove_input_wme() call the add_wme_to_wm() and + remove_wme_from_wm() routines in decide.c to do their work. + + Do_input_cycle() is the top-level routine which calls all the + individual user-defined input functions, etc. + + All this stuff is really simple, and consequently pretty vulnerable + to buggy user-written I/O code. A more sophisticated version would + be bullet-proofed against bad arguments to get_xxx(), add_input_wme(), + and remove_input_wme(). Right now add_input_wme() and remove_input_wme() + do some error checking, but they're nowhere near bullet-proof. +==================================================================== */ + +Symbol *get_new_io_identifier(char first_letter) +{ + + return make_new_identifier(first_letter, TOP_GOAL_LEVEL); +} + +Symbol *get_io_sym_constant(char *name) +{ + return make_sym_constant(name); +} + +Symbol *get_io_int_constant(long value) +{ + return make_int_constant(value); +} + +Symbol *get_io_float_constant(float value) +{ + return make_float_constant(value); +} + +void release_io_symbol(Symbol * sym) +{ + symbol_remove_ref(sym); +} + +wme *add_input_wme(Symbol * id, Symbol * attr, Symbol * value) +{ + wme *w; + + /* --- a little bit of error checking --- */ + if (!(id && attr && value)) { + print("Error: an input routine gave a NULL argument to add_input_wme.\n"); + return NIL; + } + /* --- go ahead and add the wme --- */ + w = make_wme(id, attr, value, FALSE); + insert_at_head_of_dll(id->id.input_wmes, w, next, prev); + add_wme_to_wm(w); + + /* SW NOTE: + * In an ideal world, we could capture input wmes here as well as + * in soar_cAddWme. However the problem is that based on the arguments + * to this function it is impossible to determine if the wme which is + * being added references new, or just previously defined symbols. + * As a result, we cannot capture input wmes asserted using this function + * with any hope of accurately replaying them in the future. + */ + + return w; +} + +bool remove_input_wme(wme * w) +{ + wme *temp; + + /* --- a little bit of error checking --- */ + if (!w) { + print("Error: an input routine called remove_input_wme on a NULL wme.\n"); + return FALSE; + } + for (temp = w->id->id.input_wmes; temp != NIL; temp = temp->next) + if (temp == w) + break; + if (!temp) { + print("Error: an input routine called remove_input_wme on a wme that\n"); + print("isn't one of the input wmes currently in working memory.\n"); + return FALSE; + } + + /* SW NOTE: + * Since we cannot capture wmes asserted during add_input_wme, + * we will not capture wmes removed during this function call. + */ + + /* Note: for efficiency, it might be better to use a hash table for the + above test, rather than scanning the linked list. We could have one + global hash table for all the input wmes in the system. */ + /* --- go ahead and remove the wme --- */ + remove_from_dll(w->id->id.input_wmes, w, next, prev); + /* REW: begin 09.15.96 */ +#ifndef SOAR_8_ONLY + if (current_agent(operand2_mode)) { +#endif + if (w->gds) { + if (w->gds->goal != NIL) { + if (current_agent(soar_verbose_flag)) + print("\nremove_input_wme: Removing goal %d because element in GDS changed.\n", + w->gds->goal->id.level); + gds_invalid_so_remove_goal(w); + /* NOTE: the call to remove_wme_from_wm will take care + of checking if GDS should be removed */ + } + } +#ifndef SOAR_8_ONLY + } +#endif + + /* REW: end 09.15.96 */ + + remove_wme_from_wm(w); + + return TRUE; +} + +#ifndef NO_IO_CALLBACKS + +void do_input_cycle(void) +{ + wme *w; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) + print("\n--- Input Phase --- \n"); +#endif + + if (current_agent(prev_top_state) && (!current_agent(top_state))) { + /* --- top state was just removed --- */ + release_io_symbol(current_agent(io_header)); + release_io_symbol(current_agent(io_header_input)); + release_io_symbol(current_agent(io_header_output)); + current_agent(io_header) = NIL; /* RBD added 3/25/95 */ + current_agent(io_header_input) = NIL; /* RBD added 3/25/95 */ + current_agent(io_header_output) = NIL; /* KJC added 3/3/99 */ + current_agent(io_header_link) = NIL; /* KJC added 3/3/99 */ + soar_invoke_callbacks(soar_agent, INPUT_PHASE_CALLBACK, (soar_call_data) TOP_STATE_JUST_REMOVED); + } else if ((!current_agent(prev_top_state)) && current_agent(top_state)) { + /* --- top state was just created --- */ + /* Create io structure on top state. */ + current_agent(io_header) = get_new_io_identifier('I'); + current_agent(io_header_link) = add_input_wme(current_agent(top_state), + current_agent(io_symbol), current_agent(io_header)); + current_agent(io_header_input) = get_new_io_identifier('I'); + current_agent(io_header_output) = get_new_io_identifier('I'); + w = add_input_wme(current_agent(io_header), make_sym_constant("input-link"), current_agent(io_header_input)); + + w = add_input_wme(current_agent(io_header), make_sym_constant("output-link"), current_agent(io_header_output)); + + /* --- add top state io link before calling input phase callback so + * --- code can use "wmem" command. + */ + do_buffered_wm_and_ownership_changes(); + + soar_invoke_callbacks(soar_agent, INPUT_PHASE_CALLBACK, (soar_call_data) TOP_STATE_JUST_CREATED); + } + + /* --- if there is a top state, do the normal input cycle --- */ + + if (current_agent(top_state)) { + soar_invoke_callbacks(soar_agent, INPUT_PHASE_CALLBACK, (soar_call_data) NORMAL_INPUT_CYCLE); + } + + /* --- do any WM resulting changes --- */ + do_buffered_wm_and_ownership_changes(); + + /* --- save current top state for next time --- */ + current_agent(prev_top_state) = current_agent(top_state); + + /* --- reset the output-link status flag to FALSE + * --- when running til output, only want to stop if agent + * --- does add-wme to output. don't stop if add-wme done + * --- during input cycle (eg simulator updates sensor status) + * KJC 11/23/98 + */ + current_agent(output_link_changed) = FALSE; +} + +#else +void do_input_cycle(void) +{ + + /* + I don't really think we need to do this, + so I'll try not using it. + */ + /* do_buffered_wm_and_ownership_changes(); */ + current_agent(prev_top_state) = current_agent(top_state); + current_agent(output_link_changed) = FALSE; + +} + +#endif /* NO_IO_CALLBACKS */ + +/* ==================================================================== + Output Routines + + Inform_output_module_of_wm_changes() and do_output_cycle() are the + two top-level entry points to the output routines. The former is + called by the working memory manager, and the latter from the top-level + phase sequencer. + + This module maintains information about all the existing output links + and the identifiers and wmes that are in the transitive closure of them. + On each output link wme, we put a pointer to an output_link structure. + Whenever inform_output_module_of_wm_changes() is called, we look for + new output links and modifications/removals of old ones, and update + the output_link structures accordingly. + + Transitive closure information is kept as follows: each output_link + structure has a list of all the ids in the link's TC. Each id in + the system has a list of all the output_link structures that it's + in the TC of. + + After some number of calls to inform_output_module_of_wm_changes(), + eventually do_output_cycle() gets called. It scans through the list + of output links and calls the necessary output function for each + link that has changed in some way (add/modify/remove). +==================================================================== */ + +/* --- output link statuses --- */ +#define NEW_OL_STATUS 0 /* just created it */ +#define UNCHANGED_OL_STATUS 1 /* normal status */ +#define MODIFIED_BUT_SAME_TC_OL_STATUS 2 /* some value in its TC has been + modified, but the ids in its TC + are the same */ +#define MODIFIED_OL_STATUS 3 /* the set of ids in its TC has + changed */ +#define REMOVED_OL_STATUS 4 /* link has just been removed */ + +/* -------------------------------------------------------------------- + Output Link Status Updates on WM Changes + + Top-state link changes: + + For wme addition: (top-state ^link-attr anything) + create new output_link structure; mark it "new" + For wme removal: (top-state ^link-attr anything) + mark the output_link "removed" + + TC of existing link changes: + + For wme addition or removal: ( ^att constant): + for each link in associated_output_links(id), + mark link "modified but same tc" (unless it's already marked + some other more serious way) + + For wme addition or removal: ( ^att ): + for each link in associated_output_links(id), + mark link "modified" (unless it's already marked + some other more serious way) + + Note that we don't update all the TC information after every WM change. + The TC info doesn't get updated until do_output_cycle() is called. +-------------------------------------------------------------------- */ + +#define LINK_NAME_SIZE 1024 +void update_for_top_state_wme_addition(wme * w) +{ + output_link *ol; + soar_callback *cb; + char link_name[LINK_NAME_SIZE]; + + /* --- check whether the attribute is an output function --- */ + symbol_to_string(w->attr, FALSE, link_name, LINK_NAME_SIZE); + + cb = soar_exists_callback_id(soar_agent, OUTPUT_PHASE_CALLBACK, link_name); + + if (!cb) + return; + + /* --- create new output link structure --- */ + allocate_with_pool(¤t_agent(output_link_pool), &ol); + insert_at_head_of_dll(current_agent(existing_output_links), ol, next, prev); + + ol->status = NEW_OL_STATUS; + ol->link_wme = w; + wme_add_ref(w); + ol->ids_in_tc = NIL; + ol->cb = cb; + /* --- make wme point to the structure --- */ + w->output_link = ol; + + /* SW 07 10 2003 + previously, this wouldn't be done until the first OUTPUT phase. + However, if we add an output command in the 1st decision cycle, + Soar seems to ignore it. + + There may be two things going on, the first having to do with the tc + calculation, which may get done too late, in such a way that the + initial calculation includes the command. The other thing appears + to be that some data structures are not initialized until the first + output phase. Namely, id->associated_output_links does not seem + reflect the current output links until the first output-phase. + + To get past these issues, we fake a transitive closure calculation + with the knowledge that the only thing on the output link at this + point is the output-link identifier itself. This way, we capture + a snapshot of the empty output link, so Soar can detect any changes + that might occur before the first output_phase. */ + + current_agent(output_link_tc_num) = get_new_tc_number(); + ol->link_wme->value->id.tc_num = current_agent(output_link_tc_num); + current_agent(output_link_for_tc) = ol; + /* --- add output_link to id's list --- */ + push(current_agent(output_link_for_tc), ol->link_wme->value->id.associated_output_links); + +} + +void update_for_top_state_wme_removal(wme * w) +{ + if (!w->output_link) + return; + w->output_link->status = REMOVED_OL_STATUS; +} + +void update_for_io_wme_change(wme * w) +{ + cons *c; + output_link *ol; + + for (c = w->id->id.associated_output_links; c != NIL; c = c->rest) { + ol = c->first; + if (w->value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) { + /* --- mark ol "modified" --- */ + if ((ol->status == UNCHANGED_OL_STATUS) || (ol->status == MODIFIED_BUT_SAME_TC_OL_STATUS)) + ol->status = MODIFIED_OL_STATUS; + } else { + /* --- mark ol "modified but same tc" --- */ + if (ol->status == UNCHANGED_OL_STATUS) + ol->status = MODIFIED_BUT_SAME_TC_OL_STATUS; + } + } +} + +void inform_output_module_of_wm_changes(list * wmes_being_added, list * wmes_being_removed) +{ + cons *c; + wme *w; + + /* if wmes are added, set flag so can stop when running til output */ + for (c = wmes_being_added; c != NIL; c = c->rest) { + w = c->first; + + if (w->id == current_agent(io_header)) { + update_for_top_state_wme_addition(w); + current_agent(output_link_changed) = TRUE; /* KJC 11/23/98 */ + } + if (w->id->id.associated_output_links) { + update_for_io_wme_change(w); + current_agent(output_link_changed) = TRUE; /* KJC 11/23/98 */ + } +#if DEBUG_RTO + else { + char id[100]; + + symbol_to_string(w->id, FALSE, id); + if (!strcmp(id, "I3")) { + print("--> Added to I3, but doesn't register as an OL change!"); + } + } +#endif + + } + for (c = wmes_being_removed; c != NIL; c = c->rest) { + w = c->first; + if (w->id == current_agent(io_header)) + update_for_top_state_wme_removal(w); + if (w->id->id.associated_output_links) + update_for_io_wme_change(w); + } +} + +/* -------------------------------------------------------------------- + Updating Link TC Information + + We make no attempt to do the TC updating intelligently. Whenever the + TC changes, we throw away all the old TC info and recalculate the new + TC from scratch. I figure that this part of the system won't get + used very frequently and I hope it won't be a time hog. + + Remove_output_link_tc_info() and calculate_output_link_tc_info() are + the main routines here. +-------------------------------------------------------------------- */ + +void remove_output_link_tc_info(output_link * ol) +{ + cons *c, *prev_c; + Symbol *id; + + while (ol->ids_in_tc) { /* for each id in the old TC... */ + c = ol->ids_in_tc; + ol->ids_in_tc = c->rest; + id = c->first; + free_cons(c); + + /* --- remove "ol" from the list of associated_output_links(id) --- */ + prev_c = NIL; + for (c = id->id.associated_output_links; c != NIL; prev_c = c, c = c->rest) + if (c->first == ol) + break; + if (!c) { + char msg[MESSAGE_SIZE]; + strncpy(msg, "io.c: Internal error: can't find output link in id's list\n", MESSAGE_SIZE); + msg[MESSAGE_SIZE - 1] = 0; + abort_with_fatal_error(msg); + } + if (prev_c) + prev_c->rest = c->rest; + else + id->id.associated_output_links = c->rest; + free_cons(c); + symbol_remove_ref(id); + } +} + +void add_id_to_output_link_tc(Symbol * id) +{ + slot *s; + wme *w; + + /* --- if id is already in the TC, exit --- */ + if (id->id.tc_num == current_agent(output_link_tc_num)) + return; + id->id.tc_num = current_agent(output_link_tc_num); + + /* --- add id to output_link's list --- */ + push(id, current_agent(output_link_for_tc)->ids_in_tc); + symbol_add_ref(id); /* make sure the id doesn't get deallocated before we + have a chance to free the cons cell we just added */ + + /* --- add output_link to id's list --- */ + push(current_agent(output_link_for_tc), id->id.associated_output_links); + + /* --- do TC through working memory --- */ + /* --- scan through all wmes for all slots for this id --- */ + for (w = id->id.input_wmes; w != NIL; w = w->next) + if (w->value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) + add_id_to_output_link_tc(w->value); + for (s = id->id.slots; s != NIL; s = s->next) + for (w = s->wmes; w != NIL; w = w->next) + if (w->value->common.symbol_type == IDENTIFIER_SYMBOL_TYPE) + add_id_to_output_link_tc(w->value); + /* don't need to check impasse_wmes, because we couldn't have a pointer + to a goal or impasse identifier */ +} + +void calculate_output_link_tc_info(output_link * ol) +{ + /* --- if link doesn't have any substructure, there's no TC --- */ + if (ol->link_wme->value->common.symbol_type != IDENTIFIER_SYMBOL_TYPE) + return; + + /* --- do TC starting with the link wme's value --- */ + current_agent(output_link_for_tc) = ol; + current_agent(output_link_tc_num) = get_new_tc_number(); + add_id_to_output_link_tc(ol->link_wme->value); +} + +/* -------------------------------------------------------------------- + Building the list of IO_Wme's + + These routines create and destroy the list of io_wme's in the TC + of a given output_link. Get_io_wmes_for_output_link() and + deallocate_io_wme_list() are the main entry points. The TC info + must have already been calculated for the given output link before + get_io_wmes_for_output_link() is called. +-------------------------------------------------------------------- */ + +void add_wme_to_collected_io_wmes(wme * w) +{ + io_wme *new; + + allocate_with_pool(¤t_agent(io_wme_pool), &new); + new->next = current_agent(collected_io_wmes); + current_agent(collected_io_wmes) = new; + new->id = w->id; + new->attr = w->attr; + new->value = w->value; +} + +io_wme *get_io_wmes_for_output_link(output_link * ol) +{ + cons *c; + Symbol *id; + slot *s; + wme *w; + + current_agent(collected_io_wmes) = NIL; + add_wme_to_collected_io_wmes(ol->link_wme); + for (c = ol->ids_in_tc; c != NIL; c = c->rest) { + id = c->first; + for (w = id->id.input_wmes; w != NIL; w = w->next) + add_wme_to_collected_io_wmes(w); + for (s = id->id.slots; s != NIL; s = s->next) + for (w = s->wmes; w != NIL; w = w->next) + add_wme_to_collected_io_wmes(w); + } + return current_agent(collected_io_wmes); +} + +void deallocate_io_wme_list(io_wme * iw) +{ + io_wme *next; + + while (iw) { + next = iw->next; + free_with_pool(¤t_agent(io_wme_pool), iw); + iw = next; + } +} + +/* -------------------------------------------------------------------- + Do Output Cycle + + This routine is called from the top-level sequencer, and it performs + the whole output phase. It scans through the list of existing output + links, and takes the appropriate action on each one that's changed. +-------------------------------------------------------------------- */ + +/* Struct used to pass output data to callback functions */ +output_call_info output_call_data; + +#ifndef NO_IO_CALLBACKS + +void do_output_cycle(void) +{ + output_link *ol, *next_ol; + io_wme *iw_list; + +#ifndef TRACE_CONTEXT_DECISIONS_ONLY + if (current_agent(sysparams)[TRACE_PHASES_SYSPARAM]) + print("\n--- Output Phase ---\n"); +#endif + + for (ol = current_agent(existing_output_links); ol != NIL; ol = next_ol) { + next_ol = ol->next; + + switch (ol->status) { + case UNCHANGED_OL_STATUS: + /* --- link is unchanged, so do nothing --- */ + break; + + case NEW_OL_STATUS: + + /* --- calculate tc, and call the output function --- */ + calculate_output_link_tc_info(ol); + iw_list = get_io_wmes_for_output_link(ol); + output_call_data.mode = ADDED_OUTPUT_COMMAND; + output_call_data.outputs = iw_list; + (ol->cb->function) (soar_agent, ol->cb->data, &output_call_data); + deallocate_io_wme_list(iw_list); + ol->status = UNCHANGED_OL_STATUS; + break; + + case MODIFIED_BUT_SAME_TC_OL_STATUS: + /* --- don't have to redo the TC, but do call the output function --- */ + iw_list = get_io_wmes_for_output_link(ol); + output_call_data.mode = MODIFIED_OUTPUT_COMMAND; + output_call_data.outputs = iw_list; + (ol->cb->function) (soar_agent, ol->cb->data, &output_call_data); + deallocate_io_wme_list(iw_list); + ol->status = UNCHANGED_OL_STATUS; + break; + + case MODIFIED_OL_STATUS: + /* --- redo the TC, and call the output function */ + remove_output_link_tc_info(ol); + calculate_output_link_tc_info(ol); + iw_list = get_io_wmes_for_output_link(ol); + output_call_data.mode = MODIFIED_OUTPUT_COMMAND; + output_call_data.outputs = iw_list; + (ol->cb->function) (soar_agent, ol->cb->data, &output_call_data); + deallocate_io_wme_list(iw_list); + ol->status = UNCHANGED_OL_STATUS; + break; + + case REMOVED_OL_STATUS: + /* --- call the output function, and free output_link structure --- */ + remove_output_link_tc_info(ol); /* sets ids_in_tc to NIL */ + iw_list = get_io_wmes_for_output_link(ol); /* gives just the link wme */ + output_call_data.mode = REMOVED_OUTPUT_COMMAND; + output_call_data.outputs = iw_list; + (ol->cb->function) (soar_agent, ol->cb->data, &output_call_data); + deallocate_io_wme_list(iw_list); + wme_remove_ref(ol->link_wme); + remove_from_dll(current_agent(existing_output_links), ol, next, prev); + free_with_pool(¤t_agent(output_link_pool), ol); + break; + } + } /* end of for ol */ +} +#else + +void do_output_cycle(void) +{ + output_link *ol, *next_ol; + + for (ol = current_agent(existing_output_links); ol != NIL; ol = next_ol) { + next_ol = ol->next; + + switch (ol->status) { + case UNCHANGED_OL_STATUS: + /* --- link is unchanged, so do nothing --- */ + break; + + default: + print("io.c: Error -- Output Link has changed, but kernel was built with NO_IO_CALLBACKS\n"); + } + } +} +#endif + +/* -------------------------------------------------------------------- + Get Output Value + + This is a simple utility function for use in users' output functions. + It finds things in an io_wme chain. It takes "outputs" (the io_wme + chain), and "id" and "attr" (symbols to match against the wmes), and + returns the value from the first wme in the chain with a matching id + and attribute. Either "id" or "attr" (or both) can be specified as + "don't care" by giving NULL (0) pointers for them instead of pointers + to symbols. If no matching wme is found, the function returns a + NULL pointer. +-------------------------------------------------------------------- */ + +Symbol *get_output_value(io_wme * outputs, Symbol * id, Symbol * attr) +{ + io_wme *iw; + + for (iw = outputs; iw != NIL; iw = iw->next) + if (((id == NIL) || (id == iw->id)) && ((attr == NIL) || (attr == iw->attr))) + return iw->value; + return NIL; +} + +/* ==================================================================== + + Utilities that used to be part of text I/O, but we still need + them now that text I/O is gone. + + Get_next_io_symbol_from_text_input_line() is used by the "accept" + RHS function. + +==================================================================== */ + +/* -------------------------------------------------------------------- + Parsing a Line of Text Input + + Get_next_io_symbol_from_text_input_line (char **text_read_position) is + the main text input parser. It reads text from text_read_position + and returns a (Symbol *) for the first item read. It updates + text_read_position to point to the next character not yet read. + If end-of-line is reached without any symbol being read, NIL is + returned. +-------------------------------------------------------------------- */ + +bool tio_constituent_char[256]; +bool tio_whitespace[256]; + +Symbol *get_io_symbol_from_tio_constituent_string(char *input_string) +{ + int int_val; + float float_val; + bool possible_id, possible_var, possible_sc, possible_ic, possible_fc; + bool rereadable; + + determine_possible_symbol_types_for_string(input_string, + strlen(input_string), + &possible_id, + &possible_var, &possible_sc, &possible_ic, &possible_fc, &rereadable); + + /* --- check whether it's an integer --- */ + if (possible_ic) { + errno = 0; + int_val = strtol(input_string, NULL, 10); + if (errno) { + print("Text Input Error: bad integer (probably too large)\n"); + return NIL; + } + return get_io_int_constant(int_val); + } + + /* --- check whether it's a floating point number --- */ + if (possible_fc) { + errno = 0; + /*float_val = (float) strtod (input_string,NULL,10); */ + float_val = (float) strtod(input_string, NULL); + if (errno) { + print("Text Input Error: bad floating point number\n"); + return NIL; + } + return get_io_float_constant(float_val); + } + + /* --- otherwise it must be a symbolic constant --- */ + return get_io_sym_constant(input_string); +} + +#define MAX_TEXT_INPUT_LINE_LENGTH 1000 /* used to be in soarkernel.h */ + +Symbol *get_next_io_symbol_from_text_input_line(char **text_read_position) +{ + char *ch; + char input_string[MAX_TEXT_INPUT_LINE_LENGTH + 2]; + int input_lexeme_length; + + ch = *text_read_position; + + /* --- scan past any whitespace --- */ + while (tio_whitespace[(unsigned char) (*ch)]) + ch++; + + /* --- if end of line, return NIL --- */ + if ((*ch == '\n') || (*ch == 0)) { + *text_read_position = ch; + return NIL; + } + + /* --- if not a constituent character, return single-letter symbol --- */ + if (!tio_constituent_char[(unsigned char) (*ch)]) { + input_string[0] = *ch++; + input_string[1] = 0; + *text_read_position = ch; + return get_io_sym_constant(input_string); + } + + /* --- read string of constituents --- */ + input_lexeme_length = 0; + while (tio_constituent_char[(unsigned char) (*ch)]) + input_string[input_lexeme_length++] = *ch++; + + /* --- return the appropriate kind of symbol --- */ + input_string[input_lexeme_length] = 0; + *text_read_position = ch; + return get_io_symbol_from_tio_constituent_string(input_string); +} + +/* ==================================================================== + + Initialization for Soar I/O + +==================================================================== */ + +char extra_tio_constituents[] = "+-._"; + +void init_soar_io(void) +{ + unsigned int i; + + init_memory_pool(¤t_agent(output_link_pool), sizeof(output_link), "output link"); + init_memory_pool(¤t_agent(io_wme_pool), sizeof(io_wme), "io wme"); + + /* --- setup constituent_char array --- */ + for (i = 0; i < 256; i++) + tio_constituent_char[i] = (char) isalnum(i); + for (i = 0; i < strlen(extra_tio_constituents); i++) + tio_constituent_char[(int) extra_tio_constituents[i]] = TRUE; + + /* --- setup whitespace array --- */ + for (i = 0; i < 256; i++) + tio_whitespace[i] = (char) isspace(i); + tio_whitespace[(int) '\n'] = FALSE; /* for text i/o, crlf isn't whitespace */ +} diff --git a/soar-8.5.2/kernel/legacy.c b/soar-8.5.2/kernel/legacy.c new file mode 100644 index 0000000..ff88161 --- /dev/null +++ b/soar-8.5.2/kernel/legacy.c @@ -0,0 +1,221 @@ +#include "soarkernel.h" +#include "soar_core_api.h" +#include "soar_ecore_api.h" + +/* Depreciated: + * Use: + */ + +/* Depreciated: + * Use: soar_cCreateAgent + */ +agent *create_soar_agent(char *name) +{ + soar_cCreateAgent(name); + return (agent *) soar_cGetAgentByName(name); +} + +/* Depreciated: + * Use: soar_cDestroyAgent + */ +void destroy_soar_agent(agent * d) +{ + soar_cDestroyAgentByAddress(d); +} + +/* Depreciated: + * Use: soar_cReInitSoar + */ +void reinitialize_soar(void) +{ + soar_cReInitSoar(); +} + +/* Depreciated: + * Use: soar_cInitializeSoar + */ +void init_soar(void) +{ + soar_cInitializeSoar(); +} + +/* Depreciated: + * Use: soar_cAddInputFunction + */ +void add_input_function(agent * a, soar_callback_fn f, + soar_callback_data cb_data, soar_callback_free_fn free_fn, char *name) +{ + soar_cAddInputFunction(a, f, cb_data, free_fn, name); +} + +/* Depreciated: + * Use: soar_cRemoveInputFunction + */ +void remove_input_function(agent * a, char *name) +{ + soar_cRemoveInputFunction(a, name); +} + +/* Depreciated: + * Use: soar_cAddOutputFunction + */ +void add_output_function(agent * a, soar_callback_fn f, + soar_callback_data cb_data, soar_callback_free_fn free_fn, char *output_link_name) +{ + soar_cAddOutputFunction(a, f, cb_data, free_fn, output_link_name); + +} + +/* Depreciated: + * Use: soar_cRemoveOutputFunction + */ +void remove_output_function(agent * a, char *name) +{ + + soar_cRemoveOutputFunction(a, name); +} + +/* Depreciated: + * Use: soar_cSetSysparam + * moved from init_soar.c + */ +/* +void set_sysparam( int param_number, long new_val ) { + soar_cSetSysparam( param_number, new_val ); +} +*/ + +/* Depreciated: + * Use: soar_ecExplainChunkTrace + * moved from explain.c + */ +void explain_trace_named_chunk(char *name) +{ + soar_ecExplainChunkTrace(name); +} + +/* Depreciated: + * Use: soar_ecExplainChunkConditionList + * moved from explain.c + */ + +void explain_cond_list(char *name) +{ + soar_ecExplainChunkConditionList(name); +} + +/* Depreciated: + * Use: soar_ecExplainChunk + * moved from explain.c + */ + +void explain_chunk(char *name, int cond_number) +{ + soar_ecExplainChunkCondition(name, cond_number); +} + +/* Depreciated: + * Use: soar_cTestAllMonitorableCallbacks + * moved from callback.c + */ +void soar_test_all_monitorable_callbacks(soar_callback_agent a) +{ + soar_cTestAllMonitorableCallbacks(a); +} + +/* Depreciated: + * Use: soar_cRemoveAllCallbacksForEvent + * moved from callback.c + */ +void soar_remove_all_callbacks_for_event(soar_callback_agent a, SOAR_CALLBACK_TYPE ct) +{ + soar_cRemoveAllCallbacksForEvent(a, ct); +} + +/* Depreciated: + * Use: soar_cRemoveAllMonitorableCallbacks + * moved from callback.c + */ +void soar_remove_all_monitorable_callbacks(soar_callback_agent a) +{ + + soar_cRemoveAllMonitorableCallbacks(a); +} + +/* Depreciated: + * Use: soar_cListAllCallbacksForEvent + * moved from callback.c + */ +void soar_list_all_callbacks_for_event(soar_callback_agent a, SOAR_CALLBACK_TYPE ct) +{ + + soar_cListAllCallbacksForEvent(a, ct); +} + +/* Depreciated: + * Use: soar_cListAllCallbacks + * moved from callback.c + */ + +void soar_list_all_callbacks(soar_callback_agent a, bool monitorable_only) +{ + + soar_cListAllCallbacks(a, monitorable_only); +} + +/* Depreciated: + * Use: soar_cCallbackNameToEnum + * moved from callback.c + */ +SOAR_CALLBACK_TYPE soar_callback_name_to_enum(char *name, bool monitorable_only) +{ + + return soar_cCallbackNameToEnum(name, monitorable_only); +} + +/* Depreciated: + * Use: soar_ecPrintReteStatistics + * moved from rete.c + */ + +void print_rete_statistics(void) +{ + + soar_ecPrintReteStatistics(); +} + +/* Depreciated: + * Use: soar_ecPrintMemoryStatistics + * moved from rete.c + */ + +void print_memory_statistics(void) +{ + + soar_ecPrintMemoryStatistics(); +} + +/* Depreciated: + * Use: soar_ecPrintMemoryPoolStatistics + * moved from rete.c + */ +void print_memory_pool_statistics(void) +{ + + soar_ecPrintMemoryPoolStatistics(); +} + +/* Depreciated: + * Use: soar_ecPrintInternalSymbols + * moved from symtab.c + */ +void print_internal_symbols(void) +{ + + soar_ecPrintInternalSymbols(); +} + +void print_memories(int n, byte type[]) +{ + soar_ecPrintMemories(n, (int *) type); +} diff --git a/soar-8.5.2/kernel/lexer.c b/soar-8.5.2/kernel/lexer.c new file mode 100644 index 0000000..2ad9279 --- /dev/null +++ b/soar-8.5.2/kernel/lexer.c @@ -0,0 +1,1221 @@ +/************************************************************************* + * + * file: lexer.c + * + * ======================================================================= + * + * lexer.c + * + * The lexer reads files and returns a stream of lexemes. Get_lexeme() is + * the main routine; it looks for the next lexeme in the input, and stores + * it in the global variable "lexeme". See the structure definition below. + * + * Restrictions: the lexer cannot read individual input lines longer than + * MAX_LEXER_LINE_LENGTH characters. Thus, a single lexeme can't be longer + * than that either. + * + * The lexer maintains a stack of files being read, in order to handle nested + * loads. Start_lex_from_file() and stop_lex_from_file() push and pop the + * stack. Immediately after start_lex_from_file(), the current lexeme (global + * variable) is undefined. Immediately after stop_lex_from_file(), the + * current lexeme is automatically restored to whatever it was just before + * the corresponding start_lex_from_file() call. + * + * Determine_possible_symbol_types_for_string() is a utility routine which + * figures out what kind(s) of symbol a given string could represent. + * + * Print_location_of_most_recent_lexeme() is used to print an indication + * of where a parser error occurred. It tries to print out the current + * source line with a pointer to where the error was detected. + * + * Current_lexer_parentheses_level() returns the current level of parentheses + * nesting (0 means no open paren's have been encountered). + * Skip_ahead_to_balanced_parentheses() eats lexemes until the appropriate + * closing paren is found (0 means eat until back at the top level). + * + * Fake_rparen_at_next_end_of_line() tells the lexer to insert a fake + * R_PAREN_LEXEME token the next time it reaches the end of a line. + * + * Set_lexer_allow_ids() tells the lexer whether to allow identifiers to + * be read. If FALSE, things that look like identifiers will be returned + * as SYM_CONSTANT_LEXEME's instead. + * + * BUGBUG There are still problems with Soar not being very friendly + * when users have typos in productions, particularly with mismatched + * braces and parens. see also parser.c + * ======================================================================= + * + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ +/* ====================================================================== + lexer.c + + See comments in soarkernel.h for an overview. + ====================================================================== */ + +#include "soarkernel.h" +#include +#include +#include +#include + +bool constituent_char[256]; /* is the character a symbol constituent? */ +bool whitespace[256]; /* is the character whitespace? */ +bool number_starters[256]; /* could the character initiate a number? */ + +/* ====================================================================== + Start/Stop Lex from File + + The lexer maintains a stack of files being read, in order to handle nested + loads. Start_lex_from_file() and stop_lex_from_file() push and pop the + stack. Immediately after start_lex_from_file(), the current lexeme (agent + variable) is undefined. Immediately after stop_lex_from_file(), the + current lexeme is automatically restored to whatever it was just before + the corresponding start_lex_from_file() call. +====================================================================== */ + +void start_lex_from_file(char *filename, FILE * already_opened_file) +{ + lexer_source_file *lsf; + + lsf = allocate_memory(sizeof(lexer_source_file), MISCELLANEOUS_MEM_USAGE); + lsf->saved_lexeme = current_agent(lexeme); + lsf->saved_current_char = current_agent(current_char); + lsf->parent_file = current_agent(current_file); + current_agent(current_file) = lsf; + lsf->filename = make_memory_block_for_string(filename); + lsf->file = already_opened_file; + lsf->fake_rparen_at_eol = FALSE; + lsf->allow_ids = TRUE; + lsf->parentheses_level = 0; + lsf->column_of_start_of_last_lexeme = 0; + lsf->line_of_start_of_last_lexeme = 0; + lsf->current_line = 0; + lsf->current_column = 0; + lsf->buffer[0] = 0; + current_agent(current_char) = ' '; /* whitespace--to force immediate read of first line */ +} + +void stop_lex_from_file(void) +{ + lexer_source_file *lsf; + + if (reading_from_top_level()) { + print("Internal error: tried to stop_lex_from_file at top level\n"); + return; + } + lsf = current_agent(current_file); + current_agent(current_file) = current_agent(current_file)->parent_file; + current_agent(current_char) = lsf->saved_current_char; + current_agent(lexeme) = lsf->saved_lexeme; + + free_memory_block_for_string(lsf->filename); + free_memory(lsf, MISCELLANEOUS_MEM_USAGE); +} + +/* ====================================================================== + Get next char + + Get_next_char() gets the next character from the current input file and + puts it into the agent variable current_char. +====================================================================== */ + +void get_next_char(void) +{ + char *s; + + /* + Previously this block of code was only used in conjunction with the + Tcl interface, however, the more robust alternate_input_string + mechanism subsumes input_sting, so I am using this block in + all future builds of Soar8. + + 081699 SW + */ + + /* Soar-Bugs #54, TMH */ + if (current_agent(alternate_input_exit) && + (current_agent(alternate_input_string) == NULL) && (current_agent(alternate_input_suffix) == NULL)) { + current_agent(current_char) = EOF_AS_CHAR; + control_c_handler(0); + return; + } + + if (current_agent(alternate_input_string) != NULL) { + current_agent(current_char) = *current_agent(alternate_input_string)++; + + if (current_agent(current_char) == '\0') { + current_agent(alternate_input_string) = NIL; + current_agent(current_char) = *current_agent(alternate_input_suffix)++; + } + } else if (current_agent(alternate_input_suffix) != NULL) { + current_agent(current_char) = *current_agent(alternate_input_suffix)++; + + if (current_agent(current_char) == '\0') { + current_agent(alternate_input_suffix) = NIL; + + /* Soar-Bugs #54, TMH */ + if (current_agent(alternate_input_exit)) { + current_agent(current_char) = EOF_AS_CHAR; + control_c_handler(0); + return; + } + + current_agent(current_char) = current_agent(current_file)->buffer + [current_agent(current_file)->current_column++]; + } + } else { + current_agent(current_char) = current_agent(current_file)->buffer + [current_agent(current_file)->current_column++]; + } + + if (current_agent(current_char)) + return; + + if ((current_agent(current_file)->current_column == BUFSIZE) && + (current_agent(current_file)->buffer[BUFSIZE - 2] != '\n') && + (current_agent(current_file)->buffer[BUFSIZE - 2] != EOF_AS_CHAR)) { + char msg[512]; + snprintf(msg, MESSAGE_SIZE, + "lexer.c: Error: line too long (max allowed is %d chars)\nFile %s, line %lu\n", + MAX_LEXER_LINE_LENGTH, current_agent(current_file)->filename, + current_agent(current_file)->current_line); + msg[MESSAGE_SIZE - 1] = 0; /* snprintf doesn't set last char to null if output is truncated */ + abort_with_fatal_error(msg); + } + + s = fgets(current_agent(current_file)->buffer, BUFSIZE, current_agent(current_file)->file); + + if (s) { + current_agent(current_file)->current_line++; + if (reading_from_top_level()) { + tell_printer_that_output_column_has_been_reset(); + if (current_agent(logging_to_file)) + print_string_to_log_file_only(current_agent(current_file)->buffer); + } + } else { + /* s==NIL means immediate eof encountered or read error occurred */ + if (!feof(current_agent(current_file)->file)) { + if (reading_from_top_level()) { + + control_c_handler(0); /* AGR 581 */ + + return; + } else { + print("I/O error while reading file %s; ignoring the rest of it.\n", + current_agent(current_file)->filename); + } + } + current_agent(current_file)->buffer[0] = EOF_AS_CHAR; + current_agent(current_file)->buffer[1] = 0; + } + current_agent(current_char) = current_agent(current_file)->buffer[0]; + current_agent(current_file)->current_column = 1; +} + +/* ====================================================================== + + Lexer Utility Routines + +====================================================================== */ + +#define record_position_of_start_of_lexeme() { \ + current_agent(current_file)->column_of_start_of_last_lexeme = \ + current_agent(current_file)->current_column - 1; \ + current_agent(current_file)->line_of_start_of_last_lexeme = \ + current_agent(current_file)->current_line; } + +/* redefined for Soar 7, want case-sensitivity to match Tcl. KJC 5/96 +#define store_and_advance() { \ + current_agent(lexeme).string[current_agent(lexeme).length++] = (isupper((char)current_agent(current_char)) ? \ + tolower((char)current_agent(current_char)) : \ + (char)current_agent(current_char)); \ + get_next_char(); } +*/ +#define store_and_advance() { \ + current_agent(lexeme).string[current_agent(lexeme).length++] = \ + (char)current_agent(current_char); \ + get_next_char(); } + +#define finish() { current_agent(lexeme).string[current_agent(lexeme).length]=0; } + +void read_constituent_string(void) +{ +#ifdef __SC__ + char *buf; + int i, len; +#endif + + while ((current_agent(current_char) != EOF_AS_CHAR) && + constituent_char[(unsigned char) current_agent(current_char)]) + store_and_advance(); + finish(); +} + +void read_rest_of_floating_point_number(void) +{ + /* --- at entry, current_char=="."; we read the "." and rest of number --- */ + store_and_advance(); + while (isdigit(current_agent(current_char))) + store_and_advance(); /* string of digits */ + if ((current_agent(current_char) == 'e') || (current_agent(current_char) == 'E')) { + store_and_advance(); /* E */ + if ((current_agent(current_char) == '+') || (current_agent(current_char) == '-')) + store_and_advance(); /* optional leading + or - */ + while (isdigit(current_agent(current_char))) + store_and_advance(); /* string of digits */ + } + finish(); + +#ifdef __SC__ + if (strcmp("soar>", current_agent(lexeme).string)) { /* if the lexeme doesn't equal "soar>" */ + if (!(strncmp("soar>", current_agent(lexeme).string, 5))) { /* but the first 5 chars are "soar>" */ + /* then SIOW messed up so ignore the "soar>" */ + buf = + (char *) allocate_memory((len = (strlen(current_agent(lexeme).string) + 1)) * sizeof(char), + STRING_MEM_USAGE); + for (i = 0; i <= len; i++) { + buf[i] = current_agent(lexeme).string[i]; + } + for (i = 5; i <= len; i++) { + current_agent(lexeme).string[i - 5] = buf[i]; + } + free_memory_block_for_string(buf); + } + } +#endif +} + +void determine_type_of_constituent_string(void) +{ + bool possible_id, possible_var, possible_sc, possible_ic, possible_fc; + bool rereadable; + + determine_possible_symbol_types_for_string(current_agent(lexeme).string, + current_agent(lexeme).length, + &possible_id, + &possible_var, &possible_sc, &possible_ic, &possible_fc, &rereadable); + + /* --- check whether it's a variable --- */ + if (possible_var) { + current_agent(lexeme).type = VARIABLE_LEXEME; + return; + } + + /* --- check whether it's an integer --- */ + if (possible_ic) { + errno = 0; + current_agent(lexeme).type = INT_CONSTANT_LEXEME; + current_agent(lexeme).int_val = strtol(current_agent(lexeme).string, NULL, 10); + if (errno) { + print("Error: bad integer (probably too large)\n"); + print_location_of_most_recent_lexeme(); + current_agent(lexeme).int_val = 0; + } + return; + } + + /* --- check whether it's a floating point number --- */ + if (possible_fc) { + errno = 0; + current_agent(lexeme).type = FLOAT_CONSTANT_LEXEME; + /*current_agent(lexeme).float_val = (float) strtod (current_agent(lexeme).string,NULL,10); */ + current_agent(lexeme).float_val = (float) strtod(current_agent(lexeme).string, NULL); + if (errno) { + print("Error: bad floating point number\n"); + print_location_of_most_recent_lexeme(); + current_agent(lexeme).float_val = 0.0; + } + return; + } + + /* --- check if it's an identifier --- */ + if (current_agent(current_file)->allow_ids && possible_id) { + current_agent(lexeme).id_letter = (char) toupper(current_agent(lexeme).string[0]); + errno = 0; + current_agent(lexeme).type = IDENTIFIER_LEXEME; + current_agent(lexeme).id_number = strtoul(&(current_agent(lexeme).string[1]), NULL, 10); + if (errno) { + print("Error: bad number for identifier (probably too large)\n"); + print_location_of_most_recent_lexeme(); + current_agent(lexeme).id_number = 0; + } + return; + } + + /* --- otherwise it must be a symbolic constant --- */ + if (possible_sc) { + current_agent(lexeme).type = SYM_CONSTANT_LEXEME; + if (current_agent(sysparams)[PRINT_WARNINGS_SYSPARAM]) { + if (current_agent(lexeme).string[0] == '<') { + if (current_agent(lexeme).string[1] == '<') { + print("Warning: Possible disjunctive encountered in reading symbolic constant\n"); + print(" If a disjunctive was intended, add a space after <<\n"); + print(" If a constant was intended, surround constant with vertical bars\n"); + print_location_of_most_recent_lexeme(); + } else { + print("Warning: Possible variable encountered in reading symbolic constant\n"); + print(" If a constant was intended, surround constant with vertical bars\n"); + print_location_of_most_recent_lexeme(); + } + } else { + if (current_agent(lexeme).string[current_agent(lexeme).length - 1] == '>') { + if (current_agent(lexeme).string[current_agent(lexeme).length - 2] == '>') { + print("Warning: Possible disjunctive encountered in reading symbolic constant\n"); + print(" If a disjunctive was intended, add a space before >>\n"); + print(" If a constant was intended, surround constant with vertical bars\n"); + print_location_of_most_recent_lexeme(); + } else { + print("Warning: Possible variable encountered in reading symbolic constant\n"); + print(" If a constant was intended, surround constant with vertical bars\n"); + print_location_of_most_recent_lexeme(); + } + } + } + } + return; + } + + /* + previously the following statement was used only with the Tcl Interface + but its functionality is required for the API. Thus, I am leaving + it in, and commenting out the block which follows it. + + 081699 SW + */ + current_agent(lexeme).type = QUOTED_STRING_LEXEME; + + /* + char msg[128]; + strcpy (msg, "Internal error: can't determine_type_of_constituent_string\n"); + abort_with_fatal_error(msg); + */ +} + +void do_fake_rparen(void) +{ + record_position_of_start_of_lexeme(); + current_agent(lexeme).type = R_PAREN_LEXEME; + current_agent(lexeme).length = 1; + current_agent(lexeme).string[0] = ')'; + current_agent(lexeme).string[1] = 0; + if (current_agent(current_file)->parentheses_level > 0) + current_agent(current_file)->parentheses_level--; + current_agent(current_file)->fake_rparen_at_eol = FALSE; +} + +/* ====================================================================== + Lex such-and-such Routines + + These routines are called from get_lexeme(). Which routine gets called + depends on the first character of the new lexeme being read. Each routine's + job is to finish reading the lexeme and store the necessary items in + the agent variable "lexeme". +====================================================================== */ + +void (*(lexer_routines[256])) (void); + +void lex_eof(void) +{ + if (current_agent(current_file)->fake_rparen_at_eol) { + do_fake_rparen(); + return; + } + store_and_advance(); + finish(); + current_agent(lexeme).type = EOF_LEXEME; +} + +void lex_at(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = AT_LEXEME; +} + +void lex_tilde(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = TILDE_LEXEME; +} + +void lex_up_arrow(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = UP_ARROW_LEXEME; +} + +void lex_lbrace(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = L_BRACE_LEXEME; +} + +void lex_rbrace(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = R_BRACE_LEXEME; +} + +void lex_exclamation_point(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = EXCLAMATION_POINT_LEXEME; +} + +void lex_comma(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = COMMA_LEXEME; +} + +void lex_equal(void) +{ + /* Lexeme might be "=", or symbol */ + /* Note: this routine relies on = being a constituent character */ + + read_constituent_string(); + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = EQUAL_LEXEME; + return; + } + determine_type_of_constituent_string(); +} + +void lex_ampersand(void) +{ + /* Lexeme might be "&", or symbol */ + /* Note: this routine relies on & being a constituent character */ + + read_constituent_string(); + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = AMPERSAND_LEXEME; + return; + } + determine_type_of_constituent_string(); +} + +void lex_lparen(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = L_PAREN_LEXEME; + current_agent(current_file)->parentheses_level++; +} + +void lex_rparen(void) +{ + store_and_advance(); + finish(); + current_agent(lexeme).type = R_PAREN_LEXEME; + if (current_agent(current_file)->parentheses_level > 0) + current_agent(current_file)->parentheses_level--; +} + +void lex_greater(void) +{ + /* Lexeme might be ">", ">=", ">>", or symbol */ + /* Note: this routine relies on =,> being constituent characters */ + + read_constituent_string(); + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = GREATER_LEXEME; + return; + } + if (current_agent(lexeme).length == 2) { + if (current_agent(lexeme).string[1] == '>') { + current_agent(lexeme).type = GREATER_GREATER_LEXEME; + return; + } + if (current_agent(lexeme).string[1] == '=') { + current_agent(lexeme).type = GREATER_EQUAL_LEXEME; + return; + } + } + determine_type_of_constituent_string(); +} + +void lex_less(void) +{ + /* Lexeme might be "<", "<=", "<=>", "<>", "<<", or variable */ + /* Note: this routine relies on =,<,> being constituent characters */ + + read_constituent_string(); + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = LESS_LEXEME; + return; + } + if (current_agent(lexeme).length == 2) { + if (current_agent(lexeme).string[1] == '>') { + current_agent(lexeme).type = NOT_EQUAL_LEXEME; + return; + } + if (current_agent(lexeme).string[1] == '=') { + current_agent(lexeme).type = LESS_EQUAL_LEXEME; + return; + } + if (current_agent(lexeme).string[1] == '<') { + current_agent(lexeme).type = LESS_LESS_LEXEME; + return; + } + } + if (current_agent(lexeme).length == 3) { + if ((current_agent(lexeme).string[1] == '=') && (current_agent(lexeme).string[2] == '>')) { + current_agent(lexeme).type = LESS_EQUAL_GREATER_LEXEME; + return; + } + } + determine_type_of_constituent_string(); + +} + +void lex_period(void) +{ + store_and_advance(); + finish(); + /* --- if we stopped at '.', it might be a floating-point number, so be + careful to check for this case --- */ + if (isdigit(current_agent(current_char))) + read_rest_of_floating_point_number(); + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = PERIOD_LEXEME; + return; + } + determine_type_of_constituent_string(); +} + +void lex_plus(void) +{ + /* Lexeme might be +, number, or symbol */ + /* Note: this routine relies on various things being constituent chars */ + int i; + bool could_be_floating_point; + + read_constituent_string(); + /* --- if we stopped at '.', it might be a floating-point number, so be + careful to check for this case --- */ + if (current_agent(current_char) == '.') { + could_be_floating_point = TRUE; + for (i = 1; i < current_agent(lexeme).length; i++) + if (!isdigit(current_agent(lexeme).string[i])) + could_be_floating_point = FALSE; + if (could_be_floating_point) + read_rest_of_floating_point_number(); + } + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = PLUS_LEXEME; + return; + } + determine_type_of_constituent_string(); +} + +void lex_minus(void) +{ + /* Lexeme might be -, -->, number, or symbol */ + /* Note: this routine relies on various things being constituent chars */ + int i; + bool could_be_floating_point; + + read_constituent_string(); + /* --- if we stopped at '.', it might be a floating-point number, so be + careful to check for this case --- */ + if (current_agent(current_char) == '.') { + could_be_floating_point = TRUE; + for (i = 1; i < current_agent(lexeme).length; i++) + if (!isdigit(current_agent(lexeme).string[i])) + could_be_floating_point = FALSE; + if (could_be_floating_point) + read_rest_of_floating_point_number(); + } + if (current_agent(lexeme).length == 1) { + current_agent(lexeme).type = MINUS_LEXEME; + return; + } + if (current_agent(lexeme).length == 3) { + if ((current_agent(lexeme).string[1] == '-') && (current_agent(lexeme).string[2] == '>')) { + current_agent(lexeme).type = RIGHT_ARROW_LEXEME; + return; + } + } + determine_type_of_constituent_string(); +} + +void lex_digit(void) +{ + int i; + bool could_be_floating_point; + + read_constituent_string(); + /* --- if we stopped at '.', it might be a floating-point number, so be + careful to check for this case --- */ + if (current_agent(current_char) == '.') { + could_be_floating_point = TRUE; + for (i = 1; i < current_agent(lexeme).length; i++) + if (!isdigit(current_agent(lexeme).string[i])) + could_be_floating_point = FALSE; + if (could_be_floating_point) + read_rest_of_floating_point_number(); + } + determine_type_of_constituent_string(); +} + +void lex_unknown(void) +{ + if (reading_from_top_level() && current_agent(current_char) == 0) { + } else { + print("Error: Unknown character encountered by lexer, code=%d\n", current_agent(current_char)); + print("File %s, line %lu, column %lu.\n", current_agent(current_file)->filename, + current_agent(current_file)->current_line, current_agent(current_file)->current_column); + /* + As far as we can tell this won't work + currently, even if it ever does get called. + Thus, we're taking it out. + 081799 SW + */ + /* + if (! reading_from_top_level()) { + respond_to_load_errors (); + if (current_agent(load_errors_quit)) + current_agent(current_char) = EOF_AS_CHAR; + } + */ + } + get_next_char(); + get_lexeme(); +} + +void lex_constituent_string(void) +{ + read_constituent_string(); + determine_type_of_constituent_string(); +} + +void lex_vbar(void) +{ + current_agent(lexeme).type = SYM_CONSTANT_LEXEME; + get_next_char(); + + for (;;) { + if ((current_agent(current_char) == EOF_AS_CHAR) || (current_agent(lexeme).length == MAX_LEXEME_LENGTH)) { + print("Error: opening '|' without closing '|'\n"); + print_location_of_most_recent_lexeme(); + /* BUGBUG if reading from top level, don't want to signal EOF */ + current_agent(lexeme).type = EOF_LEXEME; + current_agent(lexeme).string[0] = EOF_AS_CHAR; + current_agent(lexeme).string[1] = 0; + current_agent(lexeme).length = 1; + return; + } + if (current_agent(current_char) == '\\') { + get_next_char(); + current_agent(lexeme).string[current_agent(lexeme).length++] = (char) current_agent(current_char); + get_next_char(); + } else if (current_agent(current_char) == '|') { + get_next_char(); + break; + } else { + current_agent(lexeme).string[current_agent(lexeme).length++] = (char) current_agent(current_char); + get_next_char(); + } + } + + current_agent(lexeme).string[current_agent(lexeme).length] = 0; +} + +void lex_quote(void) +{ + current_agent(lexeme).type = QUOTED_STRING_LEXEME; + get_next_char(); + for (;;) { + if ((current_agent(current_char) == EOF_AS_CHAR) || (current_agent(lexeme).length == MAX_LEXEME_LENGTH)) { + print("Error: opening '\"' without closing '\"'\n"); + print_location_of_most_recent_lexeme(); + /* BUGBUG if reading from top level, don't want to signal EOF */ + current_agent(lexeme).type = EOF_LEXEME; + current_agent(lexeme).string[0] = EOF_AS_CHAR; + current_agent(lexeme).string[1] = 0; + current_agent(lexeme).length = 1; + return; + } + if (current_agent(current_char) == '\\') { + get_next_char(); + current_agent(lexeme).string[current_agent(lexeme).length++] = (char) current_agent(current_char); + get_next_char(); + } else if (current_agent(current_char) == '"') { + get_next_char(); + break; + } else { + current_agent(lexeme).string[current_agent(lexeme).length++] = (char) current_agent(current_char); + get_next_char(); + } + } + current_agent(lexeme).string[current_agent(lexeme).length] = 0; +} + +/* AGR 562 begin */ + +/* There are 2 functions here, for 2 different schemes for handling the + shell escape. + Scheme 1: A '$' signals that all the rest of the text up to the '\n' + is to be passed to the system() command verbatim. The whole string, + including the '$' as its first character, is stored in a single + lexeme which has the type DOLLAR_STRING_LEXEME. + Scheme 2: A '$' is a single lexeme, much like a '(' or '&'. All the + subsequent lexemes are gotten individually with calls to get_lexeme(). + This makes it easier to parse the shell command, so that commands like + cd, pushd, popd, etc. can be trapped and the equivalent Soar commands + executed instead. The problem with this scheme is that pulling the + string apart into lexemes eliminates any special spacing the user may + have done in specifying the shell command. For that reason, my current + plan is to follow scheme 1. AGR 3-Jun-94 */ + +void lex_dollar(void) +{ + current_agent(lexeme).type = DOLLAR_STRING_LEXEME; + current_agent(lexeme).string[0] = '$'; + current_agent(lexeme).length = 1; + get_next_char(); /* consume the '$' */ + while ((current_agent(current_char) != '\n') && + (current_agent(current_char) != EOF_AS_CHAR) && (current_agent(lexeme).length < MAX_LEXEME_LENGTH - 1)) { + current_agent(lexeme).string[current_agent(lexeme).length++] = current_agent(current_char); + get_next_char(); + } + current_agent(lexeme).string[current_agent(lexeme).length] = '\0'; +} + +/* +void lex_dollar (void) { + store_and_advance(); + finish(); + current_agent(lexeme).type = DOLLAR_STRING_LEXEME; +} +*/ + +/* AGR 562 end */ + +/* ====================================================================== + Get lexeme + + This is the main routine called from outside the lexer. It reads past + any whitespace, then calls some lex_xxx routine (using the lexer_routines[] + table) based on the first character of the lexeme. +====================================================================== */ + +void get_lexeme(void) +{ + + /* AGR 568 begin */ + if (current_agent(lex_alias)) { + current_agent(lexeme) = current_agent(lex_alias)->lexeme; + current_agent(lex_alias) = current_agent(lex_alias)->next; + return; + } + /* AGR 568 end */ + + current_agent(lexeme).length = 0; + current_agent(lexeme).string[0] = 0; + + /* + A block of code was removed from here which seemed + to deal with a number of interface + and formatting details. I am taking out ancient stuff which + deals with the unix interface (this should be pushed into + a real interface layer if it to be used anyway) and leaving + behind the new Soar8 behavior which is what we used to get + only in the cases of using the Tcl interface + 081699 SW + */ + +/* AGR 534 The only time a prompt should be printed out is if there's + a command being expected; ie. the prompt shouldn't print out if we're + in the middle of entering a production. So if we're in the middle of + entering a production, then the parentheses level will be > 0, so that's + the criteria we will use. AGR 5-Apr-94 */ + + current_agent(load_errors_quit) = FALSE; /* AGR 527c */ + + while (current_agent(load_errors_quit) == FALSE) { /* AGR 527c */ + if (current_agent(current_char) == EOF_AS_CHAR) + break; + if (whitespace[(unsigned char) current_agent(current_char)]) { + if (current_agent(current_char) == '\n') { + if (current_agent(current_file)->fake_rparen_at_eol) { + do_fake_rparen(); + return; + } + + /* + A block of code was removed from here which seemed + to deal with a number of interface + and formatting details. I am taking out ancient stuff which + deals with the unix interface (this should be pushed into + a real interface layer if it to be used anyway) and leaving + behind the new Soar8 behavior which is what we used to get + only in the cases of using the Tcl interface + 081699 SW + */ + + } + get_next_char(); + continue; + } + + /* + The following section deals with parsing Soar8 and Soar7 syntax. + I am removing the old (Soar7 and prior) stuff, and leaving + the behavior which previously was used only in conjunction + with the Tcl interface. + + 081699 SW + */ + + if (current_agent(current_char) == ';') { + /* --- skip the semi-colon, forces newline in Soar8 --- */ + get_next_char(); /* consume it */ + continue; + } + if (current_agent(current_char) == '#') { + /* --- read from hash to end-of-line --- */ + while ((current_agent(current_char) != '\n') && (current_agent(current_char) != EOF_AS_CHAR)) + get_next_char(); + if (current_agent(current_file)->fake_rparen_at_eol) { + do_fake_rparen(); + return; + } + if (current_agent(current_char) != EOF_AS_CHAR) + get_next_char(); + continue; + } + + break; /* if no whitespace or comments found, break out of the loop */ + } + /* --- no more whitespace, so go get the actual lexeme --- */ + record_position_of_start_of_lexeme(); + if (current_agent(current_char) != EOF_AS_CHAR) + (*(lexer_routines[(unsigned char) current_agent(current_char)])) (); + else + lex_eof(); +} + +/* ====================================================================== + Init lexer + + This should be called before anything else in this file. It does all + the necessary init stuff for the lexer, and starts the lexer reading from + standard input. +====================================================================== */ + +char extra_constituents[] = "$%&*+-/:<=>?_"; + +void init_lexer(void) +{ + unsigned int i; + + /* --- setup constituent_char array --- */ + for (i = 0; i < 256; i++) + if (isalnum(i)) + constituent_char[i] = TRUE; + else + constituent_char[i] = FALSE; + for (i = 0; i < strlen(extra_constituents); i++) + constituent_char[(int) extra_constituents[i]] = TRUE; + + /* --- setup whitespace array --- */ + for (i = 0; i < 256; i++) + if (isspace(i)) + whitespace[i] = TRUE; + else + whitespace[i] = FALSE; + + /* --- setup number_starters array --- */ + for (i = 0; i < 256; i++) + if (isdigit(i)) + number_starters[i] = TRUE; + else + number_starters[i] = FALSE; + number_starters['+'] = TRUE; + number_starters['-'] = TRUE; + number_starters['.'] = TRUE; + + /* --- setup lexer_routines array --- */ + for (i = 0; i < 256; i++) + lexer_routines[i] = lex_unknown; + for (i = 0; i < 256; i++) + if (constituent_char[i]) + lexer_routines[i] = lex_constituent_string; + for (i = 0; i < 256; i++) + if (isdigit(i)) + lexer_routines[i] = lex_digit; + lexer_routines['@'] = lex_at; + lexer_routines['('] = lex_lparen; + lexer_routines[')'] = lex_rparen; + lexer_routines['+'] = lex_plus; + lexer_routines['-'] = lex_minus; + lexer_routines['~'] = lex_tilde; + lexer_routines['^'] = lex_up_arrow; + lexer_routines['{'] = lex_lbrace; + lexer_routines['}'] = lex_rbrace; + lexer_routines['!'] = lex_exclamation_point; + lexer_routines['>'] = lex_greater; + lexer_routines['<'] = lex_less; + lexer_routines['='] = lex_equal; + lexer_routines['&'] = lex_ampersand; + lexer_routines['|'] = lex_vbar; + lexer_routines[','] = lex_comma; + lexer_routines['.'] = lex_period; + lexer_routines['"'] = lex_quote; + lexer_routines['$'] = lex_dollar; /* AGR 562 */ + + /* --- initially we're reading from the standard input --- */ + start_lex_from_file("[standard input]", stdin); +} + +/* ====================================================================== + Print location of most recent lexeme + + This routine is used to print an indication of where a parser or interface + command error occurred. It tries to print out the current source line + with a pointer to where the error was detected. If the current source + line is no longer available, it just prints out the line number instead. + + BUGBUG: if the input line contains any tabs, the pointer comes out in + the wrong place. +====================================================================== */ + +void print_location_of_most_recent_lexeme(void) +{ + int i; + + if (current_agent(current_file)->line_of_start_of_last_lexeme == current_agent(current_file)->current_line) { + /* --- error occurred on current line, so print out the line --- */ + if (!reading_from_top_level()) { + print("File %s, line %lu:\n", current_agent(current_file)->filename, + current_agent(current_file)->current_line); + /* respond_to_load_errors (); AGR 527a */ + } + if (current_agent(current_file)->buffer[strlen(current_agent(current_file)->buffer) - 1] == '\n') + print_string(current_agent(current_file)->buffer); + else + print("%s\n", current_agent(current_file)->buffer); + for (i = 0; i < current_agent(current_file)->column_of_start_of_last_lexeme; i++) + print_string("-"); + print_string("^\n"); + + /* + As far as we can tell this won't work + currently, even if it ever does get called. + Thus, we're taking it out. + 081799 SW + */ + /* + if (! reading_from_top_level()) { + respond_to_load_errors (); + if (current_agent(load_errors_quit)) + current_agent(current_char) = EOF_AS_CHAR; + } + */ +/* AGR 527a The respond_to_load_errors call came too early (above), + and the "continue" prompt appeared before the offending line was printed + out, so the respond_to_load_errors call was moved here. + AGR 26-Apr-94 */ + + } else { + /* --- error occurred on a previous line, so just give the position --- */ + print("File %s, line %lu, column %lu.\n", current_agent(current_file)->filename, + current_agent(current_file)->line_of_start_of_last_lexeme, + current_agent(current_file)->column_of_start_of_last_lexeme + 1); + + /* + As far as we can tell this won't work + currently, even if it ever does get called. + Thus, we're taking it out. + 081799 SW + */ + /* + if (! reading_from_top_level()) { + respond_to_load_errors (); + if (current_agent(load_errors_quit)) + current_agent(current_char) = EOF_AS_CHAR; + } + */ + } +} + +/* ====================================================================== + Parentheses Utilities + + Current_lexer_parentheses_level() returns the current level of parentheses + nesting (0 means no open paren's have been encountered). + + Skip_ahead_to_balanced_parentheses() eats lexemes until the appropriate + closing paren is found (0 means eat until back at the top level). + + Fake_rparen_at_next_end_of_line() tells the lexer to insert a fake + R_PAREN_LEXEME token the next time it reaches the end of a line. +====================================================================== */ + +int current_lexer_parentheses_level(void) +{ + return current_agent(current_file)->parentheses_level; +} + +void skip_ahead_to_balanced_parentheses(int parentheses_level) +{ + for (;;) { + if (current_agent(lexeme).type == EOF_LEXEME) + return; + if ((current_agent(lexeme).type == R_PAREN_LEXEME) && + (parentheses_level == current_agent(current_file)->parentheses_level)) + return; + get_lexeme(); + } +} + +void fake_rparen_at_next_end_of_line(void) +{ + current_agent(current_file)->parentheses_level++; + current_agent(current_file)->fake_rparen_at_eol = TRUE; +} + +/* ====================================================================== + Set lexer allow ids + + This routine should be called to tell the lexer whether to allow + identifiers to be read. If FALSE, things that look like identifiers + will be returned as SYM_CONSTANT_LEXEME's instead. +====================================================================== */ + +void set_lexer_allow_ids(bool allow_identifiers) +{ + current_agent(current_file)->allow_ids = allow_identifiers; +} + +/* ====================================================================== + Determine possible symbol types for string + + This is a utility routine which figures out what kind(s) of symbol a + given string could represent. At entry: s, length_of_s represent the + string. At exit: possible_xxx is set to TRUE/FALSE to indicate + whether the given string could represent that kind of symbol; rereadable + is set to TRUE indicating whether the lexer would read the given string + as a symbol with exactly the same name (as opposed to treating it as a + special lexeme like "+", changing upper to lower case, etc. +====================================================================== */ + +void determine_possible_symbol_types_for_string(char *s, + int length_of_s, + bool * possible_id, + bool * possible_var, + bool * possible_sc, + bool * possible_ic, bool * possible_fc, bool * rereadable) +{ + char *ch; + bool rereadability_dead, rereadability_questionable; + + *possible_id = FALSE; + *possible_var = FALSE; + *possible_sc = FALSE; + *possible_ic = FALSE; + *possible_fc = FALSE; + *rereadable = FALSE; + + /* --- check if it's an integer or floating point number --- */ + if (number_starters[(unsigned char) (*s)]) { + ch = s; + if ((*ch == '+') || (*ch == '-')) + ch++; /* optional leading + or - */ + while (isdigit(*ch)) + ch++; /* string of digits */ + if ((*ch == 0) && (isdigit(*(ch - 1)))) + *possible_ic = TRUE; + if (*ch == '.') { + ch++; /* decimal point */ + while (isdigit(*ch)) + ch++; /* string of digits */ + if ((*ch == 'e') || (*ch == 'E')) { + ch++; /* E */ + if ((*ch == '+') || (*ch == '-')) + ch++; /* optional leading + or - */ + while (isdigit(*ch)) + ch++; /* string of digits */ + } + if (*ch == 0) + *possible_fc = TRUE; + } + } + + /* --- make sure it's entirely constituent characters --- */ + for (ch = s; *ch != 0; ch++) + if (!constituent_char[(unsigned char) (*ch)]) + return; + + /* --- check for rereadability --- */ + rereadability_questionable = FALSE; + rereadability_dead = FALSE; + for (ch = s; *ch != 0; ch++) { + if (islower(*ch) || isdigit(*ch)) + continue; /* these guys are fine */ + if (isupper(*ch)) { + rereadability_dead = TRUE; + break; + } + rereadability_questionable = TRUE; + } + if (!rereadability_dead) { + if ((!rereadability_questionable) || + (length_of_s >= LENGTH_OF_LONGEST_SPECIAL_LEXEME) || ((length_of_s == 1) && (*s == '*'))) + *rereadable = TRUE; + } + + /* --- any string of constituents could be a sym constant --- */ + *possible_sc = TRUE; + + /* --- check whether it's a variable --- */ + if ((*s == '<') && (*(s + length_of_s - 1) == '>')) + *possible_var = TRUE; + + /* --- check if it's an identifier --- */ + if (isalpha(*s)) { + /* --- is the rest of the string an integer? --- */ + ch = s + 1; + while (isdigit(*ch)) + ch++; /* string of digits */ + if ((*ch == 0) && (isdigit(*(ch - 1)))) + *possible_id = TRUE; + } +} diff --git a/soar-8.5.2/kernel/libsoarkernel.a b/soar-8.5.2/kernel/libsoarkernel.a new file mode 100644 index 0000000..bd65526 Binary files /dev/null and b/soar-8.5.2/kernel/libsoarkernel.a differ diff --git a/soar-8.5.2/kernel/license.txt b/soar-8.5.2/kernel/license.txt new file mode 100644 index 0000000..3ea2d6d --- /dev/null +++ b/soar-8.5.2/kernel/license.txt @@ -0,0 +1,32 @@ +/* + * Copyright 1995-2004 Carnegie Mellon University, + * University of Michigan, + * University of Southern California/Information + * Sciences Institute. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE SOAR CONSORTIUM ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE SOAR CONSORTIUM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * The views and conclusions contained in the software and documentation are + * those of the authors and should not be interpreted as representing official + * policies, either expressed or implied, of Carnegie Mellon University, the + * University of Michigan, the University of Southern California/Information + * Sciences Institute, or the Soar consortium. + * ======================================================================= + */ \ No newline at end of file diff --git a/soar-8.5.2/kernel/make-soar-build-info b/soar-8.5.2/kernel/make-soar-build-info new file mode 100644 index 0000000..98bfe9c --- /dev/null +++ b/soar-8.5.2/kernel/make-soar-build-info @@ -0,0 +1,226 @@ +#!/usr/bin/perl + + +# make an Info File. + + +@Paths = ( "./", "../interface" ); +@FileTypes = ( '.*\.c$', '.*\.h$' ); +$Template = './soarBuildInfo.tmp'; +$InfoFile = './soarBuildInfo.c'; +$AllDefined = './BuildOptions'; +$InfoFileExists = 0; +%ExcludedFlags = ( ); + +$nFilesRead = 0; +$nFileSkipped = 0; + +print "\nLooking for old version of $InfoFile\n"; + +if ( -r $InfoFile ) { + $InfoFileExists = 1; + $InfoFileUpdate = (-C $InfoFile); +} +print "Making File: $InfoFile\n"; + + +# Now open the template and make the info file: + +open( TEMPLATE, $Template ) or die "Can't open template: '$Template'"; +open( INFO, ">$InfoFile" ) or die "Can't open Info File: '$InfoFile'"; +open( ALLDEFS, ">$AllDefined" ) or die "Can't open Defs file: '$AllDefined'"; + + +print "Reading Source Files...\n"; + +foreach $path (@Paths) { + + opendir( DIR, $path ); + @allFiles = readdir( DIR ); + + foreach $fileType (@FileTypes) { + + @files = grep( /$fileType/, @allFiles); + + foreach $file (@files) { + if ( (-C $file) > $InfoFileUpdate ) { +# print "Skipping $file\n"; +# $nFilesSkipped++; +# next; + + } + $nFilesRead++; + open( README, $path.'/'.$file) or die "can't open $file"; + + + $lines = 0; + + + PROCESS_LINE: while( ) { + + @flagsInThisLine = (); + if ( /^\s*\#ifdef\s+(\w+)/ ) { + $Flags{$1}++; + @flagsInThisLine = ($1); + + } elsif ( /^\s*\#ifndef\s+(\w+)/ ) { + $Flags{$1}++; + @flagsInThisLine = ($1); + + } elsif ( /^\s*\#if.*defined\(\s*(\w+)\).*/ ) { + + # The line begins with a #if and has at least one + # defined(XXX), find all of the flags on this line + @flgs = /defined\(\s*(\w+)\)/g ; + foreach $f (@flgs) { $Flags{$f}++; } + @flagsInThisLine = @flgs; + } + + $lines++; + + if ( /.*ExcludeFromBuildInfo(.*)/i ) { + if ( $#flagsInThisLine > -1 ) { + foreach $f (@flagsInThisLine) { + if ( $ExcludedFlags{$f} < 1 ) { + print "Excluding Flag: $f\n"; + } + $ExcludedFlags{$f}++; + } + } + else { + $_ = $1; + if ( /\s+(\w+)\W/ ) { + if ( $ExcludedFlags{$1} < 1 ) { + print "Excluding Flag: $1\n"; + + } + $ExcludedFlags{$1}++; + } + } + } + + + next PROCESS_LINE; + } + continue { + @flagsInThisLine = (); + } + + close( README ); + + } + } +} + +foreach $exFlag (keys(%ExcludedFlags)) { + if ( $ExcludedFlags{$exFlag} >= 1 ) { + if (exists $Flags{$exFlag}) { + $ExcludedFlags{$exFlag} += $Flags{$exFlag}; + delete $Flags{$exFlag}; + } + } else { + print "WARNING: Excluded Flag list is corrupted!!\n"; + } + +} +print "-------------------------------------------------------------------\n"; +print "These Flags appear only once in the source code. They may be typos\n"; +foreach $exFlag (sort(keys(%ExcludedFlags))) { + if ( $ExcludedFlags{$exFlag} <= 1 ) { + print "\t $exFlag\n"; + } +} +foreach $flag (sort(keys(%Flags))) { + if ( $Flags{$flag} <= 1 ) { + print "\t $flag\n"; + } +} +print "-------------------------------------------------------------------\n"; + +$HeadOrFoot = 1; +while( $line =