AI-powered reverse prompt engineering educational game
Project description
๐ฏ AI Prompt Engineering Game
Learn AI prompt engineering through reverse engineering! ๐ฎ
An educational CLI game where students see a target image and must craft prompts to recreate it using AI image generation. Perfect for learning prompt engineering, visual analysis, and AI communication skills.
โ Cross-Platform Compatible: Works seamlessly on Windows, macOS, and Linux (Ubuntu/Debian)
๐ Quick Start
Install
pip install ai-prompt-game
Play
ai-prompt-game
That's it! The game will guide you through setup and start your first challenge.
๐ฎ How It Works
- See a target image (beautiful sunset, ocean waves, etc.)
- Write a prompt describing what you see
- AI generates an image based on your prompt
- Get scored on how well it matches the target
- Improve and try again until you master it!
Example Game Flow
๐ฏ Target: Mountain Sunset
[Shows beautiful sunset image]
[Attempt #1] Your prompt: landscape
๐ Score: 23.4% - "Too generic! Describe the colors and lighting."
[Attempt #2] Your prompt: sunset over mountains
๐ Score: 67.8% - "Better! Add more details about the dramatic sky."
[Attempt #3] Your prompt: golden sunset over mountain peaks with dramatic clouds
๐ Score: 89.1% - "Excellent! Almost perfect!"
๐ You're learning prompt engineering!
โจ Features
- ๐ฏ Multiple Challenges: Mountain sunsets, ocean waves, forests, beaches, aurora
- ๐ค Real AI Generation: Uses Pollinations.ai (free) or your own models
- ๐ Smart Scoring: 4-metric similarity analysis (structure, colors, edges, composition)
- ๐ Educational Feedback: Learn what makes prompts effective
- ๐ Progress Tracking: See your improvement over time
- ๐ผ๏ธ Visual Display: See target and generated images side-by-side
- ๐ Works Offline: After setup, only AI generation needs internet
- ๐ฅ๏ธ Cross-Platform: Native support for Windows, macOS, and Linux
๐ ๏ธ Installation Options
Option 1: Simple Install (Recommended)
pip install ai-prompt-game
ai-prompt-game --setup # Download challenge images
ai-prompt-game # Start playing!
Option 2: Development Install
git clone https://github.com/surajsahani/ai-prompt-game.git
cd ai-prompt-game
pip install -e .
ai-prompt-game --setup
Option 3: With Advanced AI Models
# For local Hugging Face models
pip install ai-prompt-game[huggingface]
# For Replicate API
pip install ai-prompt-game[replicate]
๐ฅ๏ธ Platform-Specific Setup
Windows
# Install via pip (works in Command Prompt or PowerShell)
pip install ai-prompt-game
ai-prompt-game
# If you encounter OpenCV issues:
pip install opencv-python-headless
Ubuntu/Linux
# Standard installation
pip install ai-prompt-game
# If you need system OpenCV dependencies:
sudo apt-get update
sudo apt-get install python3-opencv libopencv-dev
# Then install the game
pip install ai-prompt-game
ai-prompt-game
macOS
# Standard installation works out of the box
pip install ai-prompt-game
ai-prompt-game
Note: All platforms use the same commands once installed. The game automatically detects your operating system and adapts accordingly.
๐ผ๏ธ Visual Features
The game includes visual display mode that shows images side-by-side:
- Target Image: The image you're trying to recreate
- Generated Image: Your AI-generated result
- Real-time Comparison: See both images with similarity scores
- Automatic Saving: All images saved to
~/.ai-prompt-game/generated/
Visual Mode Commands
ai-prompt-game # Full visual mode (default)
ai-prompt-game --no-visual # Text-only mode
Visual mode requires: matplotlib (automatically installed with the package)
๐ฏ Game Commands
ai-prompt-game # Start interactive game with visual display
ai-prompt-game --setup # Setup game files and targets
ai-prompt-game --list-targets # Show available challenges
ai-prompt-game --target sunset # Play specific challenge
ai-prompt-game --quick # Quick 5-minute game
ai-prompt-game --stats # Show your progress
ai-prompt-game --no-visual # Text-only mode (no image display)
In-Game Commands
progress- Show current game progresstarget- Show target image info againhelp- Show help and tipsquit- Exit game
๐ Educational Value
Perfect for learning:
- Prompt Engineering: How to communicate effectively with AI
- Visual Analysis: Breaking down images into describable components
- Iterative Improvement: Learning from feedback and refining
- AI Understanding: How image generation actually works
For Educators
- Measurable Learning: Quantified skill improvement
- Engaging Format: Students love the game approach
- Scalable: Works for 1 or 1000 students
- Progress Tracking: Built-in analytics and statistics
๐ค AI Models Supported
| Model | Cost | Quality | Setup |
|---|---|---|---|
| Pollinations.ai | Free | High | None (default) |
| Hugging Face | Free | Very High | Local GPU recommended |
| Replicate | Pay-per-use | Highest | API key required |
Using Different Models
# Use Pollinations.ai (default, free)
ai-prompt-game --model pollinations
# Use local Hugging Face model
ai-prompt-game --model huggingface
# Use Replicate API
ai-prompt-game --model replicate
๐ Scoring System
The game uses an advanced multi-metric scoring system:
๐ค LLaVA AI-Enhanced Scoring (Optional)
- LLaVA Semantic (25%): AI-powered semantic understanding of image similarity
- Structure (20%): Layout and composition matching
- Colors (20%): Color distribution and palette
- Edges (20%): Shape and boundary detection
- Dominant Colors (15%): Key color matching
๐ง Traditional Scoring (Fallback)
- Structure (30%): Layout and composition matching
- Colors (25%): Color distribution and palette
- Edges (25%): Shape and boundary detection
- Dominant Colors (20%): Key color matching
Combined Score: Weighted average of all metrics (0-100%)
๐ Enable LLaVA Enhancement
# Install LLaVA dependencies (large download ~13GB)
pip install transformers torch torchvision
# Use LLaVA-enhanced scoring (default)
ai-prompt-game
# Disable LLaVA (traditional metrics only)
ai-prompt-game --no-llava
LLaVA Benefits:
- ๐ง Semantic understanding (not just pixel comparison)
- ๐ฏ Better scoring for artistic and stylistic matches
- ๐ฌ AI explanations of what matches/differs
- ๐จ Understands context, mood, and composition
๐ฏ Challenge Targets
- ๐ Mountain Sunset (Medium) - Golden hour over peaks
- ๐ Ocean Waves (Hard) - Powerful waves on rocky shore
- ๐ฒ Misty Forest (Medium) - Peaceful forest path with mist
- ๐๏ธ Tropical Beach (Easy) - Crystal clear water and white sand
- ๐ Northern Lights (Hard) - Aurora borealis over snow
๐ Example Learning Progression
Session 1: "landscape" โ 15.6% โ "Be more specific!"
Session 2: "sunset mountains" โ 42.3% โ "Add color details!"
Session 3: "golden sunset over mountain peaks" โ 68.7% โ "Great progress!"
Session 4: "golden sunset over mountain peaks with dramatic clouds" โ 89.1% โ "Almost perfect!"
Session 5: "golden sunset over mountain peaks with dramatic orange clouds and lake reflection" โ 96.7% โ "MASTERY!"
๐ Result: Student learned effective prompt engineering!
๐ง Advanced Usage
Custom Targets
from ai_prompt_game import PromptGame
game = PromptGame()
game.add_custom_target("my_image.jpg", "My Custom Challenge")
API Integration
from ai_prompt_game import ImageGenerator, ImageComparison
generator = ImageGenerator("pollinations")
comparator = ImageComparison()
# Generate image
image = generator.generate("sunset over mountains")
# Compare with target
scores = comparator.compare(image, target_image)
print(f"Similarity: {scores['combined']:.3f}")
๐ค Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Development Setup
git clone https://github.com/surajsahani/ai-prompt-game.git
cd ai-prompt-game
pip install -e .[dev]
pytest # Run tests
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
- Pollinations.ai for free, high-quality image generation
- Unsplash for beautiful target images
- OpenCV for image processing capabilities
- Education community for inspiration and feedback
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: surajkumarsahani1997@gmail.com
Made with โค๏ธ for AI education
"Making AI education engaging, measurable, and fun - one prompt at a time!"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_prompt_game-1.1.0.tar.gz.
File metadata
- Download URL: ai_prompt_game-1.1.0.tar.gz
- Upload date:
- Size: 24.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
956ab25bc1165d2104956e78ee1441258ffa2b02686579dba685763c078cbc90
|
|
| MD5 |
d66ac9ff1e4f8280e3c9a45c97024ad4
|
|
| BLAKE2b-256 |
52cdbefbbcd31d011ad868405845b5b484e36837f68b10f9e8087abb41fb45fd
|
File details
Details for the file ai_prompt_game-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ai_prompt_game-1.1.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b77a2ca595399a8b46aa5cfac5aa32cc7903369afca583c759d02b100774386
|
|
| MD5 |
6c5a05e9297a6e4c152254c0f9ab3835
|
|
| BLAKE2b-256 |
73a066895983f3f3f8dae61763ea22bb0b00edf73d5da621c24e394dce6c6a95
|