Single-prompt code generation is a bottleneck. If you want an LLM to generate a complex web game, a single API call just isn't going to cut it. It usually results in a broken, hallucinated block of code.
To solve this, I built the Autonomous Multi-Agent Game Engine targeting HTML5 and Phaser.js.
After experimenting with 2D engines like Pyxel, I pivoted to Phaser.js for its robust community and web-native ecosystem. Then, I mapped out a traditional game development lifecycle and translated it into a parallel, agentic workflow.
Welcome to the V2 Pipeline—a major evolutionary leap from basic code generation. We have transformed the architecture into a multi-phase, self-correcting workflow that guarantees robust, playable, and complex web games from a single text prompt.
By separating the "thinking about design" from the "writing of syntax," hallucination drops drastically. The system orchestrates 5 distinct AI specialists working together:
- 🔍 Research Agent: Establishes context, mechanics, and game tropes before a single line of code is written.
- 📝 Script Agent (The Designer): Formulates a detailed blueprint and rule set based on the research.
- 🧠 Logic Agent (The Architect): Handles spatial reasoning, mathematics, and visual constraints, outputting precise pseudocode and a visual draw manifest.
- 💻 Coding Agent (The Developer): Compiles the context into functional, executable JavaScript using the Phaser.js framework.
- 🛡️ Validator Agent (The QA Tester): An autonomous QA loop that acts as a safety net. It catches syntax errors, missing assets, and API misuse, forcing self-correction from the Coding Agent up to 3 times.
The Validator Agent ensures the final output is a completely self-contained, playable game.html file that runs instantly in any modern browser without a local server.
The biggest challenge right now is extracting maximum reasoning capability while staying under the rate limits of free-tier models. The Coding Agent must hold the Research Report, Game Design, Pseudocode, and Draw Manifest all in its active memory.
This engine reaches its full potential when powered by high-intelligence, frontier reasoning models (such as Gemini 2.5 Flash/Pro with extended thinking budgets). The architecture is proving that multi-agent orchestration is the future of complex code generation.
Ensure you have Python 3.8+ installed along with the required Google GenAI SDK:
pip install google-genai python-dotenvCreate a .env file in the root directory and add your Gemini API key:
GEMINI_API_KEY="your_api_key_here"Simply run the pipeline orchestrator from your terminal. You can pass your concept directly:
python pipeline.py "make a neon-style platformer game with a double jump"Or run it interactively:
python pipeline.py
# Prompt: Enter your game concept:The pipeline will stream logs detailing the time taken by each agent. Once complete, it generates:
build/web/game.html🎮: The final playable game! Open this file directly in any web browser.output/: Contains the markdown files generated by each agent (Research, Design, Logic, and Validation). Read these if you want to peer into the AI's "brain" and see exactly how it planned your game!
Built utilizing Advanced Multi-Agent AI architecture.