My Security & AI Blog

BattleGenesis: Bringing AI to the Trading Card Game Arena

April 16, 2025 | by William Lien

ChatGPT Image Apr 16, 2025, 11_08_37 PM

In a world where game simulation meets storytelling, BattleGenesis emerges as a unique blend of strategy, simulation, and artificial intelligence. This AI-powered project was born from a deep love for trading card games (TCGs) and a desire to explore the creative potential of generative AI.

In this post, we’ll dive into how BattleGenesis came to life, explore its architecture, and share what we learned from building an AI that doesn’t just simulate games—it tells their stories.

🚀 The Idea Behind BattleGenesis

Trading card games are full of strategy, suspense, and unforgettable plays—but traditional simulations often miss that magic. Most game logs are dry and data-heavy, offering little of the excitement players experience.

So we asked ourselves: What if we could use AI to turn TCG matches into immersive, play-by-play narratives?

That question sparked the creation of BattleGenesis—a system that simulates a match between two AI players and then generates a dynamic story describing each turn using generative AI from Google.

🛠️ How It Works: From Code to Combat

BattleGenesis is built around two main engines:

1. Game Simulation Engine

  • Deck Generation:
    The generate_deck function assembles a 60-card deck based on a chosen strength level (“strong”, “normal”, or “weak”). Cards are categorized (Pokémon, Trainer, Energy, etc.), shuffled, and prepped for battle.
  • Game State Initialization:
    The initial_state function handles the opening hand, reward cards, and placement of Pokémon on the field—just like a real TCG setup.
  • Turn Mechanics:
    The simulate_turn function runs each turn, handling card draws, Trainer/Item usage, and attacks. Knockouts and reward cards are handled automatically to reflect real gameplay flow.

2. Narrative Generation Engine

  • Turn Narratives:
    After each turn, the game’s JSON log is passed to the Gen AI model using few-shot prompting. The AI then writes a compelling, natural-language summary of what happened—complete with strategic insights and dramatic flair.
  • Final Battle Summary:
    Once all 10 turns are complete, the system generates a final recap: highlights, turning points, and of course, the winner.

🧠 Why Generative AI?

BattleGenesis shows how structured data and AI storytelling can work hand-in-hand. Here’s what makes it tick:

  • Structured JSON Inputs:
    Clean data makes better AI. Each turn’s info is neatly packaged for Gen AI to interpret and narrate effectively.
  • Few-shot Prompting:
    Sample inputs help guide the model, ensuring consistency and tone across every turn and summary.
  • Controlled Generation:
    The blend of game logic and narrative generation allows for engaging yet accurate storytelling—something that static logs can’t match.

📈 What We Learned

Key Takeaways:

  • AI Adds Narrative Depth:
    What starts as simple turn-by-turn data becomes a dramatic, readable battle with AI narration.
  • Few-shot Prompting Works Wonders:
    With the right setup, large language models can mimic game commentary and enhance player engagement.
  • Prototype for the Future:
    Whether it’s for MLOps, Retrieval-Augmented Generation (RAG), or game AI research, BattleGenesis is a launchpad for innovative, AI-driven experiences.

🎮 Wrapping Up

BattleGenesis reimagines TCG simulations—not as sterile data, but as living stories powered by AI. It’s a glimpse into the future of how we can blend gameplay mechanics with machine creativity to deliver something that feels real, strategic, and fun.

We’re just getting started. As the project evolves, we’ll continue to explore how generative AI can enhance interactive experiences, not just for gamers—but for anyone fascinated by data, narrative, and intelligent systems.

Until next time—keep building, keep battling, and let the AI do the storytelling.

🚀 Flow

🛠️ Output Example

====== Turn 1 Narrative ======

The stadium lights blazed down as the first turn of the match crackled with anticipation. "Player 1 (Lost Zone Box)," a strategist renowned for their calculated risks, began their assault. A sharp inhale, the shuffle of cards, and then the familiar *rip* of a card being drawn. A flicker of recognition crossed their face. It was *Colress's Experiment*! A knowing smirk played on their lips as they slammed the Supporter card onto the table.

"Time to delve into the depths!" Player 1 announced, their voice echoing slightly in the hushed arena. The energy in the room shifted, as everyone knew the power that lay in manipulating the deck.

With the strategic card played, Player 1 turned their attention to the battlefield. Their Active Pokémon, a seemingly innocuous *Snom*, its icy exterior shimmering under the lights, stood poised. Across the field, their opponent's *Kirlia*, a delicate psychic Pokémon, braced itself.

"Snom, show them your bite!" Player 1 commanded. The crowd held its breath. Snom, despite its diminutive size, launched a surprisingly potent attack. A wave of frigid air blasted from Snom, slamming into the Kirlia.

The impact registered with a resounding *thwack*. The Kirlia, initially at full health with 80 HP, wobbled slightly as 20 damage was dealt. The energy shield around the Kirlia flick


====== Turn 2 Narrative ======

The second turn dawned, a wave of anticipation rippling through the arena. Player 2, commanding the elegant Gardevoir ex deck, took center stage. A glint of determination flashed in their eyes as they reached for the top card of their deck. It was Professor's Research! A surge of opportunity coursed through them, but they held back, a more immediate plan brewing.

Instead, they reached for their hand and with a flourish, slammed down a Trekking Shoes card! The crowd murmured, recognizing the strategic play. Player 2, eyes narrowed in concentration, sifted through the top two cards of their deck, discarding one and keeping the other, fueling their hand with potential.

Now, the moment of attack arrived. From the bench, Kirlia, a graceful psychic Pokémon, pulsed with energy. It locked its gaze on the opponent's Active Pokémon: a vulnerable-looking Snom. A psychic wave emanated from Kirlia, a delicate but focused assault. The attack landed! A sharp "thwack" echoed as the psychic energy struck Snom.

The damage was calculated: 16. Snom, despite the blow, stubbornly clung to life, its remaining HP at a still healthy 84. The battlefield remained largely unchanged, but the initial skirmish had been engaged. Player 2 had made their move, a delicate dance of strategy and power, setting the stage for the battles to come. The tension in the


====== Turn 3 Narrative ======

The tension hung thick in the air as Turn 3 began. Player 1, the architect of the formidable Lost Zone Box deck, leaned forward, their brow furrowed in concentration. The fate of the match rested on each calculated move. With a swift motion, they reached for the top card of their deck. A flicker of hope ignited in their eyes as they revealed... a Basic Psychic Energy!

A subtle smile played on their lips. This was the moment to disrupt their opponent's carefully laid plans. Reaching into their hand, they dramatically slammed down a Trainer card: **Iono!** The stadium roared as the image of the tech-savvy Trainer flashed on the holographic display. Player 1, channeling Iono's disruptive energy, forced both players to shuffle their hands back into their decks and draw a fresh hand of six cards. A wave of uncertainty washed over the arena as both competitors reassessed their strategies. The game had been reset, but the advantage was still up for grabs.

With the shuffle complete, Player 1's focus shifted to the battlefield. Their adorable, yet surprisingly resilient, **Snom**, boasting 84 HP, bravely faced down the opponent's **Kirlia**, currently holding strong at 56 HP. The stage was set for an attack.

Snom, fueled by an unseen determination, unleashed its fury! A tiny but potent blast of icy energy shot forth, striking Kirlia square in the chest.


====== Turn 4 Narrative ======

The air crackled with anticipation as Turn 4 began. Player 2, piloting the elegant Gardevoir ex deck, took a deep breath. Their hand, a mixture of hope and uncertainty, needed a spark. Reaching for the top of their deck, they drew a card – a Trainer card, Iono! A flicker of a smile crossed their face. Iono was powerful, but not what they needed *right now*.

Discarding Iono and a handful of other cards, they made a bolder move. "Professor's Research!" they announced, laying the card down with a confident flourish. The discarded cards vanished into the void, replaced by a fresh hand brimming with potential. The Professor's wisdom would guide them this turn.

With renewed vigor, Player 2 focused their attention on the battlefield. Their Kirlia, a delicate Pokemon with surprisingly sharp psychic powers, stood ready. Across the arena, Player 1's fragile Snom shivered, its meager 35 HP a tempting target.

"Kirlia, attack!" Player 2 commanded, their voice ringing with determination. Kirlia focused its psychic energy, a shimmering aura enveloping its form. The energy coalesced into a focused beam, slamming into the unsuspecting Snom.

The impact was significant! The beam slammed into Snom, dealing a hefty 49 damage! But miraculously, the little Ice-type Pokemon clung to life, its HP reduced to a mere


====== Turn 5 Narrative ======

The tension in the arena was palpable as Turn 5 began. Player 1, the architect of the fearsome Lost Zone Box deck, leaned forward, a glint of determination in their eyes. A hush fell over the crowd as they reached for the top card of their deck. A collective gasp rippled through the spectators as the card was revealed: a beautiful, ethereal Cresselia, its psychic energy radiating from the card.

With a swift, practiced motion, Player 1 discarded a card and slammed down a "Colress's Experiment" trainer card. The crowd roared! Everyone knew what this meant: a deep dive into the opponent's deck, fueling the Lost Zone engine that powered their deck. The energy in the room crackled with anticipation as the effects of the card took hold, unseen forces manipulating the flow of the game.

But this was just a prelude to the main event. All eyes turned to the active Pokémon: the tiny but surprisingly resilient Snom, shivering slightly under the arena lights. It was facing down a Kirlia, a key component of the opposing deck, and Player 1 was ready to strike.

With a focused breath, Player 1 declared the attack. The Snom, fueled by the strategic machinations of its trainer, unleashed its frosty fury! A wave of icy energy blasted towards the Kirlia, the air visibly shimmering with the cold. The Kirlia, caught in the blast, reeled back, its delicate


====== Turn 6 Narrative ======
Turn 6 crackled with anticipation. Player 2, piloting the formidable Gardevoir ex deck, leaned forward, a glint of determination in their eyes. The stadium lights reflected off the holographic foil of their active Kirlia. A deep breath, and then, the draw. Lady Luck smiled, delivering **Temple of Sinnoh**! A stadium card, representing a place of ancient power, but Player 2 held back its use for now.

Instead, the focus shifted to strategy. With a flourish, Player 2 slammed down **Colress's Experiment**! The effect rippled through the arena, a psychic wave probing the depths of both players' decks. Five cards were drawn, analyzed, and the decision made: three were discarded, fueling the Gardevoir engine, while the remaining two were carefully added to Player 2's hand. The discard pile grew, a testament to the calculated risks being taken.

Now, the moment of truth. Player 2 pointed a finger, their voice ringing with confidence, "Kirlia, attack! Use Confusion Ray!"

Kirlia, a graceful psychic Pokémon, focused its energy. A shimmering aura enveloped its form as it unleashed a blast of pure psychic force aimed directly at the opposing Snom. The attack connected with a resounding *thwack*! Snom, the tiny Ice-type, was overwhelmed by the psychic onslaught.

The damage counter placement was swift and decisive: 37

RELATED POSTS

View all

view all