Tickd.ai
← The Tickd Guide

Inspiration

How to Build a Generative Fantasy Map Generator in the Browser Using Claude 3.5 Sonnet and SVG

Learn how to prompt Claude 3.5 Sonnet to build a fully interactive, procedurally generated fantasy map simulator using vanilla JavaScript and scalable vector graphics.

Updated 10/27/2026

The Allure of Procedural Cartography

Every great fantasy adventure begins with a map. From the hand-drawn mountains of Middle-earth to the sprawling dynamic worlds of modern roguelikes, cartography sets the boundaries of our imagination. But while static maps are wonderful, there is something uniquely magical about procedural generation—the ability to click a button and watch a brand-new, completely unique continent carve itself out of a digital ocean.

If you are an indie developer, a tabletop game master, or simply a creative tinkerer, building a custom map generator is an incredibly rewarding project. Traditionally, this required deep knowledge of noise algorithms, canvas rendering, and coordinate mathematics.

With Claude 3.5 Sonnet, however, you can build a fully functional, highly interactive procedural fantasy map generator in the browser in less than an hour. By leveraging pure vanilla JavaScript and scalable vector graphics (SVG), we can bypass heavy external libraries and build a lightweight, infinitely scalable tool that looks gorgeous on any screen.

Which AI should I use for this?

Tickd is independent and not affiliated with any AI company.

Why SVG is the Secret Weapon for Procedural Art

When developers think of procedural generation, they usually jump straight to the HTML5 Canvas API. While Canvas is great for pixel-level manipulation, it has a major drawback: scalability. Zooming into a canvas-based map leads to blurry pixels, and rendering crisp labels requires complex text-rendering workarounds.

SVG (Scalable Vector Graphics), on the other hand, is a perfect fit for this kind of creative experiment. It treats every mountain, river, and castle as a distinct DOM element. This means:

  • Infinite Zoom: Your coastlines and mountains remain razor-sharp, whether viewed on a mobile screen or printed on a massive poster.
  • Easy Styling: You can style your entire map using standard CSS variables (perfect for switching from a "parchment" look to a dark "dungeon master" mode).
  • Native Interactivity: You can attach hover effects and click listeners directly to individual cities, regions, and geographic landmarks.

Architectural Blueprint: How the Generator Works

Before we write our prompt for Claude, we need to understand the logic of procedural map design. A good fantasy map generator relies on a series of layered algorithms:

  1. The Coastline (Perlin/Simplex Noise Approximation): Instead of generating random noise, we use a grid of values modulated by overlapping sine waves (often called fractional Brownian motion) to create realistic, jagged landmasses rather than perfect circles.
  2. The Heightmap (Elevation): We designate certain inland regions as high-elevation zones, which will dictate where mountains spawn.
  3. The Hydrology (Rivers): Rivers should flow from high-elevation zones (mountains) down to low-elevation zones (the sea), carving realistic paths.
  4. The Landmarks (Settlements & Forests): Cities spawn near water sources (coasts or rivers), while forests cluster in flat, low-elevation areas.

It takes some careful prompting to get the generator to tick all these boxes, but structuring your prompt sequentially guarantees Claude will output working code on the first attempt.

The Prompt Sequence to Build the Generator

To prevent Claude from hitting token limits or writing oversimplified code, do not ask it to write the entire app in one go. Instead, use a structured approach. Start by establishing the core generation engine with this prompt:

> "Act as an expert frontend engineer specializing in creative coding and procedural generation. I want to build a single-file HTML/JS procedural fantasy map generator. The generator must render its output as a beautifully styled SVG. > > For the first step, write the core HTML structure and a JavaScript engine that generates a random island shape using simplified 2D noise (using mathematical sine/cosine approximations to avoid external libraries). It should output a clean, winding SVG path representing the coastline. Include a 'Generate' button to refresh the seed. Keep the styling clean, modern, and minimal for the UI container."

Once Claude delivers this foundational code, you can inspect the output. You will have a clean, interactive page that generates unique landmasses on every click.

Next, you will want to layer in the geography. Use this follow-up prompt to add mountains, forests, and rivers:

> "Now, let's add geographical layers. Inside the generated island, use the elevation data to distribute geographic elements: > 1. Mountains: Render these as stylized, overlapping triangular SVG paths in high-elevation areas. > 2. Rivers: Generate 2-3 winding paths that start near the mountains and trace a path to the nearest coastline point. > 3. Forests: Scatter small, stylized evergreen tree icons (using simple SVG shapes) in clusters across low-lying inland areas. > Make sure these elements scale beautifully when the SVG is resized."

Finally, add the narrative flair—names, cities, and paths. This is where the map truly comes alive:

> "Let's add the final narrative layer. Create an algorithm that generates fantasy names (e.g., combining prefixes like 'Gloom', 'Storm', 'River' with suffixes like 'wood', 'run', 'glen'). Place 3-4 major cities on the map, prioritizing locations near rivers or coastlines. Render them as small red shields or castle icons, with their names rendered as clean SVG text with a soft white glow effect behind them so they are legible over the terrain."

Refining the Aesthetic: The Parchment Effect

To make your generator look like a hand-drawn map pulled from an ancient tome, you can apply a subtle CSS filter directly to the SVG element. By combining a turbulence filter with a color matrix, you can simulate the texture of aged parchment:

`html <svg viewBox="0 0 800 600" style="filter: url(#paper-texture); background: #f2e8cf;"> <defs> <filter id="paper-texture"> <feTurbulence type="fractalNoise" baseFrequency="0.04" numOctaves="3" result="noise" /> <feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.07 0" /> <feBlend mode="multiply" in="SourceGraphic" in2="noise" /> </filter> </defs> <!-- Map elements go here --> </svg> `

This CSS trick instantly elevates the generator from a sterile vector mockup to an atmospheric work of art.

Taking It Further

Once your base generator is running smoothly, the possibilities for expansion are endless. You could integrate a pathfinding algorithm to draw trade routes between generated cities, or hook the map data up to an LLM to generate unique lore and quest hooks for every single landmark on the screen.

If you run into any quirks while rendering complex SVG math or scaling nested groups within the browser, check out our Claude troubleshooting hub for solutions to common canvas-to-DOM scaling issues. What starts as a simple browser experiment might just become the foundation of your next game project!

claudeprocedural-generationjavascriptsvgcreative

Keep going

Build something with the prompt generator, decode the jargon in the glossary, or compare the tools on our platform deep-dives.