CoolFace
Apppublic

rsakeri/adventure_engine

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

title: Puch Adventure Engine emoji: ๐Ÿš€ colorFrom: indigo colorTo: purple sdk: docker pinned: false ---

Puch Adventure Engine

Rewrite Your Favorite Stories


Ever wished you could change the ending of your favorite movie? Or explore what would happen if a key character made a different choice? Puch Adventure Engine is a stateful, AI-powered storytelling game that puts you in the director's chair.

Built as a Model Context Protocol (MCP) server for the Puch AI client, this engine lets you step into any fictional universe, become any character, and explore infinite "what if" scenarios. Lead the Starks to victory in Game of Thrones, see what happens if Walter White refuses to cook in Breaking Bad, or create entirely new adventures in worlds of your own making. Powered by Google's Gemini API, every choice you make creates a unique, branching narrative.


๐Ÿš€ Key Features

  • โ€”Infinite Story Possibilities Powered by the Google Gemini API, the engine acts as a dynamic Dungeon Master, creating unique narratives, characters, and outcomes for every choice.
  • โ€”Explore "What Ifs" Dive into your favorite TV shows, movies, and books. Change character fates and see how the story unfolds based on your decisions.
  • โ€”True Player Agency Don't like the options provided? Type your own custom action to guide the story in any direction.
  • โ€”Stateful & Personal Sessions Persistent, unique game state for every user. Leave and return to your adventure anytime.
  • โ€”Visually Rich Experience Each narrative turn is accompanied by a scene image. (Demo uses placeholder images; engine supports AI-generated images.)
  • โ€”Seamless Puch AI Integration Built to work natively within the Puch AI chat client.

๐Ÿ› ๏ธ Getting Started: 5-Minute Setup Guide

Prerequisites

  • โ€”Python 3.9+
  • โ€”`uv` (fast Python package installer)
  • โ€”Active ngrok account

Step 1: Clone the Repository

bash
git clone <your-repo-url>
cd puch-adventure-engine

Step 2: Set Up the Environment

bash
# Create the virtual environment
uv venv

# Activate the environment (macOS/Linux)
source .venv/bin/activate

# Install all required packages
uv pip install -r requirements.txt

Step 3: Configure Your Secret Keys

Create a .env file in the root directory. You can copy .env.example if provided.

env
# This is a password YOU invent. It will be used to connect to your server.
AUTH_TOKEN="a-secret-password-of-your-choice"

# Your phone number in the format required by Puch AI for validation.
MY_NUMBER="919876543210"

# Your free API key from Google AI Studio for the Gemini model.
GEMINI_API_KEY="your_google_gemini_api_key_here"

Step 4: Run the Server

bash
python adventure_engine.py
You should see: ๐Ÿš€ Starting MCP server...

Step 5: Expose Your Server with ngrok

Open a new terminal window:

bash
ngrok http 8086

Copy the HTTPS "Forwarding" URL provided by ngrok (e.g., https://<random-string>.ngrok-free.app).


๐ŸŽฎ How to Play

  • โ€”Connect Your Server: Use the /mcp connect command with your ngrok URL and secret AUTH_TOKEN. Do not add `/mcp` to the end of the URL.
text
	/mcp connect https://<your-ngrok-url>.ngrok-free.app your-secret-token
  • โ€”Start Your Adventure: The most reliable way to begin is by explicitly calling the start_adventure tool.
text
	@PuchAdventureEngine start_adventure
  • โ€”Make Your Choices: The AI Dungeon Master will present a scene, image, and choices. Type a suggested choice or your own custom action.
  • โ€”Manage Your Game:
  • โ€”@PuchAdventureEngine show_status โ€” Check your character's inventory.
  • โ€”@PuchAdventureEngine reset_adventure โ€” End your current game and start fresh.

๐Ÿง‘โ€๐Ÿ’ป Technology Stack

  • โ€”Backend: Python
  • โ€”MCP Framework: FastMCP
  • โ€”Text Generation: Google Gemini API (gemini-1.5-flash)
  • โ€”Image Generation: Placeholder Service (via.placeholder.com)
  • โ€”Server: Uvicorn

Ready to rewrite your favorite stories? Start your adventure now!