Everchanging Grimoire

How the LLM Works

The game uses Gemini's function calling (structured tool use) to enforce strict JSON schema responses.

After each floor, the game sends Gemini:

  • Stage number, combat style, dominant element, damage sources
  • HP remaining/lost, time spent clearing the floor
  • Full details of every equipped spell (name, tags, damage, speed, cooldown, element)
  • The previous floor's manifest (for narrative continuity)

Gemini returns a Floor Manifest containing:

  • Floor name and tileset
  • Enemy spawns (archetype IDs + modifier flags like armored, berserk, elemental_immune)
  • A new spell with composed behavior tags
  • A narrative stage_message from the Chronicle (the Grimoire's voice)
  • Player HP scaling

Stage 1 is always a fixed handcrafted floor so the first Gemini call has real session data to react to.

Spell icons are generated via Nano Banana (Gemini image generation) from each spell's name, tags, and element.


Spell System

Spells are pure data — no runtime code generation. The engine has handlers for ~60 behavior tags across movement types, trajectory modifiers, on-impact effects, status effects, and corruption tags. The LLM creates novel spells by composing new combinations of tags, producing emergent behaviors.

  • 3 active spell slots — quickswap with 1, 2, 3
  • Cursed spells — powerful stats with a built-in downside (e.g. SELF_DAMAGE, ENEMY_HOMING)
  • Spell merging — every 5 floors, fuse 2-3 spells into one that fires all components simultaneously

Enemy System

Enemies are a fixed library of archetypes with coded behavior (melee charger, ranged sentinel, tank brute, fast skitter, exploder, shield bearer, healer drone, mimic shade, and more). The LLM decides which enemies appear, how many, and what modifiers to apply based on how you've been playing.


Map System

Floors are assembled from handcrafted 20x20 chamber prefabs in a 4x2 grid (80x40 total). Each of the 10 tilesets (acid, bubblegum, dungeon, flames, forest, frozen, honey, ocean, rocky, techy) has 8 unique chambers. Gemini picks the tileset; chambers are randomized from that set.

Built With

Share this project:

Updates