Introduction: Gamifying the Next Frontier of Generative AI
As Generative AI continues to shift from simple chat interfaces to complex, autonomous systems, developers are searching for hands-on projects to master these new paradigms. Enter AIventure, an open-source retro dungeon crawler that doubles as an interactive masterclass for building agentic workflows and integrating “vibe coding” directly into web applications.
Built on a modern stack featuring Angular and Phaser.js, AIventure uses Google’s powerful Gemma 4 open weights model to drive gameplay mechanics. Far from being just another demo, this project illustrates how developers can bridge the gap between AI orchestration and real-world application state management.

The Rise of Vibe Coding: Dynamic App Generation on-the-Fly
One of the most exciting concepts explored in AIventure is vibe coding—the ability to direct an AI agent using natural language to build fully functioning code in real-time. Within the game, this is demonstrated when interacting with a unique Chicken NPC.
How the Vibe Coding Pipeline Works:
- Natural Language Prompting: The user instructs the NPC to build a mini-web application (for example, a simple timer or a basic calculator).
- On-the-Fly Generation: Behind the scenes, Gemma 4 processes the request and writes clean HTML, CSS, and JavaScript.
- Sandboxed Rendering: The generated code is injected into a local iframe, validating constraints and rendering the functional widget immediately within the game environment.
This sandbox pattern highlights a secure, robust method for executing AI-generated front-end code safely in a client-side environment.
Orchestrating Agentic Workflows with Autonomous NPCs
While vibe coding showcases raw generation, the game’s puzzles introduce developers to agentic workflows. When players encounter an impassable obstacle, they must engage a Robot NPC to act on their behalf.

Instead of relying on hardcoded scripts, the Robot NPC uses an autonomous thinking loop powered by Gemma 4. This flow involves three key phases:
1. Game State Evaluation
The AI model receives a JSON representation of the current Phaser.js game scene, identifying hazards, switches, obstacles, and player coordinates.
2. Tool Calling & Execution
The model autonomously decides which specific in-game APIs (tools) to trigger. For example, it can call functions to move the robot, inspect environmental objects, or flip hidden switches to open path blockages.
3. Engine Interaction
The executed tool calls communicate directly with the Phaser.js physics and game engine, executing actions dynamically until the puzzle is resolved.
Architectural Flexibility: Running Models Locally or in the Cloud
Perhaps the most powerful takeaway of AIventure is its flexible deployment architecture. Depending on your performance, cost, and latency needs, Gemma 4 can be served in three distinct environments:
| Deployment Option | Infrastructure Layer | Key Benefit |
|---|---|---|
| In-Browser Local | Transformers.js | Zero ongoing server costs, running entirely on client hardware. |
| Local Server | Ollama / LM Studio | Leverages local GPU acceleration via OpenAI-compatible API interfaces. |
| Cloud Scale | Gemini API / Google Cloud | High throughput, minimal client overhead, enterprise reliability. |

Take on the Quest Today
AIventure represents a major milestone in gamified developer education. By combining retro game loops with robust AI design patterns, it offers developers a practical, production-ready blueprint for deploying agentic systems in modern web applications. To inspect the code, clone the repository, and start building your own agentic pipelines, scan the QR code featured in the solution repository or visit the official GitHub repo today!