# Implementation of DEvelopmentAl Learning (IDEAL) Course

## Implementation of interactional motivation

Interactional motivation is compatible with the motivation to predict results introduced on Page 13. We can imagine agents implemented with the two motivational principles concurrently. For simplicity, however, the algorithm in Table 23 only implements interactional motivation.

Table 23: Algorithm of a rudimentary interactionally motivated system.

01   createPrimitiveInteraction(e1, r1, -1)
02   createPrimitiveInteraction(e2, r2, 1)
03   experiment = e1
04   While()
05      if (mood = PAINED)
06         experiment = getOtherExperiment(experiment)
07      if (experiment = e1)
08         result = r1
09      else
10         result = r2
11      enactedInteraction = getInteraction(experiment, result)
12      if (enactedInteraction.valence ≥ 0)
14      else
15         mood = PAINED
16      print experiment, result, mood

Table 23, line 01: Interactions ⟨e1,r1⟩ is stored in memory and set with a negative valence (-1). 02: Interaction ⟨e2,r2⟩ is stored in memory and set with a positive valence (1). 04: If the agent is pained then it picks another experiment. Lines 07 to 10 implement the same environment as on Page 13. 11: Retrieves the enacted interaction from the experiment and the result 12 to 15: if the enacted interaction has a positive valence then the agent is pleased, otherwise it is pained.

Notably, if more interactions were specified, the agent would stick to the first interaction it tried that has a positive valence. If all the interactions had a negative valence, the agent would keep trying other interactions. This behavior is still very primitive. In the following lessons, we will address the problem of "scaling up" towards more intelligent behaviors in more complex environments.

If you have no interest in programming, then you can skip the rest of this page and proceed to the next page.

If you are doing the programming activities, then begin with running Existence020 (below), which implements the algorithm in Table 23, and observe that you obtain the trace shown in Table 24.

Project 2 (files to modify or to add to Project 1):

• main / Main ← Uncomment the instruction to run Existence020 instead of Existence010.
• existence / Existence020 ← Overrides Existence010 and implements the algorithm in Table 23.
• coupling / interaction / Interaction020 ← Overrides Interaction010 and adds a valence attribute.

Additionally, your programming activity is to modify Existence020 so that the agent implements self-satisfaction (as we did on Page 13) in addition to interactional motivation.

So, you can observe in the trace that, as long as the agent is not bored, it chooses experiments that result in interactions that have a positive valence, and when it gets bored, it chooses another experiment even though it knows that this experiment may result in a painful interaction.

You will find that there is not a unique solution to associate these two motivational principles. For example, you will have to choose where the boredom comes from; it may come from enacting always the same interaction or simply from always being pleased. It is likely that different developers will implement different agents that generate different behaviors, and this is perfectly fine. You can just follow our favorite guideline: do the simplest you can.

If you are re-implementing this project in a different language, it is not necessary to reproduce the hierarchy of classes. You can simply modify your previous version to integrate the changes shown in Project 2. The hierarchy of classes has only been done for pedagogical purpose, to highlight the changes from one version to the next. We will keep following this incremental approach in the next lessons.