Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame...
Transcript of Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame...
![Page 1: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/1.jpg)
Principles of Computer Game Design and Implementation
Lecture 19
![Page 2: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/2.jpg)
Game Artificial Intelligence
In computer games, AI refers to a collection of techniques that control the computer player
• AI is anything that contributes to the perceived intelligence of an entity, regardless of what’s under the hood
2
![Page 3: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/3.jpg)
Outline for today
• Introduction
• Sense-Think-Act Cycle:
– Sensing
3
![Page 4: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/4.jpg)
No really intelligent behaviour
Some History
• Initially, there was no computer player in games (Pong, Space Wars, Tetris)
• Early examples are not very smart – Pac-Man ghosts (chaise mode):
• Plan just one step ahead
• Never reverse the direction of travel
• Certain tiles enforce certain behaviour
• Target tile depends on the ghost personality– Move where the player is
– Move where the player will be
4
AI and level
developed
together
![Page 5: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/5.jpg)
Requirements
• Be intelligent but purposely flawed
• Have no unintended weaknesses
• Perform within CPU and memory constraints
– Cheat! (but players don’t like it. If they notice.)
• Be configurable by game designers /player
• Be visible
– Perception window can be very small
5
![Page 6: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/6.jpg)
Be Visible
• Make sure player knows what agent is doing
– Patrolling agent speaks on the radio
– Changes in behaviour are easy to spot
• Eliminate invisible AI activity
– “Level of detail”: if player sees, show activity, else don’t do it.
6
![Page 7: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/7.jpg)
Example: 100% Optimisation
• That’s what we perceive
7
Floor plan
![Page 8: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/8.jpg)
Example: 100% Optimisation
• What happens:
– Soldiers are spawned by the control system when needed
– Helps with the CPU cycles
8
Floor plan
![Page 9: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/9.jpg)
Traditional AI
Science and Engineering
• the science of understanding intelligent entities - of developing theories which attempt to explain and predict the nature of such entities;
• the engineering of intelligent entities.
9
![Page 10: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/10.jpg)
Four Views of AI
• Systems that think like humans– cognitive science, expert systems
• Systems that act like humans– The Turing Test, chess programs
• Systems that think rationally– Approaches based on logic and mathematics
• Systems that act rationally– Contemporary agent based approaches
10
CO
MP
21
9
It’s all about substance!
![Page 11: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/11.jpg)
Game AI
• Biased towards engineering: developing algorithms that appear to behave intelligently
– human or animal like
• Sometimes these two approaches do overlap
– But not necessarily
11
It’s all about appearance!
![Page 12: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/12.jpg)
Approaches to Game AI
• “Proper” – FSMs, planning, path finding, collision avoidance,
expert systems, fuzzy logic…
• “Ad-Hoc”– Hacks
• Animation can show more intelligence than algorithm
– Heuristics• Choose most constraint option
• Do most difficult thing first
• Try the most promising thing first
12
![Page 13: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/13.jpg)
Intelligent Entities
It is convenient to distinguish
• Game agents
– autonomous entities that observe and act upon an environment.
• Game characters
• Virtual Player
– performs the same operations as the human player.
• Chess
13
![Page 14: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/14.jpg)
Agents and Virtual Player
• Agents, no virtual player
– Shooters, racing, …
• Virtual player, no agents
– Chess, …
• Both
– Strategy games, team sport games, …
14
![Page 15: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/15.jpg)
Agents
• Act as
– enemies, allies, neutral characters
• Constantly go through a
– Sense – Think – Act cycle
• Sometimes can learn new behaviours
• Example: first-person shooter enemies, other car drivers, units in strategies
15
![Page 16: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/16.jpg)
Sense-Think-Act Cycle: Sensing
• Agent can have access to perfectinformation of the game world– May be expensive/difficult to tease out useful
info
• Game World Information– Complete terrain layout
– Location and state of every game object
– Location and state of player
• But isn’t this cheating???
16
![Page 17: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/17.jpg)
Sensing: Enforcing Limitations
• Human limitations?
• Limitations such as– Not knowing about unexplored areas
– Not seeing through walls
– Not knowing location or state of player
• Can only know about things seen, heard, or told about
• Must create a sensing model
17
![Page 18: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/18.jpg)
Sensing:Human Vision Model for Agents
• Get a list of all objects or agents; for each:
1. Is it within the viewing distance of the agent?• How far can the agent see?
• What does the code look like?
2. Is it within the viewing angle of the agent?
• What is the agent’s viewing angle?
• What does the code look like?
3. Is it unobscured by the environment?• Most expensive test, so it is purposely last
• What does the code look like?
18
![Page 19: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/19.jpg)
Partial Visibility
• Check for bounding body visibility
– Expensive
• React to player motion
– Corresponds nicely to the human perception
19
![Page 20: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/20.jpg)
Sensing: Human Hearing Model
• Humans can hear sounds– Can recognize sounds
• Knows what emits each sound
– Can sense volume• Indicates distance of sound
– Can sense pitch• Sounds muffled through walls have more bass
– Can sense location• Where sound is coming from
20
![Page 21: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/21.jpg)
Sensing: Modeling Hearing Efficiently
• Event-based approach
– When sound is emitted, it alerts interested agents
• Use distance and zones to determine how far sound can travel
21
![Page 22: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/22.jpg)
Sensing: Communication
• Agents might talk amongst themselves!
– Guards might alert other guards
– Agents witness player location and spread the word
• Model sensed knowledge through communication
– Event-driven when agents within vicinity of each other
22
![Page 23: Principles of Computer Game Design and Implementationtsakalid/game_materials/lecture19.pdfGame Artificial Intelligence In computer games, AI refers to a collection of ... •Perform](https://reader034.fdocuments.net/reader034/viewer/2022042411/5f2ac7470bfad96d3f480958/html5/thumbnails/23.jpg)
Sensing: Reaction Times
• Agents shouldn’t see, hear, communicate instantaneously
• Players notice!
• Build in artificial reaction times
– Vision: ¼ to ½ second
– Hearing: ¼ to ½ second
– Communication: > 2 seconds
23