Introduction To Artificial Intelligence in Games
Introduction To Artificial Intelligence in Games
1
Assessment
Total: 100 marks
2
Motivations for AI in Games
• Many applications for AI
- Computer vision, natural language processing, speech recognition, …
- But games are some of the more interesting.
- Opponents that are challenging, or allies that are helpful.
• No need for other players:
- If there are no other players to play with, the game can add AIs to play as
the other players.
- Also, in team-based games, teams can be filled up with AIs for example to
balance the number of players.
• PVE (Player vs. Environment):
- In some multiplayer games, the players are not competed against each
other but against the game itself or the “environment”.
- In this case, the AI can take control of the enemies in the environment.
3
Motivations for AI in Games (cont.)
• Realistic world:
- AIs are not only employed for controlling humanoid characters, but can also
control other entities in the world.
- Examples are animals or flocks of birds that populate the world and make it
more believable.
• Challenge:
- AI can also provide a challenge to players that a human might not be able to
provide.
• Testing:
- an AI can allow a single developer to test a game without getting other
developers to play with him.
4
AI for Games different than AI for CS
• Must be smart,
– Play in a fun and challenging way
• No unintended weaknesses
– No “golden path” to defeat
– Must not look dumb
• Must perform in real time (CPU)
• “Amount” and type of AI for game can vary
5
Model of Game AI
• It splits the AI task into three sections: movement, decision making, and strategy.
• The first two sections contain algorithms that work on a character-by-character basis.
• the last section operates on a whole team or side.
• Around these three AI elements is a whole set of additional infrastructure. 6
Model of Game AI
7
World Interface (Sensing)
• Gather current world state: barriers, opponents, NPC, objects, …
• Needs limitations: vision, hearing, range, etc.
Vision:
- Check magnitude (ie- is it too far away?)
- Check angle (ie- within 120° viewing angle?)
• Communication between players
- Model sensing data from other agents
An NPC (non-player character) is a character in a game that is not controlled by the person playing
the game, nor by any sort of AI. They just be there to fill the world. For example, in games with large
cities, NPCs are used as citizens on the street, simply walking in a single direction or running away
from you. They help make the game's world feel more realistic and alive.
8
Movement
Kinematic Dynamic
10
Pathfinding
• Pathfinding is the next level in the AI model: it uses global information about the
map to find a valid path from the current and target locations. 11
Pathfinding
• Generate a path for an AI to follow
• Based on a graph:
- Basic connectivity: point B can be reached from A if there is a connection
between them.
- Costs: How “hard“ is it to get from A to B?
- Directions: In which direction is the connection? (E.g. jumping down an
unclimbable ledge)
• Ex. A* algorithm
12
Decision Making
13
Decision Making
• This layer of AI refers to how individual AIs make their decisions (what to do next,
where to move to, etc.)
• Each character has a range of different behaviors that they could choose to
perform: attacking, standing still, hiding, exploring, patrolling, and so on.
• Structure decisions as a series of conditions and actions as leaves
• The decision making system needs to work out which of these behaviors is the
most appropriate at each moment of the game.
• The chosen behavior can then be executed using movement AI
• Algorithms for Decision-Making:
- MinMax Algorithm
14
Strategy
15
Strategy
• Strategical AI is concerned with providing global information to AIs or with
synchronizing the actions of several AIs.
• Analyze the game world:
- How strong is the influence of each player?
• High-level commands passed downwards
17
Execution Management
• It describes how the execution of AI tasks are scheduled.
• It manages tasks so that they are spread out over available frames instead of
always slowing down every N’th frame.
18
19