Soar::WM::Element - Work with Soar working memory elements
version 0.04
use Soar::WM qw(wm_root); my $root = wm_root(<<ENDWM); (S1 ^foo bar ^foo buzz ^baz boo ^link S2 ^link S3) (S2 ^faz far ^boo baz ^fuzz buzz) (S3 ^junk foo) ENDWM print $root->id; # 'S1' my $val = $root->first_val('link'); print $val->id; # 'S2' print $val->first_val('faz'); # 'far'
This module allows one to traverse working memory by accessing attributes and values of a single element at a time.
Soar::WM::Element - Perl extension for representing Soar working memory elements.
new
Creates a new instance of Soar::WM::Element. There are two required arguments: 1. An instance of Soar::WM which is to contain this element 2. The WME ID of this element. If the given ID does not exist in the given working memory, this method will croak.
id
Returns the WME ID of the this element ('S1', 'W3', etc.)
atts
Returns an array pointer containing the attributes present in this element.
vals
Takes one required argument, an attribute name, and returns an array pointer containing all of the values of the given attribute for this element. Any values that are names of other working memory elements will be blessed as new Soar::WM::Elements.
children
The same as vals, but returns the value of every attribute as an array pointer. The optional parameter 'links_only => 1' will cause the method to only return children which are links to other Soar::WM::Elements.
first_val
Takes one required argument, an attribute name, and returns the first value of the given attribute for this element. If the values is the names of another working memory element, it will be blessed as a new Soar::WM::Element.
num_links
Returns the number of values in all of this element's attributes which are names of other existing working memory elements.
The homepage for the Soar cognitive architecture is here: http://sitemaker.umich.edu/soar/home.
Nathan Glenn <garfieldnate@gmail.com>
This software is copyright (c) 2012 by Nathan Glenn.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Soar::WM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Soar::WM
CPAN shell
perl -MCPAN -e shell install Soar::WM
For more information on module installation, please visit the detailed CPAN module installation guide.