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.
This article was published as a part of the Data Science Blogathon.
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.
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:
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
AWS can be difficult to navigate for beginners. Here’s are a few catches you might want to look out for:
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 .
A. The Valorant Team Builder is an AI-powered tool that helps players create optimized teams based on individual player stats and performance metrics.
A. The AI analyzes player data, including skill levels, previous match performance, and role preferences, to recommend the best possible team compositions.
A. Yes, users can set preferences for specific roles, agent types, and player styles to tailor team recommendations to their strategies.
A. Absolutely! The Team Builder is designed for both casual players and competitive gamers looking to enhance their team synergy.
A. Player data is updated regularly to reflect the latest performance statistics and trends in the Valorant community.
A. The basic features of the Team Builder are free, with premium options available for advanced analytics and personalized recommendations.