AutoEnv - AI Game Skin Generator

December 14, 2025 ยท View on GitHub

Part of VR-Bench Project

Generate themed 2D game skins for maze-type games using AI image generation with automatic visual description.

โœจ Features

  • ๐ŸŽฎ 4 Game Types: maze, pathfinder, sokoban, trapfield
  • ๐ŸŽจ Custom Themes: Any visual style you can describe
  • ๐Ÿค– AI Visual Description: Automatic skin description using vision models
  • โšก Async Pipeline: Parallel asset generation with DAG architecture
  • ๐ŸŽฏ Style Consistency: Style Anchor mechanism ensures unified look
  • ๐Ÿ’ฐ Cost Tracking: Real-time API usage and cost monitoring
  • ๐Ÿ–ผ๏ธ Auto Processing: Background removal and transparent PNG output

๐Ÿš€ Quick Start

1. Install Dependencies

All dependencies are managed in VR-Bench's root requirements.txt:

cd /data/yc/VR-Bench
pip install -r requirements.txt

2. Configure API

Edit /data/yc/VR-Bench/.env file:

# Image Generation API (for AutoEnv skin generation)
IMAGE_GEN_API_KEY=your_api_key_here
IMAGE_GEN_BASE_URL=https://api.openai.com/v1
IMAGE_GEN_MODEL=gemini-2.5-flash-image

๐Ÿ’ก Note: AutoEnv uses VR-Bench's unified .env configuration. Environment variables are automatically loaded.

3. Generate Skins

cd /data/yc/VR-Bench/AutoEnv
python run_skin_generation.py \
  --maze-type maze \
  --theme "cyberpunk neon city"

๐ŸŽฎ Game Types

TypeComponentsDescription
maze4player, goal, wall, floor
pathfinder3start, end, road
sokoban5player, goal, box, wall, floor
trapfield4player, goal, trap, floor

๐Ÿ“ฆ Output Structure

workspace/envs/<game_type>_<timestamp>/
โ”œโ”€โ”€ analysis.json          # Game configuration analysis
โ”œโ”€โ”€ strategy.json          # Asset generation strategy
โ””โ”€โ”€ skins/                 # Generated skin assets
    โ”œโ”€โ”€ wall.png          # Transparent PNG (auto-cropped)
    โ”œโ”€โ”€ floor.png
    โ”œโ”€โ”€ player.png
    โ”œโ”€โ”€ target.png
    โ””โ”€โ”€ description.json  # AI-generated visual descriptions

description.json Example

{
  "game_type": "maze",
  "skin_id": "20231214_130944",
  "visual_description": {
    "player": "white rabbit",
    "goal": "orange carrots",
    "wall": "gray rock",
    "floor": "green grass tiles"
  }
}

๐Ÿค– AI-Powered: Visual descriptions are automatically generated by analyzing the actual skin images using vision models.

๐Ÿ’ก Examples

# Medieval castle maze
python run_skin_generation.py --maze-type maze --theme "medieval stone castle"

# Candy land pathfinder
python run_skin_generation.py --maze-type pathfinder --theme "candy land with lollipops"

# Industrial warehouse sokoban
python run_skin_generation.py --maze-type sokoban --theme "industrial warehouse"

# Lava dungeon trapfield
python run_skin_generation.py --maze-type trapfield --theme "lava dungeon with fire"

๐Ÿ—๏ธ Architecture

Pipeline (DAG)

Analyzer โ†’ Strategist โ†’ AssetGenerator โ†’ BackgroundRemoval
NodeFunctionOutput
AnalyzerNodeLoad game configurationanalysis.json
StrategistNodeGenerate asset promptsstrategy.json
AssetGeneratorNodeCreate images (Style Anchor + I2I)PNG files
BackgroundRemovalNodeProcess & analyze imagesTransparent PNGs + description.json

Key Mechanisms

  1. Style Anchor: First asset (wall/road) generated via text-to-image, others use image-to-image for consistency
  2. Parallel Generation: All non-anchor assets generated concurrently using asyncio.gather()
  3. Vision Analysis: Each skin analyzed by multimodal LLM to generate visual descriptions
  4. Cost Tracking: Real-time monitoring using contextvars for thread-safe cost aggregation

Project Structure

AutoEnv/
โ”œโ”€โ”€ run_skin_generation.py          # Entry point (164 lines)
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ engine/
โ”‚   โ”‚   โ”œโ”€โ”€ async_llm.py           # LLM client (449 lines)
โ”‚   โ”‚   โ””โ”€โ”€ cost_monitor.py        # Cost tracking (116 lines)
โ”‚   โ”œโ”€โ”€ pipeline/
โ”‚   โ”‚   โ”œโ”€โ”€ base_node.py           # Node abstraction (45 lines)
โ”‚   โ”‚   โ””โ”€โ”€ base_pipeline.py       # DAG executor (55 lines)
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ””โ”€โ”€ image.py               # Image utilities (13 lines)
โ”œโ”€โ”€ autoenv/
โ”‚   โ””โ”€โ”€ pipeline/
โ”‚       โ””โ”€โ”€ visual/
โ”‚           โ”œโ”€โ”€ nodes.py           # 4 pipeline nodes (365 lines)
โ”‚           โ”œโ”€โ”€ pipeline.py        # Visual pipeline (80 lines)
โ”‚           โ”œโ”€โ”€ prompt.py          # Prompt templates (12 lines)
โ”‚           โ””โ”€โ”€ maze_assets_config.py  # Asset configs (200 lines)
โ””โ”€โ”€ config/
    โ””โ”€โ”€ env_skin_gen.yaml          # Default config

Total: ~1650 lines of clean, focused code

โš™๏ธ Configuration

Environment Variables

AutoEnv integrates with VR-Bench's unified .env configuration:

# Image Generation API (for skin generation)
IMAGE_GEN_API_KEY=your_api_key_here
IMAGE_GEN_BASE_URL=https://api.openai.com/v1
IMAGE_GEN_MODEL=gemini-2.5-flash-image

Configuration Priority

  1. Environment Variables (highest) - from VR-Bench/.env
  2. YAML Config (fallback) - from config/model_config.yaml

Supported Models

  • gemini-2.5-flash-image (recommended, fast & cheap)
  • dall-e-3 (high quality)
  • Any OpenAI-compatible image generation API

๐Ÿ“‹ Requirements

  • Python 3.10+
  • Dependencies: openai, pydantic, rembg, pillow, python-dotenv
  • Image generation API with vision capability
  • All dependencies managed in VR-Bench's root requirements.txt

๐Ÿ”— Integration with VR-Bench

AutoEnv is part of the VR-Bench project:

  • โœ… Unified Configuration: Shares .env file with VR-Bench
  • โœ… Dependency Management: Single requirements.txt at VR-Bench root
  • โœ… Output Format: Compatible with VR-Bench's skin format
  • โœ… Cost Tracking: Integrated cost monitoring system
  • โœ… Secure: Credentials not in version control

๐Ÿ“Š Code Statistics

  • Total Lines: 1,648
  • Python Files: 16
  • Core Nodes: 4 (Analyzer, Strategist, Generator, BackgroundRemoval)
  • Architecture: Clean DAG pipeline with Pydantic validation

๐Ÿ“„ License

MIT License