############################################################################
# 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> -)}

