# Framework for Incorporating Artificial Somatic Markers in the Decision-Making of Autonomous Agents
## 4 Design of Artificial Somatic Markers for Decision-Making of Autonomous Agents
### Designing Algorithms for the Decision-Making of Autonomous Agents  
This subsection includes the design of a set of algorithms for the decision-making of autonomous agents, by considering the incorporation of artificial somatic markers. The main objective of algorithm 1 is to recognize a decision context. It begins with the identification of a new stimulus. It should be noted that in the present research, a stimulus is understood as a signal (internal or external) that can generate some type of reaction in the autonomous agent. After a stimulus is detected, it is required to determine its origin. It is important to note that if the stimulus is the product of an autonomous agent's own process (cognitive or of another nature), its origin is understood as \"internal\". Conversely, if the stimulus is triggered outside the autonomous agent, then its origin is understood as \"external\". Another relevant aspect is determining the type of stimulus detected. In the present research work, the types of stimuli considered are associated to the evocation of specific and different sensations, and that by themselves have the potential capacity to generate a reaction in the autonomous agent, such as threat, opportunity, joy, sadness, fear, surprise, anger. It is also considered a \"neutral\" type of stimulus. Except for the neutral type, the emotional state is updated in each case (according to the type of stimulus detected). Then, for all types of stimulus, algorithm 2 is called, indicating the received stimulus and its type in the call. ```
Begin
1 newStimulus = get_Stimuli( )
2 stimulusOrigin = determine Origin (newStimulus)
3 /*stimulusOrigin! {external'; 'internal'} */
4 stimulusType = get Stimulus Type (newStimulus) /* using past somatic reactions */ /*stimulusType! {threat'; 'opportunity'; 'joy';'sadness'; 'fear';'surprise'; 'anger'; 'neutral'} */
5 If (stimulusType!='neutral')
6 emotional_effects = get Emotional Effects (newStimulus, stimulusType) /*emotional updating*/
7 EndIf
8 Determination of the Courses of Action (newStimulus, stimulusType) EndAlgorithm 1

Figure 1: General view of decision-making phases. On the other hand, algorithm 2 aims to determine alternative courses of action based on the stimulus detected. For this, first, a list of past goals that are associated with the detected stimulus or its type is obtained. A past goal corresponds to an objective that the autonomous agent tried to achieve, and, therefore, there is a record of it within his long-term memory. In this sense, to reach this goal, some actions have to be identified and executed. Thus, step two obtains the record of actions carried out based on past goals, always associated with the detected stimulus. Next, both the list of past goals and the list of past actions give rise to a list of levels of success achieved. In the next step, a list of emotional effects is obtained considering the past actions and the levels of success achieved. ```
1:\(\{\)stimulus; stimulusType\(\}\) Begin
2:\(\{\)  
On the other hand, for the rest of the stimulus types, it is important to note that they all suggest a \"normal\" (not \"fast\") treatment. For stimuli of the \"joy\" type, actions and goals with a \"neutral\" profile are sought. Meanwhile, for stimuli of the \"sadness\" type, actions and goals that have given \"joy\" in the past are sought. Similarly, for stimuli of the \"fear\" type, actions and goals that have given \"confidence\" in the past are sought. For stimuli of the \"surprise\" type, actions and goals with a \"neutral\" profile are sought. Meanwhile, for stimuli of the \"anger\" type, actions and goals are sought that in the past have given \"tranquility\". In all these cases, a call is made to the \"analysis of decision options\" algorithm, providing a refined list of actions, a refined list of goals, also indicating the type of stimulus and that a \"normal priority\" response is required.