Goals and Emotions Performance measure. Performance measure Sensors. Emotional responses Camera. Sensors. Camera. Microphone Speed gauge

An AI Task Summary of AI Course • To summarise what we have learned, lets build an AI car driver • We will characterise the environment • Choose sen...
2 downloads 1 Views 93KB Size
An AI Task

Summary of AI Course

• To summarise what we have learned, lets build an AI car driver • We will characterise the environment • Choose sensors and sensor processing • Choose a representation for knowledge • Build an environment model • Allow the agent to learn • Show how searching can be used for planning

Goals and Emotions

Goals and Emotions

• Performance measure Sensors

• Performance measure

• Emotional responses

• Reflex trigger

• Camera

• Microphone • Speed gauge

• Emotional responses

Sensors

• Reflex trigger

• Camera

• Microphone Reflex Rules

Actuators

• Speed gauge

•Reflex Rules

• Motors Sensor Processor • Feature detection • Object identification • Encoding and inference

Search and Plan

Controller • Models

• Speakers • Control signals

• Rules

Learner

• Motors •Sensor Processor • Feature detection • Object identification

• Central control

• Encoding and inference

Logic Processor

•Actuators

•Controller

• Speakers

• Models

• Control signals

• Rules • Central control

•Search and Plan

•Learner

•Logic Processor

• Tree search

• Neural networks

• Inference engine

• Tree search

• Neural networks

• Inference engine

• Genetic algorithm

• Decision trees

• Knowledge base

• Genetic algorithm

• Decision trees

• Knowledge base

The Task • To drive a car safely and at a legal and acceptable speed • Specific goals – Avoid crashes – Avoid stopping completely – Make fast progress – Stay on the road

The Environment • Partly hidden (actually, most of it is hidden, as we only see the bit of road ahead of us) • Multi agent – other road users • Fixed, except for other road users, but we move through it so it appears to change • Continuous – you do not drive one step at a time with periods to think in between • Deterministic, with other agents showing some small degree of stochasticity

1

Actuators

Sensors

• We can have either a robot with human limbs to drive a normal car • Or make things easier and fit motors to the steering wheel and pedals • Modern cars have a local network that carries commands from indicators etc., so we could plug directly into that

• A hard solution would be a robot with a head with eyes to look at the road and the dashboard • An easier approach would be a camera mounted on the car, range finders to measure distance, and readings on speed, engine revs etc. straight from the car’s local network

Sensor Processing

Sensor Processing

• Some inputs from sensors are in usable form, speed for example • Others, such as input from the camera need more processing to extract meaning Image from camera

Edge detection

Region of interest finding

Representation

• Knowledge about the environment is inferred from the image

• Road curve angle ahead • Car ahead? • Distance to next car • Distance from side of road • Current gear • Current steering angle etc.

Template matching

Reflex Agent • Simple rules allow the reflex agent to slow down if it is approaching another car, turn at corners, etc. • Will cause excessive slowing at bends when what is around the corner is unknown • Cannot predict the behaviour of other drivers and act accordingly • Driving style is very jerky

2

Environment Model

Modelling the Car

• Smoother driving requires planning ahead • Model usual behaviour of other drivers on the road • Model possible turns a road might take • Model actual knowledge of routes taken before • Model the consequences of actions of the agent in controlling the car

• A simple example: Modelling the gear box • Let’s assume the agent can’t see where the gear stick is or work out what gear it is in from the current speed and revs • It needs to keep track of its actions and update its model of the gear box • So: start in neutral, move lever left and forward, update model state to record current gear = 1st. Etc.

Learning the Model

Learning the Model

• The model could be learned by having a human drive the agent’s car (with sensors running and with recordings of all actuator behaviour) • This data could be used offline to model the environment safely • Better than trial and error approach! • Learn: sensor → predicted event → required action

• Learning by example has the disadvantage that you may never see a crash • So many paths of the decision tree will be unknown to the model • Learning in a simulator would allow a more robust model, with experience of crashes

Off-Line Learning

Data Set for Learning

• Let’s try a neural network • We need to represent the environment and our actions as variables: – – – – – – – –

Angle of road ahead (-180 to +180) Car on road ahead (yes / no) Distance to car ahead (0 to 300m) Steering wheel angle Current brake pressure Current accelerator pressure Speed Outcome (crash, stop, progress)

Road curve

Car

Distance

Steering

Brake

Gas

Speed

Outcome

164

No

182

-21

0.813232

0.834977

65

107

Yes

253

43

0.838104

0.314193

63

Stop

-159

No

64

-34

0.179366

0.787063

62

Progress

85 -129

Crash

Yes

58

46

0.660272

0.08658

34

Stop

No

218

148

0.855358

0.336036

12

Progress

126

Yes

231

-65

0.199282

0.243973

3

Progress

-114

No

167

75

0.917026

0.683029

41

Progress

Yes

52

-159

0.540734

0.051086

58

Progress

11

3

Neural Network Training

Searching the Model

• This data (and a lot more like it) would be:

• Other drivers respond to our actions, and those actions also move us through the environment • To drive more smoothly, we need a flexible plan that chooses a number of steps, predicts their consequences, and then picks more actions • Many possible actions end in a crash • A search is required to find one that doesn’t • Possible actions are passed through the model and the result compared to a goal or performance measure

– Split into training and test set – The training data used to train a neural network to predict outcome from the other variables – The predictions tested on the unseen test data to see if it works – The network used to predict the outcome of actions in a given situation for the tree search

Driver Search Tree

Representing Knowledge

Now

Accelerate

Crash

Brake

Brake

Stop

Turn left

Turn Right

Accelerate

Turn left

Progress

Crash

Turn Right

Crash

Goals = • Avoid crashes • Avoid stopping

• Some knowledge can be pre-programmed, and logic is a good way to represent and manipulate it • ∀x Brake lights on(x) → Slowing(x) • Allows inference about what the car in front is about to do • Car in front slowing → Press brake • You can also infer possible actions to take

• Progress along road

Faster Search

Goals

• Often, the same situation leads to more than one possible correct action: braking or just easing off the accelerator, for example • Logic can cope with this:

• Progress against some of our goals is constantly measurable, speed for example is available from sensors • Avoiding crashing is harder to monitor, as once it has happened, it is too late • Goals can be contradictory – going fast and not crashing! • How does the agent measure performance?

– Car in front slowing → (Press brake U decelerate)

• Searches can be shortened by only following those paths suggested by the logical inference rules • If brake lights in front trigger the need for action, only explore the routes that start with braking and decelerating

4

Artificial Emotions • For measurable goals such as speed, we can define a rule that causes the artificial happiness of the agent to increase • This happiness measure can be used as feedback for learning and planning • We can also use artificial fear, which increases in dangerous situations – perhaps learned from the simulator • Again, minimising fear is part of the goal in the planning search

Artificial Emotions • Just like human emotions, artificial ones can operate at the planning level • And they can operate at a reflex level – When fear goes over a certain value, switch away from searching and planning and put all resources into avoidance – There is no need to search for the very best way of avoiding a crash, just a quick way!

Goals and Emotions

Turing Test

• Performance measure Sensors

• If our car had darkened windows and nobody could see the robot driver, would our agent pass the Turing test? • A domain specific version of it, yes • Would it be truly intelligent? • Depends on your definition – Weak AI: Yes, it appears to drive intelligently – Strong AI: No, it doesn’t experience the driving or have consciousness of it

• Emotional responses • Reflex trigger

• Camera • Microphone • Speed gauge

Reflex Rules

Actuators • Motors

Sensor Processor • Feature detection • Object identification • Encoding and inference

Search and Plan

Controller • Models

• Speakers • Control signals

• Rules • Central control

Learner

Logic Processor

• Tree search

• Neural networks

• Inference engine

• Genetic algorithm

• Decision trees

• Knowledge base

5