Emotive Decision Making (3)

Note:
This is a somewhat technical programming section which carries on from ideas and techniques developed at length in "Lingo Sorcery"

In a human, emotions are triggered as the result of interactions between different parts of the brain and signals from the body's various sensors (the senses). Emotional influences emanate from various data banks in the brain's neural memory and the senses input messages in response to what is happening in the environment.

As complicated as the actual biological mechanisms which bring this about might be, we can simulate the essence of this system very easily using lists and objects.

An object has properties, which can serve as data base memories. An object can contain handlers which allow it to explore, or respond to, the environment. In other words, an object can act like a human and sense the environment for activity, check what it observes against previous experience and take suitable action.

If you feel that it is not quite the same, because an object doesn't realize what it is doing, remember most of the time humans make decisions completely unconsciously. If we want an object to act "consciously" in some situations, we can achieve this through a range of appropriate handlers.

It is all a question of thinking of object Joe as having a virtual "human like" brain to make decisions, learn and adapt. This can be a far more powerful conceptual framework than thinking in terms of variables and code syntax.

Combining virtual "emotion" with virtual "reason" , it then becomes easy for us to visualize an object making complex decisions (and turning this into code when the programming strategy is formulated is almost a formality).

The lists, which hold the records of Joe's eagerness to decide upon any particular action we can store as data in Joe's brain (in a property of Joe's brain). Fig 20/8 shows the parent script of Joe where his brain is loaded up at birth with all his "learned" emotional responses.


Joe --Parent script

property money,lonely,needExercise,joesBrain
 
on new me
  loadJoesBrain
  return me
end
 
on LoadJoesBrain me
  set JoesBrain to [:]
  addProp joesBrain,#broke,[0,0,-maxInteger(),0,-maxInteger()]
  addProp joesBrain,#rich,[0,0,20,0,0]
  addProp joesBrain,#lonely,[-10,-5,10,-30,20]
  addProp joesBrain,#notLonely,[0,0,0,0,0]
  addProp joesBrain,#energetic,[10,0,0,-30,10]
  addProp joesBrain,#lazy,[-20,-10,0,20,10]
  addProp joesBrain,#sunny,[10,10,0,-10,-10]
  addProp joesBrain,#raining,[-30,-20,0,20,20]
  addProp joesBrain,#barking,[-30,+50,10,-50,-50]
  addProp joesBrain,#notBarking,[0,-10,0,0,0]
end

Figure 20/8 Joe's brain is loaded up with emotional responses


Fig 20/9 shows you what JoesBrain looks like if you ask to see it from the message box. This is perhaps how an alien might view the inside of a human brain if it were represented as programming code on a computer screen.


From the message box:

LoadJoesBrain joe

put the joesBrain of joe
-- [#broke: [0, 0, -2147483647, 0, -2147483647], #rich: [0, 0, 20, 0, 0], #lonely: [-10, -5, 10, -30, 20], #notLonely: [0, 0, 0, 0, 0], #energetic: [10, 0, 0, -30, 10], #lazy: [-20, -10, 0, 20, 10], #sunny: [10, 10, 0, -10, -10], #raining: [-30, -20, 0, 20, 20], #barking: [-30, 50, 10, -50, -50], #notBarking: [0, -10, 0, 0, 0]]

Figure 20/9 A look inside Joe's brain at his emotions


You can get to view just a part of joesBrain by looking at the properties of joesBrain. Fig 20/10 shows, from the message box, the area of Joe's "emotions" which come into play if he were "broke".

Are you beginning to get the idea?


From the message box:

put the broke of the joesBrain of joe
-- [0, 0, -2147483647, 0, -2147483647]

Figure 20/10 Emotional effect of Joe being broke


Now we are in a position to see Joe's emotion generating mechanism as it accesses his brain (generateEmotions) - see fig 20/11.


Joe --Parent script

on generateEmotions me,weather,dogBarking
  set options to [#cycling:1,#walkDog:1,#shopping:1,#stayHome:1,#playCards:1]
  set eagerness to [0,0,0,0,0]
  repeat with i in [weather,money,lonely,dogBarking,needExercise]
    case i of
      "broke":      set eagerness to eagerness + the broke of  joesBrain
      "rich":       set eagerness to eagerness + the rich of joesBrain
      "lonely":     set eagerness to eagerness + the lonely of joesBrain
      "not lonely": set eagerness to eagerness + the notLonely of joesBrain
      "energetic":  set eagerness to eagerness + the energetic of joesBrain
      "lazy":       set eagerness to eagerness + the lazy of joesBrain
      "sunny":      set eagerness to eagerness + the sunny of joesBrain
      "raining":    set eagerness to eagerness + the raining of joesBrain
      "barking":    set eagerness to eagerness + the barking of joesBrain
      "not barking":set eagerness to eagerness + the notBarking of joesBrain
    end case
  end repeat
  put eagerness  
end

Figure 20/11 The emotions in Joe's brain decides his eagerness for each option


Just to make sure, that Joe can make 'emotional' decisions by accessing information in his brain, we can test it out from the message box (see fig 20/12).

We create a broke and lonely Joe who is very energetic. We can see he will go cycling in sunny and rainy weather if his dog isn't barking to go out, but, if the dog is barking he'll take it out even if it is raining.


From the message box:

wakeUp joe
-- "broke"
-- "lonely"
-- "energetic"

generateEmotions joe,"sunny","not barking"
-- [10, -5, -2147483637, -70, -2147483627]
generateEmotions joe,"raining","barking"
-- [-60, 25, -2147483627, -90, -2147483647]
generateEmotions joe,"raining","not barking"
-- [-30, -35, -2147483637, -40, -2147483597]

Figure 20/12 Joe's emotions under differing circumstances


Considering other options

At the moment, Joe's options are hard wired into Joe's emotion generating mechanism. They ought not to be permanently fixed there because we might want Joe to consider other alternatives.

We might want to get Joe to consult his "Things to do today" pad, or, we might want to get him to connect up to the Internet to get a list of tasks for him to consider.

Perhaps we shall want to birth lots of people from Joe's parent script (calling them by other names) and get them to have different options, or, even we might want to get them to combine on a large project where each has a different area of responsibility or decision making.

Are you beginning to see the scope of this paradigm?

Let's now take the options out of the handler and put them in a property of Joe's which we will call options. The options can then be can be installed at birth; given to Joe by someone else; or Joe can read them from somewhere.

A setOptions handler in Joe's parent script is shown in fig 20/13. This takes two parameters, a list of new options and an optional parameter telling Joe to forget all the options he already has in memory.

Joe is now very flexible, his options can be changed to allow him to make a range of decisions in any given set of circumstances.


Joe --Parent script

property money,lonely,needExercise,joesBrain,options
 
on setOptions me,optionsList,clearPrevious
  if clearPrevious or voidp(options) then set options to []
  repeat with i in optionsList
    append options,i
  end repeat
  put "Joe's options" && options
end
 

Figure 20/13 Putting a list of options in Joe's brain


We can now get Joe's "emotions" to decide which action to take by calling a decision handler (see fig 20/14). This compares all the values of Joe's 'emotions' (eagerness values) and picks the one Joe is most eager about after eliminating the options he is unable to choose.


Joe --Parent script

on generateEmotions me,weather,dogBarking
  set eagerness to [0,0,0,0,0]
  repeat with i in [weather,money,lonely,dogBarking,needExercise]
    case i of
      "broke":      set eagerness to eagerness + the broke of  joesBrain
      "rich":       set eagerness to eagerness + the rich of joesBrain
      "lonely":     set eagerness to eagerness + the lonely of joesBrain
      "not lonely": set eagerness to eagerness + the notLonely of joesBrain
      "energetic":  set eagerness to eagerness + the energetic of joesBrain
      "lazy":       set eagerness to eagerness + the lazy of joesBrain
      "sunny":      set eagerness to eagerness + the sunny of joesBrain
      "raining":    set eagerness to eagerness + the raining of joesBrain
      "barking":    set eagerness to eagerness + the barking of joesBrain
      "not barking":set eagerness to eagerness + the notBarking of joesBrain
    end case
  end repeat
  put eagerness  
  put "Joe's decision is - " & decision(me,eagerness)
end
 
on decision me,eagerness
  put -maxInteger() into it
  set count to 1
  repeat with i in eagerness
    if i > it then
      put i into it
      put getAt(options,count) into joesDecision
    end if
    set count to count +1
  end repeat
  return joesDecision
end

Figure 20/14 Giving Joe's brain a decision making mechanism


Waking Joe up from the message box (see fig 20/15), finds Joe rich, lazy and not lonely. Looking out of the window, Joe sees that the weather is sunny and as the dog is nor barking to be taken out for a walk decides to go shopping.

In principle, how is Joe's brain working differently from a human brain?


From the message box:

wakeUp joe
-- "rich"
-- "not lonely"
-- "lazy"

loadJoesBrain joe

setOptions joe,[#cycling:1,#walkDog:1,#shopping:1,#stayHome:1,#playCards:1]
-- "Joe's options [#cycling, #walkDog, #shopping, #stayHome, #playCards]"

generateEmotions joe,"sunny","not barking"
-- [-10, -10, 20, 10, 0]
-- "Joe's decision is - shopping"

Figure 20/15 Joe's emotions help him make a decision


At the moment, Joe is still limited to just five possible actions, because his "emotional conditioning" provides only "emotional" responses to the five particular options we "conditioned" him for.

If we want Joe to be truly flexible, like a human, and be able to adapt and learn in any new situation, we must provide a mechanism whereby Joe can be emotionally conditioned to make decisions about new situations as they come along.

To provide this versatility, we shall have to remove the hard-wiring of the 'emotions' from Joe's emotion generating mechanism and place the 'emotions' where humans keep theirs - in the brain.

Let's now take the 'emotions' out of the emotion generating mechanism and place them next to joesBrain in a property we shall call conditioning.

The use of the word "conditioning" is to remind us that these are the 'emotions' which are conditioned into Joe in much the same way that emotions are conditioned into animals and humans.

As a first step we will have Joe load his emotional conditioning himself, using the handler loadConditioning which sets up the 'emotions' from a list internal to the handler (see fig 20/16). You will realize of course that Joe could just as easily access such a list of "emotions" as a parameter from an external source, but, that is a triviality and not worth illustrating here.


Joe --Parent script

on loadConditioning me
  set conditioning to [:]
  set conditioning to ¬
   [[#weather:[#sunny:[10,10,0,-10,-10],#raining:[-30,-20,0,20,20]]] ,¬
   [#money:[#broke:[0,0,-maxInteger(),0,-maxInteger()],#rich:[0,0,20,0,0]]],¬
   [#lonely:[#lonely:[-10,-5,10,-30,20],#notLonely:[0,0,0,0,0]]],¬
   [#dogBarking:[#barking:[-30,+50,10,-50,-50],#notBarking:[0,-10,0,0,0]]],¬
   [#needExercise:[#energetic:[10,0,0,-30,10],#lazy:[-20,-10,0,20,10]]]]
end

Figure 20/16 Conditioning Joe's emotions for optimum decision making


The results of this "conditioning" of Joe can be seen from the message box as shown in fig 20/17.


From the message box:

LoadConditioning joe

put the conditioning of joe
-- [#weather: [#sunny: [10, 10, 0, -10, -10], #raining: [-30, -20, 0, 20, 20]], #money: [#broke: [0, 0, -2147483647, 0, -2147483647], #rich: [0, 0, 20, 0, 0]], #lonely: [#lonely: [-10, -5, 10, -30, 20], #notLonely: [0, 0, 0, 0, 0]], #dogBarking: [#barking: [-30, 50, 10, -50, -50], #notBarking: [0, -10, 0, 0, 0]], #needExercise: [#energetic: [10, 0, 0, -30, 10], #lazy: [-20, -10, 0, 20, 10]]]

put the weather of the conditioning of joe
-- [#sunny: [10, 10, 0, -10, -10], #raining: [-30, -20, 0, 20, 20]]

put the sunny of the weather of the conditioning of joe
-- [10, 10, 0, -10, -10]

Figure 20/17 Looking inside Joe's brain to see how he is emotionally conditioned



[Index]
[Next - Emotive decisions (4)]
[Back - Emotive decisions (2)]


Peter Small August 1996

Email:
peter@genps.demon.co.uk

Version 1.00

© Copyright 1996 Peter Small
No reproduction in whole or part without prior permission