AI Asset Generation Overview

The most distinctive feature of Medieval Deck is its AI-powered asset generation pipeline. Instead of relying on manually created art, the game uses Stable Diffusion XL (SDXL), a powerful text-to-image model, to generate all visual assets. This includes backgrounds, hero sprites, and even UI elements.

This automated approach ensures a cohesive and unique visual style that aligns perfectly with the game's gothic medieval theme.

Key Components

The pipeline is located in the /gen_assets directory and is composed of three main parts:

  1. Art Direction (art_direction.py): A module that translates high-level artistic goals into detailed, structured text prompts for the AI model. It acts as the creative director for the AI.
  2. Asset Generator (generate_backgrounds.py): The core engine of the pipeline. It takes prompts from the Art Direction module, interfaces with the SDXL model via the diffusers library, generates images, applies post-processing, and caches the results.
  3. RTX 5070 Optimizer (rtx_optimizer.py): An advanced performance layer specifically designed to optimize the generation process for high-end NVIDIA GPUs (like the RTX 5070). It manages VRAM, enables hardware-specific accelerations, and ensures maximum quality with reasonable performance.

The Workflow

  1. A game screen (e.g., SelectionScreen) needs an asset.
  2. It calls a method on the AssetGenerator class (e.g., generate_hero_background('knight')).
  3. The AssetGenerator first checks if the asset has already been generated and cached on disk.
  4. If not, it requests a detailed prompt from the ArtDirection module.
  5. It configures the generation parameters using the RTX5070Optimizer.
  6. It runs the SDXL pipeline to generate the raw image.
  7. It applies post-processing effects (like sharpening and contrast enhancement) to match the game's aesthetic.
  8. It saves the final image to the /assets directory and returns the file path.

This entire process is decoupled from the main game logic, meaning the game simply requests and loads images, unaware of the complex generation process behind the scenes.