Title: 11'3: Movement of Ants plus more Matlab, plus Artificial Life
111.3 Movement of Ants(plus more Matlab, plus
Artificial Life)
2Movement of Ants
- Ant movement complicates the spread-of-fire
model in a number of ways - Each ant has an orientation (N, S, E, W)
- Each cell contains an ant, a quantity of
pheromone (chemical deposited by ants and
attractive to them), both, or neither - Ant cannot move into cell occupied by another
3Ordered Pair Representation
- We can represent ant presence/absence/orientation
using one number 0 no ant 1
E, 2 N, 3 W, 4 Ss - Another number can represent the concentration of
pheromone from zero to some maximum (e.g. 5). - Book suggests using an ordered pair (like
Cartesian coordinate) to combine these e.g., (1,
3) east-facing ant in a cell with a 3/5
concentration of pheromone.
4Single-Number Representation
- Matlab prefers to have a single number in each
cell. So we can use a two-digit number to
represent an ordered pair (3,5) becomes 35 (0,
2) becomes 2, etc. - grid 10ant pheromone
- ant fix(grid/10) fix keeps integer part
- pheromone mod(grid, 10)
5Matrices and Indexing
- Weve seen how to perform operations on an entire
matrix at once grid(rand(n)ltprobTree) 1, etc. - What if we want to operate on individual rows,
columns, and elements? - grid(i, j) accesses row i, column j of grid.
- grid(i, ) accesses all columns of row i
- grid(, j) accesses all rows of column j
6Matrices and Indexing Examples
grid(2, 3) 1 a tree grows at 2,3 grid(1,
) 2 whole top row on fire
7Ranges and Indexing
- But were supposed to start with a gradient strip
of pheromone a range like 0, 1, 2, 3, 4, 5 - In Matlab we can simply say 15
- grid(3, 48) 15
- For a vertical strip, we transpose the range
- grid(26, 4) (15)
- Lets put an arbitrarily long horizontal strip
of gradient in an arbitrary row....
8Initializing the Gradient
phergrid zeros(n) NxN pheromone grid row
fix(randn)1 indices start at 1 len
fix(randn)1 length of gradient strip col
fix(rand(n-len))1 starting
column phergrid(row, colcollen-1) 1len
help me Obi-wan!
9Initializing the Ants
- For trees we simply did
- probTree 0.2
- grid zeros(n)
- grid(rand(n)ltprobTree)
- But here we want several possible values for each
ant - So we can set up a grid full of ant values, then
zero it out where appropriate....
10Initializing the Ants
probAnt 0.2 antgrid fix(4rand(n))1 4
directions antgrid(rand(n) gt probAnt) 0
Putting it all together
grid 10antgrid phergrid
11Updating the Grid
- An ant turns in the direction of the neighboring
cell with the greatest amount of pheromone (in a
tie, pick one at random), then walks in that
direction - If theres no ant in a cell, the pheromone
decreases by 1 at each time step, with a minimum
value of 0. - If an ant leaves a cell, the amount of pheromone
increases by 1 (ant deposits pheromone). - So long as there is an ant in a cell, the amount
of pheromone in the cell stays constant.
12Avoiding Collisions
- For an ant facing in a given direction and about
to walk in that direction, there are three
potential ants in other cells that it could
collide with. - For example, if I am an ant facing North
NN
NE
NW
N
me
13Avoiding Collisions
- Because there are four other directions (S, E,
W), each cell has a potential collision with 12
others
- As a first approximation, we can ignore
collisions e.g., cell is occupied by last ant to
move there, and others go away (maybe replaced by
new ones being born).
14The Big Picture Self-Organization Spontaneous
Orders
- By itself, the rules for movement of ants arent
terribly interesting. - What interests scientists is the spontaneous
orders and self-organizing behaviors that emerge
from such simple systems of rules. - This is a profound idea that shows up in biology,
economics, and the social sciences.
15Spontaneous Orders in Markets
Every individual...generally, indeed, neither
intends to promote the public interest, nor knows
how much he is promoting it. By preferring the
support of domestic to that of foreign industry
he intends only his own security and by
directing that industry in such a manner as its
produce may be of the greatest value, he intends
only his own gain, and he is in this, as in many
other cases, led by an invisible hand to promote
an end which was no part of his intention. -
Adam Smith, The Wealth of Nations
Adam Smith (1723-1790)
16(No Transcript)
17(No Transcript)
18Termite Nest-Building
19Bird Flocks
20Boids Artificial Birds
- Flocks of birds appear to be moving as a coherent
whole, following a leader avoiding obstacles - Can this global behavior instead be emergent from
the local behavior of individuals birds? - Boids (Reynolds 1986) Each boid follows three
simple rules
21Boids Artificial Birds
Separation steer to avoid crowding local
flockmates
Alignment steer towards the average heading of
local flockmates
Cohesion steer to move toward the average
position of local flockmates
http//www.red3d.com/cwr/boids/
22Evolution of Cooperation
- Consider the Prisoners Dilemma game where you
and I are arrested for committing a crime. - If I defect (rat you out) and you cooperate with
me (keep quiet), you get 10 years and I go free. - If I cooperate and you defect, I get 10 years and
you go free. - If we both cooperate, we each get six months
- If we both defect, we both get five years.
- What is the best strategy?
23Evolution of Cooperation
- The best strategy is for me is to defect (same
for you). - If I defect, the expected value (average value)
of my punishment is 2.5 years (0 if you
cooperate, 5 if you defect) - If I cooperate, the expected value of my
punishment is 5.25 years (6 months if you
cooperate, 10 years if you defect). - But what if we repeat this game over and over,
allowing each of us to remember what others did
in previous iterations (repetitions)?
24Iterated Prisoners Dilemma
- Axelrod (1981/1984) Held a simulated tournament
among various PD strategies submitted by
contestants - Strategies could be arbitrarily simple (always
defect, always cooperate) or complicated (keep
track of other guys last five moves, then try to
predict what hell do next time, etc.) - Amazingly, winning strategy was simple
tit for tat (quid pro
quo) - Always cooperate with someone the first
time. - Subsequently, do what he did on your
previous encounter with him.
25Iterated Prisoners Dilemma (Artificial) Life
Lessons?
- In general, most successful strategies followed
four rules - Be nice Dont be the first to defect
- Be provocable (dont be a sucker)
- Dont be envious dont strive for a payoff
greater than the other players - Dont be to clever (KISS principle)
26The Bad News People Are Naturally Envious
- Ultimatum game psychology experiment with human
subjects (Güth et al. 1982) -
- Subject A is given 10 and told to share some of
it (in whole ) with subject B, where B knows
how much A is given - Optimal for A is to give B 1 and keep 9
- Typically, A will offer 3, and B will refuse to
accept anything less (!)
27The Good News TFT is an Evolutionarily Stable
Strategy
- Q What happens when we introduce a cheater
(always defects) into a population of TFT
players? - A The cheater initially gains some points by
exploiting TFT players niceness, but soon is
overwhelmed by subsequent TFT retribution. - So TFT is an evolutionarily stable strategy
(Maynard-Smith 1982)
28Evolution of Communication
- What is communication?
- Communication is the phenomenon of one organism
producing a signal that when responded to by
another organism confers some advantage (or the
statistical probability of it) to the signaler or
his group. - - G. Burghardt (1970)
- How does a community come to share a common
system of communication (language)?
29Evolution of Communication
- MacLennan (1990) Simulate communication by a
simple matching game each simorg (simulated
organism) has a private situation that it wants
to describe to others.
30- MacLennan (1990) Simulation communication by a
simple matching game - To communicate a situation, the individual looks
up its current situation in a table and emits an
symbol into the shared environment - Each individual then uses its own table to
convert the shared symbol back into a guess about
the private situation of the emitter. - Whenever an individual matches the emitters
situation, it and the emitter get a fitness point - Individuals with highest fitness get to survive
31Evolution of Communication Results, Fitness
fitness
iteration
32Evolution of Communication Results, Denotation
Matrix
First iteration random association of symbols
with situations
33Evolution of Communication Results, Denotation
Matrix
Last iteration systematic association of symbols
with situations
34synonyms
35homonyms
36Quantifying Denotation (Dis)order
- Shannon Information Entropy quantifies (in
bits) amount of disorder in a distribution
where pk is the probability of event (situation) k
- Examples
- p 0.25, .25, .25, .25, H 2.0
- p .95, .025, .0125 ,.0125 , H 0.36
Claude Shannon (1916-2001)
37Choosing the Next Generation
Fitness-Proportionate Selection use our biased
roulette wheel to favor individuals with higher
fitness, without ruling out selection of
low-fitness individuals
individuals
i1
i3
i4
i2
8
10
22
60
normalized fitnesses
38Iterating Over Generations
- A highly expressive language like Matlab may
allow us to avoid explicit iteration (looping),
via operators like sum, gt , etc. - But when the current generation (population)
depends on the previous one, we say that the
model is inherently iterative. - For such models we use an explicit loop,
typically a for loop....
39Original Population Model in Matlab
growth rate k 0.1 initial population P0
100 P zeros(1, 20) P(1) P0 iterate for
t 220 P(t) P(t-1) kP(t-1) end
analytical solution Pa P0 exp(k120)
overlay plots plot(P) hold on plot(Pa, 'r') red
40Modeling Simulation Conclusions
- Cellular automata and related simulations can be
a powerful and exciting way of exploring
phenomena for which an actual experiment is too
difficult or costly. - But one must be careful not to build-in the
very behavior that one claims is emergent. - One must also be careful not to over-interpret
the results.
41Potential Projects
- Implement collision avoidance in ants simulation.
- Implement Conways Game of Life in init, update
functions. - Implement MacLennans evolution of communication
algorithm.