################################################################## # Elaboration productions sp { elaborate*init (state ^superstate nil) --> ( ^close-distance 800) } sp { elaborate*robot*stopped (state ^io.input-link.currentcycle.robot.Vel 0.0) --> ( ^condition robot-stopped) } sp { elaborate*robot*moving (state ^io.input-link.currentcycle.robot.Vel { <> 0.0 } ) --> ( ^condition robot-moving) } sp { elaborate*object-nearby-in-front (state ^io.input-link.currentcycle ) ( ^sonar.sonar ) ( ^close-distance ) ( ^number << 2 3 4 5 >> ) ( ^reading { < } ) --> ( ^condition object-nearby-in-front) } sp { elaborate*object-nearby-to-right (state ^io.input-link.currentcycle ) ( ^sonar.sonar ) ( ^close-distance ) ( ^number << 6 7 >> ) ( ^reading { < } ) --> ( ^condition object-nearby-to-right) } sp { elaborate*object-nearby-to-left (state ^io.input-link.currentcycle ) ( ^sonar.sonar ) ( ^close-distance ) ( ^number << 0 1 >> ) ( ^reading { < } ) --> ( ^condition object-nearby-to-left) } ################################################################## # Operators sp { propose*move*forward (state ) ( ^condition robot-stopped) - ( ^condition object-nearby-in-front) - ( ^action moving-forward) --> ( ^operator + = ) ( ^name move-forward) ( ^target-velocity 200) } sp { apply*move*forward (state ^io.output-link
    ^operator ) ( ^name move-forward) ( ^target-velocity ) --> ( ^action moving-forward) (
      ^command ) ( ^name setVel ^param1 ) } # turn right sp { propose*start*turn*right (state ) ( ^condition object-nearby-in-front) - ( ^condition object-nearby-to-right) - ( ^action turning-right) --> ( ^operator + =) ( ^name start-turn-right) } sp { apply*start*turn*right (state ^io.output-link
        ^operator ) ( ^name start-turn-right) --> ( ^action turning-right) (
          ^command ) ( ^name setVel2 ^param1 150 ^param2 0) } sp { propose*stop*turn*right (state ) - ( ^condition object-nearby-in-front) ( ^action turning-right) --> ( ^operator + =) ( ^name stop-turn-right) } sp { apply*stop*turn*right (state ^io.output-link
            ^operator ) ( ^name stop-turn-right) --> ( ^action turning-right -) (
              ^command ) ( ^name setVel ^param1 200) } # turn left sp { propose*start*turn*left (state ) ( ^condition object-nearby-in-front) - ( ^condition object-nearby-to-left) - ( ^action turning-left) --> ( ^operator + =) ( ^name start-turn-left) } sp { apply*start*turn*left (state ^io.output-link
                ^operator ) ( ^name start-turn-left) --> ( ^action turning-left) (
                  ^command ) ( ^name setVel2 ^param1 0 ^param2 150) } sp { propose*stop*turn*left (state ) - ( ^condition object-nearby-in-front) ( ^action turning-left) --> ( ^operator + =) ( ^name stop-turn-left) } sp { apply*stop*turn*left (state ^io.output-link
                    ^operator ) ( ^name stop-turn-left) --> ( ^action turning-left -) (
                      ^command ) ( ^name setVel ^param1 200) } # rotate sp { propose*start*rotate (state ) ( ^condition object-nearby-in-front) ( ^condition object-nearby-to-right) ( ^condition object-nearby-to-left) - ( ^action rotating) --> ( ^operator + =) ( ^name start-rotating) } sp { apply*start*rotate (state ^io.output-link
                        ^operator ) ( ^name start-rotating) --> ( ^action rotating) (
                          ^command ) ( ^name setVel2 ^param1 -100 ^param2 100) } sp { propose*stop*rotate (state ) - ( ^condition object-nearby-in-front) ( ^action rotating) --> ( ^operator + =) ( ^name stop-rotating) } sp { apply*stop*rotate (state ^io.output-link
                            ^operator ) ( ^name stop-rotating) --> ( ^action rotating -) (
                              ^command ) ( ^name setVel ^param1 200) } # Wait operator sp { propose*wait*operator (state ^attribute state ^choices none -^operator.name wait) --> ( ^operator +) ( ^name wait) } sp { apply*wait*operator (state ^operator ) ( ^name wait) --> ( ^random elaboration) } ################################################################## # Action removal production # The test of the output-link guarantees that # 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 { apply*remove-command (state ^io.output-link
                                ) (
                                  ^command ) ( ^status complete) ( ^operator.name ) --> (
                                    ^command -) }