AI in Games Blogs ML Bots Levelling-up NPCs with AI

Julian Togelius Associate professor in the Department of Computer Science and Engineering at New York University, Julian co-founded modl.ai in 2017, where he is currently a Research Director. Julian founded his very first company focusing on instant messaging platforms in 2003, Togelius Tanke & Teknik. He has about 15 years of experience in AI and computer games. Julian was also the editor-in-chief of the IEEE Transactions on Games journal. In 2018, he co-authored the textbook Artificial Intelligence and Games with Georgios N.Yannakakis and was also the co-organizer of the Artificial Intelligence and Games Summer School.

read |

Developments in AI are rapidly changing many industries, including games. Today, global game developers like Ubisoft and EA, or game engine companies such as Unity, have their own AI research divisions. Advances in AI mean that aspects of the games we play are becoming more realistic, whilst on the development side AI-based tools are automating aspects of the game creation process that are time and resource-intensive.
The groundwork for these advances can be seen in almost two decades of academic research into AI for video games. Over the years, we’ve seen more and more of this research being integrated into games. From Left 4 Dead’s AI director, Shadow of Mordor’s Nemesis system, to world-beating NPCs in F.E.A.R. But many many games fall short. Electronic Arts aimed to make bots in the poorly received Battlefield 2042 nearly indistinguishable from real players, but at the game’s launch, fans bashed EA’s bots for either being unbeatable or completely incompetent.
To see progress, and the benefits AI brings, the gaming industry needs to collectively move away from the outdated, staid approaches to NPC design.

This image was generated from https://store.playstation.com/

Buffing bot ‘Intelligence’

Playing against the computer has been a fundamental part of gaming since the industry’s earliest days. But the advent of multiplayer games in the late ‘90s largely made game-playing bots are an afterthought in many genres, as playing against bots simply couldn’t offer the same challenge or excitement as competitive online play. On the other hand, maybe multiplayer games are so popular because the bots are so bad? But that’s more of a chicken and egg
conundrum that’s probably not worth delving into here.
The main issue is that modern bots, in general, are still built on the foundations that were laid over 40 years ago and really haven’t progressed much since then.
The kind of AI that controls the bots in most games is closer to an intricate set of rules or mechanisms manually created by designers. A rudimentary example that is still commonplace in gaming today is finite state machines. Finite state machines mean a bot switches behaviour depending on the actions of the player, or when certain in-game conditions are met. For instance, in Pacman, the ghosts have four: roam, run, chase and head back to base.
Early games did not use much AI for bots, partly because we did not have the AI methods yet and partly because hardware was limited in capacity. To put this in some kind of perspective, the Atari 2600 (1977) had 128 bytes of RAM, by comparison, an Xbox Series X has roughly 16 million times the processing power. Which gives you some idea of just how far we’ve come. Despite this progress, these game design conventions stuck.
More recent titles like EA’s Star Wars: Battlefront 2 exemplify this perfectly, as its bots are well-known for being less than capable. EA suggests this is an intentional design feature to allow lower-skilled players to enjoy the game better – but let’s take their word for it on this one.
Developers play with sliders to fine-tune bot behaviour for the most enjoyable results.
Research conducted by Bungie during the development of Halo found that players believed enemies were more intelligent by simply increasing their damage output, health, and how aggressive they were in combat. By making the bots more powerful but not necessarily changing their behaviors, the number of players that considered the bots ‘very intelligent’ rose from 8% to 43%.

Simply creating bots that play a game more efficiently or effectively is not very interesting to game designers nor the players themselves. So really, bot intelligence in games is less about outright intelligence and more about smoke and mirrors tricks to give the illusion of intelligence. AI allows designers to engineer bots not just to be better at the game, but to give
more life-like, surprising and unique responses in any given situation.

Since co-founding modl.ai we’ve undertaken several projects to create more engaging bots.
An interesting project was when Flamebait Games asked us to create the AI for its game Forge and Fight! The game allows players to craft weapons in thousands of possible combinations, so the challenge was building AI robust enough to handle the randomness of the in-game weapons, with the ability to change tactics depending on whether the human players preferred to attack or defend. The end result? Bots with a far more strategic approach than seen with conventional AI bots. In the words of Flamebait’s CEO, Mattias Lindblad, “The cool thing is to see how it all comes together to make the bots behave precisely like human players.” You can read more about it in their case study.

AI has the ability to make NPCs – the non-playable characters present in many adventure games, who seem to love standing out in the open just so they can share arcane lore or hand out quests – far more dynamic and engaging.

Game developers can be wary of using machine learning in their NPCs because it makes them less predictable but may interfere with the designer’s vision for the game. This is probably the biggest reason why the use of AI-powered NPCs hasn’t advanced much, because many game design conventions are still based on an era before we had usable modern AI.

However, there are many ways AI could help make better NPCs. For example, more interesting behaviour, more collaborative actions, and better dialogue. Using AI could produce more surprising reactions from NPCs, rather than just being a pre-programmed cue to produce an obvious response. It could also greatly simplify the development of NPC, the complexity of which currently limits both the number and sophistication of characters you
can meet in a game.

Also, it’s a common gripe from players about NPCs designed to assist you, often just ending up thwarting your progress or obstructing gameplay. With better player modeling, we can create AI agents that can predict with some degree of accuracy what the player will do next and plan around that to help them carry out their goals.

Some of these improvements to NPCs can fit into games as designed today. But what’s even more exciting is to think of the new game designs that better AI makes possible, as the designs we use today are largely built around the lack of effective AI.

Speech, a next-level challenge for AI

AI will also bring about a revolution in the use of natural language by game characters.
Almost universally, game characters ‘speak’ in pre-written sentences, and interaction usually follows a dialogue tree where the player can choose from a very limited set of things to say.
This is a very stifling form of interaction, and it was never anyone’s idea about how best to interact with game characters. It’s more of a workaround, which has become the norm over the past four decades of video games because we don’t know how to actually make game characters talk.

Bethesda’s much-beloved Elder Scrolls V: Skyrim is well known for having some less than realistic NPCs. The commonality of the phrase from nearly every town guard in the game, “I used to be an adventurer like you. Then I took an arrow in the knee”, became so well-known it spawned countless memes, videos, remixes, and articles. While it’s hard to imagine a world
without this iconic, yet strangely specific, phrase, gamers probably wouldn’t have as much patience for this kind of thing from a modern AAA title.

The massive progress in deep learning-based language models promises a way of ultimately getting around this. By giving language models the right prompts, it is now possible to generate (written) interactive dialogue on particular topics and in particular styles.

With the pace of progress in research on fine-tuning and controlling language models, it’s likely that we will see deep learning-powered NPC dialogue in the not-too-distant future. AI Dungeon 2 has already made headlines with its use of AI. The AI-based text adventure game allows players to do almost anything by simply typing in a command and the algorithm then
crafts a tailored response. But by giving players unlimited choice means it’s very hard for developers to control a player’s experience and enjoy the game as intended. In the case of AI Dungeon 2, giving players unlimited freedom resulted in some very disturbing results – leading the game’s developers, Latitude, to impose filters and moderation on the game.

As things stand, it is still very hard to control the output of language models, and NPCs built this way may end up saying things that interfere with the game’s design or worse. The now- famous South Korean chatbot Lee Luda that was tested on Facebook and has now officially been cancelled after it reported using racial slurs against users. Lee Luda isn’t alone either,
we’ve seen previous iterations of chatbots, like Microsoft’s Tay in 2016, encounter the same problems. In general, controlling bias and preventing offensive outputs is a very challenging part of using AI systems. Fortunately, there’s an abundance of research in this area, so it might only be a matter of time before methods are developed to help avoid these common issues.

The missing piece of the Gamedev puzzle?

Advancements in NPC game design have stagnated in recent years. Tried and tested design methods that were first implemented decades ago, before we had modern AI techniques and the computing power to use it, are still commonplace in many AAA games today. NPCs are ripe to be overhauled, but only if developers can embrace artificial intelligence. As AI research continues to advance and unearth new ways of working, it will unlock entirely new approaches to game design. So, I believe it’s only a matter of time before the industry can fully realise the technology’s potential and completely transform the traditional gaming experience.

Developments in AI are rapidly changing many industries, including games. Today, global game developers like Ubisoft and EA, or game engine companies such as Unity, have their own AI research divisions. Advances in AI mean that aspects of the games we play are becoming more realistic, whilst on the development side AI-based tools are automating aspects of the game creation process that are time and resource-intensive.
The groundwork for these advances can be seen in almost two decades of academic research into AI for video games. Over the years, we’ve seen more and more of this research being integrated into games. From Left 4 Dead’s AI director, Shadow of Mordor’s Nemesis system, to world-beating NPCs in F.E.A.R. But many many games fall short. Electronic Arts aimed to make bots in the poorly received Battlefield 2042 nearly indistinguishable from real players, but at the game’s launch, fans bashed EA’s bots for either being unbeatable or completely incompetent.
To see progress, and the benefits AI brings, the gaming industry needs to collectively move away from the outdated, staid approaches to NPC design.

This image was generated from https://store.playstation.com/

Buffing bot ‘Intelligence’

Playing against the computer has been a fundamental part of gaming since the industry’s earliest days. But the advent of multiplayer games in the late ‘90s largely made game-playing bots are an afterthought in many genres, as playing against bots simply couldn’t offer the same challenge or excitement as competitive online play. On the other hand, maybe multiplayer games are so popular because the bots are so bad? But that’s more of a chicken and egg
conundrum that’s probably not worth delving into here.
The main issue is that modern bots, in general, are still built on the foundations that were laid over 40 years ago and really haven’t progressed much since then.
The kind of AI that controls the bots in most games is closer to an intricate set of rules or mechanisms manually created by designers. A rudimentary example that is still commonplace in gaming today is finite state machines. Finite state machines mean a bot switches behaviour depending on the actions of the player, or when certain in-game conditions are met. For instance, in Pacman, the ghosts have four: roam, run, chase and head back to base.
Early games did not use much AI for bots, partly because we did not have the AI methods yet and partly because hardware was limited in capacity. To put this in some kind of perspective, the Atari 2600 (1977) had 128 bytes of RAM, by comparison, an Xbox Series X has roughly 16 million times the processing power. Which gives you some idea of just how far we’ve come. Despite this progress, these game design conventions stuck.
More recent titles like EA’s Star Wars: Battlefront 2 exemplify this perfectly, as its bots are well-known for being less than capable. EA suggests this is an intentional design feature to allow lower-skilled players to enjoy the game better – but let’s take their word for it on this one.
Developers play with sliders to fine-tune bot behaviour for the most enjoyable results.
Research conducted by Bungie during the development of Halo found that players believed enemies were more intelligent by simply increasing their damage output, health, and how aggressive they were in combat. By making the bots more powerful but not necessarily changing their behaviors, the number of players that considered the bots ‘very intelligent’ rose from 8% to 43%.

Simply creating bots that play a game more efficiently or effectively is not very interesting to game designers nor the players themselves. So really, bot intelligence in games is less about outright intelligence and more about smoke and mirrors tricks to give the illusion of intelligence. AI allows designers to engineer bots not just to be better at the game, but to give
more life-like, surprising and unique responses in any given situation.

Since co-founding modl.ai we’ve undertaken several projects to create more engaging bots.
An interesting project was when Flamebait Games asked us to create the AI for its game Forge and Fight! The game allows players to craft weapons in thousands of possible combinations, so the challenge was building AI robust enough to handle the randomness of the in-game weapons, with the ability to change tactics depending on whether the human players preferred to attack or defend. The end result? Bots with a far more strategic approach than seen with conventional AI bots. In the words of Flamebait’s CEO, Mattias Lindblad, “The cool thing is to see how it all comes together to make the bots behave precisely like human players.” You can read more about it in their case study.

AI has the ability to make NPCs – the non-playable characters present in many adventure games, who seem to love standing out in the open just so they can share arcane lore or hand out quests – far more dynamic and engaging.

Game developers can be wary of using machine learning in their NPCs because it makes them less predictable but may interfere with the designer’s vision for the game. This is probably the biggest reason why the use of AI-powered NPCs hasn’t advanced much, because many game design conventions are still based on an era before we had usable modern AI.

However, there are many ways AI could help make better NPCs. For example, more interesting behaviour, more collaborative actions, and better dialogue. Using AI could produce more surprising reactions from NPCs, rather than just being a pre-programmed cue to produce an obvious response. It could also greatly simplify the development of NPC, the complexity of which currently limits both the number and sophistication of characters you
can meet in a game.

Also, it’s a common gripe from players about NPCs designed to assist you, often just ending up thwarting your progress or obstructing gameplay. With better player modeling, we can create AI agents that can predict with some degree of accuracy what the player will do next and plan around that to help them carry out their goals.

Some of these improvements to NPCs can fit into games as designed today. But what’s even more exciting is to think of the new game designs that better AI makes possible, as the designs we use today are largely built around the lack of effective AI.

Speech, a next-level challenge for AI

AI will also bring about a revolution in the use of natural language by game characters.
Almost universally, game characters ‘speak’ in pre-written sentences, and interaction usually follows a dialogue tree where the player can choose from a very limited set of things to say.
This is a very stifling form of interaction, and it was never anyone’s idea about how best to interact with game characters. It’s more of a workaround, which has become the norm over the past four decades of video games because we don’t know how to actually make game characters talk.

Bethesda’s much-beloved Elder Scrolls V: Skyrim is well known for having some less than realistic NPCs. The commonality of the phrase from nearly every town guard in the game, “I used to be an adventurer like you. Then I took an arrow in the knee”, became so well-known it spawned countless memes, videos, remixes, and articles. While it’s hard to imagine a world
without this iconic, yet strangely specific, phrase, gamers probably wouldn’t have as much patience for this kind of thing from a modern AAA title.

The massive progress in deep learning-based language models promises a way of ultimately getting around this. By giving language models the right prompts, it is now possible to generate (written) interactive dialogue on particular topics and in particular styles.

With the pace of progress in research on fine-tuning and controlling language models, it’s likely that we will see deep learning-powered NPC dialogue in the not-too-distant future. AI Dungeon 2 has already made headlines with its use of AI. The AI-based text adventure game allows players to do almost anything by simply typing in a command and the algorithm then
crafts a tailored response. But by giving players unlimited choice means it’s very hard for developers to control a player’s experience and enjoy the game as intended. In the case of AI Dungeon 2, giving players unlimited freedom resulted in some very disturbing results – leading the game’s developers, Latitude, to impose filters and moderation on the game.

As things stand, it is still very hard to control the output of language models, and NPCs built this way may end up saying things that interfere with the game’s design or worse. The now- famous South Korean chatbot Lee Luda that was tested on Facebook and has now officially been cancelled after it reported using racial slurs against users. Lee Luda isn’t alone either,
we’ve seen previous iterations of chatbots, like Microsoft’s Tay in 2016, encounter the same problems. In general, controlling bias and preventing offensive outputs is a very challenging part of using AI systems. Fortunately, there’s an abundance of research in this area, so it might only be a matter of time before methods are developed to help avoid these common issues.

The missing piece of the Gamedev puzzle?

Advancements in NPC game design have stagnated in recent years. Tried and tested design methods that were first implemented decades ago, before we had modern AI techniques and the computing power to use it, are still commonplace in many AAA games today. NPCs are ripe to be overhauled, but only if developers can embrace artificial intelligence. As AI research continues to advance and unearth new ways of working, it will unlock entirely new approaches to game design. So, I believe it’s only a matter of time before the industry can fully realise the technology’s potential and completely transform the traditional gaming experience.

Published by Julian Togelius

Associate professor in the Department of Computer Science and Engineering at New York University, Julian co-founded modl.ai in 2017, where he is currently a Research Director. Julian founded his very first company focusing on instant messaging platforms in 2003, Togelius Tanke & Teknik. He has about 15 years of experience in AI and computer games. Julian was also the editor-in-chief of the IEEE Transactions on Games journal. In 2018, he co-authored the textbook Artificial Intelligence and Games with Georgios N.Yannakakis and was also the co-organizer of the Artificial Intelligence and Games Summer School.