Inspiration

We all love fantasy games and tabletop RPGs like D&D, but a good campaign takes a lot of prep, and a good Dungeon Master isn't always available. We wanted to see if AI could be that DM, but one that stays grounded. Most AI storytelling forgets its own world: it invents cities that aren't on the map and contradicts itself. We wanted every playthrough to occur in a brand-new world with real geography, kingdoms, cultures and religions, and for the story to respect all of it.

What it does

SOLAR RPG is a native desktop fantasy RPG where every new game generates a fresh, procedural world and a campaign built for it.

  • Generates a unique world using Azgaar's Fantasy Map Generator: kingdoms, cities, cultures, religions, rivers and coastlines.
  • Creates a D&D-style campaign with Google Gemini. Gemini reads a compact brief of the real world and writes a title, NPCs, quests, lore, plot threads, and hidden secrets, plus an atmospheric opening that starts in an actual city on the map.
  • Turns your character idea into a playable character. Describe who you are in your own words, and the AI DM adapts it to the setting (and transparently tones down overpowered concepts).
  • Runs the adventure turn by turn. Type what you want to do and the DM responds with narration, NPC dialogue, and bounded changes to your health and inventory.
  • Narrates the story aloud with ElevenLabs text-to-speech. If audio fails, the game stays playable in text-only mode.
  • Includes an offline demo that needs no network or API keys.

The key idea: the AI only proposes, and our code validates everything. Gemini can't change IDs, coordinates or geography, and secrets never leak into narration, so the story stays consistent with the world.

How we built it

We built it with the help of Claude and Codex as AI coding assistants, in Python.

  • World generation: Playwright drives Azgaar's generator in a sandboxed headless Chromium and downloads its original JSON export. We also read the map's cell mesh from the same session, since the export has no coordinates.
  • Geometry: Shapely/GEOS rebuilds land, lake and ocean polygons and simplifies coastlines with Ramer-Douglas-Peucker on shared boundaries, so towns stay on land and shores line up with no gaps or overlaps.
  • AI Dungeon Master: Google Gemini (google-genai) returns structured JSON. Every proposal is validated against the world, and rejected ones get a correction prompt. State is saved with all-or-nothing writes and rollback.
  • Voice: ElevenLabs narration with local caching, played through Qt Multimedia.
  • Desktop app: PySide6 (Qt) UI with a single background worker, a cancel button, and plain-text rendering of all AI output.
  • Reliability and security: World generation runs in a supervised process with hard timeouts, memory limits and full process cleanup (psutil). API keys live in the OS credential manager (keyring), and error messages are scrubbed of secrets.
  • Testing: A large offline unittest suite using real captured Azgaar worlds, fake AI clients, and real spawned processes.

Challenges we ran into

  • Getting the API keys to work correctly. Handling Gemini and ElevenLabs keys securely and reliably took real work: storing them in the OS credential manager, never writing them to saves or logs, and handling Gemini 3's rejection of custom temperature settings. ElevenLabs also needs a voice ID, not a display name like "Rachel."
  • Missing map data. The world export had no coordinates and the ocean isn't in the mesh, so we had to reconstruct geography ourselves. One real world even had a patch of sea with no feature ID, which we preserve as null instead of inventing an ID.
  • Keeping simplified coastlines correct, so ports never end up in the sea.
  • Unreliable upstream worlds. Occasionally the generator produces inconsistent geography, so we reject the world and automatically retry with a fresh one.
  • Hangs and slow operations. Downloads and geometry calls can block, so we moved generation into a supervised worker with deadlines and cancellation.
  • Keeping the AI honest. Preventing hallucinated IDs, leaked secrets and invalid state changes required strict validation and bounded retries.

Accomplishments that we're proud of

  • Every playthrough gets a brand-new world, and the AI-written campaign is anchored to its real cities, kingdoms and rivalries.
  • A validation-first design where the AI can't corrupt the world or the save files.
  • A robust pipeline that handles failures gracefully with retries, rollback, cancellation, and a responsive UI.
  • Secure handling of API keys and sanitized errors.
  • An extensive offline test suite built on real generated worlds.
  • Working AI narration that brings the campaign to life.

What we learned

  • LLMs are most useful as creative proposers, with deterministic code acting as the referee.
  • Structured JSON output plus validation and correction retries makes AI output dependable enough to build a game on.
  • Real-world integration is mostly edge cases: timeouts, rate limits, quotas, file locks, and upstream data quirks.
  • Treat API keys and AI-generated text as untrusted from day one.
  • AI coding assistants speed up development a lot, but you still need tests and review to trust the result.

What's next for SOLAR RPG

  • Adaptive music that matches the setting and mood of each campaign (a grim war-torn kingdom should sound different from a quiet fishing port).
  • Faster character audio. Voice generation for characters is currently slow, so we want to pre-generate, stream, and cache more aggressively.
  • Distinct voices for individual NPCs.
  • Travel along the world's real routes with coastline-aware movement.
  • Fully wiring character creation and world-changing actions into the desktop UI.
  • Linux and macOS testing and packaging.
  • Further optimization, bugfixing and QOL improvement.

Built With

Share this project:

Updates

Submission history