Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - thenightwassaved

Pages: [1]
1
Off Topic / Anyone ever used Soar?
« on: March 13, 2009, 11:08:32 PM »
Link is: http://sitemaker.umich.edu/soar/home

(Disclaimer: It has been a awhile since I used this last. I might get some things wrong or remember things incorrectly. If anyone knows the correct workings please do correct me.)

I first got into it when a friend had to learn it for school. The whole idea of programming outside the usual C/C++ style was weird. My first look at a soar program was "wait, how this this even work...?" and I'm sure if I saw a darwinbot back then I would feel the same. Learning soar made the transition into darwinbots easier but I really miss some features of soar.

Eaters is a sim environment provided with the soar package. The provide some "agents" and the tutorial is based around writing these. I want to post a small example of a soar eaters agent (it is further developed in the tutorial) in order to discuss some interesting things I liked:

Code: [Select]
############################################################################
# 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 <s> ^io.input-link.my-location.<dir>.content
                 << normalfood bonusfood >>)
-->
   (<s> ^operator <o> + =)
   (<o> ^name move-to-food
        ^direction <dir>)}

# 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 <s> ^io.output-link <ol>
              ^operator <o>)
   (<o> ^name move-to-food
        ^direction <dir>)
-->
   (<ol> ^move.direction <dir>)}

# 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 <s> ^io.output-link <ol>
              ^operator.name move-to-food)
   (<ol> ^move <move>)
   (<move> ^status complete)
-
   (<ol> ^move <move> -)}

The text after "sp{" is the name for the condition and follows a convention. The propose* tests wether something should be done and then sets the state and any options so the apply* condition can do the actual change.

For example, in propose*move-to-food the <dir> is a variable that gets caught when io.input-link.my-location.<dir>.content equals normalfood or bonusfood (these are defined in the sim) and is passed to apply*move-to-food by being stored in ^direction and at the same time ^name is being set to move-to-food.

Soar works by collecting all the propose* rules and then selecting one, then running the apply* that matches. There is also more like learning that soar can do. Furthermore, all rules can have precedence over each other that each rule can itself set.

To be honest, it has been a while since I used it. At least take a look at the documentation (I can only find it from the download so far) or at least check out the Eaters game (and load an agent).

I guess more than anything I want to hear some thoughts on soar or the code or anything similar in darwinbots.


Pages: [1]