Emotive Decision Making (1)
Note:
This is a somewhat technical programming section which carries on from ideas
and techniques developed at length in "Lingo Sorcery"
One of the fundamental problems of artificial intelligence is in trying
to decide exactly what is meant by intelligence. To glibly state that you
are about to create an intelligent object has little or no meaning unless
you define what you mean by intelligence.
The first object we made [in the Lingo Sorcery book] was a virus object
which had the intelligence to be aware of its environment and was able to
choose its moves so that it stayed within a specified area and avoid any
hazards.
That is an intelligence of sorts, but, you would hardly describe that simple
object, which had just a few lines of code, as being particularly intelligent.
Yet, in essence, it is displaying a very sophisticated form of intelligence
- especially if you think in terms of an object modeling its environment
in its own memory and thinking about moves before it makes them.
Again it is a question of semantics and paradigm shifts. You can think about
objects as having an uncanny knack of thinking and reasoning similar to
that of humans, or, you can think about exactly the same thing in terms
of programming structures. The former allows you to think creatively, the
latter allows you to code efficiently.
An intelligent human will make a decision as a result of information and
careful reasoning. A person might use the information they have in their
own mind to come to a conclusion based upon this personal knowledge, or,
they might realize they have insufficient knowledge and seek supplementary
information elsewhere to reach a final decision. This is conscious human
reasoning, but, is this what is meant as intelligence?
In the previous section, on logical thinking networks, we saw the development
of a simple network of objects which did nothing more than switch message
paths according to information being fed into the network.
This simple network can be used to combine the effects of different information;
resulting in a conclusion based upon an aggregate. Such a network will allow
various factors to be taken into account.
As a result of a series of logical decisions based upon this information,
a conclusion will be drawn (the result). Could this be likened to conscious
human reasoning? Could this be construed as intelligence?
You'll want to argue that real intelligence is something much more than
just the rational decision making which can be reproduced by a computer.
You'll want to explain that besides conscious rational thinking, intelligence
is backed up by an unconscious decision making process which is hard to
define.
You'll want to argue that intelligence is also something which involves
feelings and emotions and is about hunches and guesses. You'll want to explain
that the intelligence exhibited in human decision making has a certain wooliness
where answers are not always clear cut and where emotions can often outweigh
rationality.
However, let us remember that humans are only a result of an evolutionary
process which has formed the mechanisms of thought and emotions out of chemicals
and chemical reactions. If such chemicals and chemical reactions can be
modeled on a computer (which in theory they can ) there is every reason
to suppose that the underlying mechanisms they form can also be modeled
in computer code.
The most surprising aspect of biological systems is that, once the apparent
complexity is broken down into an OOPS system, the underlying mechanisms
often turn out to be elegantly simple.
As was dramatically illustrated in "How God Makes God", this appears
to be the case with the seemingly unfathomable concept of emotions. Simply
by switching paradigms, the principles of emotive decision making can be
dramatically modeled and exposed.
Not only can emotive systems be exhibited and simulated on a computer, they
can also be created in high level languages like Lingo. Even more incredible,
the Lingo handlers which emulate the human brain's basic emotive decision
making mechanisms turn out to be so simple that they can be designed using
no more than a couple of dozen lines of scripting.
We can discover this for ourselves by developing a system of virtual emotions
in a Lingo object. Space does not permit the development of a highly complex
example of this kind of intelligence, but, nevertheless, we will be able
to demonstrate the principles and basic mechanisms.
Imagine a Lingo object capable of thought. Imagine creating such an object
such that it has to decide what to do when it wakes up in the morning. Could
this be likened to creating an object with conscious reasoning?
How could you design such an object: an object which functions in a way
which would appear to be similar to that of a human being?
First, the object would have to be designed to be aware of its "self".
Then it must be arranged for this object to be able to take stock of its
environment. It must have a memory which would contain all the possible
choices of things that it can do.
It must then have a system of "emotions" which would allow the
object to experience an emotional preference for one or other of its options
according to the various factors relating to "self" and the environment.
Isn't that how human's make a decision as to what they want to do when they
wake up in the morning?
Bearing in mind that this is just a simple example to illustrate basic principles,
let's give an object a few possible choices of things it can do when it
"wakes up".
Choosing just a representative sample of options, let's say: it can take
a cycle ride to see its friend in the nearby village, or, it can take its
software dog for a walk in the park. Perhaps it can drive over to SoftCity
and do some shopping. Perhaps it can stay at home reading, or, invite a
friend over for a game of cards.
How do you start to design such an object, which thinks like a human?
Thinking of an object like this instead of thinking in terms of computer
code is an essential feature of OOPS thinking. Again it is simply a question
of a paradigm shift where you can take your overall framework outside of
the rigid confines of computer coding syntax.
If it helps you with the paradigm shift, draw a little figure and put it
into a cast member, give it a name and put a parent script into the scriptText
of that cast member.
You will then have an object; and a simple birth handler will put it into
memory for you. If you feel like going the whole hog you can even put it
onto the stage and give it a name - Joe.
Now, give Joe a simple empty handler in his parent script called
comeAlive. Send a message to Joe:
comeAlive Joe
Joe is now alive in the space inside of your computer memory (to
be more accurate, Joe is alive in the ram space allocated to the
Director application or player).
Joe now has to think about what to do. This is simple to arrange
in Lingo, because the object Joe can be given a list of possibilities
stored in a list in one of its properties. (Note: a more complex example
could see object Joe having a larger memory by consulting a field
in a cast member, or, an internal or external data base).
Say the possibilities are:
cycling,walkDog,shopping,stayHome,playCards
How does Joe choose between these possibilities? His
decision might be affected by the weather, how much money he has, whether
or not he feels lonely, whether the dog is barking to go out, whether or
not he needs the exercise. All these influences will have a bearing on Joe's
decision:
weather,money,lonely,dogBarking,needExercise
Already, in this extremely simple situation, you can see this
is quite a difficult problem for Joe. There are a lot of interdependencies.
How should Joe go about deciding? How would a human decide?
A human Joe would look outside at the weather and listen to see if
the dog is barking to go out. He'd also think about how much money he had
to spend.
However, his decision would not often be based purely upon these completely
rational factors. More than likely Joe would just "feel"
like doing something. He will make a decision which has both a rational
and an emotional content.
He may feel lazy or perhaps lonely, he'll have a range of emotions which
may conflict with a logical decision. Is this what we mean when we talk
about human intelligence? Let us now see if we can get the object Joe
to "think" like this.
We'll arrange it so that when Joe wakes up he'll either be "rich"
or "broke"; "lonely" or "not lonely"; "energetic"
or "lazy". Using the wakeUp handler shown in fig 20/1,
we can arrange that these states are randomly assigned to Joe's properties.
These properties will then describe Joe's "self" - his
inner feeling known only to himself (a real life Joe would have hundreds
of such "self" properties - but, so could object Joe if
we had the space available here).
Joe --Parent script
property money,lonely,needExercise
on new me
return me
end
on wakeUp me
set money = getAt(["broke","rich"],random(2))
set lonely = getAt(["lonely","not lonely"],random(2))
set needExercise = getAt(["energetic","lazy"],random(2))
put money
put lonely
put needExercise
end
Button script
on mouseUp
global Joe
set Joe to new(script "Joe")
end
Figure 20/1 An object named Joe wakes up one morning
Fig 20/2 shows how Joe is "woken up" three
time from the message box and each time he wakes it is with a new set of
characteristics: which will influence his decision as to what he is going
to do first thing in the day.
From message box:
wakeUp joe
-- "broke"
-- "not lonely"
-- "lazy"
wakeUp joe
-- "rich"
-- "not lonely"
-- "lazy"
wakeUp joe
-- "broke"
-- "lonely"
-- "energetic"
Figure 20/2 Joe can wake up with a random set of states
(Note: Joe has only three characteristic states here,
but, there is no reason why Joe shouldn't have as many as you would
like to give him).
We will assume that there are also two external things that could affect
Joe's decision: the weather and the state of this dog (again there
could be innumerable other influences, but, for simplicity we are assuming
just these two).
To get Joe to decide what he is going to do today, we send him a
decideWhatToDo message (see fig 20/3). Joe knows, from his
properties, his state of wealth, his inclination to do anything energetic
and whether or not he is lonely. He also has to find out what the weather
is like and will listen to hear if his dog is barking to be taken for a
walk.
We could arrange handlers for Joe to find these things out for himself,
but, for simplicity we'll tell him this information when we send the decideWhatToDo
message by including these details in the parameters weather and
dogBarking:-
decideWhatToDo Joe,"raining","barking"
This message tells Joe to decide what to do on a rainy
day and with the dog barking to go out for a walk. The decideWhatToDo
handler in Joe's parent script is shown in fig 20/3.
Joe --Parent script
on decideWhatToDo me,weather,dogBarking
set options to [#cycling:1,#walkDog:1,#shopping:1,#stayHome:1,#playCards:1]
set cantDo to []
repeat with i in [weather,money,lonely,dogBarking,needExercise]
case i of
"broke": append cantDo,[3,5]
"rich": append cantDo,[]
"lonely": append cantDo,[1,4]
"not lonely": append cantDo,[]
"energetic": append cantDo,[4,5]
"lazy": append cantDo,[1,2,3]
"sunny": append cantDo,[4,5]
"raining": append cantDo,[1,2,3]
"barking": append cantDo,[1,4,5]
"not barking": append cantDo,[]
end case
end repeat
put cantDo
repeat with i in cantDo
if count(i) >0 then
repeat with j in i
setAt options,j, 0
end repeat
end if
end repeat
put options
end
Figure 20/3 Joe knows what he can't do
Joe must first draw up a list of options which are shown
in this handler as a simple list of five items (options list). This
list is set into the handler, but, could have been provided as another parameter,
or, Joe could have searched a data base for a whole range of different
possibilities.
We could use nested if... then... else... structures and lists to
decide between the options but the case statement, introduced in
version 5 of director, is particularly well suited for illustrating these
decision making mechanisms (this is being used for ease of explanation and
isn't required in the final code).
The case statement will take a variable and look to see if the contents
of that variable are contained in a look up table within its structure.
In fig 20/3, we are using the variable i in a repeat with i in...
loop, where i sequentially assumes the values of a property list
containing all the factors which might affect Joe's decision.
For each of the possible characteristics or conditions there is a matching
instruction. This instruction, adds the options which are not possible due
to that particular state or condition, into a cantDo list. This allows
Joe to go through all of his properties and any external factors
to see which of the possible options is or is not possible under the circumstances.
Looking at the Lingo script, you can see that it is a fairly trivial exercise
to set this up. However, in your mind space you have this guy named Joe
who can consider a number of possibilities and take several factors into
consideration before coming to a decision.
Now this is a very powerful paradigm because you can expand up on this concept
to make Joe act (seemingly) very intelligently. Fig 20/4 shows Joe
being woken up and asked to decide what to do first thing that day under
a number of different conditions
From message box:
wakeUp joe
-- "rich"
-- "not lonely"
-- "lazy"
decideWhatToDo joe,"raining","not barking"
-- [[1, 2, 3], [], [], [], [1, 2, 3]]
-- [#cycling: 0, #walkDog: 0, #shopping: 0, #stayHome: 1, #playCards: 1]
decideWhatToDo joe,"sunny","not barking"
-- [[4, 5], [], [], [], [1, 2, 3]]
-- [#cycling: 0, #walkDog: 0, #shopping: 0, #stayHome: 0, #playCards: 0]
decideWhatToDo joe,"sunny","barking"
-- [[4, 5], [], [], [1, 4, 5], [1, 2, 3]]
-- [#cycling: 0, #walkDog: 0, #shopping: 0, #stayHome: 0, #playCards: 0]
Figure 20/4 Joe decides what to do in various conditions
In this example, Joe wakes up to find himself rich and
lazy but not a lonely person.
When "thinking" about what he is going to do, when it is raining
outside with the dog not barking to go for a walk, Joe will be able
to decide that he will either stay at home, or, play cards with his friend.
Because Joe is "rich" and "not lonely", he can
take up any of the options (the cantDo lists are empty for "rich"
and "not lonely"). However, he is lazy so he does not choose to
go cycling, walking the dog or shopping (items 1,2 and 3 have been placed
in the cantDo list under "lazy").
In this case it would not have mattered whether Joe was lazy or not
because the weather would have removed these options anyway (the cantDo
list corresponding to "raining" contains the option numbers 1,2
and 3). Luckily, the dog is not barking to go out so it leaves Joe
two possible alternatives.
Notice how all the options, which are canceled out by the various separate
considerations, are removed from the final list of options, using two nested
repeat with i in... repeat loops.
Emotional Decision making
The decision making mechanism, in object Joe's, decideWhatToDo
handler, falls far short of human decision making capabilities. The mechanism
is rigid and inflexible with large areas of the decision landscape left
uncovered. This often leaves Joe incapable of making a decision because
either he has too many equally valid choices or no choices at all.
Human decision making on the other hand is not coarse like Joe's.
Humans have a fuzzier way of deciding what to do. They can strike a balance
between a number of competing influences and conditions and come up with
a compromise.
Humans are able to do this because they have emotions.
It can be shown, as was demonstrated in the CD-ROM "How God Makes God",
that emotions are a subtle biological control system. They have evolved,
over time, to motivate a human being towards acting in ways which are optimally
efficient for survival and reproduction. There are no hard and fast rules
associated with an emotional decision process, the decisions are always
a blend of all the possible factors involved.
Using the same technique which was used successfully to model human emotions
in the CD-ROM "How God Makes God", we can give Joe an emotional
decision making system similar to that of humans. It works on the principle
that you can ascribe to each of the factors influencing a decision an "eagerness"
value, which reflects the relative bias that any particular factor brings
to the decision making process.
For example, if Joe is lazy he will have negative values of eagerness
towards cycling or walking the dog. He might have an ambivalent eagerness
towards going shopping because, although he may be eager to go shopping,
he might be too lazy to make the effort. Being lazy he will probably have
an eagerness to stay at home or play a game of cards with his friend.
The actual values used to express the extent of Joe's eagerness
in various situations can be arranged in a number of ways (which we'll discuss
later). For the purpose of this simple outline example, we shall use arbitrarily
chosen values which reflect some degree of reality. These are shown in the
case statement inside the feelWhatToDo handler shown fig 20/5.
Here, the case statement is used as before, except that relative
values of eagerness are used instead of simply the logical operators:
true or false.
Let's take an example from this case statement, where each of Joe's
characteristics are allocated to a list. This list reflects the various
effects the characteristic will have on each of Joe's 'desires' to
choose a particular option.
If Joe is lazy, this characteristic (in our example) would contribute
an eagerness value of minus twenty to his inclination to go cycling;
minus ten to his inclination to taking the dog for a walk; a neutral zero
to represent his ambivalent attitude towards shopping; plus twenty for staying
at home and plus ten for playing cards.
If being lazy was the only factor influencing Joe's choice, he would
stay at home. However, there are other factors which may affect that decision:
the dog may be barking to go out for a walk. That factor is going to add
a different eagerness influence on Joe's activity decision.
Certainly Joe couldn't take the dog out if he went for a cycle ride
(in this example anyway) so the dog's insistent barking would dissuade Joe
from going cycling (-30). In order to stop the dog from barking there may
be an incentive for Joe to take the dog for a walk (+50). A compromise
might be to take the dog shopping with him (+10). Joe certainly wouldn't
be keen to stay at home with the dog barking (-50), nor invite his friend
around for a quiet game of cards (-50).
Having two factors influencing Joe's decision, the two eagerness
factors are then combined:
Lazy factor plus Barking factor equals Combined effect:
Eagerness to go cycling = -20 -30 = -50
Eagerness to walk dog = -10 +50 = +40
Eagerness to go shopping = 0 +10 = +10
Eagerness to stay home = 20 -50 = -30
Eagerness to play cards = 10 -50 = -40
The combination of the two factors, causes lazy Joe to
make the decision to take the dog for a walk because, under these conditions,
that is what Joe "prefers" to do.
Notice how we are ascribing human emotions to the results of the summation
of two variables. This is the necessary paradigm shift to be able to imaginatively
think of things for Joe to do.
For the imagination to fantasize roles for Joe to play it is far
more fruitful to think of Joe having emotional reactions to events
and conditions than to think in terms of values in variables.
[Index]
[Next - Emotive decisions (2)]
[Back - Logical thinking networks]
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