Lexitrail blends Agones & AI to make learning Chinese characters fun & interactive.
The gaming industry is about to undergo a transformation with generative AI. It will change player experiences by providing and frequently already does tailored surroundings, dynamic narratives, and individualised NPCs. The term “living games” is becoming more and more popular.
This promise is demonstrated by the recent release of Genie 2, a large-scale base world model developed by Google DeepMind. With the help of generative AI and supported by Kubernetes, Agones, and Open Match, living cloud gaming can bring these developments to a large audience without compromising usability or performance.
Let us walk you through the process of incorporating state-of-the-art generative AI models, like Google’s Gemini, or open models, like Gemma, into scalable multiplayer gaming servers that are driven by Agones and Google Kubernetes Engine (GKE) in this blog post. This blog will demonstrate how generative AI can be used to improve a sample game. This will allow developers to add AI-driven features to their games, like interactive user guidance, real-time chat capabilities, and customised summaries of user progress, while still ensuring scalability and dependability.
Cloud gaming with Agones: the foundation for scalable multiplayer experiences
Developers can effectively manage a large number of dedicated game servers with Agones, an open-source game server hosting solution based on Kubernetes. Although Agones can be used with any Kubernetes deployment, Google Cloud users can receive official support when it is run on GKE.
Additionally, Agones interfaces with Open Match, an open-source matchmaking technology that makes it easier to create multiplayer matches according to player parameters like location or skill level.
Agones and Open Match together offer a strong basis for cloud games that can grow in size.
Generative AI’s Potential in Cloud Gaming
Living games can surpass standard live services by employing generative AI in real-time, producing a dynamic and captivating player experience without requiring continuous developer involvement. Through elements like dynamic storyline adaption, responsive NPC interactions, and personalised in-game content, living games may create a strong bond between players and the game environment while guaranteeing that every playthrough is different.
Building a language learning game with gen AI: A technical walkthrough
It developed a language-learning game called Lexitrail to provide a basic illustration of the merging of Agones with generative AI. In addition to helping users learn Chinese characters interactively, Lexitrail’s multiplayer feature allows users to compete with one another.
Lexitrail makes use of a MySQL database, a Python Flask backend, and a React frontend. They are all set up on Google Kubernetes Engine (GKE) in clusters. The game session management layer, which is implemented as Agones game servers for smooth game session handling, is a crucial part.
It utilise the strength of the Gemini and Imagen models within Lexitrail. These models help gamers learn and remember words by producing nuanced, unclear hint visuals. In addition to the LLM prompts, it offer further user-specific context to further customise the experience.
High-Level Architecture of Lexitrail
The basic structure and elements supporting the Lexitrail system are depicted in the diagram below.
The following essential characteristics of this architecture are intended to improve the gaming experience:
Seamless game sessions
In both single-player and multiplayer modes, seamless gameplay with fast state transitions is guaranteed when Agones is used for game session management.
Integration of generative AI
Because of the flexibility of the generative AI integration layer, developers can design endpoints for both closed models (like Gemini and Imagen) and open models (like Llama, Stable Diffusion, and Gemma). After then, these endpoints can be combined with other elements of the game application to create intricate and evocative hint graphics that are especially suited to the needs of each unique game.
Skill-based matchmaking
By matching participants according to their ability levels, Open Match produces matches in multiplayer settings that are interesting and well-balanced.
Scalability and reliability
GKE serves as the cornerstone of this design, offering the Kubernetes infrastructure required for game server management and autoscaling. From small study groups to large tournaments, Agones and Open Match on GKE ensure that the language-learning game can easily accommodate a global player base.
The architecture of the Lexitrail game application, which is made to provide a seamless and scalable multiplayer experience, is broken down as follows:
Lexitrail frontend
This is the player’s first interface. It uses Google Login to handle authentication. The frontend controls both the user interface element and the business logic that controls its interactions. There are several game modes available. In multiplayer games, players can compete against other players or practise alone. For every game mode, players can also choose word sets according to various HSK (Hanyu Shuiping Kaoshi) levels. The matchmaking process is started by the game’s frontend when a player chooses multiplayer mode. Sending matchmaking requests to the Open Match component is part of this procedure.
Open Match
For its matchmaking system, Lexitrail uses Open Match, which is set up as a GKE service. The present configuration is simple: players are matched together if they choose the same wordset. But because of Open Match’s adaptability, developers can create more complex pairing algorithms that are suited to their particular game needs. Open Match works with the game server orchestration system to assign a specific game server for a match once it has been decided. Because the game state is an in-memory simulation, the matchmaker then relays to the game clients (via the frontend) the address and port that each client must connect to directly before they may play Lexitrail!
Game server
The game server in Lexitrail is in charge of overseeing participant pairs’ game sessions. It keeps track of intermediate word recall outcomes, manages the final scoreboard, and supervises gameplay logic. The game server also serves as a buffer layer to improve performance. It ensures that time-consuming processes, such database updates, don’t impair frontend responsiveness by batching them and flushing them to the backend asynchronously.
Agones
Using its allocator service, Lexitrail uses Agones for game server orchestration, enabling matchmakers to request the dedicated game server for every match. These game servers are maintained by Agones to guarantee availability and prevent disruptions to the user experience while they are in use. Furthermore, Lexitrail dynamically modifies the quantity of game servers in response to demand by leveraging Agones’ fleet autoscaler.
Game backend
Deployed as a GKE service, Lexitrail’s game backend controls the business logic and API interface for database interfaces. It manages queries from the game servers and frontend, retrieving and updating player information such as words, recall history, and wordsets. Furthermore, the backend creates pictures and tip phrases that help players remember and recall terms by integrating with the generative AI endpoints.
Database
MySQL powers Lexitrail’s backend database, which is set up under the GKE environment. All of the necessary game data, such as player recall history, word sets, user profiles, and individual word entries, are stored in this database. You can find the database schema here.
Generative AI integration
During gameplay, players are given words to memorise in the game’s user interface, along with visual cues to help them remember them. Integrating with generative AI endpoints that are set up inside the GKE environment produces these visual cues. To generate the hint images for every word, the game backend makes a query to the image generating model endpoint. Because of the kubernetes-based architecture’s flexibility, developers can choose and use several underlying LLMs for image production with ease.
Take the Next Step
Gen AI in gaming has a lot of potential, and the resources are now more widely available than before. As a starting point, it encourage you to look around the repository.
Explore gen AI integration
Use Agones and GKE to begin using new AI models into your own apps.
Leverage Vertex AI and GKE models
To discover how AI may improve your gaming experience, try integrating Vertex AI with open models on GKE.
Join the community
Participate in the Agones, Open Match, and larger GKE AI projects’ development community to exchange ideas, pick up tips from others, and influence the direction of Artificial Intelligence-powered gaming.
Adopting scalable AI-driven features that provide players unprecedented levels of personalisation and interaction will help you stay on the cutting edge of gaming technology and make living games a reality.
For cloud games that use cutting-edge components, Kubernetes and GKE with Agones and Open Match offer a scalable, production-tested enterprise-grade solution. Scalable, AI-powered gaming is only getting started, and Google Cloud is excited to see what you create!