game ai techniques: a brief overviewavagames.ir/wp-content/uploads/2018/04/slides-game... · amin...

36
Game AI Techniques: A Brief Overview 1 of 36 Amin Babadi In The Name Of God Game AI Techniques: A Brief Overview Amin Babadi Ph.D. Candidate in Computer and Video Games Aalto University, Finland Spring 2018

Upload: others

Post on 30-Sep-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 1 of 36Amin Babadi

In The Name Of God

Game AI Techniques:

A Brief Overview

Amin Babadi

Ph.D. Candidate in Computer and Video Games

Aalto University, Finland

Spring 2018

Page 2: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 2 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 3: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 3 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 4: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 4 of 36Amin Babadi

Who Am I?▪ Academia

o 2007-2011: B.Sc. in Software Engineering, University of Kashan, Iran

o 2011-2013: M.Sc. in AI, Sharif University of Technology, Iran

o 2013-2017: Ph.D. in AI, Isfahan University of Technology, Iran (Dropped Out)

o 2017-Present: Ph.D. in Computer and Video Games, Aalto University, Finland

▪ Industry

o 2011-2012: E.T. Armies (AI Programmer)

o 2012-2013: Awakening: Burning Ashes (Lead Programmer)

o 2016-2017: Cut (Gameplay and AI Programmer)

Page 5: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 5 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 6: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 6 of 36Amin Babadi

What Is Game AI?

Comparison between A* and a human path finder. Left: initial problem. Middle: human. Right: A*

Page 7: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 7 of 36Amin Babadi

Definition▪ Game AI consists of techniques used to produce the illusion of intelligence in

the behavior of non-playable characters (NPCs).

▪ AIs must be entities that provide just the right amount of complexity to be

challenging and engaging, but not more than that.

Page 8: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 8 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 9: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 9 of 36Amin Babadi

Architecture of AI Agents

Sense Think Act

Page 10: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 10 of 36Amin Babadi

Sense▪ All AIs need to be aware of their surroundings.

▪ What should be sensed and how?

o It largely depends on the type of game you are creating.

Page 11: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 11 of 36Amin Babadi

Think▪ Thinking stage is when the actual AI happens!

▪ Luckily, many games require only simple decision-making processes.

▪ A lot of games praised for their great AI have been built with relatively

simple algorithms!

▪ A lot more on this later!

Page 12: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 12 of 36Amin Babadi

High-Level vs Low-Level Thinking▪ High-level planning

▪ Low-level control

Page 13: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 13 of 36Amin Babadi

Act▪ Many games exaggerate this part much like in a theater play, so the

character's intentions are obvious and personality is conveyed.

▪ From AI developer’s point of view, this part is the simplest one!

Page 14: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 14 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 15: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 15 of 36Amin Babadi

The Power of Randomness▪ If there are 𝑛 possible actions with equal probability:

o Pick a random integer between 1 and 𝑛 and take the corresponding action.

▪ If there are 2 possible actions with probabilities 𝑝1 and 1 − 𝑝1:

o Pick a random number 0 ≤ 𝑟 ≤ 1, take action 1 if 𝑟 ≤ 𝑝1 and take action 2otherwise.

▪ Roulette wheel selection:

Page 16: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 16 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 17: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 17 of 36Amin Babadi

Rule-Based Systems▪ Rule-based systems allows us to model many behaviors that are tricky to

model using FSMs.

▪ We test the left hand side of each expression (the conditions) in order, and

then execute the right hand side (the action) of the first rule that is activated.

▪ Example:

1. If in contact with an enemy ⟹ combat

2. If an enemy is closer than 10 meters and I'm stronger than him ⟹ chase him

3. If an enemy is closer than 10 meters ⟹ escape him

4. If we have a command from our leader pending ⟹ execute it

5. If a friendly soldier is fighting and I have a ranged weapon ⟹ shoot at the

enemy

6. Stay still

Page 18: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 18 of 36Amin Babadi

Decision Trees▪ Simply another formulation of rule-based systems.

Page 19: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 19 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 20: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 20 of 36Amin Babadi

Finite State Machines (FSM)

Page 21: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 21 of 36Amin Babadi

FSM Variations▪ Basic

▪ Non-deterministic

▪ Parallel

▪ Synchronized

▪ Hybrid

Page 22: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 22 of 36Amin Babadi

Non-Deterministic FSM

Page 23: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 23 of 36Amin Babadi

Parallel FSM

Page 24: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 24 of 36Amin Babadi

Synchronized FSM

Page 25: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 25 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 26: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 26 of 36Amin Babadi

Search and Planning

Page 27: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 27 of 36Amin Babadi

A*

Page 28: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 28 of 36Amin Babadi

A*

Page 29: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 29 of 36Amin Babadi

Monte Carlo Tree Search (MCTS)

Page 30: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 30 of 36Amin Babadi

MCTS Characteristics▪ Aheuristic

▪ Anytime

▪ Asymmetric

Page 31: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 31 of 36Amin Babadi

Evolutionary Planning

Page 32: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 32 of 36Amin Babadi

Rolling (Receding) Horizon Evolution

▪ Genetic algorithm (for discrete actions)

▪ Evolution strategy (for continuous actions)

Page 33: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 33 of 36Amin Babadi

Rolling (Receding) Horizon Evolution

▪ Genetic algorithm (for discrete actions)

▪ Evolution strategy (for continuous actions)

Page 34: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 34 of 36Amin Babadi

Agenda▪ A little about me

▪ What is game AI?

▪ Architecture of AI agents

▪ Randomness

▪ Logical reasoning

o Rule-based systems

o Decision trees

▪ Finite state machines

▪ Search and planning

o MCTS

o Evolutionary Planning

▪ How/where to begin?

Page 35: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 35 of 36Amin Babadi

How/Where to Begin?▪ Books

▪ Websites

o AIGameDev.com (http://aigamedev.com/)

▪ Courses

o The Principles of Modern Game AI (https://courses.nucl.ai/)

Page 36: Game AI Techniques: A Brief Overviewavagames.ir/wp-content/uploads/2018/04/Slides-Game... · Amin Babadi Game AI Techniques: A Brief Overview 7 of 36 Definition Game AI consists of

Game AI Techniques: A Brief Overview 36 of 36Amin Babadi

Thanks!

https://github.com/keijiro/PuppetTest