A self-improving RPG game engine where AI agents collaborate with you to build games in real-time
Error Boundaries is a revolutionary game development framework that combines:
- ๐ฎ Traditional RPG gameplay with a meta-programming twist
- ๐ค Multi-agent AI system with specialist bots (Rendering, Mechanics, Story, Data, Testing, Assets)
- ๐ง Real-time game development powered by Claude AI via API and MCP server
- ๐ก๏ธ Error Boundary architecture that monitors system health and self-heals
- ๐ฏ Entity-Component-System (ECS) for flexible game architecture
- ๐ RAG-based knowledge system with vector embeddings and concept graphs
In Error Boundaries, bugs don't crash the gameโthey become part of the gameplay. Error entities spawn when systems degrade, and the AI bots work to fix issues while you play. It's a living game that evolves through AI-assisted development.
The engine comes with several complete mini-games demonstrating different mechanics:
| Game | Genre | Description |
|---|---|---|
| Dojo Warriors | Fighting | Martial arts combat with belt progression and special moves |
| Pixel Dive | Underwater Adventure | Dive for treasure, manage oxygen, fight sea creatures |
| Asteroid Miner | Space Mining | Mine asteroids, fight pirates, upgrade your ship |
| Gem Matcher | Puzzle | Match-3 gem puzzle with combos and power-ups |
| Robot Rumble | Combat Arena | Build and battle robots with upgrades |
| Turbo Track | Racing | High-speed racing with vehicle upgrades |
| Tower Scramble | Platformer | Climb towers, collect items, avoid obstacles |
| Block Cascade | Puzzle | Falling blocks with cascade mechanics |
| Street Brawler | Beat 'em Up | Side-scrolling combat action |
| Laser Guardian | Defense | Protect your base from waves of enemies |
| Neon Bullet Storm | Bullet Hell | Dodge patterns, shoot enemies |
| Cosmic Siege | Space Shooter | Space combat with power-ups |
| Void Defenders | Tower Defense | Strategic tower placement and upgrades |
| Starblast Squadron | Space Combat | Team-based space warfare |
- Python 3.10 or higher
- Windows/Linux/macOS
- Anthropic API key (for AI bots) or OpenAI API key
-
Clone the repository
git clone <your-repo-url> cd "Error Boundaries"
-
Install dependencies
pip install pygame chromadb networkx numpy python-dotenv anthropic openai mcp flask flask-cors
-
Verify setup (optional)
python setup_check.py
This will verify all packages are installed and directories are in place.
-
Set up environment variables
Copy the example file and add your API keys:
# On Windows copy .env.example .env # On Linux/Mac cp .env.example .env
Edit
.envand add your API key:ANTHROPIC_API_KEY=your_anthropic_key_here
Note: The knowledge base (ChromaDB) is included in the repository, so you don't need to regenerate it! Just add your API key and you're ready to go.
-
Run the game!
# With AI bots (requires API key) python main.py # Or without AI (just play the games) python main.py --no-bots
python main.py [options]
Options:
--no-bots Disable AI bot system (runs as regular game)
--no-mcp Disable MCP server
--debug Enable debug mode with verbose logging
--fps FPS Target frame rate (default: 60)
--width WIDTH Window width (default: 1280)
--height HEIGHT Window height (default: 720)
--fullscreen Start in fullscreen mode# Run without AI bots (faster startup)
python main.py --no-bots
# Run with full AI system
python main.py
# Run in debug mode
python main.py --debugError Boundaries/
โ
โโโ ๐ฎ engine/ # Core game engine
โ โโโ core/ # ECS, event system, game loop
โ โโโ ecs/ # Entity-Component-System
โ โโโ boundaries/ # Error boundary monitoring
โ โโโ subsystems/ # Rendering, audio, physics
โ โโโ gameplay/ # Entity factories, game logic
โ
โโโ ๐น๏ธ game/ # Game implementations
โ โโโ *_game.py # Individual mini-games
โ โโโ systems/ # Game systems (input, combat, etc.)
โ โโโ utils/ # Game utilities
โ โโโ entities/ # Entity templates (JSON)
โ
โโโ ๐ค bots/ # Multi-agent AI system
โ โโโ core/ # Orchestrator, communication, tasks
โ โ โโโ orchestrator.py # Coordinates specialist bots
โ โ โโโ bot_base.py # Base bot class
โ โ โโโ communication.py # Message bus for inter-bot comms
โ โ โโโ task_queue.py # Priority task distribution
โ โ
โ โโโ specialists/ # Specialist AI bots
โ โ โโโ rendering_bot.py # Graphics & UI specialist
โ โ โโโ mechanics_bot.py # Gameplay mechanics specialist
โ โ โโโ story_bot.py # Narrative & dialogue specialist
โ โ โโโ data_bot.py # Data management specialist
โ โ โโโ testing_bot.py # Testing & QA specialist
โ โ โโโ asset_bot.py # Asset management specialist
โ โ
โ โโโ knowledge/ # RAG knowledge base
โ โ โโโ knowledge_base.py # ChromaDB + NetworkX
โ โ โโโ embeddings.py # Vector embeddings
โ โ โโโ graph_db.py # Concept graph
โ โ โโโ first_principles/ # Seed knowledge (JSON)
โ โ
โ โโโ tools/ # Bot tools
โ โ โโโ engine_api.py # High-level engine interface
โ โ
โ โโโ api/ # HTTP API server
โ โโโ http_server.py # Claude Code integration (port 5555)
โ
โโโ ๐ mcp_server/ # Model Context Protocol server
โ โโโ server.py # MCP server for Claude Desktop
โ โโโ tools/ # MCP tool implementations
โ โโโ streaming.py # Real-time event streaming
โ
โโโ ๐ data/ # Runtime data
โ โโโ knowledge/ # Knowledge base storage
โ โโโ saves/ # Save files
โ โโโ templates/ # Entity templates
โ
โโโ ๐จ assets/ # Game assets
โ โโโ sprites/ # Images
โ โโโ audio/ # Sounds & music
โ โโโ fonts/ # Fonts
โ
โโโ ๐ docs/ # Documentation
โโโ ๐งช tests/ # Test suite
graph TD
A[Player/Claude Code] --> B[HTTP API :5555]
A --> C[MCP Server]
B --> D[Orchestrator Bot]
C --> D
D --> E[Task Queue]
E --> F1[Rendering Bot]
E --> F2[Mechanics Bot]
E --> F3[Story Bot]
E --> F4[Data Bot]
E --> F5[Testing Bot]
E --> F6[Asset Bot]
F1 --> G[Engine API]
F2 --> G
F3 --> G
F4 --> G
F5 --> G
F6 --> G
G --> H[Game Engine/World]
H --> I[Boundary Registry]
I --> J[Health Monitor]
J -.feedback.-> D
The orchestrator receives high-level requests and coordinates specialist bots:
# Example: Natural language game modification
result = await orchestrator.process_prompt(
"Create a quest where the player collects 10 magic mushrooms"
)Each specialist has deep expertise in their domain:
| Bot | Responsibilities |
|---|---|
| Rendering Bot | Graphics, UI/UX, shaders, visual effects, animations |
| Mechanics Bot | Game mechanics, physics, interactions, combat systems |
| Story Bot | Narrative design, dialogue, characters, quests, lore |
| Data Bot | Data structures, serialization, save/load, schemas |
| Testing Bot | Test creation, validation, QA, boundary monitoring |
| Asset Bot | Asset management, loading, optimization, pipelines |
The bots use a RAG (Retrieval-Augmented Generation) system:
- ChromaDB: Vector embeddings for semantic search
- NetworkX: Concept graph for relationships
- 50+ game concepts: Seeded knowledge about game development
# Query the knowledge base
results = knowledge_base.query(
"How do I implement a quest system?",
n_results=5
)
# Traverse concept relationships
related = knowledge_base.get_related_concepts(
"quest",
max_depth=2
)The bot system exposes an HTTP API for external integration:
# Get bot status
curl http://localhost:5555/bots/status
# Send a prompt to orchestrator
curl -X POST http://localhost:5555/bots/orchestrator/prompt \
-H "Content-Type: application/json" \
-d '{"prompt": "Add a health potion item"}'
# Query knowledge base
curl -X POST http://localhost:5555/knowledge/query \
-H "Content-Type: application/json" \
-d '{"query": "combat system", "n_results": 3}'The MCP (Model Context Protocol) server allows Claude Desktop to interact with the game:
Available MCP Tools:
prompt_game_change- Natural language game modificationsget_game_state- Query current game stateget_error_boundaries- Check system healthquery_knowledge_base- Search game dev conceptsget_bot_status- Monitor bot systemforce_spawn_error- Test error handling
Setup for Claude Desktop:
Add to %APPDATA%\Claude\claude_desktop_config.json:
{
"mcpServers": {
"error-boundaries": {
"command": "python",
"args": ["C:\\path\\to\\Error Boundaries\\mcp_server\\server.py"]
}
}
}- WASD / Arrow Keys - Move player
- Mouse - Aim/interact (game-specific)
- Space - Jump/action
- ESC - Pause menu
- P - Pause/Resume
- F1 - Toggle debug overlay
- F2 - Show entity inspector
- F3 - Show system performance
- F4 - Show boundary health
- F5 - Spawn test error
- ` (Backtick) - Open bot console
Each game subsystem is wrapped in an error boundary that:
- Validates changes against defined contracts
- Tracks health (0.0 = critical, 1.0 = perfect)
- Logs errors and violations
- Triggers AI bots when health degrades
- Spawns error entities as gameplay elements
# Error boundaries monitor critical systems
boundaries = [
"rendering", # Graphics rendering
"mechanics", # Game mechanics
"story", # Narrative systems
"data", # Data management
"audio", # Sound systems
"physics", # Physics simulation
]When a boundary's health drops below threshold, the corresponding specialist bot is automatically tasked with diagnosis and repair.
Entities: Unique IDs with components
player_id = world.create_entity()Components: Pure data (no logic)
world.add_component(player_id, Transform(x=100, y=200))
world.add_component(player_id, Health(current=100, maximum=100))
world.add_component(player_id, Velocity(dx=0, dy=0))Systems: Logic that operates on component combinations
class MovementSystem(System):
def update(self, world, dt):
for entity_id in world.get_entities_with_components(Transform, Velocity):
transform = world.get_component(entity_id, Transform)
velocity = world.get_component(entity_id, Velocity)
transform.x += velocity.dx * dt
transform.y += velocity.dy * dtCore: Transform, Velocity, Health, Renderable, Collider, Tag
Gameplay: Player, Enemy, Inventory, Quest, Dialogue, AI
Effects: Particle, Animation, SoundEmitter, Light
-
Create game file in
game/directory:class MyGame: def __init__(self): self.score = 0 def update(self, dt, keys, mouse_pos): # Update game logic pass def render(self, screen): # Render game pass
-
Register with engine:
from game.my_game import MyGame # In main.py or registration script game_registry.register_game( game_id="my_game", game_class=MyGame, metadata={ "name": "My Awesome Game", "description": "A cool game", "author": "You" } )
# In engine/ecs/component.py
from dataclasses import dataclass
from engine.ecs.component import Component
@dataclass
class MyComponent(Component):
my_field: int = 0
my_other_field: str = ""# In game/systems/
from engine.core.system import System
from engine.ecs.world import World
class MySystem(System):
def __init__(self):
super().__init__(priority=50) # Lower = earlier
def update(self, world: World, dt: float) -> None:
# Your system logic here
for entity_id in world.get_entities_with_components(MyComponent):
component = world.get_component(entity_id, MyComponent)
# Do something with componentCreate JSON files in data/templates/:
{
"name": "Magic Potion",
"components": {
"Transform": {
"x": 0,
"y": 0
},
"Renderable": {
"sprite_path": "assets/sprites/potion.png",
"layer": 5,
"width": 32,
"height": 32
},
"Collider": {
"radius": 16
},
"Item": {
"item_type": "consumable",
"effect": "heal",
"amount": 50
}
}
}# Run basic game test
python tests/test_basic.py
# Test ECS system
python tests/test_ecs_system.py
# Test bot orchestration
python tests/test_bot_orchestration.py
# Test specific game
python tests/test_dojo_warriors.py
# Test LLM integration
python tests/test_llm_manager.pyDetailed documentation is available in the docs/ directory:
FRAMEWORK_OVERVIEW.md- Bot framework architectureBOT_INTEGRATION_COMPLETE.md- Bot integration guideMCP_SETUP_INSTRUCTIONS.md- MCP server setup*_SUMMARY.md- Individual game documentation
Contributions are welcome! This project is designed to be extended and improved by both humans and AI.
- Create new mini-games using the engine
- Add new components/systems to expand capabilities
- Improve bot intelligence with better prompts/tools
- Expand knowledge base with more game dev concepts
- Add new specialist bots for additional domains
- Improve documentation and examples
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test thoroughly (
python tests/test_basic.py) - Commit your changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Add your API key to
.envfile - Or run with
--no-botsflag to disable AI system
- Install pygame:
pip install pygame - Verify your system supports OpenGL
- Run
python config.pyto create directories
- Check that API keys are valid
- Review logs in
error_boundaries.log - Try running with
--debugflag
- Ensure game engine is running first
- Check MCP server logs
- Verify paths in Claude config
- Change port in
config.py - Or stop other services using those ports
- Multiplayer support with networked ECS
- Visual node-based game editor
- More advanced AI behaviors using behavior trees
- Shader system for advanced visual effects
- Audio synthesis for procedural sound effects
- Mod support with sandboxed Python execution
- Web-based game preview
- Integration with more AI providers (Gemini, Local LLMs)
- Visual debugging tools for boundaries
- Automated testing bot that generates test cases
This repository includes everything you need to start playing and developing:
โ Included (tracked in Git):
- Complete game engine source code
- All 14+ mini-games
- AI bot system (orchestrator + 6 specialists)
- Knowledge base with 50+ game dev concepts (ChromaDB pre-seeded)
- Concept graph with relationships (NetworkX)
- Entity templates (JSON)
- Asset placeholders (sprites, basic graphics)
- Documentation and examples
- Test suite
โ Not included (you provide):
- API keys (Anthropic/OpenAI) - add to
.env - User save files (generated during play)
- Log files (generated at runtime)
- User-generated game databases
This means you can clone and play immediately - just add your API key for AI features, or use --no-bots to play without AI!
MIT License - See LICENSE file for details.
- Game Engine: Built with Python, Pygame
- AI Integration: Powered by Anthropic Claude & OpenAI GPT
- Knowledge Base: ChromaDB, NetworkX
- MCP Protocol: Model Context Protocol for Claude Desktop
- Inspiration: React Error Boundaries, ECS architecture, AI-assisted development
- Issues: Open an issue on GitHub
- Discussions: Use GitHub Discussions for questions
- Documentation: Check the
docs/folder
Built with โค๏ธ by humans and AI working together
Error Boundaries - Where bugs become features ๐โจ