Build an AI-Powered Valorant E-sports Manager with AWS Bedrock

Hariharan Ayappane Last Updated : 08 Nov, 2024
9 min read

AI is the future and there’s no doubt it will make headway into the entertainment and E-sports industries. Given the extreme competitiveness of E-sports,  gamers would love an AI assistant or manager to build the most elite team with maximum edge. Such tools could in theory use vast data and find patterns or even strategies that would be invisible to the human mind. So why wait? Let’s build an AI E-sports manager to help you build your dream team! The “Valorant Team Builder” will be focused on helping you build an elite Valorant team using data to crush your opponents.

Learning Outcomes

  • Understand the importance of team composition in Valorant for maximizing performance and strategy.
  • Learn how to utilize AI-driven insights for creating balanced and effective teams.
  • Explore customization options to tailor team roles and strategies based on individual player strengths.
  • Develop skills in performance tracking to evaluate and improve team dynamics over time.
  • Gain knowledge on best practices for sharing and saving team setups for future matches.

This article was published as a part of the Data Science Blogathon.

Developing an AI Manager with AWS Bedrock

We will be developing an AI Manager using AWS Bedrock, specifically tailored for managing and enhancing gameplay experiences in Valorant. Our AI Manager will leverage advanced machine learning models to analyze player performance, provide strategic recommendations, and optimize team compositions. Through the integration of AWS Bedrock’s robust capabilities, we aim to create a tool that not only assists players in improving their skills but also enhances their overall engagement with the game. This comprehensive approach will focus on data collection, analysis, and actionable insights to support players in their journey to becoming top-tier competitors in Valorant.

valorant team builder

Essential Steps for Data Preparation

We will be generating synthetic data roughly based on real world player data that can be found in this Kaggle dataset. A Python script generates artificial values for each in-game metric based on the type of character the player uses. Some of the metrics include:

  • ACS (Average Combat Score): This score reflects a player’s overall impact in a game by calculating damage, kills, and round contributions. It’s a quick measure of a player’s performance within a match.
  • KDA Ratio: This ratio shows the kills, deaths, and assists a player achieves in a game. It’s calculated as (Kills + Assists) / Deaths, giving insight into survivability and team contribution.
  • Headshot Percentage: This percentage shows the proportion of a player’s shots that hit an opponent’s head. High headshot rates often indicate good aim and precision. 
  • ADR (Average Damage per Round): Represents the average damage a player deals per round, highlighting consistency in inflicting damage regardless of kills.

We then use the generated data to create a SQLite database using the sqllite.py script which generates data for each in game character.

 if role == "Duelist":
   average_combat_score = round(np.random.normal(300, 30), 1)
   kill_deaths = round(np.random.normal(1.5, 0.3), 2)
   average_damage_per_round = round(np.random.normal(180, 20), 1)
   kills_per_round = round(np.random.normal(1.5, 0.3), 2)
   assists_per_round = round(np.random.normal(0.3, 0.1), 2)
   first_kills_per_round = round(np.random.uniform(0.1, 0.4), 2)
   first_deaths_per_round = round(np.random.uniform(0.0, 0.2), 2)
   headshot_percentage = round(np.random.uniform(25, 55), 1)
   clutch_success_percentage = round(np.random.uniform(15, 65), 1)
            

Based on the user’s request (e.g., “Build a professional team”), the system runs a SQL query on the database to extract the best players for the specified type of team.

  • get_agents_by_role categorizes VALORANT agents by roles.
  • get_organizations and get_regions return lists of fictional organizations and regional codes.
  • generate_player_data creates synthetic player profiles with random stats based on the player’s role, simulating real VALORANT game data.

Based on your use case you can use different stats like like goals scored per match, matches played per season etc. Find the sample synthetic data used in the project here. You can integrate the tool with real world data on players and matches using the RIOT API

Developing the User Interface

The frontend will be a Streamlit based user interface that allows users to enter the type of team they wish to build, along with some additional constraints. The team type and constraints provided will be used to select a SQL query to on the SQLite database.

user interface
   try:
        if team_type == "Professional Team Submission":
            query = """
            SELECT * FROM players
            WHERE org IN ('Ascend', 'Mystic', 'Legion', 'Phantom', 'Rising', 'Nebula', 'OrgZ', 'T1A')
            """
        elif team_type == "Semi-Professional Team Submission":
            query = """
            SELECT * FROM players
            WHERE org = 'Rising'
            """
        elif team_type == "Game Changers Team Submission":
            query = """
            SELECT * FROM players
            WHERE org = 'OrgZ'
            """

The system uses the selected SQL query to choose relevant players from the database. It then utilizes this player data to build a prompt for the LLM, requesting an analysis of the pros and cons of the selected players. These requirements can be places into the prompt you want to build and pass to the agent. The LLM will provide an analysis of the selected players and suggest justifications or changes as required as a part of the prompt.

Building Interface Using Wrapper

The frontend will interface with AWS through the boto3 library using a wrapper around the invoke_agent() method. This wrapper will allow us to easily handle the invoke_agent method is highly recommended by the the AWS SDK.

class BedrockAgentRuntimeWrapper:
    """Encapsulates Amazon Bedrock Agents Runtime actions."""

    def __init__(self, runtime_client):
        """
        :param runtime_client: A low-level client representing the Amazon Bedrock Agents Runtime.
                               Describes the API operations for running
                               inferences using Bedrock Agents.
        """
        self.agents_runtime_client = runtime_client

    def invoke_agent(self, agent_id, agent_alias_id, session_id, prompt):
        """
        Sends a prompt for the agent to process and respond to.

        :param agent_id: The unique identifier of the agent to use.
        :param agent_alias_id: The alias of the agent to use.
        :param session_id: The unique identifier of the session. Use the same value across requests
                           to continue the same conversation.
        :param prompt: The prompt that you want Claude to complete.
        :return: Inference response from the model.
        """

        try:
            runtime_client.invoke_agent(
                agentId=agent_id,
                agentAliasId=agent_alias_id,
                sessionId=session_id,
                inputText=prompt,
            )

            completion = ""

            for event in response.get("completion"):
                chunk = event["chunk"]
                completion = completion + chunk["bytes"].decode()

        except ClientError as e:
            logger.error(f"Couldn't invoke agent. {e}")
            raise

        return completion

Once we have a wrapper, we can initialize an instance of the wrapper and pass the agent instance (aka client) and send requests to the AI agent by passing in a boto3 client containing the details on our AI agent like Agent ID, Agent Alias ID, session id and prompt. You can find the agent ID and Alias ID on the page of agent creation. The session ID is just an arbitrary label for the session being run by the agent.

 try:
        runtime_client = boto3.client("bedrock-agent-runtime", 
                                    region_name="us-west-2",
                                    aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
                                    aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY")
        )
        
        # Initialize the wrapper
        bedrock_wrapper = BedrockAgentRuntimeWrapper(runtime_client)

        try:
            output_text = bedrock_wrapper.invoke_agent(agent_id, agent_alias_id, session_id, prompt)
            print(f"Agent Response: {output_text}")

The LLM can sometimes stick too rigorously to the information in the Knowledge Base (KB) and might refuse to answer details beyond the contents of the knowledge base. It’s always better to give the model some flexibility to fill in the gaps with it’s own “reasoning”. You can also ditch RAG and just use the pure LLM (Bedrock AI agent) if you want. Incorporating this sense of reasoning can be done using temperature settings or even the agent prompts. The tradeoff of this flexibility with potential LLM hallucination can be explored further based on your use case. 

Building the backend: Generative AI with AWS Bedrock

Navigate to your AWS console and search for AWS Bedrock. Request for model access. Claude model and Titan embeddings should do. The accesses will be granted almost immediately. For other models like Llama might it take a few minutes, try refreshing the page is needed.

Create an S3 bucket

An S3 bucket is a storage space provided by AWS where you can upload your documents. These documents will act as the source for our context based searches. In our case we will add some data on different player types and some basic strategies to analyze games and guidelines to interpret metrics. Provide your bucket with an appropriate name. 

Create a Knowledge Base (KB)

The knowledge base will convert all our S3 bucker data into a vector database. Navigate to the knowledge base section from Bedrock console to create a KB with an appropriate name and the S3 bucket to be used. We will simply select the name of the S3 bucket created in the prior step to connect it to the KB. The Knowledge Base will convert the data present in the S3 bucket into vector embeddings using OpenSearch Serverless (OSS) vector database provided by AWS. You can also choose another vector DB based on your preference and cost sensitivity. Normally cleaning and creating a vector DB would be a difficult process but the OSS service and AWS TITAN vector embeddings are fairly sophisticated and take care of cleaning and preprocessing of the information present in your S3 bucket.

Create an AI agent

Create your AI agent by navigating to the agent section in Bedrock console. Specify which knowledge base. Save the agent configuration and synchronize the agent with the selected knowledge base if needed. Add the KB only after the agent config else synchronizations issues will show up. Add an agent instruction (example shown below). Also add the Knowledge base to AI agent. The AI agent will use the OSS vector database created in step 2 to perform retrieval augmented generation. Save and exit the AI agent editor to avoid synchronization issues. Variance in LLM results. Sometimes provides a good analysis of players, might sometimes ignore the player data entirely.

"You are an expert at Valorant player and analyst. Answer the questions given

to you using the knowledge base as a reference only."

The application needs multiple environment variables to interface with AWS.

Overview of Variables used for VCT Team Builder

A brief overview of the variables used for VCT Team Builder Application is provided below which you can add to the .env file:

BEDROCK_AGENT_ID Unique identifier for your Bedrock agent. agent-123456
BEDROCK_AGENT_ALIAS_ID Alias identifier for your Bedrock agent. prodAlias456
BEDROCK_AGENT_TEST_UI_TITLE Title displayed at the top of the Streamlit app. VALORANT Team Builder
BEDROCK_AGENT_TEST_UI_ICON Icon displayed alongside the title in the Streamlit app. Can be an emoji or a URL to an image. 😉
BEDROCK_REGION AWS region where your Bedrock services are hosted. us-east-1
FLASK_SECRET_KEY Secret key used by Flask for session management and security. your_flask_secret_key
AWS_ACCESS_KEY_ID AWS access key ID for authentication with AWS services. your_aws_access_id
AWS_SECRET_ACCESS_KEY AWS secret access key for authentication with AWS services. your_aws_secret_access_key

Once you’re done setting up the Bedrock services with the environment variables you can run the streamlit application locally or through Streamlit cloud and start chatting with your assistant and build a elite Valorant team to outclass your opponents. 

App Demo: Valorant Team Builder 

Some notes on AWS Bedrock

AWS can be difficult to navigate for beginners. Here’s are a few catches you might want to look out for:

  • An AWS root account will not support the creation of AI agents. You’ll need to create a new IAM account . It can be setup from a root account and has to be provided with the right permissions.
  • When created, you’ll need to create policies/permissions for your new IAM account which control what services are accessible by it.
  • The policies will allow one to use service like S3 buckets, Knowledge Base and Agents. Here are the policies you’ll need to build Valorant Team Builder on your IAM account:
    • Policy for all Bedrock actions and and corresponding services.
    • Policy for all Open Search Serverless (OSS) actions and corresponding services.
    • Policy for all IAM actions including and services.
    • Policy for all Lambda actions and all corresponding services.
  • Make sure to delete the resources once done to avoid incurring excess costs 🙂
  • If you not sure where some projects costs are appearing from, then raise a ticket to AWS support under billing and accounts.
  • They can help you pinpoint the resource inflating your costs and help you shut it down.

Conclusion

Through this article you’ve learned the Ins and Outs of working with AWS Bedrock to setup a RAG toolchain. Feel free to explore the code, augment it and break it improve your understanding or use case. AI tools for text, code or video can seriously bring your A-game in any domain. Such a versatile technology puts us in a very interesting juncture of history to make revolutionary strides in software, hardware, entertainment and everything in between. Let’s make the most of it .

Key Takeaways

  • Unleash the future of gaming with an AI-powered Valorant Team Builder that crafts elite teams tailored for victory.
  • Transform your gameplay by leveraging data-driven insights to assemble a formidable Valorant squad.
  • Stay ahead in the competitive world of e-sports with an intelligent assistant that optimizes team composition based on player metrics.
  • Build your dream team effortlessly by tapping into synthetic data and advanced algorithms for strategic gaming advantages.
  • Crush your opponents in Valorant with a user-friendly app designed to help you select top-tier players based on real-time performance data.

Frequently Asked Questions

Q1. What is the Valorant Team Builder?

A. The Valorant Team Builder is an AI-powered tool that helps players create optimized teams based on individual player stats and performance metrics.

Q2. How does the AI select team members?

A. The AI analyzes player data, including skill levels, previous match performance, and role preferences, to recommend the best possible team compositions.

Q3. Can I customize my team preferences?

A. Yes, users can set preferences for specific roles, agent types, and player styles to tailor team recommendations to their strategies.

Q4. Is the tool suitable for all skill levels?

A. Absolutely! The Team Builder is designed for both casual players and competitive gamers looking to enhance their team synergy.

Q5. How often is the data updated?

A. Player data is updated regularly to reflect the latest performance statistics and trends in the Valorant community.

Q6. Is there a cost associated with using the Team Builder?

A. The basic features of the Team Builder are free, with premium options available for advanced analytics and personalized recommendations.

Hey there,
I'm an undergraduate at NITK driven by passion for technology, problem-solving and numbers. Besides these I also enjoy listening to music and playing table-tennis.

Find me on twitter: https://x.com/HariAyapps
Find me on linkedin: www.linkedin.com/in/hariharan-ayappane

Responses From Readers

Clear

We use cookies essential for this site to function well. Please click to help us improve its usefulness with additional cookies. Learn about our use of cookies in our Privacy Policy & Cookies Policy.

Show details