Inspiration

Games are usually built around a simple assumption: the player follows the story the developer prepared.

But players rarely think that way.

What happens if you refuse the mission? Tell the secret to the wrong person? Kill a character who was supposed to matter five hours later? Most games either prevent the action, ignore it, or eventually force the player back onto the original path.

We wanted to explore a different question:

What if the story adapted to the player instead?

That became Rift — an AI-native game system designed to turn fictional worlds into living, reactive experiences where characters remember what happened, relationships evolve, and the narrative can reorganize itself around the player's choices.

Our goal wasn't to build another AI chatbot inside a game. We wanted the AI to operate on the actual state of the world.

What it does

Rift is a first-person game prototype built in Unreal Engine with an external real-time narrative backend.

When the player performs an action, Rift can represent that action as part of the world's persistent state.

NPCs have their own knowledge, memories, goals, relationships, locations, and status. Information is not magically shared between every character — if the player tells one NPC a secret privately, another NPC does not automatically know it.

The narrative system then evaluates what the player's action changed.

Objectives can fail or become impossible. Planned story beats can be preserved, adapted, replaced, or removed. If the original story no longer makes sense, Rift can request a new plan rather than forcing the player back onto the original path.

Finally, an AI Director powered by Gemini receives a structured view of the updated world, including relevant NPC and narrative state, and produces a constrained set of possible story actions.

The result is a game world designed around:

Player Action → Memory → Consequence → Adaptation

instead of a fixed branching dialogue tree.

How we built it

Rift is split into several systems that communicate through a real-time backend.

The game client is built with Unreal Engine 5. Unreal communicates with a Rust backend over a persistent WebSocket connection using a versioned JSON protocol.

The backend manages authoritative game sessions and validates player actions before they can change the world.

We then built three major adaptive systems.

The NPC system tracks individual character state, knowledge, relationships, and memories. NPC memories can be persisted through TiDB, and memory visibility depends on who actually witnessed or learned about an event.

The Narrative Causality Engine evaluates missions, objectives, prerequisites, world truths, and future story checkpoints. Instead of treating the original story as immutable, it determines whether future events should be preserved, adapted, replaced, or deleted based on what has actually happened.

The AI Director uses Gemini to reason about the current world and propose structured narrative actions. The model cannot simply return arbitrary commands — its output is schema-constrained and validated against the current game state before anything can be applied.

We also built deterministic fallback behavior so the world can continue functioning if the AI provider is unavailable.

The project includes a Python-based universe/compiler layer, a Rust real-time backend, Unreal Engine gameplay, WebSockets for communication, Gemini for narrative reasoning, and TiDB for persistent NPC memory.

Challenges we ran into

The hardest part was not calling an LLM.

The hardest part was deciding what the LLM should be allowed to know and control.

If the Director knew everything and directly rewrote the world, NPC knowledge would become meaningless. If every character shared the same global context, secrets and relationships would not matter.

We had to separate objective world state from individual NPC knowledge and make sure information only propagated to characters who actually perceived it.

Another major challenge was narrative consistency.

It is easy for an AI to generate an interesting continuation. It is much harder to guarantee that the continuation does not revive a dead character, reference an impossible location, use information an NPC never learned, or silently undo the player's decision.

That led us to build deterministic validation and causality systems around the AI rather than letting the model control the game directly.

We also had to integrate several independently developed systems — NPC memory, narrative causality, the Director, Unreal networking, and persistence — while preserving a single authoritative game state.

And because we were developing on limited hardware, getting Unreal Engine to run smoothly enough for rapid testing became its own engineering challenge.

What we learned

One of the biggest lessons from Rift was that AI becomes much more useful in games when it is treated as a reasoning layer, not the source of truth.

The game engine still owns reality.

The AI can propose what happens next, but deterministic systems decide what is possible.

We also learned how important information boundaries are for believable characters. An NPC feels much more convincing when its behaviour comes from what that character has personally seen, learned, or remembered rather than from a global prompt containing the entire story.

Finally, we learned that adaptive storytelling does not require generating an entirely new story every few seconds. Often the interesting part is determining which pieces of the original story can survive the player's actions and intelligently repairing only the parts that no longer make sense.

Accomplishments we're proud of

Rift already supports a live Unreal-to-Rust WebSocket connection with session creation, validated player actions, world events, duplicate-action protection, and protocol validation.

Our NPC system supports private knowledge, persistent memories, relationship state, witnesses, second-hand information, and live TiDB persistence.

Our narrative engine can detect when player actions invalidate missions or future story events and can classify future story beats as PRESERVE, ADAPT, REPLACE, or DELETE.

Our Gemini-powered Director produces schema-constrained decisions that are checked against the actual world before they are accepted.

Most importantly, these systems were designed to work together around one core rule:

The world changes first. The AI reacts second.

What's next

The next step for Rift is expanding the final gameplay loop so more of the Director's decisions become immediately visible inside Unreal Engine through NPC movement, dialogue, objectives, and world changes.

We also want to expand persistent memory retrieval, richer dialogue generation, procedural world content, and support for importing increasingly complex fictional universes.

Long term, Rift could become a framework for experiences where players do not simply choose between authored branches.

They create the branch.

Built With

Share this project:

Updates

Submission history