AI Lec2 SimpleAgent
AI Lec2 SimpleAgent
s1 s2 s3
s8 s4
s7 s6 s5
Solid
object
1 3
6
4
5
Input Sensory x1 x2
number vector (move east)
1 0000110 0 0
2 1110 0000 1
3 00100 00 0 1
4 00000 00 0 0
5 00001 00 0 0
6 01100 00 0 1
© 1998 Morgan Kaufman Publishers
xi
wi Σ
wn Threshold, θ
...
xn
n
f = 1 if Σ
i=1
xi wi ≥ θ
= 0 otherwise
© 1998 Morgan Kaufmann Publishers
Not all Boolean functions can be implemented as TLUs - those can are
called linearly separable functions. Here is an example:
x1 1
–1
x2 1.5 x1 x 2 x3
x3 1
© 1998 Morgan Kaufman Publishers
W ← W + c(d − f )X,
0 Next to wall
Feature
vector, X 1
1
1 In a corner
1
x1 x2 x3 x4
In each diagram, the indicated feature has value 1 if and only if at least one of the shaded
cells is not free.
© 1998 Morgan Kaufman Publishers
Given the four features, we can specify a function of these features that
will select the right action for boundary-following as follows:
if none of the four features equal to 1, then move north (it could be
any direction).
if x1 = 1 and x2 = 0, then move east;
if x2 = 1 and x3 = 0, then move south;
if x3 = 1 and x4 = 0, then move west;
if x4 = 1 and x1 = 0, then move north.
We now need to represent and implement perception and action functions.
To that end, we briefly review Boolean algebra below.
1 + 1 = 1, 1 + 0 = 1, 0 + 0 = 0,
1 · 1 = 1, 1 · 0 = 0, 0 · 0 = 0,
1 = 0, 0 = 1
inCorner → nil,
1 → bf ,
nw n ne
w e
sw s se
We shall assume that the program that we are looking for can be
constructed from the primitives ones (east, west, etc) by Boolean ops and
conditionals. The example in the following slide represent a program that
does the same thing as the following production system:
(n + ne)e → east,
(e + se)s → south,
(s + sw )w → west,
1 → north.
AND east IF
e se s OR NOT north
s sw w
Given a program, and a starting position for the robot, we run it until
it has carried out 60 steps, and then count the number of cells next
to the wall that are visited during these 60 steps. (Max=32, Min=0.)
For a given program, we do ten of these runs with the robot starting
at ten randomly chosen starting positions. The total count of the
next-to-the-wall cels visited is taken as the fitness of the program.
(Max = 320, Min=0.)
NOT NOT
AND
Randomly chosen IF AND
crossover points
se IF AND OR se se IF
north
150
100
50
0
0 1 2 3 4 5 6 7 8 9 10
Generation number
© 1998 Morgan Kaufman Publishers
Recall that S-R agents have no memory; they just respond to the
current stimuli.
Often one needs more powerful agents. State machines are agents
who can remember the action that they have just done, and the state
that the previous environment is in, and can have some mental states.
Action function of a state machine is then a mapping of the current
sensory inputs, the state of the environment at the previous time step,
the action that the machine has just taken, and the current mental
states.
Feature vector, X t 0
1
1
1
Sensory 1
input Action
Perceptual Action
at
X t–1 processing function
a t–1
Memory
(previous feature
vector and
previous action)