#region parameters numeric-indifferent-mode -s indifferent-selection -g indifferent-selection -e 0 #endregion #region Initialize ######################## # Initialize Ernest when the State has no name sp {propose*initialize-Ernest (state ^superstate nil -^name) --> ( ^operator +) ( ^name initialize-Ernest) } sp {apply*initialize-Ernest (state ^operator ) ( ^name initialize-Ernest) --> # State ( ^name Ernest ^token select ^ern # Ernest ^cnt 0 # Cycle counter ) # Ernest's initialisation ( ^thi 0 # Not thinking ^ltm # Long-term memory (stores the schemas) ^stm # Short-term memory (stores the context) ^wom ) # Working memory (stores the activated schemas) ( ^sch )( ^do |senseForward| ^wei 100) # 2 Touch forward ( ^sch )( ^do |forward| ^wei 100) # 3 Move forward ( ^sch )( ^do |turnRight| ^wei 100) # 4 Turn right ( ^sch )( ^do |turnLeft| ^wei 100) # 5 Turn left ( ^sch )( ^do |senseRight| ^wei 100) # 6 Touch right ( ^sch )( ^do |senseLeft| ^wei 100) # 7 Touch left ( ^act ) ( ^sch ^sta S ^val -1 ^tag | - Foward_wall| ^cnt 1) # Touch forward S (obstacle) ( ^act ) ( ^sch ^sta F ^val -1 ^tag | - Foward_clear| ^cnt 1) # Touch forward F (empty) ( ^act ) ( ^sch ^sta S ^val 10 ^tag | - Move_forward| ^cnt 1) # Moving forward S ( ^act ) ( ^sch ^sta F ^val -10 ^tag | - Bump_wall| ^cnt 1) # Moving forward F ( ^act ) ( ^sch ^sta S ^val -1 ^tag | - Turn_right| ^cnt 1) # Turn right S ( ^act ) ( ^sch ^sta S ^val -1 ^tag | - Turn_left| ^cnt 1) # Turn left S ( ^act ) ( ^sch ^sta S ^val -1 ^tag | - Right_wall| ^cnt 1) # Touch right S (obstacle) ( ^act ) ( ^sch ^sta F ^val -1 ^tag | - Right_clear| ^cnt 1) # Touch right F (empty) ( ^act ) ( ^sch ^sta S ^val -1 ^tag | - Left_wall| ^cnt 1) # Touch left S (obstacle) ( ^act ) ( ^sch ^sta F ^val -1 ^tag | - Left_clear| ^cnt 1) # Touch left F (empty) } #endregion #region Select ############################ # All schemas that have enough reinforcement # are proposed with a preference of 0 sp {Ernest*propose*select*schema (state ^name Ernest ^token select ^ern ) ( ^ltm ) ( ^sch ) ( ^wei > 4) # 4 (regularity threshold) --> ( ^operator + =) ( ^name select ^int ) } # Allways support primitive schemas sp {Ernest*propose*support*primary*schema (state ^name Ernest ^token select ^ern ^operator +) ( ^name select ^int ) ( ^do ) --> ( ^sup sup) } # Every activated schema (whose context matches the current context) # proposes its intention # The weight of the proposition is equal to the weight of the matching schema # multiplied by the value of the intention subschema sp {Ernest*propose*activate*schema (state ^name Ernest ^token select ^ern ^operator +) ( ^name select ^int ) ( ^stm # ^ltm ^wom ) # activated schemas ( ^cur ) # ( ^act.sch ) # ( ^act ) # ( ^sch ) ( ^con ^int ^wei ) ( ^sch ^sta ) ( ^sch ^sta ^val ) --> ( ^operator = (* )) ( ^sup sup) # (write |Match | | = ( | |=| | , | |=| |(| |) , | |) propose | | (| (* ) |)|(crlf)) } # Propagate the activation to the second level subschema # The weight of the proposition is equal to the weight of the matching schema # multiplied by the value of its intention # only if their intention has not passed the regularity threshold sp {Ernest*propose*prefer*forward*schema (state ^name Ernest ^token select ^ern ^operator +) ( ^name select ^int ) ( #^stm ^wom ) ( ^cur ) ( ^act.sch ) # ( ^act ) ( ^con ^int ^wei ) ( ^sch ^sta ^val ) ( ^con.sch ^wei < 5) ( ^sch ^sta ) --> ( ^operator + = (* )) ( ^sup sup) # (write |Match | | = ( | |=| | , | |=| |(| |) , | |) propose | | (| (* ) |)|(crlf)) } # The schemas that have support get a base activation of 100 # (only way I have found to prevent schemas that have no support from being selected) sp {Ernest*propose*support (state ^name Ernest ^token select ^ern ^operator +) ( ^name select ^int ^sup sup) --> ( ^operator = 100) } # Select the succeeding act of the most weighted schema # The act gets a token equal to con (context = first par of the schema) # Initialize a new situation. Set it equal to the current situation # Move to enact sp {Ernest*apply*select*schema (state ^operator ^ern ) ( ^name select ^int ) ( ^ltm ) # ( ^act ) # ( ^sch # ^sta S # ^val ) --> ( ^token select - ^token predict ) # enact predict ( # ^ena # Selects the succeeding act for no prediction nor think ^sch # ^sit ^temp ) # tremporary situation for convenience # ( ^tok con) # # (write |Select | |=| |S|(crlf)) # (write |Select | ||(crlf)) # (write || ||(crlf)) } #endregion #region Predict ########################### # Both acts (S and F) that match the selected schema are proposed sp {Ernest*propose*token*predict (state ^name Ernest ^token predict ^ern ) ( ^sch ^ltm ) ( ^act ) ( ^sch ) --> ( ^operator + =) ( ^name predict ^act ) } # Every activated schema whose intention is selected # proposes its predicted act # The weight of the proposition is equal to the weight of the matching schema sp {Ernest*propose*predict*schema (state ^name Ernest ^token predict ^ern ^operator +) ( ^name predict ^act ) ( ^sch ^tag ^sta ) ( ^wom ) ( ^cur ) ( ^act ) ( ^sch ) ( ^con ^int ^wei ) ( ^sch ^sta ) --> ( ^operator = ) (write |Predict | | = | | (| |) based on | | = | |S = ( | |=| | , | |=| |) | ||(crlf)) } sp {Ernest*propose*predict*subschema (state ^name Ernest ^token predict ^ern ^operator +) ( ^name predict ^act ) ( ^sch ^tag ^sta ) ( ^wom ) ( ^cur ) ( ^act ) ( ^sch ) ( ^con ^int ^wei ) ( ^sch ^sta ) ( ^con ) ( ^sch ^sta ) --> ( ^operator = ) (write |Predict | | = | | (| |) based on | | = | |S = ( | |=| | , | |=| | , | |) | ||(crlf)) } # the selected act is proposed to be enacted # the selected schema is cleared sp {Ernest*apply*predict (state ^operator ^ern ^token predict) ( ^name predict ^act ) ( ^sch ^sta ^tag ) --> ( ^token predict - ^token enact ) # think ( ^ena ^sch -) ( ^tok con) (write |Intend | |=| | | ||(crlf)) } #endregion #region Think ############################# # TOKEN sp {Ernest*propose*token*think (state ^name Ernest ^token think) --> ( ^operator + ) ( ^name think) } sp {Ernest*apply*token*think (state ^operator ) ( ^name think) ( ^token ) --> ( ^token - ^token enact) } # STARTS THINKING # If the selected act is supported by an activated schema # then start dreaming # save the curent situation sp {Ernest*apply*start*thinking (state ^name Ernest ^ern ^operator ) ( ^name think) ( ^ena ^stm ^wom ^thi 0) ( ^sch ) # ( ^con # ^int ) # ( ^sch.con ) # ( ^cur.act.sch.int ) - ( ^dre ) # to prevent from restarting dreaming because of activations in the dream --> ( ^thi 1 ^thi 0 - ^dre ) ( ^stm ^wom ^ena ) # (write |Dreaming|(crlf)) } # END THINKING # Restore the situation to its value before starting thinking sp {Ernest*apply*end*thinking (state ^name Ernest ^ern ^operator ) ( ^name think) ( ^dre ^thi 0 ^stm ^wom ^ena ) ( ^tok con) ( ^ena ^stm ^wom ) --> ( ^dre - ^stm - ^wom - ^ena - ^stm ^wom ^ena ) ( ^tok con -) # activate the schema before thinking ( ^tok con) # (write |Do | ||(crlf)) } # THINK ENACTION # During the enact phace # This operator has priority over the enact phase sp {Ernest*propose*enact*dream (state ^name Ernest ^ern ^token enact) ( ^ltm ^thi > 0) ( ^act ) ( ^sch ^tok con) # ( ^do ) No need to go through all the details!!! The enacted schema is dreamed to succeed --> ( ^operator + >) ( ^name dream ^act ) } # The selected act succeeds # Whatever its expectation # Decrements the thinking counter sp {Ernest*apply*enact*dream (state ^name Ernest ^ern ^operator ) ( ^name dream ^act ) ( ^thi ) ( ^tok con ^tag ) --> ( ^don ^thi - ^thi (- 1 )) ( ^tok con - ^tok S) (write || ||(crlf)) } #endregion #region Initialise Recursive Subacts ###### # When an act's token is con # and its schema's context has not yet a token # then its schema's context gets a token equal to con sp {Ernest*propose*subschema*con (state ^name Ernest ^ern ^token enact) # ( ^ltm ) ( ^act ) ( ^tok con ^sch.con ) - ( ^tok ) --> ( ^operator +) ( ^name subcon ^con ) } sp {Ernest*apply*subschema*con (state ^name Ernest ^operator ) ( ^name subcon ^con ) --> ( ^tok con) # (write |Context: | | expects | (crlf)) } # When an act's token is int (intention = second part of the schema) # and its schema's intention has not yet a token # Then its schema's intention schema gets a token equal to con sp {Ernest*propose*subschema*int (state ^name Ernest ^ern ^token enact) ( ^ltm ) ( ^act ) ( ^tok int ^sch.int ) - ( ^tok ) --> ( ^operator +) ( ^name subint ^int ) } sp {Ernest*apply*subschema*int (state ^name Ernest ^operator ) ( ^name subint ^int ) --> ( ^tok con) # (write |Intention: | | expects | (crlf)) } #endregion #region Lowest State ###################### # If Ernest is not dreaming # then send the action to the output sp {Ernest*output*schema (state ^name Ernest ^token enact ^io.output-link ^ern ) ( ^ltm ^thi <= 0) ( ^act ) ( ^sch ^tok con) ( ^do ) - ( ^dre ) --> ( ^|vacuum.types.action| ) ( ^move ) (write || ||(crlf)) } #endregion #region Environment ####################### # When a schema has a do and a token equal con # and there is a response from the environment sp {Substate*propose*vacuum (state ^name Ernest ^ern.ltm ^token enact ^io.input-link ) ( ^|vacuum.types.position| ) ( ^get ) ( ^act ) ( ^sch ^tok con) ( ^do ) --> ( ^operator +) ( ^name vacuum ^act ^get ) } # Get the response from the environment # The elementary act is retrieved # If the response matches the act status # Then the act tok is set to S sp {Substate*apply*vacuum*don (state ^name Ernest ^ern ^operator ) ( ^name vacuum ^act ^get ) ( ^ltm ) ( ^sta ^tok con) --> ( ^don ) ( ^tok con - ^tok S) # (write |Get act || = | ||(crlf)) } # If the response does not matches the act status # the act tok is set to F # The actually enacted act is memorized as don sp {Substate*apply*vacuum*fai (state ^name Ernest ^ern ^operator ) ( ^name vacuum ^act ^get ) ( ^ltm ) ( ^act ) # ( ^sta { <> } Does not work I dont know why?? ( ^sta <> ^sch ^tok con) ( ^sta ^sch - ^tok ) --> ( ^don ) ( ^tok con - ^tok F) # (write |Get act || = | ||(crlf)) } #endregion #region Assess the substate ############### # CONTEXT SUCCEED # An act has a tok = con # and a schema's context with a tok = S # The act token is moved to int # The schema's context is desactivated # the don act is cleared sp {Ernest*propose*current*context*succeed (state ^name Ernest ^ern ) ( ^ltm ) ( ^act ) ( ^sch.con ^tok con) ( ^tok S) --> ( ^operator +) ( ^name consuc ^act ) } sp {Ernest*apply*current*context*succeed (state ^ern ^operator ) ( ^don ) ( ^name consuc ^act ) ( ^tok con ^sch.con ) ( ^sta ^val ^tok S ^sch ) --> ( ^don -) ( ^tok con - ^tok int) ( ^tok S -) (write || |=| |(| |) Correct|(crlf)) } # INTENTION SUCCEED # An act has a tok = int # and a schema's intention with a tok = S # The schema's intention is desactivated # If the act had an expectation of S # The act token is moved to don # It is memorized as don instead of the previous one sp {Substate*propose*current*intention*succeed (state ^ern ) ( ^ltm ) ( ^act ) ( ^sch.int ^tok int) ( ^tok S) --> ( ^operator +) ( ^name intsuc ^act ) } # The succeeding act was created when the schema was created sp {Ernest*apply*current*intention*succeed*expected (state ^ern ^operator ) ( ^ltm ^don ) ( ^name intsuc ^act ) ( ^tok int ^sch ^sta S) ( ^wei ^int ) ( ^sch ^sta ^val ^tok S) --> ( ^don ^don -) ( ^tok int - ^tok S) ( ^tok S -) ( ^wei - ^wei (+ .02 )) (write || |=| |(| |) Correct|(crlf)) } # If the act had an expectation of F # The act token is moved to F # the succeeding act is memorized as done instead of the previous one sp {Ernest*apply*current*intention*succeed*unexpected (state ^ern ^operator ) ( ^ltm ^don ) ( ^act ) ( ^sch ^sta S) ( ^name intsuc ^act ) ( ^tok int ^sch ^sta F) ( ^int ^wei ) ( ^sch ^sta ^val ^tok S) --> ( ^don ^don -) ( ^tok int - ^tok F) ( ^tok S -) ( ^wei - ^wei (+ .02 )) (write || |=| |(| |) Incorrect|(crlf)) } # CONTEXT FAIL # An act has a tok = con # and a schema's context with a tok = F sp {Ernest*propose*context*failed (state ^name Ernest ^ern ) ( ^ltm ) ( ^act ) ( ^sch.con ^tok con) ( ^tok F) --> ( ^operator +) ( ^name confail ^act ) } # if the act had a expectation of S # The act's token is moved to fai # Its schema's context is cleared # and the done act remains sp {Ernest*apply*context*failed*unexpected (state ^ern ^operator ) ( ^name confail ^act ) ( ^sch.con ^tok con ^sta S) ( ^tok F ^val ^sta ^sch ) --> ( ^tok con - ^tok F) ( ^tok F -) (write || | = | |(| |) Incorrect|(crlf)) } # If the act had an expectation of F # The act's token is moved to S # Its schema's context is cleared # and the done act remains # TODO or the done act should be the failing act sp {Ernest*apply*context*failed*expected (state ^ern ^operator ) ( ^name confail ^act ) ( ^sch.con ^tok con ^sta F) ( ^tok F ^val ^sta ^sch ) --> ( ^tok con - ^tok S) ( ^tok F -) (write || | = | |(| |) Correct|(crlf)) } # INTENTION FAIL # If there is an act with an token equal to int # and its schema's intention is F # Then create operator intfail sp {Ernest*propose*intention*failed (state ^name Ernest ^ern ) ( ^ltm ) ( ^act ) ( ^sch.int ^tok int) ( ^tok F) --> ( ^operator +) ( ^name intfail ^act ) } # If the act had an expectation of S # The act's token is moved to fai # Its schema's intention is cleared # The don is cleared to be remplaced sp {Ernest*apply*intention*failed*unexpected (state ^ern ^operator ) ( ^name intfail ^act ) ( ^don ^ltm ) ( ^sch ^sta S) ( ^int ) ( ^sta ^val ^tok F ^sch ) --> ( ^tok int - ^tok F) ( ^tok F -) ( ^don -) (write || | = | |(| |) Incorrect|(crlf)) } # If the act had an expectation of F # The act's token is moved to S # Its schema's intention is cleared # The don is cleared to be remplaced sp {Ernest*apply*intention*failed*expected (state ^ern ^operator ) ( ^name intfail ^act ) ( ^don ^ltm ) ( ^sch ^sta F) ( ^int ) ( ^sta ^val ^tok F ^sch ) --> ( ^tok int - ^tok S) ( ^tok F -) ( ^don -) (write || | = | |(| |) Missed|(crlf)) } # Memorize the done schema # its context is the context of the curent schema # its intention is the last don act # If it already exists sp {Ernest*apply*intention*failed*done*exist (state ^ern ^operator ) ( ^name intfail ^act ) ( ^sch.con ) ( ^ltm ^don ) ( ^act ^sch ) ( ^con ^int ) ( ^sch ^sta S) --> ( ^don ) # (write || |S (| |) Unexpected|(crlf)) } # If the done schema does not exist # then create the done schema and the done act sp {Ernest*apply*intention*failed*construct*done (state ^ern ^operator ) ( ^name intfail ^act ) ( ^sch.con ) ( ^ltm ^don ) ( ^sch ^sta ^val ) ( ^sch ^sta ^val ) - {( ^sch )( ^con ^int )} --> ( ^don ) ( ^act ^act ^sch ) ( ^sch ^sta S ^val (+ )) ( ^sch ^sta F ^val -5) ( ^con ^int ^wei 1) (write |Construct | | = | |S| (+ ) | = ( | | = | | , | | = | | , 1 )|(crlf)) } #endregion #region Assess ############################ # TOKEN enact -> assess -> learn # When the selected act has a tok = S or F sp {Ernest*propose*token*assess (state ^name Ernest ^token enact ^ern ) ( ^ena ) ( ^tok << S F >>) --> ( ^operator + ) ( ^name assess ^ena ) } # Decrement the counter # Clear the enacted act and the performed act # The performed act is in the situation # The performed act is a base for activation sp {Ernest*apply*token*assess (state ^cnt ^operator ^token ^cnt ^ern ) ( ^name assess ^ena ) ( ^sit ^don ) ( ^tok ) ( ^sch ^sta ^tag ) --> ( ^token - ^token learn ^cnt - ^cnt (+ 1)) ( ^ena - ^don - ^con ) ( ^tok -) ( ^act ) (write |Situation done | |=| | | ||(crlf)) } # If the performed act has an intention and it succeeded # then the intention is also in the situation # (necessary for proposing same-level schema at the next cycle) sp {Ernest*sit*don*sub (state ^name Ernest ^ern ^operator ) ( ^name assess) ( ^sit ^don ) ( ^sch ^sta S) ( ^int ) ( ^sch ^sta ^tag ) --> ( ^act ) (write |Situation done's intention | |=| ||(crlf)) } # Succeeding act correctly enacted # The performed act is observed sp {Ernest*apply*token*assess*S*S (state ^operator ^ern ) ( ^name assess ^ena ) ( ^sta S ^tok S ^sch ^tag ) --> ( ^obs ) (write |Correct | |=| |S | ||(crlf)) } # Succeeding act incorrectly enacted # The observed act is the fail act # The failing act is in the situation # The failing act is a base for activation sp {Ernest*apply*token*assess*S*F (state ^ern ^operator ) ( ^name assess ^ena ) ( ^ltm ^don ^sit ) ( ^act ) ( ^sta S ^tok F ^sch ) ( ^sch ^sta F ^tag ) ( ^sch ^sta ^tag ) --> ( # ^don # ^fai ^suc ^obs ^con ) ( ^act ) (write |Incorrect | |=| | | ||(crlf)) (write |Situation fail | |=| |F | ||(crlf)) (write |Oh!|(crlf)) } # Failing act succeeded (incorrect enaction) # The observed act is the succeeding act sp {Ernest*apply*token*assess*F*S (state ^ern ^operator ) ( ^name assess ^ena ) ( ^ltm ^don ) ( ^sta F ^tok F ^sch ) ( ^sch ^sta ^tag ) --> ( ^obs ) (write |Incorrect | |=| | | ||(crlf)) (write |Oh!|(crlf)) } # Failing act Failed (correct enaction) # The observed act is the enacted act sp {Ernest*apply*token*assess*F*F (state ^ern ^operator ) ( ^name assess ^ena ) # ( ^don ) ( ^sta F ^tok S ^sch ^tag ) --> ( ^obs ) (write |Correct | |=| |F | ||(crlf)) } #endregion #region Learn ############################# # TOKEN assess -> learn -> context sp {Ernest*propose*token*learn (state ^name Ernest ^token learn) --> ( ^operator + ) ( ^name learn) } sp {Ernest*apply*token*learn (state ^operator ^token ) ( ^name learn) --> ( ^token - ^token forget) } # ASSESS FAIL # If the schema has failed and its act has a val (satisfaction value) # the val is the average between the previous val and the don schema val sp {Ernest*apply*val*fail*update (state ^name Ernest ^ern ^operator ) ( ^name learn) ( ^suc ^obs ^thi <= 0) ( ^sch ^val ^tag ^sta F) ( ^val ^tag ) - ( ^dre ) --> ( #^fai - ^suc -) ( ^val - ^val #(/ (+ ) 2 ) ^tag - ^tag ) (write |Fail | | = | |F ( | | -> | | ) from | || (crlf)) } # LEARN BY OBSERVATION (first learning mechanism) # Search the existing schemas that match the obtained situation # Their context is the previous context # Their intention is the done schema # They are part of the new situation # Increment their weight sp {Ernest*apply*assess (state ^name Ernest ^ern ^operator ) ( ^name learn) ( ^obs ^temp ^ltm ^stm ^thi <= 0) ( ^act ) ( ^sch ^act ) ( ^sch ^sta S ^tag ) ( ^con ^int ^wei ) ( ^sch ^sta )( ^sch ^sta ) - ( ^dre ) --> ( ^act ) ( ^wei (+ 1) ^wei - ) (write |Observe | |=| |S = ( | |=| | , | |=| | , | (+ 1) | ) | || (crlf)) } # Construct higher level schemas that do not exist # Construct their succeed and fail acts # their succeeding act is in the situation # Their fail value is set to -5. Ernest is not able to assess the real cost of failure, but he just doesn't like to fail. sp {Ernest*apply*construct (state ^name Ernest ^ern ^operator ) ( ^name learn) ( ^obs ^ltm ^stm ^temp ^thi <= 0) ( ^act ) ( ^sch ^sta ^val ) ( ^sch ^sta ^val ) - {( ^sch )( ^con ^int )} - ( ^dre ) # ( ^do ) # limit level # ( ^do ) # limit level --> ( ^sch ^act ^act ) ( ^act ) ( ^sch ^sta S ^val (+ )) ( ^sch ^sta F ^val -5 ) ( ^con ^int ^wei 1) (write |Observe | |=| |S(| (+ ) |) = ( | |=| | , | |=| | , 1 )| (crlf)) } # LEARN BY INDUCTION (second learning mechanism) # For all activated acts # If the schema intention matches what was done # then they are completed # if the higher schema does not exist then it is created sp {Ernest*apply*done*cur (state ^name Ernest ^ern ^operator ) ( ^name learn) #limits learning ( ^ltm ^wom ^obs ^temp ^thi <= 0) ( ^cur ) ( ^sit ^act ) ( ^act ) ( ^sta ^sch ^val ) ( ^sch ) ( ^int ) ( ^act ) ( ^sch ^sta S ^val ) - {( ^sch )( ^con ^int )} - ( ^dre ) --> ( ^sch ^act ^act ) ( ^act ) ( ^sch ^sta S ^val (+ )) ( ^sch ^sta F ^val -5 ) ( ^con ^int ^wei 1) (write |Confirm | | = | |S(| (+ ) |) = ( | |=| | , | |=| |S , 1)|(crlf)) } # if the second order schema already exists # then reinforce it # Its succeeding act is in the situation sp {Ernest*apply*done*cur*reinforce (state ^name Ernest ^ern ^operator ) ( ^name learn) ( ^ltm ^wom ^obs ^temp ^thi <= 0) ( ^act ^sch ) ( ^cur ) ( ^sit ^act ) ( ^act ) ( ^sch ) ( ^sch ^tag ^sta S) ( ^con ^int ^wei ) ( ^sta ^sch ) ( ^sch ^sta S) ( ^int ) - ( ^dre ) --> ( ^act ) ( ^wei (+ 1) ^wei -) (write |Confirm | | = ||S = ( | |=| | , | |=||S , |(+ 1)|) | ||(crlf)) } # Clear working memory # TODO keep ongoing activations? sp {Ernest*apply*abort*cur (state ^name Ernest ^ern ^operator ) ( ^name learn) ( ^wom ) --> ( ^wom - ^wom ) } #endregion #region forget ############################# # (not currently used) # TOKEN assess -> learn -> context sp {Ernest*propose*token*forget (state ^name Ernest ^token forget) --> ( ^operator + ) ( ^name forget) } sp {Ernest*apply*token*forget (state ^operator ^token ) ( ^name forget) --> ( ^token - ^token context) } sp {Ernest*apply*forget (state ^ern ^operator ^token ) ( ^name forget) ( ^ltm ) ( ^sch ) ( ^wei > 0) --> ( ^wei - ^wei (- .01)) } sp {Ernest*apply*clear (state ^ern ^operator ^token ) ( ^name forget) ( ^ltm ) ( ^sch ^act ) ( ^sch ^sta ^eff ^tag ) ( ^wei <= 0) --> ( ^sch - ^act -) (write |Forget | |=| ||(crlf)) } #endregion #region Situation ######################### # token context -> trace sp {Ernest*propose*token*memo (state ^name Ernest ^token context) --> ( ^operator + ) ( ^name context) } sp {Ernest*apply*token*memo (state ^operator ^token ) ( ^name context) --> ( ^token - ^token select) } # SITUATION # Creates the curent situation # Includes the done act sp {Ernest*sit*don (state ^name Ernest ^ern ^operator ) ( ^name contextooooo) ( ^sit ^don ) ( ^sch ^sta ^tag ) --> ( ^act ) (write |Situation done | |=| | | ||(crlf)) } # The top situation acts are in the situation # Only if their schemas are based on frozen schemas sp {Ernest*apply*memo*context (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^sit ^temp ) ( ^act ) ( ^sch ^sta ^tag ) ( ^sch.con.sch.wei > 4) ( ^sch.int.sch.wei > 4) --> ( ^act ) (write |Situation top | |=| | | || (crlf)) } # ACTIVATION # Succeeding Acts that have a schema that is in the situation are activated # The activation is associated to the previous situation # (Acts from the curent situation do not create activation because their context is lost anyway) # (The previous situation will be kept as long as there is an activated schema based on it) sp {Ernest*propose*activate*schema*don (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^stm ^ltm ^wom ^con ) ( ^act ) ( ^sch ^tag ^sta S) ( ^con ^int ^wei ) ( ^sch ^sta ) ( ^sch ^sta ) --> ( ^cur ) ( ^sit ^act ) (write |Activate | | = | |S = ( | |=| | , | |=| | , | |) | ||(crlf)) } # Activate schema from the don's intention sp {Ernest*propose*activate*schema*don*int (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^ltm ^wom ^con ) ( ^sch ^sta S) ( ^con ^int ) ( ^act ) ( ^sch ^tag ^sta S) ( ^con ^int ^wei ) ( ^sch ^sta ) ( ^sch ^sta ) --> ( ^cur ) ( #^sit ^act ) # ( ^act ) Dont construct schema by confirmation from an int activation (write |Activate int | | = | |S = ( | |=| | , | |=| | , | |) | ||(crlf)) } # Activates schema from the top situation # These activations are used for the selection but not for the learning # because they are not attached to any situation. sp {Ernest*propose*activate*schema*temp (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^ltm ^wom ^temp ) ( ^act ) ( ^act ) ( ^sch ^tag ^sta S) ( ^con ^int ^wei ) ( ^sch ^sta ) ( ^sch ^sta ) ( ^sch.con.sch.wei > 4) ( ^sch.int.sch.wei > 4) --> ( ^cur ) ( ^act ) (write |Activate top | | = | |S = ( | |=| | , | |=| | , | |) | ||(crlf)) } # SHIFT # The curent situation becomes the short term memory situation # and the previous stm is only supported by the activations sp {Ernest*apply*memo*clear*old*context (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^stm ^sit ) --> ( ^stm - ^stm ^sit -) # (write |Clear old context | (crlf)) } # CLEAR # Clear the done acts sp {Ernest*apply*memo*clear*obs (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^obs ) --> ( ^obs -) } sp {Ernest*apply*memo*clear*con (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^con ) --> ( ^con -) } # Clear the temporary situation sp {Ernest*apply*memo*clear*context (state ^name Ernest ^ern ^operator ) ( ^name context) ( ^temp ) --> ( ^temp -) } # If the done act is secondary # and it is a repetition # then say Bored! #sp {Ernest*apply*boring # (state ^name Ernest # ^ern # ^operator # ^cnt # ^token ) # ( ^name context) # ( ^don ) # ( ^sch.con # ^sch.int # ^tag # ^val # ^cnt ) # ( ^sch.con ) ## - ( ^sta dream) #--> ## ( ^sta dream) # ( ^name Ernest - # ^ern - # ^token - # ^cnt - ) # (write |Bored!|(crlf)) ## (write |Stop,| |,| |,| |,| (/ )|,| ||(crlf)) # } #endregion #region Trace ############################# # When a new act is constructed # its tag is the concatenation of its con and int tags sp {Ernest*tag*act (state ^name Ernest ^ern ) ( ^ltm ) ( ^act ) ( ^sch.con ^sch.int ^val ) ( ^tag ^cnt ) ( ^tag ^cnt ) --> ( ^tag (concat ) ^cnt (+ ) ^eff (/ (+ )) ) } # If the done act is secondary # and it is not a repetition # then say Good! #sp {Ernest*trace*secondary # (state ^name Ernest # ^ern # ^token context) # ( ^don ) # ( ^sch.con # ^sch.int {<> }) # ^sch.int {<> }) # ^sch.int <> ) # ( ^sch.con ) #--> # (write |Good!|(crlf)) #} #endregion