• 沒有找到結果。

Digital games design-Game AI III

N/A
N/A
Protected

Academic year: 2021

Share "Digital games design-Game AI III"

Copied!
30
0
0

加載中.... (立即查看全文)

全文

(1)

Week16 4/June/2008

Instructor: I-Hsien Ting

(2)

Neural Network

(3)
(4)

細胞體

樹狀突

軸索

(5)

There are about

1011

neurons in a adult’s

brain

Each neuron can be contacted by other 104

neurons

Neural Network for Game

Generally, only about

10

neurons will be used for

digital games

Sometimes, a simple network is very useful for us

to solve problems

Neural Network makes the concept of

“Adapting”

(6)

Some digital game applications use the neural

network the entire AI

So-called:

Giant Neural Network

However, neural network is a

time-consuming task

Use Neural Network only for part or special AI

function

(7)
(8)
(9)
(10)
(11)
(12)
(13)

Hidden Layer

activation

function

W eight

(14)

友軍 容許擊中次數 敵人是否交戰 距離

追逐

群聚

閃躲

0

1

0

0.2

0.9

0.1

0.1

0

1

1

0.2

0.9

0.1

0.1

0

1

0

0.8

0.1

0.1

0.1

0.01 0.5

0

0.2

0.9

0.1

0.1

0

0.25

1

0.5

0.1

0.9

0.1

0

0.2

1

0.2

0.1

0.1

0.9

0.3

0.2

0

0.2

0.9

0.1

0.1

0

0.2

0

0.3

0.1

0.9

0.1

0

1

0

0.2

0.1

0.9

0.1

0

1

1

0.6

0.1

0.1

0.1

0

1

0

0.8

0.1

0.9

0.1

0.1

0.2

0

0.2

0.1

0.1

0.9

0

0.25

1

0.5

0.1

0.1

0.9

0

0.6

0

0.2

0.1

0.1

0.9

(15)
(16)
(17)

A ideal solution for game difficulty

optimization

Based on the evolution theory that defined by

Charles Darwin on 1859

Natural Selection & Fitness

Chromosome (DNA& Protein)

Biological

(18)

A

D

Z

Y

R

N

X

E

T

W

H

A

H

D

E

Y

A

W

Z

A

R

D

X

Y

(19)

A

D

Z

Y

R

N

X

E

T

W

H

A

H

D

E

Y

A

J

Z

A

R

P

X

Y

(20)
(21)
(22)

void ai_World::Encode(void)

// --- //

{

int

i;

for (i=1;i<kMaxFlowers;i++)

{

temperature[i]=tb_Rnd(1,75);

water[i]=tb_Rnd(1,75);

sunlight[i]=tb_Rnd(1,75);

nutrient[i]=tb_Rnd(1,75);

beneficialInsect[i]=tb_Rnd(1,75);

harmfulInsect[i]=tb_Rnd(1,75);

}

currentTemperature=tb_Rnd(1,75);

currentWater=tb_Rnd(1,75);

currentSunlight=tb_Rnd(1,75);

currentNutrient=tb_Rnd(1,75);

currentBeneficialInsect=tb_Rnd(1,75);

currentHarmfulInsect=tb_Rnd(1,75);

}

(23)
(24)

// --- //

int ai_World::Fitness(int flower)

// --- //

{

int

theFitness;

theFitness=fabs(temperature[flower]-currentTemperature);

theFitness=theFitness+fabs(water[flower]-currentWater);

theFitness=theFitness+fabs(sunlight[flower]-currentSunlight);

theFitness=theFitness+fabs(nutrient[flower]-currentNutrient);

theFitness=theFitness+fabs(beneficialInsect[flower]-currentBeneficialInsect);

theFitness=theFitness+fabs(harmfulInsect[flower]-currentHarmfulInsect);

return (theFitness);

}

(25)
(26)
(27)

void ai_World::Evolve(void) // --- // { int fitTemperature[kMaxFlowers]; int fitWater[kMaxFlowers]; int fitSunlight[kMaxFlowers]; int fitNutrient[kMaxFlowers]; int fitBeneficialInsect[kMaxFlowers]; int fitHarmfulInsect[kMaxFlowers]; int i; int leastFit=0; int leastFitIndex; for (i=1;i<kMaxFlowers;i++) if (Fitness(i)>leastFit) { leastFit=Fitness(i); leastFitIndex=i; } temperature[leastFitIndex]=temperature[tb_Rnd(1,10)]; water[leastFitIndex]=water[tb_Rnd(1,10)]; sunlight[leastFitIndex]=sunlight[tb_Rnd(1,10)]; nutrient[leastFitIndex]=nutrient[tb_Rnd(1,10)]; beneficialInsect[leastFitIndex]=beneficialInsect[tb_Rnd(1,10)]; harmfulInsect[leastFitIndex]=harmfulInsect[tb_Rnd(1,10)];

(28)

for (i=1;i<kMaxFlowers;i++) { fitTemperature[i]=temperature[tb_Rnd(1,10)]; fitWater[i]=water[tb_Rnd(1,10)]; fitSunlight[i]=sunlight[tb_Rnd(1,10)]; fitNutrient[i]=nutrient[tb_Rnd(1,10)]; fitBeneficialInsect[i]=beneficialInsect[tb_Rnd(1,10)]; fitHarmfulInsect[i]=harmfulInsect[tb_Rnd(1,10)]; } for (i=1;i<kMaxFlowers;i++) { temperature[i]=fitTemperature[i]; water[i]=fitWater[i]; sunlight[i]=fitSunlight[i]; nutrient[i]=fitNutrient[i]; beneficialInsect[i]=fitBeneficialInsect[i]; harmfulInsect[i]=fitHarmfulInsect[i]; } for (i=1;i<kMaxFlowers;i++) { if (tb_Rnd(1,100)==1) temperature[i]=tb_Rnd(1,75); if (tb_Rnd(1,100)==1) water[i]=tb_Rnd(1,75); if (tb_Rnd(1,100)==1) sunlight[i]=tb_Rnd(1,75); if (tb_Rnd(1,100)==1) nutrient[i]=tb_Rnd(1,75); if (tb_Rnd(1,100)==1) beneficialInsect[i]=tb_Rnd(1,75); if (tb_Rnd(1,100)==1) harmfulInsect[i]=tb_Rnd(1,75); }}

(29)

Path Finding??

Best for unpredictable situation

E.g. Player

To make game AI adaptable when facing different

player

(30)

參考文獻

相關文件

Help pupils create paradigmatic associations by introducing the superordinates of different sports (e.g. water sports, track and field events, ball games) and guiding them to

Researches of game algorithms from earlier two-player games and perfect information games extend to multi-player games and imperfect information games3. There are many kinds of

Object decoration (for example bottle, hat, parcel/packet, car,etc) (十四) 花籃 Flower basket. (十五) 胸花

Keyboard, mouse, and other pointing devices; touch screens, pen input, other input for smart phones, game controllers, digital cameras, voice input, video input,. scanners

Object decoration (for example bottle, hat, parcel/packet, car,etc) (十四) 花籃 Flower basket. (十五)

Keywords: Computer game applications; CCNA Certification Training; digital content design; game-based Learning;

This study, analysis of numerical simulation software Flovent within five transient flow field,explore the different design of large high-temperature thermostat room

It finds the water-leaking factors for structures, and then discusses prevention methods and measures from design and constructional point of views.. It was found that