{"slug": "transformers-js-dungeon-crawler", "title": "Transformers.js Dungeon Crawler", "summary": "A developer built a browser-based text dungeon crawler on Transformers.js that runs the storyteller model locally on the player's device, using a separate structured JSON pass to propose game-state changes that a rules layer called OpenJev validates against the generated scene. The game tracks a coordinate map of visited rooms and passages, gives each floor one to three in-game days to find the next staircase, and awards XP and loot on defeats, with two attribute points per level-up. The author cautions that structured output makes state changes checkable but \"doesn't guarantee a good story,\" and the first visit requires a model download.", "body_md": "I’ve been thinking about how we can use Transformers.js for local AI on the client side. I’ve tried it in my [train game](https://mattcool.tech/posts/transformersjs-in-web-games/) and explored browser-based agents in the [AI Lab](https://mattcool.tech/posts/local-webgpu-agents-transformers-js/). This time, I wanted to build a text-based dungeon crawler around structured JSON output.\n\nI’ve clearly been reading [Dungeon Crawler Carl](https://en.wikipedia.org/wiki/Dungeon_Crawler_Carl) and wanted to see if I could do a similar version in the browser.\n\nI’ve seen [AI Dungeon](https://aidungeon.com/) do this with AI-generated adventures: you type what your character does, and the story responds. It’s great! [Their models run in the cloud](https://help.aidungeon.com/getting-started), but can we do something similar running locally in a webpage? With Transformers.js, the models download to your device and generate the story there.\n\nIn my experiment below, you build your character and then the storyteller gets your attributes, inventory, nearby characters, and recent events. It writes the next scene, then a separate structured JSON pass proposes changes to the game state. OpenJev checks those decisions against the scene. The game applies the rules for time, health, enemies, XP, and loot. OpenJev also checks whether proposed starting skills fit the background you supplied.\n\nA coordinate map tracks visited rooms and connected passages on each floor. The storyteller sees what you have discovered, and travel distance helps determine how much time an action takes. The exit stays unknown until you find it. Hostile creatures attack outside the guide room, so exploring quickly leads to encounters.\n\nEach floor gives you one to three in-game days to find the next staircase. Actions spend game time; reading and typing don’t. At zero, the floor collapses and kills everything still on it.\n\nDefeats immediately award XP and collect loot, including rewards from tougher enemies’ chests. If your inventory is full, the rewards stay in the chest. Later floors drop stronger equipment. Each level-up gives you two points to assign to your attributes.\n\nThe first visit needs a download, and generation runs locally on your device. This is still an experiment: structured output makes state changes checkable, but it doesn’t guarantee a good story.\n\nOpen the book below to play and let me know what you think!", "url": "https://wpnews.pro/news/transformers-js-dungeon-crawler", "canonical_source": "https://mattcool.tech/posts/transformersjs-dungeon-crawler/", "published_at": "2026-09-24 16:00:00+00:00", "updated_at": "2026-10-20 20:15:31.418066+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-tools", "generative-ai", "large-language-models", "ai-agents"], "entities": ["Transformers.js", "OpenJev", "AI Dungeon", "Dungeon Crawler Carl"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/transformers-js-dungeon-crawler", "markdown": "https://wpnews.pro/news/transformers-js-dungeon-crawler.md", "text": "https://wpnews.pro/news/transformers-js-dungeon-crawler.txt", "jsonld": "https://wpnews.pro/news/transformers-js-dungeon-crawler.jsonld"}}