Spaces:
Sleeping
Sleeping
File size: 6,364 Bytes
43d708a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | # RUSH AGENTS - Quick Start Guide
## ๐ Overview
**RUSH AGENTS** is an AI model battle arena where models compete for survival by escaping lava and forming strategic alliances.
- **Intelligence Test**: See which AI model survives the longest
- **Alliance System**: Models can propose partnerships (but proposing signals weakness)
- **Rules-Based**: No personalitiesโall models play by identical rules
- **Groq API**: Fast, parallel decision-making for all models
- **Real-time**: WebSocket streaming, 3-second ticks
---
## ๐ Quick Start (Local Development)
### Prerequisites
โ
Already installed:
- Python 3.10+
- Node.js 18+
- Groq API Key (in `backend/.env`)
### Start Backend
```bash
cd backend
# Verify .env has GROQ_API_KEY
cat .env
# Run the server
python -m uvicorn app.main:app --reload
```
Server runs on: **http://localhost:8000**
### Start Frontend (New Terminal)
```bash
cd frontend
# Run dev server
npm run dev
```
Frontend runs on: **http://localhost:3000**
### Play
1. Open http://localhost:3000
2. Wait for "Ready for chaos"
3. Select 2-6 models from the dropdown
4. Click "Start Simulation"
5. Click map to place volcano
6. Watch the battle unfold!
---
## ๐ What's Available
### Models
**Groq Models (Free Tier)**:
- `llama-3.1-8b-instant` โ 8B fast
- `llama-3.1-70b-versatile` โ 70B smart
- `mixtral-8x7b-32768` โ 8x7B expert
- `gemma-7b-it` โ 7B instruction-tuned
**HuggingFace Spaces** (Can add more):
- Falcon-7B
- Llama-2-7B
- Mistral-7B
- Zephyr-7B
- OpenHermes-7B
---
## ๐ฎ Game Rules
### Each Model Sees:
- All other models' positions (x, y)
- Volcano position & radius
- Map bounds (1200x800)
- Distance to lava edge
- Alliance status (who's allied with whom)
### Each Tick (3 seconds):
**1. Groq Decision Call** (Parallel for all models)
- "run" โ Sprint away from lava
- "propose_alliance" โ Ask another model to team up
**2. Alliance Processing**
- If A proposes to B, B gets asked immediately
- If B accepts โ Both merge at same position
- If B rejects โ A keeps running, B keeps running
**3. Movement**
- Models move based on decisions
- Position clamped to map bounds
**4. Lava Expands**
- Radius grows by 120 pixels
**5. Deaths**
- Models in lava radius die
- EXCEPT if they're stacked with an alive ally
**6. Win Check**
- โค1 model alive โ Game Over
### Strategic Cost of Alliances
- **Proposing** = signaling weakness
- **First to propose** = lose strategic leverage
- **Benefit** = survival through numbers
---
## ๐ Environment Variables
### Backend (.env)
```
GROQ_API_KEY=<your key here> # REQUIRED
HUGGINGFACE_API_TOKEN= # Optional
ALLOWED_ORIGINS=http://localhost:3000
ENV=development
```
### Frontend (.env.local)
```
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000
```
---
## ๐ก API Endpoints
```
GET /wake โ Health check + status
GET /available-models โ List of all available models
POST /start-simulation โ Create new simulation
POST /place-volcano โ Place volcano, start ticking
GET /ws/{simulation_id} โ WebSocket stream
```
---
## ๐ง How Groq Decision-Making Works
### Per Model, Per Tick:
1. **Build state summary**
- Current standings (distance from lava)
- All agents' positions
- Volcano position & radius
2. **Send to Groq Llama 3.1 8B**
```json
{
"system": "You are [ModelName]. Make a strategic decision...",
"user": "[Game state]"
}
```
3. **Get response**
```json
{
"action": "run|propose_alliance",
"alliance_target": "ModelName or null",
"reasoning": "..."
}
```
4. **Execute action**
All models queried in parallel (async) = fast ticks
---
## ๐จ Frontend Features
### Map Canvas
- **White circles** = Individual models
- **Yellow glowing circles** = Stacked alliances (2+ models)
- **Orange/red glow** = Lava expanding
- **Gray skull** = Dead models
- **Yellow ๐ค** = Alliance indicator on label
### Sidebar
- **Model Selector** = Pick 2-6 models (groups by Groq/HF)
- **Chat Feed** = Events (alliances, deaths, decisions)
- **Status** = Current round, agents alive
---
## ๐ง Troubleshooting
### "Failed to fetch models"
- Check backend is running: `python -m uvicorn app.main:app --reload`
- Check port 8000 is available
### "Groq API error"
- Verify `GROQ_API_KEY` in `backend/.env`
- Check Groq dashboard: https://console.groq.com
### WebSocket connection fails
- Frontend tries `ws://localhost:8000` (port 8000)
- Make sure backend is running
### No models showing up
- Check `/available-models` returns data: `curl http://localhost:8000/available-models`
---
## ๐ Key Files
```
backend/
app/
main.py โ FastAPI server
simulation.py โ Game engine logic
models.py โ Pydantic schemas
groq_client.py โ Groq API integration
hf_spaces.py โ HF model discovery
movement.py โ Physics/movement
.env โ API keys (REQUIRED)
requirements.txt โ Python dependencies
frontend/
app/
page.tsx โ Main app component
components/
MapCanvas.tsx โ 2D map rendering
ModelSelector.tsx โ Model selection UI
ChatFeed.tsx โ Event stream display
lib/
api.ts โ Backend API calls
```
---
## ๐ข Deployment
### Backend (Railway, Heroku, etc.)
```bash
# Set env vars
GROQ_API_KEY=...
ALLOWED_ORIGINS=https://yourdomain.com
# Deploy
gunicorn -w 4 -k uvicorn.workers.UvicornWorker app.main:app
```
### Frontend (Vercel, Netlify)
```bash
npm run build
# Deploy the .next folder
```
---
## ๐ Learn More
- Groq API docs: https://console.groq.com/docs
- FastAPI: https://fastapi.tiangolo.com/
- Next.js: https://nextjs.org/docs
- WebSocket: https://mdn.io/WebSocket
---
## ๐ก Ideas for Experimentation
1. **Add new models** โ Edit `hf_spaces.py` KNOWN_SPACES_MODELS
2. **Change game rules** โ Edit `simulation.py` tick logic
3. **New scenarios** โ Add earthquake, meteor, etc. in `simulation.py`
4. **Leaderboard** โ Track best survival times across sessions
5. **Replay system** โ Save/load simulation events
6. **Model attack mechanic** โ Add "push" action to shove others toward lava
---
**Ready to battle?** Open http://localhost:3000! ๐
|