0% found this document useful (0 votes)
47 views25 pages

AI For Games Notes

Uploaded by

Riza Atik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views25 pages

AI For Games Notes

Uploaded by

Riza Atik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

AI for games notes

1) Introduction to AI in games -

https://blog.ipleaders.in/ai-in-gaming-all-you-need-to-know/

Introduction

Al is generally defined as the wisdom of making computers do things that bear


intelligence when done by humans. Al is usually defined as the science of making
computers do things that require intelligence, when done by humans. Hence, it
refers to a broad set of algorithms deduced from computer science, computer
graphics, robotics, and control propositions in general. Hence, AI in gaming could just
mean "automated calculation" or a destined and limited set of responses to a
destined and limited set of inputs.

What's Al in gaming

AI refers to the integration of artificial intelligence into the videotape game. This
primarily refers to the control of non-playing characters ( NPCs). These characters
interact with players more realistically and actively, adding to the absorption of the
game. This enhances the gameplay.
Al is also being used in game design to produce more dynamic and intriguing
situations and content. This can help inventors produce more varied and absorbing
games with less trouble. For illustration, AI might be used to design game situations
that are procedurally generated, meaning that they're created on the cover as the
player progresses through the game. This can help keep the game fresh and
intriguing for players, as they aren't simply playing through the same situations over
and over again. This makes the game more gruelling and satisfying for players, as
they feel they are playing against a good opponent.

Types of Al in gaming

There are two main approaches to game playing in AI


 Rule-based systems
 Machine learning-based systems.
Rule-grounded systems use a set of fixed rules to play the game, while machine
learning-based systems use algorithms to learn from experience and form opinions
grounded on that experience. They induce models grounded in algorithmic literacy,
which can continue to learn as the data increases. Hence, these become more
accurate models with time and experience.
1.BOTS or non-playable characters NPCs): These characters are set up in
colourful games. They can completely interact with the player and make the
game more realistic to play. Some of these characters can also make it
difficult to pass a certain position as they work based on their programming
so if they're programmed to make a position feel hard to pass, it gets difficult
for the player.
2.Visual effects & realism: AI is also used to make existing games look even
better with new-age graphics, natural animations, lighting, reflections, etc.
for providing more realistic textures and visual effects, thereby giving a more
immersive experience. Game inventors use Al to enhance the graphic designs
of games that existed in earlier forms and make them look more natural and
closer to real life.
3.Voice & speech recognition: AI uses Natural Language Processing ( NLP) to
make the game feel more realistic. You, as a player, can talk to the other
players in the game, and they can reply to you each time by using this system
by the AI. SIRI and CORTANA are a few exemplifications of this nature.
4. Music: Now, with advanced AI, numerous game inventors are also using AI to
make the music for their games. Making music is a task that isn't easy, so by
using AI, we can make the process much quicker and more efficient in the
long run.

Benefits of Al in gaming
1) Realistic non-player characteristics: NPCs or non-player characters, are the
characters in the game who act intelligently as if they were controlled by human
players. These characters' behaviour is determined by AI algorithms and that
adds depth & complexity to the game, making it more immersive for the players.
2) Enhanced player experience: NPCs can completely interact with the player and
make the game more real to play. Some of these characters can also make it
delicate to pass a certain level as they work on their programming so if they are
programmed to make a level feel hard to pass, it gets difficult for the player.
3) Intelligent game balancing & testing :
a)AI can be used to balance multiplayer games, ensuring fair & enjoyable
experiences for all players. Al-powered testing can simulate hundreds of
gameplay scenarios, uncovering hidden bugs & optimising game mechanics
more efficiently. AI algorithms can be employed for matchmaking to create
balanced teams or opponents based on players' skill levels and preferences.
b)Game Al can figure out the ability and emotional state of the player, and then
tailor the game according to that. This could even involve dynamic game
difficulty balancing, in which the difficulty of the game is adjusted in real-
time, depending on the player's ability. AI in gaming could even assist in
figuring out the player's next move intent.
4) Innovative and creative ideas: AI can also be used to get some out of the box
ideas for games. It is a great tool to find fresh ideas, as the games can quickly get
repetitive. The companies need to have newer ideas for the games to flourish.
5) Game stage design: AI can also be used to make better levels designed for the
game to be more playable and more enjoyable for the players. The stages can be
designed with increasing challenging levels to make them more enthralling. It has
to be challenging yet not frustrating. It is truly a great tool for designers who
have to constantly think of game design.
6) Player monitoring and well-being:
a)Behaviour analytics: AI algorithms can analyse player behaviour to identify
patterns, preferences, and areas for improvement. This information can be
used to personalise gaming experiences.
b)Health monitoring: Wearable devices or in-game sensors can be used to
monitor players' physical health indicators. Al analyses this data to detect
signs of fatigue or stress.
c) Alerts and breaks: Al can generate alerts or recommend breaks for players
based on their health data. This helps prevent extended gaming sessions that
may negatively impact well-being.
7) Cheating prevention: AI is used at large to help with infidelity, especially in
multiplayer games. These games are played by millions of players at the same
time and numerous of these players also resort to the practice of infidelity. Al is
used to find those players by assaying their gaming patterns and also giving them
warnings, either guarding or blocking them straight to make the terrain better for
the genuine players
8) Quality assurance: Numerous gaming companies also use Al to test their games.
numerous times, newer games that don't have numerous brigades and games
that are generally independent use AI to find bugs in their games and also to fix
them so that the gaming can be better by those independent gaming companies.
9) Data mining & analytics: AI can be used to understand the number of players. It's
used to check how many players are playing the game and how many are playing
a certain kidney of the game. This helps gaming companies concentrate on
what's in demand and enhance their gaming experience.

Most popular Al games


1. AI dungeon: AI Dungeon is a single-player/multiplayer text adventure game
which uses artificial intelligence to generate content and allows players to create and
share adventures and custom prompts
2. GTA series: Grand Theft Auto games have been revolutionary for various
reasons. It allowed a player to do many things that they wanted to do in an open-
world game.There are a large number of NPAs in GTA that allow the player to
interact with different characters in the game more realistically.
3. Black & White : Black & White, a God video game, combines elements of
artificial life and strategy. The player acts as a god whose goal is to defeat Nemesis,
another god who wants to take over the world. A primary theme is the concept of
good and evil, with the atmosphere being affected by the player's moral choices.
4. Fortnite: A popular game, this game also uses AI to make gaming more
dynamic. It uses Al to make the environment change, bring various new events into
the games, and change the whole gaming element.
5. Civilisation Series: In this game, you can design various ancient civilizations. In
this game, Al is used to make the objectives of the game more and more unique and
interactive.
Future of Al in gaming

The global video game market size is projected to hit around USD 610.6 billion by
2032, growing at a CAGR of 10.5% during the forecast period of 2023-2032.
Al will be a critical contributor to redefining the future of the gaming industry. AI in
gaming is going to be transformed with more technological advancements. In the
future, with AI, the whole game can be developed within a few hours with highly
detailed levels. Newer developments, such as personalised gaming experiences, will
come out of the content to give an experience that is different for each player.
Enhanced natural language processing will make your gaming more and more real.
This language processing will make it real to interact with the characters of the
game, such as a person does with a human. The graphical rendering powered by the
AI will make the whole gaming experience look more and more real and closer to the
real world. Al is also a great option for sound design, making it better for different
levels.

Limitations
There are many limitations to AI and they will apply to the gaming industry too. With
more time invested in the development of AI, we will see whether it will be able to
overcome them or not.
◦ AI, although quite powerful, still has certain limitations. You can not give
commands to the Al in the middle of the game and change the whole mechanics of
how the game works.
◦ You can not develop a whole game just by commanding the AI. Also, there's a
bias that can come into the AI.
◦ There's also an ethical issue with AI. If not given proper instructions, Al can add
problematic stuff to the game.

2) Historical perspectives and milestones -

https://www.developers.dev/tech-talk/video-game-design-the-history-of-ai.html

This blog explores the importance of artificial intelligence in gaming, from


early examples like Pac-Man to sophisticated algorithms in recent games
such as "Middle Earth Shadow of War." The article discusses AI's role in
producing immersive experiences and how it has grown over time, affecting
game design with features such as adaptable NPCs, generative content
production, and improved image improvement.
It also addresses the potential future of AI in gaming, ranging from
autonomous game creation to the enhancement of NPCs with human-like
intelligence and emotions.

What Is AI In Gaming?
Artificial intelligence refers to programming that allows characters, including
enemies and non-playable characters, in video games to behave in a way that
makes them feel like they are being controlled by humans or have their own
minds.
This is how AI can make games more immersive. But what does it mean in
practice?
You have probably played Pacman before. It is one of the most iconic
examples of early AI. Four different coloured ghosts pursue Pacman as he
tries to collect every dot on the screen.
They do not follow Pacman, and they also seem to try to ambush him when
he is playing. How did they do this? Each ghost is programmed to respond to
Pacmans location.
One ghost is to wander, and one ghost is to follow Pacman aggressively.
Another ghost is to follow Pacman in the same direction unless Pacman is
catching up to it.
The final ghost will follow Pacman when he is far away but move to a
particular location on the map when Pacman is near.
These four behaviors make the ghosts appear to have a will, even though
they are playing a 1980 game. They feel alive.
That is why AI in video games serves its purpose.

What Is The Importance Of AI?


Nearly all games employ AI in some way or another. It would be difficult for
games to offer an immersive experience without AI.
AIs goal is to immerse players as much as possible. This is achieved by giving
characters in the game a lifelike quality even though the world is fantasy.
The options for how AI interacts with players' experiences change as AI
becomes more sophisticated.
Consider a game such as "Middle Earth Shadow of War" and the nemesis
system. Monolith Productions' open-world adventure game features a
variety of enemy orcs.
They have many personalities, traits, as well as applications. Any orc you see
in the game can join you, betray you, spy for you, etc.
The nemesis system makes the most memorable moments of gameplay even
more memorable.
For example, by defeating an orc captain, you may create an enemy who will
follow you into the future and remind you what you did in the past.
This system aims to give players a new way to interact with NPCs in the
game. It feels personal when an orc captain kills your favorite ally, orcish.
The game becomes more intense when the difficult enemy you spent ages
defeating returns at the worst possible moment.
This game is tailored to the players actions and procedurally generated
characters. Each player will experience a different experience.
Despite all this technology, the program still follows pre-programmed
instructions from its game developers.
A similar game could have AI that uses new technology. It might not only
have orcs who seem to plan or befriend the player but also genuinely plot
and feel emotions towards it.
It would be a game that changes according to every action the player takes.

Video Game Design: The History Of AI


Artificial Intelligence is used to create adaptive, intelligent or responsive
behavior in video games. This is used most often by characters that are not
players.
Modern video game design uses AI in many different ways. AI has been a part
of video game design since the 1970s as mentioned on Big Data Analytics
News.

AI In Video Games: Early Days


Nearly every video game now uses artificial intelligence in some way. The
only casino games that do not use AI are slots.
To ensure fair gameplay, random number generators are used in slots. AI
programs cannot play slot machines, so you can be sure it is not being used
to unfair advantage.
AI has long been a feature in video games.
Twenty years before the Pong video game, artificial intelligence was used in
computerized games. The 1951 mathematical strategy game Nim is one of
the earliest examples of artificial intelligence.
It is a game where two people work together to remove objects from piles.
The computer beat human players regularly.
The University of Manchester's AI Ferranti Mark 1 computer also created a
game of chess and checkers.
These were the first-ever computer programs. Arthur Samuel created the
checkers program. The program was further developed in the 1950s, 1960s,
and 1970s.
Deep Blues IBM computer defeated Garry Kasparov in 1997 as the chess
champion.
This led to AI-based checkers games. These games were not AI-based like the
classic video games Spacewar and Pong.

The Evolution Of AI Since The 1970s In Video Games


In the 1970s, AI was a key component of video game design. The difficulty
level of 1978s Space Invaders was well-known for its complex levels and
unique patterns of movement that was based on input from players.
In 1980, Pac-Man added AI patterns to his maze. AI-enabled Pac-Man's
ghosts to have different personalities. AI technology was used to fight games
like 1984s Karate Champ.
First Queen, an action-role-playing video game, introduced AI-controlled
characters in 1988. Dragon Quest IV introduced AI programmers that allowed
players to modify the AI routines of non-player characters during combat .
This idea was later used in RPGs such as Secret of Mana 1993.

AI In Sports Games: 1980s & 1990s


AI was also used during the 1980s and 1990s in sports games. AI was used in
games such as Madden Football, Earl Weaver Baseball and Tony La Russa
Baseball to imitate the coaching or managerial styles of real-life coaches and
managers.
Later sports games gave players the ability to control variables and create
their coaching or managerial strategies.

There Were Many New Ways To Use AI In The 1990s And 2000s
Formal AI tools, such as finite state machines (FAI), were used to create new
video games in the 1990s. Real-time strategy games such as economic
planning, pathfinding and real-time decision-making were made possible by
AI.
These were the first games that had problems. Herzog Zweis' pathfinding was
hampered in the second game. To control its units, it used only three-state
state machines.
In 1992, Dune II used no cheats. These problems were quickly resolved as AI
became more sophisticated.
Later, video games utilized bottom-up AI techniques. In Creatures and
Black&White for instance, AI was used to assess player actions .
The facade was 2005s first interactive multi-way dialogue.

How Is Artificial Intelligence In Gaming Changing?


AI in video games is mainly restricted to pathfinding and finite state
machines. Pathfinding is the programming that instructs an AI-controlled
NPC in which direction it should go.
This is important, from retro-styled 8-bit games to huge open-world RPGs.
Developers do not want the villagers of a town that they are developing to
be able to climb over walls or become stuck in the ground.
They do not want them standing still.
Finite state machines, on the other hand, allow the AI to modify its behavior
depending on certain conditions. This is evident in the Metal Gear Solid
series enemy soldiers.
If you are caught in their area of vision, an alarm is triggered, and all the
enemies within the vicinity begin to gather around your location to attack.
You must leave their area of vision and hide long enough to allow the guards
to abandon pursuit and return to their original positions.
These two states are basically the "Chase state" and "patrol state". Although
these may seem like basic ideas, they are the foundation of most AI
programming.
According to the SIMS series, AI gets food when they are hungry. They go to
bed when they feel tired. This mimics real decision-making, but it is really
the state of a SIM changing to "Go to the nearest source of foods" and the
pathfinding program telling them where to find that sourc e.
How is AI changing? It is already changing a lot with the number of states
and pathfinding that developers can provide to NPCs.
It's clear that there is a huge difference between Skyrim and Pacman.
However, the same AI technology used to create self-driving vehicles and
recognize faces is poised to revolutionize the AI industry in gaming.
Pathfinding may not be limited to telling an AI where it should go. Artificial
intelligence might be able to create realistic landscapes and calculate the
walls it can or cannot walk through, all from scratch.
Imagine the possibilities of video games telling stories if NPCs could express
their emotions. NPCs would have personalities, memories and dream s.
They also have an intelligence that is indistinguishable from humans. With
recent experimental AI results at Expressive Intelligence Studio showing real
emotion in AI, data scientists are making progress.
They will soon be able to use these AI in games, and it will not take long
before they achieve this goal. This means that pathfinding and states may
soon be shaken, which is the foundation of all AI.

What Are The Pros And Cons Of AI In Video Games?


What are the benefits and drawbacks of AIs changing status and the new
technologies? These are only a few of the many pros and cons to consider as
we move into a new era of gaming.
Artificial Intelligence: Pros
As AI develops, we can expect shorter development cycles because AI is able
to take on more of the load. The ability to procedurally generate characters
and worlds will increase in sophistication.
There will not be random NPCs wandering around with just one or two
states. They will have a whole range of actions to enhance the experience.
It is also exciting to see how NPCs can have real emotions. This will
fundamentally change the way players interact with them.
You can either care deeply about the people of the town you are protecting,
or you can hate the evil enemy who always seems to be one step ahead until
you defeat them.
There are many opportunities with AI that are constantly evolving, but also
there are some issues.

Artificial Intelligence: Cons


Game makers are losing more control as AI becomes more sophisticated. This
could mean that we may lose out on the well-crafted worlds and levels that
we have come to expect in favor of something simpler but more robotic.
This could be similar to the way Unity players can tell if a game was created
using stock assets. It can affect the overall experience.
This also means that we might get some more confusing games when the AI
programming goes wrong. In Aliens: Colonial Marines, for example, the AI
enemies behaved in unusual and bizarre ways that destroyed the immersion.
Will we be able to eliminate this problem or make it more manageable? It is
difficult to know. There is also the possibility that AI may be able to do more
game programming by itself, which could impact the careers of many best
game designers currently working in the industry.
These are important considerations as we continue to explore uncharted
waters.
AI In Game Development

In just a few years, AI might play a greater role in the development of games
than it does in the game itself. Recent experiments with deep learning
technology allowed AI to learn from a sequence of images and text to
replicate the experience.
AI is being used to create works of art that look like Picassos or emails that
appear to be written by humans. The same technology is being used to
develop games.
In an experiment, artificial intelligence was able to program a level of a
playable game using only photographs.
This technology is becoming more reliable, and a wide variety of open-world
games can be generated easily by AI and then edited by developers and
designers.
This will speed up the development process. Deep fake technology and facial
recognition software are also emerging, which could play an important role
in future development cycles.
An AI can recognize and use different faces it scans with deep fake
technology.
Although it is still in its infancy, this type of AI can scan faces to create 3D
models that are impressively realistic.
Imagine if the same technology could be used to create a building or
landscape. This would save developers countless hours.
It is possible that an AI could use all of these technologies to create a
complete game without the need for developers.
These AIs may be able to create games entirely from scratch by using players
preferences and habits as a guideline.
This will allow them to create unique experiences for each player. Although
it's difficult to predict when it will reach this point, it wouldn't surprise if AI
plays a larger role in game development over the next few years.

AI And Games: The Impact And Importance Of AI


Expert Game designers work hard to provide players with engaging
interactive experiences. These interactive experiences are the result of the
combined effects of many game elements.
This includes graphics, sounds and gameplay timing Narratives, challenges,
narratives and content that interacts directly with players (allies or
opponents).
AI has become a powerful tool to help video game designers manage the
increasing complexity of game dynamics.
Businesses also see significant benefits from AI in gaming. With a projected
market value of approx 314 billion dollars by 2026, wide range in the gaming
solution industry is expected to be one of the most lucrative.
The funding for AI-based games has been steadily increasing.
Many startups are now focusing on this field. A startup company that creates
games using AI-generated infinite storylines raised 3.3 million USD in seed
funding in January 2021.
This interactive play company has raised approximately 32.5 million USD.
Lithuanian-based AI gaming startup has raised 5.1 Million USD in funding.
It focuses primarily on AI gaming data exploration, helping gamers improve
their playing.
Our AI services can increase your bottom line by up to 45%. You can see for
yourself for your game design programs.

Examples Of AI In Games
There are many ways to use AI in games. It can be used to enhance images,
automate the level generation and stories, balance in-game complexity and
add intelligence to non-playing characters.

Image Enhancement
AI engineers are at the forefront of image enhancement. They are developing
a deep learning system that transforms 3D-rendered graphics into
photorealistic images.
Grand Theft Auto 5 has seen the implementation of such a system. This
neural network can recreate LA and southern California landscap es with
great detail.
High-quality 3D synthetic images can be transformed into realistic-looking
depictions using the most advanced image enhancement AI algorithms.
Image enhancement can be used to enhance the graphics of old video games.
This job involves taking a low-resolution image and turning it into an
identical version with many more pixels.
This is known as "AI upscaling".

Game Level Generation


Procedural Content Generation (PCG) is the name for a game-level
generation. These are the names of a group of advanced AI algorithms that
generate large open-world environments and new game levels.
This is one of the most promising uses of artificial intelligence in game
development. These are some of the most loved games.
These games let players explore vast landscapes. These games are very time-
consuming both from a design and development perspective.
AI algorithms are able to optimize and build new scenery based on the
game's current status. No Man's Sky, an AI-based game, has an infinite
number of new levels that can be generated as you play.
Stories And Scenarios
Artificial intelligence is used to create stories and scenarios. AI is most often
used to create interactive stories.
This type of game allows users to create or influence dramatic stories
through their actions and words. AI programs analyze text and create
scenarios from previously learned stories.
AI Dungeon 2 is a well-known example of such an application.
OpenAI developed a state-of-the-art open-source text generation system
that is based on the Choose Your Own Adventure books.

Balancing In-Game Complexity


AI algorithms have the advantage of being able to model complex systems.
Developers are constantly striving to make games that are more realistic and
immersive.
Modeling the real world can be difficult. Artificial intelligence algorithms can
forecast the future effects of player actions and model emotions and
weather to balance out in-game complexity.
FIFAs ultimate team mode is a good example of such an application. FIFA
calculates a team score based on personality traits.
Based on in-game events, such as losing the ball or making a good pass, team
morale can fluctuate between low and high.
This is how teams with more skilled players can lose to teams with weaker
players. This is where AI can be used as an additional layer of complexity.

Intelligence To Non-Playing Characters (NPCs)


Currently, opponents are pre-programmed NPCs. However, AI is now working
on adding intelligence to these characters.
This will make them more unpredictable and enjoyable to play against. AI
also allows NPCs to become smarter and can respond to game conditions in
new and unique ways.
AI-based NPCs have been developed by many gaming companies.
SEED (EA), for example, trains NPC characters by mimicking the best players
in awesome games. This will greatly reduce the time it takes to develop NPCs
as hard coding their behavior can be tedious and slow.

Artificial Intelligence And Gaming: The Future


AI technology is being constantly improved and improved. This is mostly
done by robots and software engineers (software developers)more than
game developers.
This is because AI is being used in new ways for games poses a risk.
Developers have complete control over the world that they create.
Developers do not have to leave their games up to intelligent AI.
This could lead to unexpected bugs or glitches. The possibilities of how an AI
character reacts to a player will vary depending on how they interact with
the world.
This means that developers will not be able to playtest every possible action.
Although the potential opportunities and technology are fascinating, the big
studios are slow to embrace them. How long will it take? Although it is likely,
it is difficult to predict when.
It may come to an end when the technology is well-understood enough that
studios are willing to take this risk. More likely, however, ambitious indie
developers will make the initial push within the next few years to get the ball
rolling.
It is possible that AI will be everything we ever imagined it could be by the
end of this decade, given how quickly technology is improving.

https://www.linkedin.com/pulse/evolution-ai-games-historical-overview-suvrajit-
sarkar-ayukf/

Introduction

The journey of Artificial Intelligence (AI) in games is a fascinating story of innovation,


creativity, and technological advancement. From the rudimentary AI opponents in
early video games to the complex, learning algorithms that power today’s gaming
experiences, AI has undergone a remarkable evolution. This article delves into the
history, significant milestones, and the future trajectory of AI in gaming, providing a
comprehensive look at how AI has transformed the gaming industry.

The Dawn of Game AI

The origins of AI in games can be traced back to the 1950s and 60s, with the
development of games like "Tic-Tac-Toe" and "Chess" on computers. These games,
although simple by today’s standards, laid the groundwork for AI in gaming,
demonstrating that machines could be programmed to take on human opponents in
strategy games.

Advancements in the 70s and 80s

The 1970s and 80s saw significant advancements in game AI. The introduction of
arcade games like "Pong" and "Space Invaders" brought AI-controlled opponents to
the mainstream audience. These games featured simple AI that could respond to
player actions, making the gaming experience more dynamic.
The 90s: The Rise of 3D Gaming and Complex AI

The 1990s ushered in a new era of 3D gaming, which demanded more sophisticated
AI to manage complex environments and narratives. Games like "Doom" (1993) and
"Half-Life" (1998) featured AI that could navigate 3D spaces and exhibit behaviours
that mimicked human tactics.

The 2000s to Present: Machine Learning and Procedural Generation

The introduction of machine learning and procedural content generation marked the
next significant phase in game AI development. Games like "The Sims" (2000), which
used AI to simulate real-life behaviours and interactions, and "No Man’s Sky" (2016),
which used procedural generation to create vast, explorable universes, showcased
the potential of AI to create more immersive and expansive gaming experiences.

AI in Mobile Gaming

With the rise of mobile gaming, AI has been instrumental in personalizing gaming
experiences for a diverse audience. AI algorithms analyse player data to tailor game
difficulty, suggest in-game purchases, and even create personalized content,
ensuring that mobile games remain engaging over time.

The Future of Game AI

Looking forward, AI is set to revolutionize game design and player interaction


further. Developments in AI, such as natural language processing and emotional
recognition, could lead to games that adapt to the player's emotional state, creating
truly personalized gaming experiences. Additionally, AI is paving the way for more
realistic and intelligent non-player characters (NPCs), making the virtual worlds more
alive and interactive than ever before.

3) A* algorithm and its variations -

https://www.simplilearn.com/tutorials/artificial-intelligence-tutorial/a-star-
algorithm

Search algorithms are designed to search for or retrieve elements from a data
structure, where they are stored. They are essential to access desired elements in a
data structure and retrieve them when a need arises. A vital aspect of search
algorithms is Path Finding, which is used to find paths that can be taken to traverse
from one point to another, by finding the most optimum route.

What is an A* Algorithm?
It is a search algorithm used to find the shortest path between an initial and a final
point. It is often used for map traversal to find the shortest path. A* was initially
designed as a graph traversal problem to help build a robot that can find its own
course. It remains a widely popular algorithm for graph traversal.

It searches for shorter paths first, thus making it an optimal and complete algorithm.
An optimal algorithm will find the least cost outcome for a problem, while a
complete algorithm finds all the possible outcomes of a problem.

Another aspect that makes A* so powerful is its implementation of weighted graphs.


A weighted graph uses numbers to represent the cost of taking each path or course
of action. This means that the algorithms can take the path with the least cost, and
find the best route in terms of distance and time.

A major drawback of the algorithm is its space and time complexity. It takes a large
amount of space to store all possible paths and a lot of time to find them.

Why A* is a Popular Choice for Pathfinding

A* (A-Star) is a popular choice for pathfinding because it combines the strengths of


Dijkstra's algorithm and Greedy Best-First Search, making it efficient and optimal. It
uses a heuristic function to evaluate paths by balancing the cost to reach a node (g-
cost) and the estimated cost to the goal (h-cost).

This ensures A* explores fewer paths than Dijkstra’s algorithm while still
guaranteeing the shortest path, provided the heuristic is admissible and consistent.
Its adaptability, efficiency, and guaranteed optimality in a wide range of scenarios
make it a go-to algorithm for applications in robotics, gaming, and navigation
systems.

Applications of A* Algorithm

The A* algorithm is widely used in various domains for pathfinding and optimization
problems. Its versatility and efficiency make it a valuable algorithm in many real-
world scenarios.

- In robotics, A* helps robots navigate obstacles and find optimal paths.

- In video games, it enables NPCs to navigate game environments intelligently.

- Route planning applications use A* to find the shortest or fastest routes between
locations.

- Logistics industries utilize A* for vehicle routing and scheduling.


- A* is also employed in AI systems, such as natural language processing and
machine learning, to optimize decision-making processes.

Why A* Search Algorithm?

A* Search Algorithm is a simple and efficient search algorithm that can be used to
find the optimal path between two nodes in a graph. It will be used for the shortest
path finding. It is an extension of Dijkstra’s shortest path algorithm (Dijkstra’s
Algorithm). The extension here is that, instead of using a priority queue to store all
the elements, we use heaps (binary trees) to store them.

The A* Search Algorithm also uses a heuristic function that provides additional
information regarding how far away from the goal node we are. This function is used
in conjunction with the f-heap data structure in order to make searching more
efficient. Let us now look at a brief explanation of the A* algorithm.

Explanation

In the event that we have a grid with many obstacles and we want to get somewhere
as rapidly as possible, the A* Search Algorithms are our savior. From a given starting
cell, we can get to the target cell as quickly as possible. It is the sum of two variables’
values that determines the node it picks at any point in time.

At each step, it picks the node with the smallest value of ‘f’ (the sum of ‘g’ and ‘h’)
and processes that node/cell. ‘g’ and ‘h’ is defined as simply as possible below:

 ‘g’ is the distance it takes to get to a certain square on the grid from the starting
point, following the path we generated to get there.
 ‘h’ is the heuristic, which is the estimation of the distance it takes to get to the
finish line from that square on the grid.
Heuristics are basically educated guesses. It is crucial to understand that we do not
know the distance to the finish point until we find the route since there are so many
things that might get in the way (e.g., walls, water, etc.). In the coming sections, we
will dive deeper into how to calculate the heuristics.

Advantages of A* Algorithm in AI

The A* algorithm offers several advantages.

 Firstly, it guarantees finding the optimal path when used with appropriate
heuristics.
 Secondly, it is efficient and can handle large search spaces by effectively pruning
unpromising paths.
 Thirdly, it can be easily tailored to accommodate different problem domains and
heuristics.
 Fourthly, A* is flexible and adaptable to varying terrain costs or constraints.
Additionally, it is widely implemented and has a vast amount of resources and
support available.
Overall, the advantages of A* algorithm in AI make it a popular choice for solving
pathfinding and optimization problems.

Disadvantages of A* Algorithm in AI

While the A* algorithm in AI has numerous advantages, it also has some limitations.

 One disadvantage is that A* can be computationally expensive in certain scenarios,


especially when the search space is extensive and the number of possible paths is
large.
 The algorithm may consume significant memory and processing resources.
 Another limitation is that A* heavily relies on the quality of the heuristic function.
If the heuristic is poorly designed or does not accurately estimate the distance to
the goal, the algorithm's performance and optimality may be compromised.
 Additionally, A* may struggle with certain types of graphs or search spaces that
exhibit irregular or unpredictable structures.

What if the search space in A* Algorithm is not a grid and is a graph?

The A* algorithm can be applied to non-grid search spaces that are represented as
graphs. In this case, the nodes in the graph represent states or locations, and the
edges represent the connections or transitions between them. The key difference
lies in the definition of neighbors for each node, which is determined by the edges in
the graph rather than the adjacent cells in a grid. A* algorithm can still be used to
find the optimal path in such graph-based search spaces by appropriately defining
the heuristic function and implementing the necessary data structures and
algorithms to traverse the graph.

A* Algorithm Example

A* has been successfully applied in numerous real-world scenarios. For instance, in


robotic path planning, A* helps robots navigate through dynamic environments
while avoiding obstacles. In game development, A* is used to create intelligent
enemy AI that can chase and follow the player efficiently. In logistics and
transportation, A* assists in finding the optimal routes for delivery vehicles,
minimizing time and cost. Additionally, A* algorithm has applications in network
routing, such as finding the shortest path in a computer network. These examples
highlight the versatility and practicality of A* algorithm concepts and
implementations in various domains.
Advanced Variations of the A Algorithm*

1. Weighted A*

Weighted A* modifies the traditional A* algorithm by introducing a weight to the


heuristic function, prioritizing paths that may be quicker to compute over strictly
optimal solutions. By increasing the weight, the algorithm favors speed, reducing
computational time at the expense of accuracy. This makes it highly useful in
scenarios where a suboptimal path is acceptable, such as in video games or
simulations where real-time decision-making is crucial.

2. Iterative Deepening A* (IDA*)

IDA* blends A* and depth-first search by exploring paths incrementally with


increasing cost thresholds, significantly reducing memory consumption. Instead of
storing all nodes in memory, it only keeps track of the current path. This is
particularly beneficial in resource-constrained environments, such as embedded
systems or mobile devices.

3. Bidirectional A*

Bidirectional A* searches from both the starting point and the goal simultaneously,
aiming to meet in the middle. This reduces the search space and improves efficiency,
especially in large and symmetrical environments like city grids or navigation
systems. It’s widely used in applications where minimizing computational effort is
key.

4. Anytime A*

Anytime A* provides a quick, suboptimal solution and iteratively refines it over time
as more computational resources become available. This is ideal for real-time
systems like robotics and video games, where an immediate response is necessary,
and the solution can improve dynamically.

5. Dynamic A* (D*)

Dynamic A* is designed to handle changing environments by dynamically


recalculating paths as obstacles or costs change. It’s highly effective in robotics and
autonomous vehicle navigation, where real-world environments are often
unpredictable and require continuous path adjustments.

6. Theta*

Theta* extends A* by allowing paths to cut diagonally across grids, enabling direct
paths rather than being restricted to grid edges. This results in shorter, more realistic
paths, making it ideal for applications like drone navigation or any domain requiring
smooth and direct movement.
4) Navmesh - from book

5) Implementing path finding in games -

https://canbayar91.medium.com/game-mechanics-2-path-finding-ab4f55c1d580

Today, we are going to talk about pathfinding. And not just in games, but about
pathfinding in general. We will start by discussing games and how game worlds
are represented in this context. Once we reduce our game world to the generic
pathfinding problem, we will be investigating different algorithms and compare
how well they perform under different circumstances.

Pathfinding algorithms aim to find the shortest path between two given points.
Many games include some sort of pathfinding mechanism, some are simple, and
some are much more advanced. These mechanisms are mainly utilized in agent
(characters, NPCs, animals or vehicles) movement and can be critical in terms of
realistic artificial intelligence feeling.

The first question we need to answer is how to represent the game world. The
environment is seemingly continuous (it is not but it feels like it is) with roads, hills,
valleys and obstacles along the way. We want to run some sort of search algorithm
on the game world to find the best route, but it is not a very easy task unless we find
a way to represent the world as a discrete set of locations. Luckily, we can.

Navigation Meshes

Representing the real world in a digital environment was one of the most interesting
subjects for me during my university years. You see, the entities in the real world are
continuous and can be divided into presumably infinitely smaller pieces, from atoms
to even smaller subatomic particles. In a computer environment, however, you have
limited space to represent things. No matter how realistic your game looks, you are
limited by the number of pixels on the screen.

In computer graphics (along with other study areas), we use polygonal meshes to
model real-world entities. A mesh is the subdivision of a continuous geometric space
into discrete geometric entities. Big words, huh? Just check the image below, this
bunny is very famous. The most common shapes used in the mesh generation process
are triangles and quadrilaterals. As you increase the number of subdivisions (using
smaller shapes), you get a smoother representation of your subject.
A navigation mesh is a polygonal mesh that is specifically used to represent the
traversable area to be later used in pathfinding. The traversable area is simply divided
into convex polygons. The process of dividing a surface into smaller polygons is
called tessellation. Each polygon shares an edge with the neighbouring polygons,
which means that you can walk between them.

If you take each cell (polygon) and assign a node to the centre of gravity in that cell,
you will obtain the Voronoi diagram of the mesh. You need to use convex polygons in
this process, otherwise, the assigned nodes may end up outside the corresponding
polygon. If you connect the nodes in neighbour cells, you will end up with the dual
graph of the mesh.

I know these are a terrible bunch of drawings but come on, dig deep! Now we have a
bunch of locations and paths that we can navigate between, instead of the terrain
data with no directions. All there is left to do is to find the shortest path between the
green and red nodes.

Path Finding Algorithms

Now that we reduced our problem to a graph search, we can turn our
focus on the path-finding algorithms.

The problem at hand is no longer any different than the generic path-finding
problem. In this section, we will go through a bunch of different solutions and try to
find the most suitable one.

Breadth First Search and Depth First Search

Let’s face it from the beginning: We will not be going with BFS or DFS. Nevertheless,
they are good for introductory reasons. Both algorithms do a very simple thing and
that is to visit every single node on the graph until the destination node is reached.
They are exhaustive algorithms, meaning they are not very efficient. In fact, using DFS
doesn’t even make sense in this context, since it does not find the shortest path.

Instead, let’s focus on the BFS algorithm. It starts from the given node and checks all
the neighbouring nodes until the destination is reached. Since it always checks the
closest nodes first, it will always return the optimum solution, as long as the edges
are not weighted (more on this later).

I am assuming that most of you are already familiar with BFS and DFS algorithms, so I
am keeping this part short. If you are unfamiliar with the algorithms though, you may
benefit from stopping here for a moment and doing a quick internet search on how
these algorithms work. Here is how you can implement BFS using a queue.

Dijkstra’s Algorithm

BFS is very simple to implement, yet it assumes that each path has the same cost. The
paths in our problem though, do not have the same cost: some take longer to
traverse than others. A good path-finding algorithm shall find the path with the
lowest cost so that you don’t get bored while travelling. Unless you like the detour…

We can overcome this issue with Dijkstra's algorithm. In Dijkstra's algorithm, we start
from the player’s current location and keep track of the reachable nodes, along with
the cost to reach that node. In the first step, only the immediate neighbours can be
reached but as you search through the neighbours, the other nodes will become
accessible.

So, we begin our search from the starting point and at each step we pick the closest
node that is reachable so far. Once a node is reached, its neighbours also become
reachable if they were not before and the distances to its unvisited neighbours are
updated with the minimum cost path we have seen so far. At the end of the
algorithm, we will have the minimum cost paths to all the nodes in the graph.

For the sake of simplicity, I assumed that nodes numbered from 1 to n. The
performance of the algorithm can be improved using a priority queue to instantly
reach the node with the lowest cost. I omitted that part since we are not interested in
the runtime analysis at the moment.

Best-First Search

Both algorithms we have seen so far suffer from the same problem: They search the
entire graph. We don’t necessarily need to do that, though. Both algorithms assume
that our search is uninformed — that we have no prior knowledge about where our
destination is. We are informed though, we know that whether our destination is to
the east or west, north or south. Think about it, would you start riding the south if
your next quest marker flashes on the northern side of your minimap?

The best first search is a greedy algorithm that utilizes this idea and it has a very
simple logic. First, we need to define a heuristic function. In our case, Euclidian
distance can be used as an estimated difference to our goal but different scenarios
work well with different heuristic functions. The algorithm chooses to move to the
node with the lowest heuristic value until the destination is reached.
The priority queue in this pseudocode is configured with a heuristic function that we
chose. Thus, the node at the front of the queue is always the one that can be reached
with the lowest cost at any given point. If you compare the pseudocode with BFS, you
can see that the only real difference is how you configure a priority queue with the
chosen heuristic function.

A* Search

Unsurprisingly, the best-first search also has a shortcoming: It doesn’t necessarily find
the shortest path. Just like its name, the A* algorithm is the star of this post and is
widely used in path-finding problems. We will continue using the Euclidian distance
heuristic from the previous algorithm. Additionally, we will use the actual costs of the
edges on the graph to create a more solid ground. So, let’s define a function f(n)

where cost(n) is the actual cost (weight of the edge) of moving from node A to node
B. h(n) is the result returning from our heuristic function, when we are at node B.
Pseudocode is not that different from the previous ones, just the heuristic function is
changed.

A* is a very efficient algorithm but it is highly dependent on how well the


heuristic function is defined. With a good heuristic function, it can guarantee to
find the shortest path but you need to understand that not all heuristic functions
necessarily return the shortest path. Nevertheless, it is your go-to option and it
is widely used in games due to its high performance and optimality.

6) Finite state machines (FSMs)- from book

7) Utility theory and Decision theory -

Introduction

In modern game development, Non-Playable Characters (NPCs) require sophisticated


decision-making to enhance player immersion. Two fundamental frameworks that
guide NPC behavior are Utility Theory and Decision Theory. These theories help
NPCs evaluate situations and make optimal choices to create engaging and
intelligent gameplay.

1. Decision Theory: A Framework for NPC Decision-Making

Decision Theory provides a structured approach for NPCs to make rational choices. It
consists of two main types:
1.1 Normative Decision Theory

Focuses on optimal decision-making based on rationality and mathematical


models.

Assumes an NPC selects the best action given perfect information.

Example: An NPC in a strategy game deciding the best move based on known
enemy positions.

1.2 Descriptive Decision Theory

Studies how decisions are actually made, including irrationality and


psychological factors.

Useful for modeling NPCs with human-like behaviors, such as fear,


hesitation, or bias.

Example: An NPC fleeing in panic rather than making a logically optimal


choice.

2. Utility Theory: Quantifying NPC Choices

Utility Theory assigns numerical values (utility scores) to different actions or


outcomes. NPCs then choose actions that maximize their expected utility.

2.1 Key Concepts of Utility Theory

Utility Function (U(s)) – Measures the desirability of a game state.

Expected Utility – Probability-weighted average of potential outcomes.

Maximization Principle – NPCs select the action with the highest expected
utility.

2.2 Example of Utility-Based Decision-Making

Consider an NPC enemy deciding whether to:

Chase the player (50% chance of success, utility = 7)

Call reinforcements (80% chance of success, utility = 9)

Hide and ambush (60% chance of success, utility = 8)


The NPC calculates the expected utility of each option and selects the highest-
scoring one.

3. Combining Decision Theory and Utility Theory

A well-designed NPC decision model follows these steps:

Sensing – Gather information from the environment (e.g., player actions,


nearby NPCs).

Evaluating Actions – Compute utility values for available choices.

Selecting the Best Action – Choose the option with the highest expected
utility.

Executing and Learning – Adapt behavior over time (e.g., through


reinforcement learning).

4. Advanced Techniques for NPC Decision-Making

Several advanced AI techniques enhance decision-making:

4.1 Markov Decision Processes (MDPs)

Used in AI planning when outcomes are uncertain.

NPCs evaluate probabilities of future states to make optimal decisions.

4.2 Monte Carlo Tree Search (MCTS)

Simulates different decision paths to predict the best course of action.

Commonly used in chess AI and real-time strategy (RTS) games.

4.3 Reinforcement Learning (RL)

NPCs learn over time by trial and error.

Applied in adaptive game AI where NPCs improve based on past experiences.

5. Real-World Applications in Game AI

Utility and Decision Theory have been successfully applied in various games:
Stealth Games – Enemies dynamically decide whether to search for or ignore
the player.

Strategy Games – AI-controlled factions assess resources and prioritize goals.

RPGs & Narrative Games – NPCs make dialogue choices based on utility-
driven models.

Conclusion

Utility Theory and Decision Theory play a crucial role in intelligent NPC behavior. By
leveraging mathematical models and probability-based decision-making, NPCs
become more adaptive, engaging, and believable. As AI in games advances, these
frameworks will continue to evolve, making NPCs smarter and more immersive.

You might also like