AI Lecture Nortes
Tim Blackwell
October 24, 2016
Contents
Contents
1 Intelligent agents
2 Solving problems by searching
2.1 Problem solving agents . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Well-dened problems . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Searching for solutions . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
5
5
3 Uninformed search strategies
3.1 Breadth rst search . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Depth rst search . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Depth-limited search . . . . . . . . . . . . . . . . . . . . . . . . . .
9
9
10
11
4 Informed search
4.1 Hill climbing/gradient descent
4.2 Local beam search . . . . . . .
4.3 Simulated annealing . . . . . .
4.4 Genetic algorithms . . . . . . .
4.5 Swarm optimisation . . . . . .
13
14
14
14
15
16
.
.
.
.
.
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
CONTENTS
5 Adversarial search
5.1 Optimal strategies - turn taking . . . . . . . . . . . . . . . . . . . . .
5.2 Optimal strategies - simultaneous moves . . . . . . . . . . . . . . . .
5.3 Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
17
17
18
21
6 Articial creativity and live algorithms
6.1 Genetic Jingle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2 Live algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
23
23
23
7 Labwork and coursework
7.1 Uninformed search . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.2 Informed search . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.3 Game theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
25
27
27
Chapter 1
Intelligent agents
Agent
Anything that perceives its environment through sensors, and can act on the environment with actuators. Or, it has inputs and outputs, but the outputs might be
movements and other physical changes.
Action
How the agent changes the external environment.
Percept, percept sequence
The agents (systems) inputs at any time; the percept sequence is the the complete
history of everything the agent has perceived.
Performance measure
Quanties how successful the agent has been.
The rational agent
For every possible percept sequence and whatever built-in knowledge, the agent
acts, insofar as it can, in order to maximise the performance measure.
Intelligence, AI
Intelligence is concerned with rational action; AI is the study of rational agents; an
articial intelligence is a rational agent.
3
CHAPTER 1. INTELLIGENT AGENTS
Autonomy
The extent to which an agent relies on percepts rather then prior knowledge.
Chapter 2
Solving problems by searching
2.1
Problem solving agents
The performance measure is sometimes simply a goal. The problem is deciding what
actions and states to consider, given a goal. Search is the process of looking for the
sequence of actions that will lead to the goal.
2.2
Well-dened problems
1. Initial state A specication of the agent at the outset.
2. A description of the possible actions
3. Transition model A description of what each action does. The state space
comprises all states reachable from the initial state by any sequence of actions,
and the actions that link states. An actions on a state produces a successor.
The state space is a directed network or graph where the nodes are states and
the edges are actions.
4. Goal test Determines if a specic state is the goal.
5. Path cost The numeric cost of a path in state space
2.3
Searching for solutions
Search tree
All possible action sequences starting at the initial state.
5
CHAPTER 2. SOLVING PROBLEMS BY SEARCHING
Expanding the current state
The application of all legal actions to the current state. This is the essence of search:
follow one option now and put the others on hold.
Frontier
The collection of nodes that have been generated but not yet expanded. Each element of the frontier is a leaf node. Leaf nodes have no successors in the search
tree.
Search strategy
Choosing what state to expand next.
Termination
The conclusion of the search due to either (i) a solution is found or (ii) no states are
left to expand.
Search strategy
A scheme for deciding which state to expand next.
2.3. SEARCHING FOR SOLUTIONS
Algorithm 1
1: procedure SimpleTreeSearch
2:
add initial state to frontier
3:
loop
4:
if frontier is empty then
5:
return failure
6:
choose and remove a node from the frontier
7:
if node contains a goal state then
8:
return the corresponding solution
9:
expand the chosen node and add resulting nodes to the frontier
Algorithm 2
1: procedure SimpleGraphSearch
2:
initialise explored set to empty
3:
add initial state to the frontier
4:
loop
5:
if frontier is empty then
6:
return failure
7:
choose and remove a node from the frontier
8:
if node contains a goal state then
9:
return the corresponding solution
10:
add the chosen node to the explored set
11:
expand the chosen node and add the resulting nodes to the frontier
12:
only if not in frontier or explored
Tree search
Notice that states can repeat, leading to loopy paths. A redundant path exists whenever there is more than one way to get from one state to another. E.g. route nding
on a rectangular grid: each state has four successors so at depth d there are 4d leaves
but only about 2d2 distinct states.
The agent needs to remember where it has been if it wants to avoid redundant
paths.
Explored set
A data structure containing every expanded node.
CHAPTER 2. SOLVING PROBLEMS BY SEARCHING
Graph search
Graph search systematically examines all states in state space.
Measuring performance
Completeness. Is the algorithm guaranteed to nd a solution when there is
one?
Optimality.
Time complexity
Space complexity
In AI we measure complexity by:
the maximum number of successors of any node (branching factor, b)
the depth of the shallowest goal node (d)
and the maximum length of any path in state space (m).
Time complexity, expressible in terms of b, d, m is the number of nodes generated
during the search and space complexity is the maximum number of nodes stored in
memory, again expressed in terms of b, d, m.
Chapter 3
Uninformed search strategies
3.1
Breadth rst search
Expand root node, then all its successors, then their successors etc.
Always expand the shallowest node.
The fringe is implemented as a FIFO queue. A node is removed from the head
of the queue and nodes are added to the tail.
Breadth-rst graph search diers from simple graph search the goal test is applied to each node when it is generated rather than when it is chosen for expansion.
Algorithm 3
1: procedure BreadthFirstGraphSearch
2:
if initial state is a goal state then
3:
return the corresponding solution
4:
initialise explored set to empty
5:
add initial state to the frontier
6:
loop
7:
if frontier is empty then
8:
return failure
9:
choose and remove a node from the frontier
10:
add the chosen node to the explored set
11:
expand the chosen node
12:
loop for each node in the expanded set
13:
if not in frontier or explored then
14:
if node contains a goal state then
15:
return the corresponding solution
16:
add the resulting nodes to the frontier
9
10
CHAPTER 3. UNINFORMED SEARCH STRATEGIES
Complete - yes, obviously
Optimal - as soon as the goal node is generated we know it is the shallowest
because all shallower have been generated already and have failed the goal test. So
breadth rst graph search will be optimal of all actions have the same cost - as they
have for movement in a 2D grid.
Time complexity - suppose each node generates b more nodes an that the solution is at depth d. At worst the goal is the last node generated. So the total number
of nodes generated is b + b2 + b3 + . . . + bd = O(bd )1 .
Space complexity - There will be O(bd1 ) nodes in explored and O(bd ) in the
frontier. Hence the storage is O(bd ). The time complexity is bad, but the space
complexity is worse - can always wait longer to get the answer, but the computer
will crash when memory is exhausted.
Exponential-complexity problems cannot be solved by uniformed methods for
any but the smallest instances.
3.2
Depth rst search
Depth rst always expands the deepest node in the frontier.
Depth-rst graph search is complete (in nite state spaces) because it will always
expand very node.
Depth-rst tree search is not complete because of loops. Although we can prevent loops by not adding a node to the frontier that is already on the path tot he
current node, we can not prevent redundant states.
Both types of depth rst searches fail in innite search spaces if an innite nongoal path is encountered.
For similar reasons, both are non-optimal.
The time complexity of depth-rst graph search is bounded by the size of the
search space (which may be innite). For nite spaces, b and m are nite and the
time complexity is O(bm ); this can be much greater than the size of the search space.
So, depth-rst tree search is not complete or optimal and has exponential running time. So we do we bother even mentioning it?
Because it has non-exponential space complexity. Once a node has been expanded, it can be removed from memory once all its descendants have been fully
explored. So it only needs O(bm) memory.
T (n) = O(f (n)) means that T (n) const f (n) for all n > n0 . For example, T = n + n2 kn2
1
for n n0 = k1
1
3.3. DEPTH-LIMITED SEARCH
performance measure
completeness
time
space
optimality
3.3
breadth rst tree search
yes
O(bd )
O(bd )
yes
11
depth rst tree search
no
O(bm )
O(bm)
no
Depth-limited search
Tree search is economical on memory, but trees can grow without limit. A simple
idea is to limit trees to a depth, l, so that nodes at depth l are treated as if they
have no successors. Clearly DepthLimitedSearch is incomplete if l < d, and nonoptimal if l > d. The space and time complexities are as for depth-rst search, but
with m (the maximum length of any path in state space) replaced by l (the eective
maximum path length).
Chapter 4
Informed search
The problems we have studied so far of have required solutions that are paths. But
many other problems only require the discovery of a goal - the path is irrelevant.
We have learnt that, without any information on the location of the goal, and if
the search space is not too big, the rational agent can do more than search systematically, and without repeats. Otherwise a memory limited search must be employed,
such a depth-rst search, or depth-limited search.
Suppose though that the agent does have access to some information, and that
the path to the goal is not important. All the agent has to do is nd the goal.
Local search algorithms base their next step on the current state, not on the
path followed so far. The paths followed are not retained. The advantages are:
1. Small memory requirement
2. Very large, perhaps even innite spaces can be searched.
The agent typically moves to a neighbouring state based on local information.
This is a local search strategy. Often the problem can be formulated as an optimisation problem. T
he local knowledge is the value of an objective function, f . The goal is to
nd the global maximum or minimum of f for (typically continuous) states x in the
search space X :
!
min
x = arg
f (x) for x X.
max
The surface f (x) is known as the state space or tness landscape. Landscapes may have a single optimum (monomodal), shoulders, local optima (multimodal), at optima and ridges. Any of these features can pose problems for algorithms.
A strategy is complete if it always nds the goal. A strategy is optimal if it nds
x . (x always exists for continuous spaces.)
13
14
4.1
CHAPTER 4. INFORMED SEARCH
Hill climbing/gradient descent
Simple. Wherever you are, move upwards/downwards. Its greedy search by another
name. It can be very fast, and is optimal if f is monomodal. Hill climbing/descending can get stuck in: local optima, on ridges and on plateaux.
These pathologies can be tackled by choosing from random amongst the uphill
moves (stochastic hill climbing) and random restarts.
4.2
Local beam search
We have lots of memory since we are not storing paths. So keep k states in memory.
Expand each state to nd successors. If a good enough solution is found then we
are done. Otherwise retain the k best states.
Run k local searches in parallel. Retain the k best successors at every step. This
diers from a search with k restarts, or k independent searches because useful information is passed between the beams.
The parallel beams can quickly converge on a small region of search space. They
suer from a lack of diversity. In stochastic beam search, the successors are chosen
at random with a probability that depends on their worth.
Problem: lack of diversity. Can cope with that by selecting the k successors at
random with a probability depending on how good the successor is. This is very
much like a genetic algorithm.
4.3
Simulated annealing
Analogy: ball falling down bumpy hillside. If the ball gets stuck in a local optima,
imagine shaking the landscape to dislodge the ball.
SimulatedAnnealing is based on an analogy with annealing, a process that
hardens metals by heating them to a high temperature and then cooling them slowly
so that they form a large crystal.
Suppose the problem is one of minimisation. A move is chosen at random. The
move is accepted if it improves the situation. Otherwise, the move is accepted with
probability ef /T where f = f (expand) f (current). Or,
expand = random(current)
move to expand with probability = min{1, ef /T }.
T is slowly reduced so that moves to states with large positive f become more
and more unlikely.
4.4. GENETIC ALGORITHMS
15
Algorithm 4
1: procedure Simulated Annealing
2:
current start node
3:
t0
4:
loop
5:
T schedule(t)
6:
if T = 0 then // GOAL TEST
7:
return current
8:
next a random neighbour of current // EXPAND
9:
E = f (next) f (current)
10:
if u U (0, 1) < eE/T then // SELECT
11:
current next
12:
tt+1
u U (0, 1) a pseudorandom number between 0 and 1 inclusive. If E is negative, f (next) < f (current) then next will be chosen; otherwise next will be chosen
with probability eE/T .
4.4
Genetic algorithms
A population of individuals; each individual is a chromosome, a string of genes. The
chromosome encodes the possible solutions to the problem. The exact encoding is
a matter of problem representation. The choice of representation can make a huge
dierence to performance.
Algorithm 5
1: procedure Genetic Algorithm
2:
initialise population in search space
3:
loop
4:
pool empty
5:
evaluate population
6:
if best individual is good enough or enough time has passed then
7:
return best individual // GOAL TEST
8:
while pool is not full do
9:
select parents from the population according to tness // SELECT
10:
produce ospring by cross over // EXPAND
11:
mutate ospring
12:
add ospring to pool
13:
population pool
16
4.5
CHAPTER 4. INFORMED SEARCH
Swarm optimisation
pi X is the current position of an agent (known in this context as a particle) in
the search space. Like beam search, there are k particles - a swarm, but unlike beam
search, the k best positions are not retained. Each particle retains its best position:
currenti best(nexti , currenti )
Trial positions (next nodes) are generated by statistical sampling:
xi (t + 1) g(t) + |pi1 (t) pi1 (t)|N (0, 1)
or
xi (t + 1) N (g, 2 )
where N (, 2 ) is the normal distribution, centred at and with standard deviation
. , are subtraction and addition modulo k and g is the best current position in
the entire swarm and the variance. 2 is |pi1 (t) pi1 (t).
Convergence is not due to freezing, but is controlled by the parameter and the
closeness of the neighbours.
Algorithm 6
1: procedure Swarm Algorithm
2:
initialise a population of particles in search space
3:
t0
4:
loop
5:
for each particle in swarm do
6:
p(t + 1) = arg min (f (p(t)) , f (x(t))) // SELECT
7:
if best particle is good enough or enough time has passed then
8:
return best individual // GOAL TEST
9:
for each particle in swarm do
10:
x(t + 1) g(t) + |plef t (t) pright (t)|N (0, 1) // EXPAND
11:
tt+1
Chapter 5
Adversarial search
Multiagent environment
Each agent has to consider the actions of the other agents. Environments are either
cooperative or adversarial (or neutral: the agents do not interact in any way).
Game theory
A branch of economics, studies adversarial search. The search for the best strategy
in a multiagent environment.
Zero-sum games
Turn taking with perfect information. The utility values at the end of the game are
equal and opposite.
Game as search
A game is a search problem in which we identify the initial state as the starting point
of the game and the rst player to move, the successor function as (move, state) pairs,
where move is any legal move, a terminal test determines when the game is over and
a utility function (objective function, payo) which gives a numeric value to the
terminal states. The search tree is now a game tree.
5.1
Optimal strategies - turn taking
Call the two players Max and Min. Max is trying to reach the terminal state of
highest utility but Min is making Maxs search as dicult as possible.
17
18
CHAPTER 5. ADVERSARIAL SEARCH
Max starts and can choose a1 , a2 or a3 . If Max chooses a1 then Min can choose
b1 , b2 or b3 .
Lets suppose the game is over - a simple game of two half moves (a single ply).
After b1 , b2 or b3 , the game has reached terminal nodes 11, 12 or 13 with utility values
U (11) = 3, U (12) = 12, U (13) = 8.
Which move will Min chose, after Maxs a1 . Min, being rational, will chose b1 .
The minimax value of node 1 is U (1) = 3. Max knows, that if she plays a1 , then
she is certain to receive a score of 3, since Min is rational.
Max therefore must chose the maximum of the minimax values of the three
available nodes, 1, 2, 3, because Max is also rational.. Suppose U (2) = 2, U (3) = 2.
Max must maximise the minimax value, dened recursively as
U (n) if n is a terminal state
minimax(n) = maxsSuccessors(n) minimax(s) if n is a max node
minsSuccessors(n) minimax(s) if n is a min node
The minimax algorithm performs a complete depth rst search of the game tree.
We already know the complexities for depth rst search. The time complexity is
O(bm ) and the space complexity is O(bm) (if the algorithm generates all the successors at once).
5.2
Optimal strategies - simultaneous moves
Player
Another name for agent
Pay-o matrix
Here, for the game of Morra.
O: one
O: two
E: one E = 2, O = 2 E = 3, O = 3
E: two E = 3, O = 3 E = 4, O = 4
Notice that this is a zero-sum game.
Pure strategy
A deterministic strategy. For a one-move game, a pure strategy is a single action.
5.2. OPTIMAL STRATEGIES - SIMULTANEOUS MOVES
19
Mixed strategy
Actions are chosen stochastically i.e. with probability. represent a mixed strategy
as, for example, [p : s, (1 p) : s ].
Strategy prole
An assignment of strategy to each player.
The prisoners dilemma
Dr Wongs slides:
[Link]
[Link]
[Link]
[Link]
Two burglars caught with stolen goods. If they keep quiet they will each get one
year for possession. If A testies against B, and B keeps quiet, then A will go free
and B will get ten years (and the other way around). But if both testify against each
other, both get 5 years.
Bob: refuse
Bob: testify
Alice: refuse
B = 1, A = 1
B = 0, A = 10
Alice: testify
B = 10, A = 0
B = 5, A = 5
Alice reasons like this: suppose Bob testies. Then I should testify as well because a payo of -5 is better than one of -10. But if Bob refuses, I should still testify,
for a similar reason.
Alice therefore testies.
Testify is often called defect and refuse is called cooperate.
A game is a prisoners dilemma for any pay-o matrix of the form
B: Cooperate
B: Defect
A: Cooperate
B = R, A = R
B = T, A = S
A: Defect
B = S, A = T
B = P, A = P
with T > R > P > S (testify, reward, penalty, sucker).
For example
B: Cooperate
B: Defect
A: Cooperate
B = 3, A = 3
B = 5, A = 0
A: Defect
B = 0, A = 5
B = 1, A = 1
20
CHAPTER 5. ADVERSARIAL SEARCH
or, abbreviated,
B: Cooperate
B: Defect
A: Cooperate
3, 3
5, 0
A: Defect
0, 5
1, 1
Domination
For a particular player: s strongly dominates s if the outcome is better for every
possible strategy of the other players.
s weakly dominates s if it is better on at least one strategy prole, and no worse
on the others.
Dominant strategy
A strategy that dominates all others.
Both Alice and Bobs dominant strategy is to testify because T > R and P > S .
Not all games have a dominant strategy - for example:
B: dvd
B: blu-ray
A: dvd
B = 9, A = 9
B = 3, A = 3
A: blu-ray
B = 1, A = 4
B = 5, A = 5
Nash equilibrium
A strategy prole is in equilibrium if no player can benet from switching strategies
if all the others stick. It is a local optimum in the space of policies.
All games have an equilibrium, although they might involve mixed strategies.
The dvd-bluray payo matrix has two Nash equilibria (dvd, dvd) and (blu-ray.
blu-ray) - but no dominant strategy.
Finding Nash equilibia in zero-sum games
First look for pure strategies. If moving horizontally or vertically in the pay-o table
gives a worse payo for A (horizontal) of B (vertical) then we have found one.
But Morra does not have a pure strategy Nash equilibrium.
Analyse using minimax.
Suppose E is Max and O in Min.
E plays rst, playing one with probability p and two with probability 1 p.
5.3. QUESTIONS
21
If E plays one, and O choses one, Es payo will be 2. If E plays two and O plays
one, Es payo is -3. But E only plays one with probability p. So the expected payo
for E, if O plays one is (2)p + (-3)(1-p) = 5p - 3.
The expected payo for E, if O plays two, is 4 - 7p.
O has to minimise Es payo because this is a zero-sum game. By minimising Es
payo, O maximises hers.
7
7
7
Now 5p 3 < 4 7p for p < 12
and 5p 3 > 4 7p for p > 12
. So for p < 12
,
7
O will chose one, and for p > 12 , O will choose two.
7
The best E can do at the start is set p to 12
, and receive an expected payo of
7
1
5( 12
) 3 = 12
.
We can push the same analysis forward from Os perspective, and we get the
7
same result: O should also set her p to 12
, but (since this is a zero-sum game), Os
1
expected payo is 12 .
7
5
There is a maximin equilibrium: both players chose strategies [ 12
: one, 12
: two]
Every two-player zero-sum game has a maximin equilibrium when you allow
mixed strategies
Every Nash equilibrium in a two-player zero-sum game is a maximin equilibrium for both players
5.3
Questions
1. Several people choose a real number between 0 and 100 in the hope of guessing
what 23 of the average will be. Is there a dominant strategy? There is a unique
pure strategy Nash equilibrium. What is it?
2.
B: go shopping
B: watch football
A: go shopping
A = 2, B = 1
A = 0, B = 0
A: watch football
A = 0, B = 0
A = 1, B = 2
Are there any pure-strategy Nash equilibria?
3. Draw the payo table for rock-paper-scissors. Assume that a win is worth 1, a
loss is worth -1 (zero-sum game). Are there any pure-strategy Nash equilibria?
4.
B: swerve
B: straight
A: swerve
A = 0, B = 0
A = 1, B = 1
A: straight
A = 1, B = 1
A = 10, B = 10
Are there any pure-strategy Nash equilibria?
Chapter 6
Articial creativity and live
algorithms
6.1
Genetic Jingle
The evaluation function is provided by the user. The user and algorithm are working
together in partnership. The goal is not necessarily optimisation. The rational agent
denition of intelligence seems less appropriate in this context.
The behaviour of algorithms in articial creativity might be very dependent on
representation.
The chromosome (representation) in Genetic Jingle is
(p1 , v1 , t1 ), (p2 , v2 , t2 ), . . . (pn , vn , tn )
where pi is a note number (pitch), vi is loudness and ti is event duration. A note of
loudness 0 is a rest.
6.2
Live algorithms
A live algorithm is an autonomous partner in a particular creative activity. It assumes, at least in theory, an equivalent role to a human, and could be viewed as the
application of AI to the arts. However, the AI is not intent on well dened problem
solving, and must be autonomous, more like a robot. The machine has to appear as
a creative individual and not a slave.
In particular, live algorithms have been developed for music improvisation (Swarm
Music).
23
Chapter 7
Labwork and coursework
Labwork
Get used to AntWorld and try some things out from any of the projects listed below.
Dip in and see which ones you like.
Coursework
Pick one project from uninformed search, informed search or game theory. (E.g.
You are interested in informed search. You pick 4.2.1: greedy search. You do not
need to answer 4.2.2, 4.2.3 or 4.2.4.)
Submit a pdf document. This document will contain everything that the question asks for: pseudocode, experiments, results and evaluation and snippets of original code, if appropriate. Write in the third person. This is a technical report.
The more challenging mini-projects are towards the bottom of the list in each
category. These projects are open-ended. Less complete answers are expected.
High marks will be awarded for insight, understanding, originality and adventure.
7.1
1.
Uninformed search
a) Run breadth-rst SimpleTreeSearch on a 16x16 grid with the start cell
(nest) at (2, 2), the goal (food) at (13, 13) and with no obstacles.
What do you notice?
What causes this behaviour?
b) Now run depth-rst SimpleTreeSearch on the above conguration.
What do you notice?
What causes this behaviour?
25
26
CHAPTER 7. LABWORK AND COURSEWORK
c) Run BreadthFirstGraphSearch with the goal in dierent positions.
What is the average number of steps (the path length) from nest to food?
Is BreadthFirstGraphSearch optimal for a specic conguration?
Is BreadthFirstGraphSearch optimal when averaged over all congurations?
2. Suppose that RandomSearch has the following rule: the ant moves to an
available neighbouring cell, picked uniformly at random. (By available, I mean
the cell is neither an obstacle or outside the grid.)
a) Write RandomSearch as pseudocode.
b) Implement RandomSearch as a method in Ant.
c) Run some experiments with dierent congurations of food and obstacles. Report your ndings.
d) Is RandomSearch complete? Optimal? What is its time and space complexity?
e) RandomSearch has one obvious pathology. What is it?
f) Fix it.
g) Evaluate your new algorithm
3. Write pseudocode for DepthLimitedSearch and implement the algorithm
in Ant. Run experiments and make comparisons with other search strategies.
4. ZipfSearch runs like this: a step count is drawn from the Zipf distribution.
The ant walks in a straight line, chosen uniformly at random, by that number
of steps, unless it encounters an obstacle or the boundary, in which case the
step count and direction are reset.
Compare ZipfSearch and RandomSearch over a variety of congurations of
nest, food and obstacles.
A possible improvement is to chose the new direction from the available directions not including the current direction. This should help avoid backtracking.
5. Write pseudocode for a random search algorithm with memory. Implement
your algorithm. Compare its performance with BreadthFirstGraphSearch.
7.2. INFORMED SEARCH
7.2
27
Informed search
1. The searcher has access, in informed search, to an objective function f - perhaps mimicking the smell of food in the air on a calm day. Suppose the
searcher always moves to the best neighbouring cell. This is called
GreedySearch.
Write pseudocode for a greedy algorithm and implement it. Watch the performance of GreedySearch without and with obstacles. What do you notice?
Fix the pathology.
Repeat the experiments with a noisy objective function - think of the smell of
food on a windy day. Experiment with the amount of noise and report your
results.
2. Implement any of the non-classical algorithms from Russell and Norvig. Report your ndings
3. Invent your own algorithm and run some experiments.
4. Try any of the non-classical algorithms, or an ant algorithm (i.e. a population
of ants), or an original algorithm on a deceptive objective function.
7.3
Game theory
1. The iterated prisoners dilemma. Write a program to run competitions between
rival strategies. [Link]