This article was created for the purpose of entering the H0 Hackathon.
#H0Hackathon
What happens when you combine modern AI agents, real-time streaming, and classic text-based RPGs?
You get Lore and Abyss—an AI-powered dark fantasy roguelike that generates immersive adventures while maintaining a persistent world state across every player decision.
Rather than building another chatbot with a fantasy prompt, I wanted to create a true game engine that keeps track of inventory, health, locations, NPCs, and story progression while streaming narrative to the player in real time.
The Problem
Traditional LLM conversations slowly lose important context.
After enough turns, models begin forgetting things like:
- Which items the player owns
- Current health
- Active quests
- NPC locations
- Previous combat outcomes
This leads to inconsistent gameplay and broken immersion.
I wanted to solve this by separating creative storytelling from structured game state.
The Solution
Instead of treating the AI as a single storyteller, Lore and Abyss treats it as part of a complete game engine.
Every player action produces two outputs simultaneously:
- Beautiful narrative text
- Structured game metadata
The narrative is streamed directly to the UI while the metadata updates the game's persistent state.
This allows storytelling to remain creative while ensuring that gameplay mechanics stay deterministic.
Tech Stack
- Next.js 16
- React 19
- TypeScript
- Tailwind CSS
- Clerk Authentication
- Amazon DynamoDB
- Amazon Bedrock-compatible AI API
- Streaming Responses
- Multi-Agent AI Architecture
System Architecture
The application consists of four major layers:
- Frontend built with Next.js
- API Routes
- Authentication
- AI & Persistence Layer
The frontend communicates with serverless API routes hosted on Vercel.
Those routes authenticate users through Clerk, persist game state in DynamoDB, and orchestrate multiple AI agents responsible for narration, combat, world state, memory, and tone.
USER
│
HTTPS
│
Next.js Frontend
│
API Routes
┌────────────┴────────────┐
│ │
Clerk Auth AWS Services
│ ┌──────────┴──────────┐
│ │ │
User Identity DynamoDB AI Agents
Streaming Responses
One of my favorite features is the streaming experience.
Instead of waiting several seconds for an entire AI response, players begin reading immediately while the backend continues generating the story.
Each response contains two sections separated by a delimiter.
The corridor grows colder with every step.
The air becomes difficult to breathe...
||METADATA_SPLIT||
{
"choices": [
"Open the ancient door",
"Retreat"
],
"worldState": {
"hp": 9,
"gold": 14,
"tensionScore": 73
}
}
The frontend immediately renders everything before ||METADATA_SPLIT||.
Once the metadata arrives, it updates:
- Player HP
- Inventory
- Available choices
- NPCs
- World state
without interrupting the reading experience.
Multi-Agent AI
Rather than relying on one massive prompt, the application separates responsibilities into specialized AI agents.
These include:
- 📖 Narrator Agent
- 🗺️ World State Agent
- 🧠 Memory Agent
- ⚔️ Combat Agent
- 🎭 Tone Agent
Each agent focuses on a specific responsibility, making the system easier to maintain while producing more consistent gameplay.
Persistent State with DynamoDB
Every game session is stored inside Amazon DynamoDB.
Instead of rewriting the complete story every turn, only the latest state delta is stored.
For example:
{
"hp": 9,
"gold": 14,
"inventory": [
"Iron Sword",
"Torch"
],
"location": "Forgotten Crypt",
"tensionScore": 73
}
This dramatically reduces database writes while improving responsiveness.
Challenges
The biggest technical challenge involved streaming.
Sometimes an AI model stops generating before the metadata has finished.
For example:
{
"worldState": {
"hp": 12,
"inventory": [
"Iron Sword",
"Leat
Attempting to parse incomplete JSON immediately crashes the application.
The solution was to wait until the stream reaches the metadata delimiter before parsing structured data, allowing narrative text to continue rendering uninterrupted.
What I Learned
Building AI-native applications is very different from building traditional web applications.
Some key lessons include:
- Streaming greatly improves perceived performance.
- Structured state should never be mixed with free-form text.
- Small state updates outperform rewriting entire documents.
- Multi-agent systems are significantly easier to reason about than one enormous prompt.
Project Links
If you'd like to explore the project further:
- Live Demo: https://lore-and-abyss.vercel.app/
- GitHub Repository: https://github.com/Talha-Tahir2001/lore-and-abyss
- Devpost Submission: https://devpost.com/software/lore-and-abyss
Feel free to try the game, browse the source code, or check out the full hackathon submission.
What's Next
Future improvements include:
- 👥 Multiplayer adventures
- 🗺️ Procedurally generated dungeon maps
- 🎲 Dice-based combat
- 🧠 Better NPC memory
- 🌎 Shared campaign worlds
Final Thoughts
Lore and Abyss started as an experiment to answer one question:
Can an AI tell compelling stories while behaving like a real game engine?
The result is a streaming RPG that combines AI narration, persistent cloud storage, structured state management, and multiple AI agents into a cohesive gameplay experience.
There's still plenty to build, but this project showed me just how exciting AI-native game development can be.
If you're also participating in the H0 Hackathon, I'd love to see what you're building!
This article was created for the purpose of entering the H0 Hackathon.
#H0Hackathon

Top comments (0)