This is a submission for the Cloudflare AI Challenge.
What I Built
(Honestly, I don't know how this isn't the priority when we talk about AIs, I mean, the storytelling potential is infinite...)
Being a kid from the '80s, I loved the series of "Choose Your Own Adventure" books - even in Brazil, they had some niche fans and translated editions. And text games from the past were also cool. Obviously, videogames and group RPGs took their place, but it is still something nice to waste time have fun.
I had this idea when AI started blooming, but most of the services had a prohibitive cost for a "fun only" project. The CloudFlare Challenge and the free tier gave me the chance to remove this code from my "brain cabinet labeled STUPID IDEAS" and put it into action. And for that, I'm truly grateful.
And how does it work? Select the type of adventure you want, then enter the name of your character and his class. The AI will start creating a story and give you three different actions so you can proceed. Then he will create a new part of the adventure based on your choice.
Oh! Fans of Easter Eggs: there's a nice one when you start playing 🥷🏽
Demo
You can test and play it here
My Code
Choose Your Own AIdventure
A retro-style AI text RPG powered by Cloudflare Workers AI. Every opening, choice, and follow-up scene is generated around your character and previous decisions.
Features
- Two settings: The Golden Axe (medieval fantasy) and The Aster Archive (cyberpunk thriller).
- AI-generated adventures: New opening, 2–3 generated choices per scene, and follow-ups based on your actions.
- Short complete runs: Endings may arrive on turn 5 and are forced by turn 6 or zero HP.
- Structured RPG state: HP, gold, inventory, class, and journey history remain visible and bounded.
- No risk spoilers: Choices are action phrases without SAFE/RISKY labels or outcome hints.
- Generated pixel art: FLUX.1 Schnell images are converted to a 256×144 grid with a fixed 20-color palette.
-
Hand-authored sprites: All six classes use native 32×32 portraits and eight-frame idle sheets with
steps(8), plus two native 128×72 local scenes. - Choice-first layout…
Journey
By the sweet JC in the sky, what a ride! First I got confused by how Workers, well, "worked", and I tried to scramble everything into a single file. When I finally noticed that Workers can act as an API and I can host the layout in CloudFlare pages, everything was a breeze - mostly. NextJS building in CloudFlare is a nuisance, but nothing that some questions to my beloved LLM couldn't solve.
I love how CloudFlare lets me create different endpoints with a single Worker. It's the best practice? Probably not, but for starters and proof of concepts it's wonderful.
There is a lot that I want to do with the idea behind the "Choose your own AIdventure", but I had less time this week to finish the project. The layout is bad, and I would love to make the system prompt better. Maybe after the challenge CloudFlare can sponsor the idea 👀
Multiple Models and/or Triple Task Types
Models Used:
llama-2-7b-chat-fp16 - for interaction with the user while playing
dreamshaper-8-lcm - each interaction brings an image so the user can "feel" the story.

Top comments (0)