Emotive Decision Making (4)

Note:
This is a somewhat technical programming section which carries on from ideas and techniques developed at length in "Lingo Sorcery"
To see the factors which are going to affect Joe's decision and the options which Joe has to decide upon, you can extend the loadConditioning handler to display these items in the message box (see figs 20/18 and 20/19).


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]]]
  put "conditioning = " & conditioning
  set joesState to [:]
  repeat with j = 1 to count(conditioning)
    addProp joesState,getPropAt(conditioning,j),empty
  end repeat
  put "joesState = " & joesState
  set options to [#cycling,#walkDog,#shopping,#stayHome,#playCards]
  put "options = " & options
end

Figure 20/18 Arranging to see Joe's emotions and option after his brain is conditioned



From the message box:

LoadConditioning joe

-- "conditioning = [#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]]]"

-- "joesState = [#weather: "", #money: "", #lonely: "", #dogBarking: "", #needExercise: ""]"

-- "options = [#cycling, #walkDog, #shopping, #stayHome, #playCards]"

Figure 20/19 Inside Joe's brain after conditioning


Now, Joe can think and act more like a human. When he wakes up he can combine the information in his memory with what he sees and hears. This is shown in the handler wakeUpPrimed (fig 20/20) where Joe's fixed state is set as before, with random values of wealth, loneliness and laziness and the external influences (the things Joe sees and hears) are passed within a parameter (joeSeesStuff) of the wakeUpPrimed message.

Note: Look at the line with the do statement in the wakeUpPrimed handler of fig 20/20. This is a little trick to be able to reference property names which are obtained from expressions or are inside variables.


Joe --Parent script

on wakeUpPrimed me,JoeSeesStuff
  set the money of joesState = getAt(["broke","rich"],random(2))
  set the lonely of joesState = getAt(["lonely","notLonely"],random(2))
  set the needExercise of joesState = getAt(["energetic","lazy"],random(2))
  repeat with x in joeSeesStuff
    put  getPropAt(x,1) into seen
    do "set the " & seen & " of joesState to getAt(x,1)"
  end repeat
  put joesState 
end

Figure 20/20 Priming Joe's brain when he wakes up


By using a "put joesState" line into the wakeUpPrimed handler, you will be able to see in the message box what criterion Joe is "thinking about" when he wakes up in the morning (see fig 20/21).
 


From the message box:

wakeUpPrimed joe,[[#weather: "sunny"],[#dogBarking: "notBarking"]]
-- [#weather: "sunny", #money: "broke", #lonely: "notLonely", #dogBarking: "notBarking", #needExercise: "lazy"]

Figure 20/21 The conditions and states Joe wakes up to one morning


The next thing we need to do is to alter Joe's emotional decision making mechanism so that it uses the conditioning 'emotions in' Joe's brain to arrive at a decision.

This involves quite tricky manipulations of property lists which can drive you mad unless you get properly organized and build up the property retrieval expressions a section at a time with a test handler. Such a test handler (testing) is shown in fig 20/22. The complete handler is shown as it finished up, after adding each level separately.


From the message box:

wakeUpPrimed joe,[[#weather: "sunny"],[#dogBarking: "notBarking"]]
-- [#weather: "sunny", #money: "broke", #lonely: "notLonely", #dogBarking: "notBarking", #needExercise: "lazy"]

Figure 20/22 A handler to help construct Joe's brain


The purpose of the testing handler was to find out how to access the property list in the property joesState and use this information to extract the appropriate 'emotional' responses from the conditioning property.

The final result of this testing handler, from the message box, is shown in fig 20/23. You can see how it nicely pulls out every level separately.


From the message box:

testing joe
-- [#weather: "raining", #money: "broke", #lonely: "lonely", #dogBarking: "notBarking", #needExercise: "energetic"]
-- #weather
-- "raining"
-- [-30, -20, 0, 20, 20]
-- "Emotions = [-30, -20, 0, 20, 20]"
-- #money
-- "broke"
-- [0, 0, -2147483647, 0, -2147483647]
-- "Emotions = [0, 0, -2147483647, 0, -2147483647]"
-- #lonely
-- "lonely"
-- [-10, -5, 10, -30, 20]
-- "Emotions = [-10, -5, 10, -30, 20]"
-- #dogBarking
-- "notBarking"
-- [0, -10, 0, 0, 0]
-- "Emotions = [0, -10, 0, 0, 0]"
-- #needExercise
-- "energetic"
-- [10, 0, 0, -30, 10]
-- "Emotions = [10, 0, 0, -30, 10]"

Figure 20/23 The stages of building Joe's brain


Having sorted out the correct way to access the property lists, it then becomes very simple to add all the appropriate emotions together to allow Joe to come to a decision ( handler useYourBrain in Fig 20/24).


Joe --Parent script

on useYourBrain me
  set eagerness to [0,0,0,0,0]
  set emotion to empty
  set emotions to empty
  repeat with i = 1 to count(joesState)
    put getPropAt(joesState,i) into state
    do "put the " & state & " of joesState into emotion"
    do "put the " & emotion  & " of the " & state & " of conditioning into emotions"
    set eagerness = eagerness + emotions
  end repeat
  put eagerness  
  put "Joe's decision is - " & emotionalPressure(me,eagerness)
end
 
on emotionalPressure 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/24 Getting Joe to use his conditioned brain


Notice that there is no need to use a case statement now. A simple repeat loop can be used which adds the appropriate emotions together to provide the aggregate for the eagerness list.

Fig 20/25 shows this useYourBrain message being sent to object Joe from the message box, with the parameters informing Joe that it is raining and that the dog is not barking to go out. Joe decides to stay at home.


From the message box:

wakeUpPrimed joe,[[#weather: "raining"],[#dogBarking: "notBarking"]]
-- [#weather: "raining", #money: "rich", #lonely: "notLonely", #dogBarking: "notBarking", #needExercise: "lazy"]

useYourBrain joe
-- [-50, -40, 20, 40, 30]
-- "Joe's decision is - stayHome"

Figure 20/25 Joe makes an emotional decision


If you have kept up with this so far, it will not need hundreds of examples for you to be able to see the multitude of different ways this brain paradigm can be put to use.

Joe can be sent new sets of options together with appropriate conditioning information which will allow him to make decisions in all kinds of situations.

Having a brain, also allows Joe to learn and to adapt to new situations. Probably you have heard about conditioning birds to do tricks or training animals by punishments or rewards. Perhaps you had a smack from a parent the first time you swore at home. These are all arranged by using brain mechanisms similar to Joe's.

For example: if Joe decides to take his dog out for a walk because it is barking, he might find it is still barking when he gets back. A brainless object, trained to respond to the dog's barking would take it out for a walk again. Not brainy Joe. He can be provided with a memory (another property) which records how long it was since the dog was last taken out for a walk and be able to adjust his emotional conditioning accordingly.

To see how easy it is, to adjust Joe's 'emotional' responses, we will arrange for Joe to have an emotional adjustment made to his brain after he takes the dog out for a walk (see fig 20/26).


From the message box:

wakeUpPrimed joe,[[#weather: "sunny"],[#dogBarking: "Barking"]]
-- [#weather: "sunny", #money: "rich", #lonely: "lonely", #dogBarking: "Barking", #needExercise: "energetic"]

useYourBrain joe
-- [-20, 55, 40, -120, -30]
-- "Joe's decision is - walkDog"

put the barking of the dogBarking of the conditioning of joe
-- [-30, 50, 10, -50, -50]

setaProp the dogBarking of the conditioning of joe,#barking,[0,0,0,0]

put the barking of the dogBarking of the conditioning of joe
-- [0, 0, 0, 0]

useYourBrain joe
-- [10, 5, 30, -70]
-- "Joe's decision is - shopping"

Figure 20/26 Joe knows when to ignore the dog's barking


As you can see from fig 20/26, Joe wakes up one morning rich, lonely and energetic. The sun is shining and the dog is barking to go out. Using his 'emotional' brain, Joe makes a decision to take the dog for a walk. The result of Joe's 'emotional' decision is shown in this figure - with the eagerness of 40 for Joe to go shopping being squashed by the 55 which tells him to take the dog out for a walk.

A look into Joe's brain shows why: the barking of the dogBarking of the conditioning of Joe is [-30,50,-50,-50] which heavily biases Joe's emotions towards taking the dog for a walk.

If, after taking the dog for a walk, Joe's emotional conditioning is adjusted to allow for the fact that the dog has just been taken for a walk, Joe will be less sympathetic if the dog is still barking when he comes back.

This adjustment, which can be sent to Joe as internal or external feedback as a parameter of a message, is shown in the setaProp line of fig 20/26, which resets Joe's emotional response to barking to [0,0,0,0,0]. After this adjustment to Joe's conditioning, Joe makes the decision to go shopping rather than taking the dog for a walk, when the dog barks again.

This simple little example should be enough information to trigger ideas for you to be able to build all kinds of brainy objects which can be set up to make all kinds of decisions and learn in all manner of different situations.

[Index]
[Next - Learning and adapting]
[Back - Emotive decisions (3)]


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