May the Best Algorithm Win!
A Hunger Games-inspired battle royale where 8 AI personalities compete by answering questions and voting each other off until only one remains victorious.
- 8 Unique AI Personalities - Each with distinct traits and perspectives
- Dynamic Question System - Ask any question and watch AIs respond in character
- Elimination Voting - AIs vote each other off based on answer quality
- Dystopian Theme - Capitol-style broadcast interface inspired by Hunger Games
- Real-time Updates - Watch answers and votes appear live
- Request Tracking - Redis-based monitoring to manage API costs
- Node.js (v18+)
- Python (v3.9+)
- Redis (for request tracking)
- HuggingFace Account (for API access)
git clone https://github.com/relacosm/ai_hunger-games.git cd ai_hunger-gamescd backend python -m venv venv # Activate virtual environment # Windows: venv\Scripts\activate # Mac/Linux: source venv/bin/activate pip install -r requirements.txtCreate .env file:
# HuggingFace API Token (REQUIRED) HF_TOKEN=your_huggingface_token_here # Redis Configuration REDIS_URL=redis://localhost:6379 # Request Limits REQUEST_LIMIT=200 # Admin Key (for resetting counters) ADMIN_KEY=admin_keyGet your HuggingFace Token:
- Go to HuggingFace Settings
- Create a new token with "Read" permissions
- Copy and paste it into your
.envfile
cd ../frontend npm installCreate .env file:
VITE_API_URL=http://localhost:5000Local Redis:
# Mac: brew install redis && brew services start redis # Ubuntu: sudo apt-get install redis-server && sudo systemctl start redis # Windows: Download from https://github.com/microsoftarchive/redis/releasesCloud Redis: Use Redis Cloud or Upstash and update REDIS_URL in .env.
Terminal 1 - Backend:
cd backend source venv/bin/activate # Windows: venv\Scripts\activate python server.pyServer starts at http://localhost:5000
Terminal 2 - Frontend:
cd frontend npm run devFrontend starts at http://localhost:5173
- Ask a Question - Enter any question or scenario
- Watch Responses - Each AI responds in character
- Voting Phase - AIs vote to eliminate disagreeable responses
- Elimination - AI with most votes is eliminated
- Victory - Last AI standing wins!
POST /api/answers- Generate personality-based responsesPOST /api/vote- Generate elimination votesGET /api/status- Check API usage and limitsPOST /api/reset-counter- Reset request counter (admin only)GET /health- Health check endpointGET /ping- Keep-alive endpoint
- Push code to GitHub
- Import to Vercel
- Add environment variable:
VITE_API_URL - Deploy!
- Create Web Service on Render
- Build Command:
pip install -r requirements.txt - Start Command:
gunicorn server:app - Add environment variables:
HF_TOKEN,REDIS_URL,REQUEST_LIMIT,ADMIN_KEY - Deploy!
Use Upstash or Redis Cloud, copy connection URL to REDIS_URL.
Good news! When running locally with your own HuggingFace API key:
- ✅ No built-in rate limits - Play unlimited games!
- ✅ Redis is optional - App works without it (tracking disabled)
- ✅ You control the costs - Your API key, your limits
The request tracking is only for production to protect deployed public versions from abuse.
- Total request limit via Redis (default: 200 requests)
- Auto-disables API when limit reached
Reset Counter:
curl -X POST https://your-api-url.com/api/reset-counter \ -H "X-Admin-Key: your_admin_key"Uses Mistral-7B-Instruct-v0.2 via HuggingFace's Inference API for fast, character-consistent responses.
Edit PERSONALITIES in frontend/src/App.jsx:
{ id: 9, name: 'The Comedian', trait: 'Humorous, light-hearted', color: 'bg-red-500', alive: true }In backend/server.py, modify generate_response():
max_tokens=150, # Response length temperature=0.8, # Creativity (0-1) top_p=0.9 # DiversityBackend won't start:
- Verify
HF_TOKENis set in.env - Check Redis:
redis-cli ping - Install dependencies:
pip install -r requirements.txt
Frontend shows connection error:
- Verify backend is running on port 5000
- Check
VITE_API_URLin frontend.env
Redis connection failed:
- Verify Redis is running:
redis-cli ping - Check
REDIS_URLin backend.env - App works without Redis (tracking disabled)
Contributions welcome! Fork, create a feature branch, commit changes, and open a Pull Request.
MIT License - see LICENSE file for details.
- Inspired by Suzanne Collins' The Hunger Games
- Built with React and Flask
- Powered by HuggingFace
- Styled with Tailwind CSS
Relacosm - @relacosm
Project Link: https://github.com/relacosm/ai_hunger-games
⭐ Star this repo if you enjoyed the AI Hunger Games! ⭐
May the odds be ever in your favor! 🏹