Author Topic: Anyone ever used Soar?  (Read 4732 times)

Offline thenightwassaved

  • Bot Neophyte
  • *
  • Posts: 2
    • View Profile
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.

« Last Edit: March 13, 2009, 11:18:30 PM by thenightwassaved »

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Anyone ever used Soar?
« Reply #1 on: March 15, 2009, 12:19:41 AM »
If you are into weird programming languages, try a functional language, like Haskell. It is really odd. For example: things like "x = x + 1" don't exist; it's impossible to change the value of a variable after it has been assigned. Also, there are no "loops". And things are usually not evaluated in the order you write them.

Although, if you can overcome the strangeness for long enough, it causes a big shift in thought process. It may initially seem something like this can't possibly be used for programming, but it (eventually) makes sense from a mathematical viewpoint.
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Anyone ever used Soar?
« Reply #2 on: April 02, 2009, 01:48:24 PM »
Been stearing around this topic for a while... currently toying with perl, then I need to realy get the hang of templates... and theres a lot of other smaller things I could probably get a better grip on.
But the topic just stayed on the main page, staring at me... so had to see what it was.

Not so sure I want to look at Soar though, but I definately need to try Haskell now. Hadn't thought about it this way before, but it's obviously a great way to get a much better grip on the use of math when coding, and I bet it's also good for training the recursive way of thinking.
By limiting your options to pure math you're forced to explore all those paths you usualy avoid because it requires thinking.
But my todo list is already huge... this is just making things worse... and can't figure out hoe to put a priority on it, this is something I realy need.

(First time Abyaly mentioned it I thought of it as another math programming laguage like matlab and such. But you're making a great point here, the lack of other options forces you to change the way you think, I just HAVE to try it now!)

Offline abyaly

  • Bot Destroyer
  • ***
  • Posts: 363
    • View Profile
Anyone ever used Soar?
« Reply #3 on: April 04, 2009, 08:05:38 PM »
Now that I look at it, that was a lousy sales pitch. I didn't even mention the positive aspects of the language
To make up for it, here is the most popular example of why Haskell is awesome:
Code: [Select]
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ qsort (filter (>= x) xs)
This is quicksort. Even though it's been compressed into two lines, this implementation is still more clear than most languages can manage. Isn't that amazing?
« Last Edit: April 04, 2009, 08:09:15 PM by abyaly »
Lancre operated on the feudal system, which was to say, everyone feuded all
the time and handed on the fight to their descendants.
        -- (Terry Pratchett, Carpe Jugulum)

Offline Moonfisher

  • Bot Overlord
  • ****
  • Posts: 592
    • View Profile
Anyone ever used Soar?
« Reply #4 on: April 07, 2009, 03:41:17 AM »
Yeah..... figured if I slept on it.... maybe I'd get it... but no...
I think I understand part of the syntax... a very small part
But maybe once I learn Haskell this will make more sence
Still haven't figured out where to put it on my todo list, I can only do one thing at the time, I'd be terrible at joggeling.