Res Caverna is a strategic, grid-based roguelike experience built around a “you-move-they-move” mechanic. Every player action, movement, spell casting, digging, or interaction, triggers a global tick that drives enemy behavior and environmental responses. The game blends procedural cave exploration, reactive AI systems, and dynamic NPC interactions, while death or recall returns the player to a central hub where progress, treasures, and relationships persist.
Genre: Strategy / Roguelike / Procedural Exploration
Engine: Unity
Core Technologies: Compute Shaders, A* Pathfinding, Observer Pattern, GPT Integration
Key Pillars: Tick-Based Gameplay, Runtime Procedural Generation, Reactive AI, Dynamic NPCs
At the core of Res Caverna lies a 3D grid-based movement system where each player action triggers a synchronized world “tick.” Enemies and entities respond to this tick by moving or executing behaviors, creating a strategic pacing model that encourages forward planning.
The Observer Pattern drives these interactions: player actions dispatch a “Dweller Tick,” observed by enemy entities. Both player and enemies rely on grid movement controllers, with enemies using a custom A* implementation (originally written in C++ and ported to Unity C#) exposed as a reusable Vector3 extension method. The algorithm computes paths using valid movement directions, a grid reference, and heuristic vector distance costs. This system ensures responsive enemy pursuit while keeping the logic modular and maintainable.
Caves are generated at runtime using Compute Shaders for high performance and seamless exploration. The CaveManager MonoBehaviour generates chunks incrementally through a queue-based system, distributing workload across multiple frames to preserve main loop performance.
The generation pipeline begins with GPU-side simplex noise evaluation, producing structured 4-tuples containing positional and fractal noise data. These values are normalized to a [0,1] range before passing into the final mesh generation stage, where triangles, UVs, and walkable grid nodes are computed. A changes buffer enables runtime modification of cave blocks, allowing placement or removal of individual elements. A value-based block indexing system (-1 remove, 0 unchanged, positive values set block type) ensures flexibility.
Neighbour-based occlusion optimization prevents hidden faces from being generated, significantly reducing triangle count (e.g., from 15,886 to 6,106 in a test case). Environmental changes are dispatched dynamically to affected chunks, triggering efficient regeneration even while the player stands within them.
Res Caverna integrates GPT-4o-mini to power dynamic NPC personalities and gameplay content generation. NPC interactions are handled via structured web requests using the OpenAI-Unity library, integrated through a GPTActor MonoBehaviour. Responses are asynchronously retrieved and deserialized with Json.NET, ensuring structured data handling.
Each NPC maintains a persistent local history log stored in text files, sent alongside prompts to preserve conversational continuity across sessions. Timestamping allows characters to reflect the passage of time between interactions.
Beyond dialogue, GPT also generates gameplay content — including new spells — through a four-pass structured pipeline: Descriptive Data, Targets Matrix, Effects Set, and VFXProperties. Each pass incrementally feeds into the next, ensuring coherent GridAction object creation while managing token complexity. Prompt templates are loaded dynamically via Resources.Load during initialization, keeping the system modular and extendable.
Death or recall returns the player to a central hub, introducing a roguelike progression loop. Here, players reconcile with NPCs, store treasures, and prepare for the next expedition into procedurally generated caves. The hub serves as both narrative anchor and systemic reset point, reinforcing the cyclical structure of exploration, risk, adaptation, and long-term progression.