# Implementation of DEvelopmentAl Learning (IDEAL) Course

Table 54 presents our radical interactionist algorithm, by introducing a few modifications in our previous algorithms of Page 43. These modifications have impacts on the learn() and anticipate() functions. The participants interested in programming will find the details on Page 57.

```001   i1 = createPrimitiveInteraction("i1", -1)
002   i2 = createPrimitiveInteraction("i2", 1)
003   i3 = createPrimitiveInteraction("i3", -1)
004   i4 = createPrimitiveInteraction("i4", 1)
... Other interactions afforded by the agent/environment coupling

005   constructExperiment(i1)
006   constructExperiment(i3)
... Other experiments constructed by default

007   while()
008      anticipations = anticipate()
009      experiment = selectExperiment(anticipations)
010      intendedInteraction = experiment.intendedInteraction()
011      enactedInteraction = enact(intendedInteraction)
012      learn()
013      if (enactedInteraction.valence ≥ 0)
015      else
016         mood = PAINED

101   function enact(intendedInteraction)
102      if intendedInteraction.isPrimitive
103         return environment.enact(intendedInteraction)
104      else
105         enactedPreInteraction = enact(intendedInteraction.preInteraction)
106         if (enactedPreInteraction ≠ intendedInteraction.preInteraction)
107            return enactedPreInteraction
108         else
109            enactedPostInteraction = enact(intendedInteraction.postInteraction)
110            return getOrLearn(enactedPreInteraction, enactedPostInteraction)
```

Table 54, Lines 001 to 004: Now, primitive interactions are created as primitive objects rather than being the product of experiments and results. Lines 005 and 006: Default experiments are created as secondary constructs from primitive interactions. Default experiments generate initial anticipations that can be picked by default when the agent begins.

Lines 007 to 016: The main loop is the same as on Page 43.

Lines 101 to 110: The enact() function is identical to that on Page 43, except for Line 103, which calls the enact(primitiveInteraction) method of the environment. The enact(primitiveInteraction) method replaces the previous giveResult(experiment) method; it tries to enact the primitive interaction in the environment and returns the actually enacted interaction. Participants interested in programming will find an environment implemented with this principle on Page 58.

The video in the next page explains and illustrates how this algorithm works.