The Random Walk Blog

2025-01-08

AI in Gaming: Elevating Player Experiences with Intelligent Agents

AI in Gaming: Elevating Player Experiences with Intelligent Agents

AI and games have been fundamentally intertwined from their inception, pushing one another to new frontiers. Games, with their precise rules and narrow subdomains, provide the perfect arena for game AI to excel. This blog offers a glimpse into one of our attempts at creating a multi-agent game and explores the complexities involved in designing a multi-agent system in the world of AI in gaming.

The Game

Let’s talk about the game we’ve built, called "Matrix". It’s a blockchain-based multiplayer game that helps players learn new languages through fun, mission-based challenges drawn from everyday life. While creating the game, we delved into the intricacies of game AI to make AI agent responses more human-like and explored how to make interactions feel more natural.

Through this journey, we identified four main processes that make any interaction more human-like:

  • Augmenting movements and natural interactions

  • Augmenting emotions

  • Augmenting memory

  • Augmenting personas

AI game.webp

The featured game poster for "Matrix"

Augmenting Movements and Natural Interactions

How Simple Games Augment Natural Movements and Interactions

Early game AI implementations were relatively simple, combining fixed patterns with behavior changes based on player actions. A common method used is the finite state machine (FSM), which divides the game into various states, each with specific rules. The AI switches between these states depending on the player’s actions.

For example, in Pac-Man, enemy behaviors follow these four states:

  • Wander around the maze

  • Chase Pac-Man

  • Return to their base

  • Run away from Pac-Man

pacman.webp

State Diagram of "Pacman"

Our Approach of AI in Gaming

In gaming, non-player characters (NPCs) act as agents that interact with players. We’ve implemented a hybrid state machine where NPC behavior is influenced not only by fixed instructions but also by real-time decisions made by the AI agent during interactions.

Game AI.webp

State Diagram of "Matrix"

AI game play.webp

Above is the screenshot of the game where there are multiple agents on the map. Players can move around the map, and whenever someone gets close, a card will pop up showing nearby players.

Augmenting Emotional Interactions with AI in Gaming

Emotions play a vital role in human interactions, influencing decision-making and relationships. In the realm of AI in gaming, simulating emotions allows game AI to feel more relatable and human.

We treat emotions as dynamic, changing based on interactions and experiences. For example, how we feel can be influenced by what we experience in our day-to-day lives—whether it's a positive event like meeting a friend or a negative event like an argument. Our emotions also shift based on how we communicate with people, how they treat us, and the overall mood of our interactions. So, instead of thinking of emotions as permanent, we see them as something that can change, grow, or shift depending on what's happening in our lives.

Our approach includes simulating basic emotions like happiness, sadness, anger, and more, updating them after each interaction using detailed prompts. For example:

"Based on the details of the last conversation, please analyze and determine what emotion best describes how the person might be feeling. Consider factors like their tone, the context of the conversation, and any emotional cues in their words.

For example, if the conversation was about a recent achievement, the person might be feeling happy or proud. If they discussed something challenging or stressful, they might be feeling anxious or frustrated. Please provide the most likely emotion based on this information.

Examples:

  • If the person talked about a fun day with friends, the emotion could be joy.

  • If they mentioned a stressful situation at school or work, the emotion might be anxiety.

  • If they shared something sad, like losing a pet, the emotion could be sadness.

the past conversation is [past_conversation] return the most likely emotion"

Augmenting Memory in Gaming with Advanced AI Techniques

Memory is essential for personalizing interactions in gaming. Game AI with memory can recall past interactions, making conversations more engaging and connected.

In "Matrix", we treat memory as something that changes based on past interactions. For example, how the AI agent responds to a player can depend on what they talked about before, making the conversation feel more connected and relevant. By keeping a record of past interactions, the AI agent can refer back to these memories, creating a more immersive AI in gaming experience.

To do this, we use a prompt:

"Based on the last conversation and past interactions with the player, please come up with a topic for the next interaction that builds on what was discussed before. Think about the player's interests and any unresolved topics or questions.

For example, if the player mentioned a hobby, the AI agent might ask about recent developments in that hobby. If there was a challenging situation discussed, the AI agent might check in to see how things have progressed. Please provide a unique and engaging topic for the next interaction based on this information."

Whenever the AI agent and player interact again, the AI agent remembers previous conversations to make the interaction better. We have added multiple prompts to create new and interesting topics for each interaction.

AI in gaming emotion augmentation.webp

The above image shows how conversations between the player and the AI agent (character in white dress) work.

Here's how it goes:

  • When the player and the AI agent talk, their conversations are saved in a database.

  • In the future, when the AI agent meets the player again, the AI agent can look up these past conversations.

  • Some private details from these past chats are removed for privacy.

  • The remaining conversation info is sent to a large language model (LLM).

  • Using this info, the LLM helps the AI agent talk to the player with context from their previous interactions, making the conversation feel more connected and personal.

Sample Scenario

Here's an example of how the AI agent (the character in the white dress) interacts with the player (the character on the left). The AI agent remembers what the player talked about before, like their interests and conversations, and stores this information in a database. Later in the game, when the player talks to the AI agent again (like in the second interaction), the AI agent uses this memory to continue the conversation with context from the previous interaction.

AI in gaming interaction1.webp

Above is the initial scenario where the AI agent gathers information about the player.

AI in gaming interaction2.webp

Above is the scenario where the AI then engages in a conversation with the player, building on the context of their previous interactions.

Augmenting Persona with AI to Create Dynamic Characters

A persona is a detailed and made-up character profile that represents a specific type of person.

Beliefs, occupation, interests, and lifestyles are some of the things that define a person's persona. We have saved the personas of each person, and any reply generated from the LLM request goes through the persona to update the sentence in their unique style.

The following is a sample interaction:

Here's the settings page where you can create an agent with a unique persona. You can describe the agent's occupation, interests, and how they'll interact with people.

The sample input and output also serve as a guide to help the model understand how to reply to anyone.

AI in gaming agent_config.webp

Above is the agent creation dashboard where player can create agents with required characteristics and tone.

AI in gaming chat_interface.webp

Above is the chat interface where the player chats with the AI agent.

Creating a multi-agent game like "Matrix" has been a fascinating journey that has deepened our understanding of how AI can enhance human-like interactions in gaming. By focusing on augmenting movements, emotions, memory, and personas, we’ve developed AI agents that react to players and adapt to their behaviors, creating a more immersive and personalized experience. Ultimately, the goal is to create worlds where AI agents are not just programmed to follow patterns, but to truly understand and respond to players in ways that feel real and authentic.

If you're curious about how intelligent agents can transform gaming experiences or want to learn more about our game "Matrix," get in touch with Random Walk today. We're here to answer your questions and collaborate on innovative gaming solutions!

Related Blogs

Top 5 AI Tools That Should Be Used in the UAE: Do you use any of these already?

The United Arab Emirates (UAE) is not only keeping pace with the AI revolution—it's leading the way. With forward-looking policies such as the **UAE Strategy for Artificial Intelligence 2031**, the nation has established itself as a global testbed for AI innovation**.

Top 5 AI Tools That Should Be Used in the UAE: Do you use any of these already?

The When, Why and for Whom: a comparison of Frontend Frameworks React, Svelte and Solid.js

As a developer, choosing the right frontend framework can significantly impact the performance, maintainability, and scalability of your web applications. This article provides an in-depth comparison of three popular frameworks: React, Svelte, and Solid.js, from a developer's perspective .

The When, Why and for Whom: a comparison of Frontend Frameworks React, Svelte and Solid.js

Matplotlib vs. Plotly: Choosing the Right Data Visualization Tool

In a data-driven world, effective visualization is essential for analyzing complex datasets. Well-crafted visuals simplify intricate information, enhance storytelling, and make insights more accessible. Among the many tools available, Matplotlib and Plotly stand out as two of the most widely used Python libraries for data visualization. Each offers distinct features catering to different user needs. Let's explore their strengths, differences, and ideal use cases.

Matplotlib vs. Plotly: Choosing the Right Data Visualization Tool

AI-Driven Social Listening: Decode Your Gamers' Minds & Boost Revenue

The gaming industry is a multi-billion-dollar battlefield where player sentiment shifts rapidly. Every day, millions of gamers voice their opinions, frustrations, and desires on platforms like Reddit, Twitter, Discord, and Twitch. But are you truly listening?

AI-Driven Social Listening: Decode Your Gamers' Minds & Boost Revenue

DeepSeek Rising: How an Open-Source Challenger Is Cracking OpenAI’s Fortress

The AI race has long been dominated by proprietary giants like OpenAI, but a new contender is making waves—DeepSeek. With its latest open-source models, DeepSeek V3 and DeepThink R1, this Chinese AI company is challenging OpenAI’s dominance by offering competitive performance at a fraction of the cost. DeepSeek’s Mixture of Experts (MoE) architecture, efficient GPU utilization, and strategic innovations have enabled it to deliver high-performance AI models with minimal computational expense. But how does it truly compare to OpenAI’s GPT-4o and GPT-o1? Let's break it down.

DeepSeek Rising: How an Open-Source Challenger Is Cracking OpenAI’s Fortress
Top 5 AI Tools That Should Be Used in the UAE: Do you use any of these already?

Top 5 AI Tools That Should Be Used in the UAE: Do you use any of these already?

The United Arab Emirates (UAE) is not only keeping pace with the AI revolution—it's leading the way. With forward-looking policies such as the **UAE Strategy for Artificial Intelligence 2031**, the nation has established itself as a global testbed for AI innovation**.

The When, Why and for Whom: a comparison of Frontend Frameworks React, Svelte and Solid.js

The When, Why and for Whom: a comparison of Frontend Frameworks React, Svelte and Solid.js

As a developer, choosing the right frontend framework can significantly impact the performance, maintainability, and scalability of your web applications. This article provides an in-depth comparison of three popular frameworks: React, Svelte, and Solid.js, from a developer's perspective .

Matplotlib vs. Plotly: Choosing the Right Data Visualization Tool

Matplotlib vs. Plotly: Choosing the Right Data Visualization Tool

In a data-driven world, effective visualization is essential for analyzing complex datasets. Well-crafted visuals simplify intricate information, enhance storytelling, and make insights more accessible. Among the many tools available, Matplotlib and Plotly stand out as two of the most widely used Python libraries for data visualization. Each offers distinct features catering to different user needs. Let's explore their strengths, differences, and ideal use cases.

AI-Driven Social Listening: Decode Your Gamers' Minds & Boost Revenue

AI-Driven Social Listening: Decode Your Gamers' Minds & Boost Revenue

The gaming industry is a multi-billion-dollar battlefield where player sentiment shifts rapidly. Every day, millions of gamers voice their opinions, frustrations, and desires on platforms like Reddit, Twitter, Discord, and Twitch. But are you truly listening?

DeepSeek Rising: How an Open-Source Challenger Is Cracking OpenAI’s Fortress

DeepSeek Rising: How an Open-Source Challenger Is Cracking OpenAI’s Fortress

The AI race has long been dominated by proprietary giants like OpenAI, but a new contender is making waves—DeepSeek. With its latest open-source models, DeepSeek V3 and DeepThink R1, this Chinese AI company is challenging OpenAI’s dominance by offering competitive performance at a fraction of the cost. DeepSeek’s Mixture of Experts (MoE) architecture, efficient GPU utilization, and strategic innovations have enabled it to deliver high-performance AI models with minimal computational expense. But how does it truly compare to OpenAI’s GPT-4o and GPT-o1? Let's break it down.

Additional

Your Random Walk Towards AI Begins Now