Lecture 1-AIx

hostitchΤεχνίτη Νοημοσύνη και Ρομποτική

23 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

54 εμφανίσεις

Computer Vision

and

Artificial Intelligence


6052
COMP

Prof.
Abdennour

El
Rhalibi

Room
639

a.elrhalibi@ljmu.ac.uk


Dr.

Yuanyuan

Shen

Room
741

y.shen@ljmu.ac.uk


2

Module Details (Attempt)


Semester
2
: Artificial Intelligence


Introduction to Artificial Intelligence in Games


Game AI and Search Techniques


Minimax

and Alpha
-
Beta algorithms


Logic Models: Boolean, Predicate, Fuzzy Logic


Expert Systems and Game AI


Multi
-
Agent Systems


Adaptive AI in Games


Decision Trees and Classifiers


Neural Network


Genetic Algorithm


Revision

3

Indicative References


Ahlquist
, J. (
2007
) 'Game Development Essentials: Game Artificial Intelligence'
1
Pap/Cdr
1418038571


Furnkranz
, J.,
Miroslav
, K. (
2002
) 'Machines That Learn to Play Games
(Advances in Computation: Theory & Practice)' Nova Biomedical
1590330218


Schwab, B. (
2004
) 'Game Engine Programming' Charles River Media
1
-
58450
-
344
-
2


Buckland, M. (
2004
) 'Programming Game AI by Example'
Wordware

Publishing,
Inc
1
-
55622
-
078
-
2


Deloura
, M. & Rabin, S. (
2002
) 'AI Game Programming Wisdom' Charles River
Media
1
-
58450
-
077
-
8


Dorfman
, L. &
Ghosh
, N. (
1996
) 'Developing Games that Learn' Manning
Publications
0
-
13
-
569617
-
8


Funge
, J. (
1999
) 'AI for Computer Games and Animation: A Cognitive
Modelling

Approach' AK Peters, Ltd.
1
-
568
-
81103
-
9


Russel

&
Norvig

(
2003
) ''Artificial Intelligence :A Modern Approach'
2
nd Prentice
Hall


Muller, Woodridge & Jennings (
1997
) 'Intelligent Agents
lll
: Agent Theories
Architecture & Languages' Springer
Verlag

+


The
Internet

4



Introduction to
Artificial Intelligence

Lecture
1

5

5

What is AI?


The study of computational systems
that “exhibit intelligence”


Pragmatic
Definition


Theories and computational models


Game AI is the control of every non
player character (NPC) in a game
(using these computational systems)


The other cars in a racing game


The opponents and monsters in a first
-
person shooter


Your units or your enemy’s units in a RTS
game

6

6

The role of AI in Games


Opponents


Teammates


Support characters


Autonomous characters (NPCs)


Commentators


Camera control


Plot and story guides/directors

7

7

Goals of an AI action Game
Opponent



Provide a challenging opponent…



…but not too challenging


Should not be superhuman in accuracy,
precision, sensing, etc.


Not always as challenging as a human



Should not be too predictable


A number of techniques provide for this:


Randomness


Multiple, fine
-
grained responses


Adaptation and learning

8

AI:
Genesis and Highlights


Logical

reasoning

calculus

was

conceived

(Leibniz,

17

century)



Leibiz


motivation
:

solve

intellectual

arguments

by

calculation



Boolean

logic

(Boole,

1847
)



Predicate

Logic

(
Frege
,

1879
)
:



Incompleteness

Theorem

(
Goedel
,

1940
’s)




Turing’s

article

about

what

machines

can

do



Term

AI

is

coined

at

the

Dartmouth

conference

(
1956
)



General

Problem

Solver

(Newell

&

Simon
;

1958
)



Period

of

great

expectations

(
1960
’s
-
70
’s)


9

AI: Some Historical Highlights
(cont’d)


Perceptrons
:

limits

to

neural

networks

(
Minksy

and

Papert
;

1969
)



Knowledge
-
based

systems

(
1970
’s)



AI

becomes

an

industry
.

Early

successes

of

Expert

systems

10

AI: Some Historical Highlights
(cont’d)


It

becomes

clear

that

expert

systems

are

hard

to

create

(problem

known

as

the

Knowledge

Acquisition

bottleneck
)



Renaissance

of

neural

networks

as

connectionism



1990
’s
:

more

consolidated

approaches

to

AI,

more

realistic

expectations,

fielded

applications
:



Applications

of

machine

learning

to

data
-
mining


Applications

of

various

AI

techniques

to

computer

games


11

Some Subareas of AI


Search


Planning


Natural

language

processing


Machine

learning


Case
-
based

reasoning


Robotics


Computer

vision


Neural

networks

12

Inoculation

All

the

topics

studied

in

this

module

(
e
.
g

Expert

Systems,

ANN

or

g
enetic

algorithms,

etc

)

are

Subfields

of

Artificial

Intelligence

(AI)
.


AI

is

about

many

things

-

different

things

to

different

people

Philosophers,

Psychologists

and

others

beginning

with

P

are

interested

in

the

nature

of

intelligence

and

mind

(they

use

AI

to

put

a

computer

in

front

of

the

armchair

they

use

for

speculation)
.


We

are

NOT!!!!!


This

doesn't

mean

these

aren't

interesting

questions

(like

“why

am

I

here?”,

“is

there

a

god?”,


)

simply

that

they

are

issues

of

no

relevance

to

us

(currently)

as

engineers
.


13

AI
have had more nonsense written about
it than
possibly any other field of human study. This means
you will have to be very critical of things you read.

In particular be very, very wary of any system
designs or discussions which imply that there is
some clever intelligent component which solves all
the tricky problems.

Systems which contain labels such as “meaning
analyser”, “understanding”, “goal directed
behaviour”....very quickly tend to gain things like
thoughts and beliefs if we are sloppy about our
thinking and reasoning.

The course has no answers to fundamental
philosophical questions
-

only techniques for solving
practical
problems for AI and in particular Game AI.


14

What

is

Artificial

Intelligence
?



...
the

building

of

computer

systems

which

address

problems

which

if

solved

by

a

human

would

be

considered

to

require

intelligence

eg

playing

chess,

game

NPC,

diagnosing

illness,

planning,

learning,

theorem

proving,

teaching
...


this

doesn't

say

anything

about

what

intelligence

is

because

nobody

knows

AI

(under

our

definition)

is

about

solving

problems
.

One

of

the

major

mechanisms

for

solving

problems

in

AI

is

SEARCH
.

Search

is

fundamental

within

AI

-

it

involves

two

important

ideas

(
i
)

Representation

(ii)

Reasoning

We

reason

about

representations

to

solve

problems


15

What

is

Game

Artificial

Intelligence
?


“...

Artificial Intelligence (AI) adds behavior
to Non
-
Playable Characters (NPCs)



Behavior

can

be

low
-

or

high
-
level



Low
-
level

behavior

such

as

finding

a

path

from

current

position

to

target

is

vital

to

games



High
-
level

behavior

such

as

decision

making

adds

realism

to

human

(or

human
-
like)

NPCs



..

Features

World/Perception

Modeling



Mobility

(Where

NPCs

can

move

through)



Visibility

(What

NPCs

can

see)



Audibility

(What

NPCs

can

here)

Path
-
Finding

Behavior

Modeling



Finite
-
State

Machine

(FSM)



Artificial

Neural

Network

(ANN)



Rule
-
based

Systems




Team

Collaboration

16

For

example

if

we

have

a

problem

such

as

the

n

queens

problem

-

placing

a

queen

on

all

the

rows

of

a

chess

board

so

that

no

queen

can

take

any

other




Q




















Q




















Q





Q




















Q








we need a
Representation

(
eg

pieces, moves, board) with which
we can
Reason

(consider different configurations of the
representation in an attempt to find a solution)

Search is about finding a route through the space of possible
configurations until we find one that corresponds to a solution to
our problem (or find them all, or some, or none)

17

Representation

If we wish to reason about a domain we need some way of
encoding information about that domain. Some
representations are better than others but good
representations typically have:

1
/ expressiveness

can I say what I want and say it unambiguously?
eg

if I want
to say “all pawns can only move forwards” I don't want to have
to say “black pawn one can only move forwards, black pawn
two can only move forwards, black pawn three ....”.

2
/ heuristic power

does the representation mean I can reason efficiently?
Compare roman numerals and Arabic numerals for long
division. The information content is exactly the same but
Arabic numerals make reasoning much easier.

18

3
/ notational convenience

is it easy to write stuff clearly, compactly and
economically(clearly related to
1
). Bear in mind that we may
have lots and lots of things to say to describe a problem

Note there’s (typically) a trade off between
1
and
2
-

the
more expressive the less easy to reason (because there’s too
much to say and hence too much to reason about)

An example representation for the n
-
queens problem:

-

a board is a list

-

the first row on the board is represented by the first position
in the list, the second row by the second and so on...

-

the position of a queen on a row is represented by a
number (
eg

4
means the queen is on the
4
th column)

19

The (
5
x
5
) board:




Q




















Q




















Q





Q




















Q





would be represented as: (
1 3 5 2 4
)

20

This is:

(
i
) expressive (it says all we want)

(ii) has heuristic power. Consider checking two elements to see
if they're on the same diagonal. This may be achieved by
computing (if x and y are the positions of two queens and z is
the difference between their rows and x is always the higher
row):

(or (= y (x + z)) (= y (x
-

z))
)

(iii) notational convenience
-

its clear, compact and
economical.

Note there are lots of other representations


21

Search

Working through the space of possible solutions

Many problems can be represented by a state space graph
-

a
graph of nodes which are states (
eg

a board + queen
assignments) connected by arcs which are manipulations of
the state
eg
















nqueens


()
-

start state (currently empty)




add a queen

(
1 1
)


new state (queen in column
1
on row
1
and queen in column
1
on row
2
)




add a queen

(
1
)


new state (queen in column
1
on row
1
)


22

One

way

of

thinking

about

the

n
-
queens

problem

is

as

the

problem

of

generating

all

the

possible

permutations

of

queens

on

rows

and

checking

which

are

solutions
.

For

the

5

by

5

board

we

want

to

ensure

that

all

possible

positions

are

considered

from

the

first

row

with

all

those

from

the

second

with

all

those

from

the

third

and

so

on
...
To

do

this,

making

sure

we

check

all

possibilities,

we

normally

like

to

be

systematic

about

the

search

and

provide

algorithms

for

checking

all

these

possible

combinations

(this

is

called

ensuring

completeness

-

ie

that

we

completely

cover

all

possibilities)
.

As

a

short

exercise

I’d

like

you

to

try

and

sketch

out

an

algorithm

which

would

provide

complete

coverage

of

the

possibilities

for

the

3
x
3

queens

problem

-

describing

the

permutations

that

can

be

checked
.

This

doesn’t

need

to

be

very

formal,

simply

outline

what

you

would

do
.

Use

the

list

representation

that

we

have

already

introduced
.

23

A simple algorithm might be (there are others): Build three lists of
length
1
containing
1
,
2
and
3
respectively. Take each of these in turn.
With each one build three new lists by adding
1
,
2
and
3
respectively.
Take each of these in turn. With each one build three new lists by
adding
1
,
2
and
3
respectively.

The result would be:


(
1 1 1
)(
1 1 2
)(
1 1 3
)(
1 2 1
)(
1 2 2
)(
1 2 3
)(
1 3 1
)(
1 3 2
)(
1 3 3
)


(
2 1 1
)(
2 1 2
)(
2 1 3
)(
2 2 1
)(
2 2 2
)(
2 2 3
)(
2 3 1
)(
2 3 2
)(
2 3 3
)


(
3 1 1
)(
3 1 2
)(
3 1 3
)(
3 2 1
)(
3 2 2
)(
3 2 3
)(
3 3 1
)(
3 3 2
)(
1 3 3
)


This approach has searched, completely, the space of possible solutions
to the
3
queens problem. Note that the “algorithm” could be easily
parameterised to provide more solutions to the n
-
queens problem. A
problem is that this is an absolutely awful algorithm (its called blind,
breadth first search).

.

24

We

have

techniques

which

will

find

solutions

to

the

1
,
000
,
000

x

1
,
000
,
000

queens

problem

in

around

10

minutes

on

an

average

PC
.

These

techniques

are

not

based

on

breadth

first

search



Types

of

search

Blind

Search

1
/

generate

and

test

-

perform

a

transformation

if

it

generates

a

solution

when

tested

terminate

else

try

another

transformation

and

keep

trying

until

solution


-

breadth

first

(try

all

the

transformations

on

the

first

state,

try

all

the

transformations

on

all

the

new

states

that

have

been

generated

and

keep

going)

25

eg

for
nqueens

3
x
3
board:

26

Depth first search

uses a different technique, it works
down the space of possibilities first
eg

for the n queens the
search space would be expanded:. ()(
1
)(
1 1
)(
1 1 1
)

The approach looks for a solution then backtracks if either a
solution is found or the partial solution fails so for the
2
-
queens the search space would expand:


27

One

of

the

things

to

note

about

depth

first

search

is

that

it

is

much

more

space

efficient

than

depth

first

search

-

at

each

decision

point

we

are

only

ever

holding

one

copy

of

one

possible

solution
.

The

down

side

of

depth

first

search

is

that

it

can

disappear

and

never

come

back

again
.

With

the

n
-
queens

we

know

that

eventually

it

will

“hit

bottom”

an

start

to

back

up

-

this

may

take

a

long

time

but

it

will

eventually

happen
.

With

other

search

spaces

(
eg

with

some

types

of

logical

theorem

proving)

the

search

space

is

such

that

this

bottom

may

never

be

reached

so

the

algorithm

may

disappear

forever
.

Often

in

problem

solving

some

solutions

are

better

than

others

-

in

the

n
-
queens

problem

(a

very

artificial

one)

all

solutions

are

equally

good,

this

isn’t

normally

the

case
.


28

For

example

suppose

we

are

solving

a

simple

resource

allocation

problem

-

we

have

3

jobs

to

do,

and

4

resources
:

job
1
:

build

engine

job

2
:

build

body

job

3
:

assemble

car


resource
-
1
:

engine
-
building
-
machine
-
1

resource
-
2
:

engine
-
building
-
machine
-
2

resource
-
3
:

body
-
building
-
machine

resource
-
4
:

assembly
-
machine


29

we

can

represent

this

problem

as

a

search

problem

eg

job
-
1
:

(engine
-
building
-
machine
-
1

engine
-
building
-
machine
-
2
)

job
-
2
:

(body
-
building
-
machine)

job
-
3
:

(assembly
-
machine)

The

search

problem

being

to

allocate

a

resource

to

each

job

-

clearly

job
-
2

and

job
-
3

are

easy

(there’s

only

one

possible

resource

for

each)

but

for

job
-
1

we

have

a

choice
.

Basic

depth

first

search

or

breadth

first

search

would

typically

simply

consider

the

options

in

the

order

in

which

we

are

given

them
.

In

our

small

example,

however,

consider

what

we

might

want

if

we

know

that

engine
-
building
-
machine
-
1

is

much

more

expensive

to

run

than

engine
-
building
-
machine
-
2

(or

much

less

reliable,

or

it

takes

longer,

or
...
)
.


We

will

prefer

solutions

using

engine
-
building
-
machine
-
2
.

30

This

type

of

problem

is

called

an

optimisation

problem

-

we

have

a

preference

ordering

on

the

solutions

and

(normally)

we

would

like

the

best

to

be

found

first

(we’ll

probably

not

be

interested

in

the

others
.

One

way

of

achieving

this

is

to

look

for

the

best
-
first

when

building

our

solutions

-

that

is

always

make

the

best

choice

first

when

we

build

the

next

bit

of

a

solution

(an

extension

of

this

idea

is

to

make

choices

that

lead

us

quickly

to

solutions

-

the

“best”

in

this

case

being

the

choices

that

lead

us

most

quickly

to

a

solution
.

Approaches

to

problem

solving

that

use

this

best

first

approach

are

called

hill

climbing

techniques

-

every

decision

they

take

looks

to

make

the

best

solution

possible

as

seen

from

the

current

position
.

An

important

point

to

note

is

that

this

approach

doesn’t

guarantee

to

generate

the

best

solution

-

good

local

decisions

don’t

always

lead

to

good

overall

decisions

(
local

optimisation

doesn’t

always

lead

to

global

optimisation

in

technical

terms)
.

31

A

particular

problem

is

that

of

local

maxima

(or

minima

if

the

view

of

optimisation

is

reversed)

-

if

we

start

hill

climbing

in

looking

for

a

solution

we

may

be

mislead

by

local

peaks

and

troughs

-

if

you

want

to

get

as

high

as

possible

climbing

the

highest

thing

in

front

of

you

isn’t

always

a

good

idea

(something

bigger

may

be

round

the

corner)
.

Imagine

a

chess

playing

computer

-

relying

on

the

next

best

move

is

probably

a

bad

idea

-

you

may

win

the

queen

then

be

mated

two

moves

later
.

Search

is

OK

but

there

are

huge

problems

with

applying

the

approaches

we

have

considered

so

far
.

In

particular

there

is

the

difficulty

of

the

combinatorial

explosion

-

enumerating

the

search

space

generates

huge

numbers

of

possibilities

(
eg

the

n
-
queens

one

would

have

to

consider

(in

the

worst

case)

n
n

possibilities
.

32

One

potential

way

round

this

is

to

try

and

avoid

some

of

the

possibilities

by,

for

example,

cutting

off

branches

of

the

search

space

as

quickly

as

possible

to

avoid

as

much

work

as

possible

(
eg

in

the

nqueens

as

soon

as

we

reach

a

situation

in

which

two

queens

attack

each

other

we

may

as

well

kill

that

branch

as

no

solution

is

possible

down

that

route)
.

Another,

more

dramatic

alternative

is

to

abandon

these

systematic

approaches

altogether

and

generate

solutions

more

erratically

(but

not

to

consider

many,

hopefully

irrelevant,

parts

of

the

search

space)
.

In

this

type

of

search

algorithm

we

“jump

around”

the

search

space

rather

than

walking

through

it

in

an

organised

way

-

we

effectively

abandon

completeness

in

the

hope

that

it

doesn’t

mean

we

miss

good

solutions

and

that

we

hit

acceptable

ones

reasonably

cheaply
.

There

are

many

ways

of

doing

this

-

simulated

annealing,

tabu

search

and

genetic

algorithms
.

33

Non

Systematic

Search

-



Genetic

Algorithms

and

Simulated

Evolution

Evolution

is

good

at

solving

problems

-

so

why

not

exploit

this

for

our

problem

solving?

How

to

do

this?

First

provide

a

representation

of

the

problem

then

provide

a

means

of

“reasoning”

that

is

evolution
-
like
.

Modelling

the

n
-
queens

problem

-

a

chromosome

representing

a

solution

eg
:


[
1

2

3

4

5
]

queens

on

rows

1

2

3

4

5

in

columns

1

2

3

4

&

5

respectively

(essentially

the

same

as

our

earlier

representation)


34

then

provide

a

reasoning

mechanism

-

roughly

speaking

it

goes

like

this
:

(
i
)

generate

lots

of

(often

random)

versions

of

potential

solutions

(chromosomes

representing

individuals

genotype

made

up

of

alles

-

in

our

example

above

[
1

2

3

4

5
]

is

an

example

of

a

chromosome

which

when

associated

with

an

individual

represents

that

individuals

genotype

which

is

made

up

-

the

1

2

3

4

5

bits

-

of

alles
)

(ii)

provide

a

way

of

putting

these

together

(mating)

and

generating

new

individuals

(
crossover

and

mutation
)

(iii)

decide

which

are

“good”

individuals

and

redo

(ii)

until

you’re

happy

or

bored


35

What

does

this

actually

mean?

Say

we

have

the

following

individuals
:

[
1

2

3

4

5
]

[
2

3

5

4

1
]

[
2

4

1

3

5
]

[
5

1

2

3

4
]

we

can

mutate

them

eg

change

[
5

1

2

3

4
]

-
>

[
1

5

2

3

4
]

mate

them

(allow

crossover)

eg



[
1

2

3

4

5
]

+

[
2

3

5

4

1
]

=

[
1

2

3

4

1
]

Then

we

decide

which

of

the

population

to

keep

-

ie

make

a

choice

on

each

individuals

fitness

(
eg

we

might

decide

to

keep

the

ones

with

the

fewest

clashes

of

queens)

Keep

doing

this

until

we’re

happy
-

but

note

there

are

several

critical

decisions

eg

how

much

mutation,

how

much

and

which

crossover,

how

to

generate

the

original

population,

how

many

to

keep

each

generation,

how

to

determine

fitness,

how

many

generations


36

Also

note

that

these

need

not

remain

constant

-

eg

we

might

decide

on

more

mutation

and

larger

populations

for

earlier

generations

than

for

later

ones
.

It

turns

out

that

getting

these

things

right

is

critical

to

success
.

The

approach

has

worked

well

(for

example

in

scheduling)

but

doesn’t

guarantee

anything

about

solutions

(even

finding

one)
.

In

later

lectures

we

will

explore

how

various

kinds

of

AI

techniques

try

to

overcome

(NOT!!!!

solve)

the

difficulties

we

have

discussed

today

by,

for

example,

trying

to

exploit

information

about

domains

and

problem

solving

strategies(sometimes

copied

from,

or

inspired

by,

humans)
.

One

of

the

major

topics

within

AI

is

the

business

of

finding

good

heuristics

for

real

problems
.

Being

“intelligent”

is

always

very

bright,

stupid

sometimes

works

best

depending

on

what

you’re

trying

to

do
.

More

accurately

modelling

simple

systems

may

provide

apparently

intelligent

behaviour
.

37

What

we

have

talked

about

are

AI

common

concepts

we

will

meet

in

the

many

techniques

we

will

study

in

details
.



What

I

will

expect

you

to

know

(
ie

be

able

to

define

and

give

examples

of

-

mostly

vocabulary)


Representation

-




expressiveness,

heuristic

power,

notational

convenience


Search

-




state

space

graph,

breadth

first

search,

depth

first

search,




optimisation,

hill

climbing,

local

minima/maxima,



Systematic

vs

non
-
systematic

search



(
eg

genetic

algorithms

vs

depth

first

search)




Basic

description

of

genetic

algorithms

-

how

they

work,


what

crossover,

mutation,

fitness,

alle
,

chromosome,


genotype

an

so

on

mean

Conclusion