Vladar's Blog

ChatGPT dungeon maps

Unfortunately, as an AI language model, I do not have the capability to create a visual schematic plan.

β€” ChatGPT

Well, we'll see about that…

illustration

Can you employ ChatGPT to generate a random dungeon map? If you ask it for this, you'll get a negative answer, something like the one presented above. But is it really so?

Presented below, Is a guide explaining how to teach ChatGPT to generate a random dungeon level map.

The software required:

Optional software:

The key to this project is D2. This scripting language allows to parse a plain text document into a vector (SVG) diagram, and since the syntax is dead simple, it's the perfect fit for our goal. Here's a D2 cheat sheet for your reference.

So, the plan is:

  1. Teach ChatGPT the basics of Declarative Diagramming.
  2. Teach ChatGPT how to use Declarative Diagramming in case of dungeon generation.
  3. Ask ChatGPT to generate a dungeon level.
  4. Parse the output through d2 and adjust the resulting SVG file as needed.
  5. (Optional) Draw a cool dungeon map based on the diagram.

I spare you the details of my couple dozen attempts to get ChatGPT do what I wanted. What follows, are prompts that seem to produce the best results at the moment. Nevertheless, I encourage you to experiment and tinker with these yourself.


Contents

Prompts ↩

1: Declarative Diagramming Rules

I want you to learn the basics of the Declarative Diagramming script - a diagram scripting language that turns text to diagrams.

1) Diagrams consist of nodes and connections between nodes. The names of nodes and connections should be unique and should not contain spaces and punctuation. If needed, instead of spaces use _ symbol instead.

2) Labels for each node is separated by a colon, e.g.:

node1: Label for the node1
node2: Label for the node2

3) There should not be empty labels. If the node does not have a label, do not put the colon either.

4) Once you write a node, you cannot redefine or append it's label later, so write all the information you need about the node in one line, e.g:
node3: Label for the node3 (additional information about the node3)

5) The connection between two nodes is represented by a -> symbol, e.g.:

node1 -> node2

6) Write connections on a separate line, using the names of already established nodes, e.g.:
node1 -> node2

7) The connections could also be labeled, just like nodes, e.g.:

node1 -> node2: Label for the connection between node1 and node2

8) Comment lines start with # symbol.

Do you understand?

Yes, I understand. Thank you for providing the basics of the Declarative Diagramming script. It seems like a simple and straightforward language for creating diagrams.

2: Dungeon Generation Rules

Replace the examples in the prompt to suit your dungeon's theme.

Next, I want you to learn how to use Declarative Diagramming script to create a dungeon level map for a fantasy tabletop role-playing game.
Here are the rules that you should follow:

1) The nodes will represent rooms of the dungeon.
Use the node labels to name and describe the rooms.
Here are some examples you can use to invent your own labels for rooms:
- Gatehouse
- Courtyard
- Guard post
- Bedroom
- Office
- Kitchen
- Larder
- Storage room
- Temple
- Barracks
- Tower stairwell
- A room with collapsed floor

2) The connections will connect all the rooms together.
Use the connection labels to name and describe the nature and appearance of the connection.
Here are some examples you can use to invent your own labels for connections:
- Wide corridor
- Narrow passage
- Natural tunnel
- Narrow corridor
- Winding passage
- Slowly descending tunnel
- Cluttered corridor
- Passage filled with rubble

3) Do not use numbers in the labels. Label rooms and connections creatively and descriptively. Each node and connection should be labeled appropriately.

4) The dungeon should be non-linear and rooms should be interconnected. Each node (room, entrance, or exit) should have at least one connection to another node. When starting with any node and following connections from there, it should be possible to reach all other nodes.

5) 60% or more of all rooms should have three or more connections to another rooms, but no more than 4-6 connections per room.

6) There should not be more than one connection between each specific pair of rooms. In other words, there should not be redundant duplicate connections.

7) Some rooms will contain entrances - ways to enter the dungeon level, and some rooms will contain exits - ways to proceed to the next dungeon level. Write these details in parentheses, like this:
bedroom: Bedroom (hidden trapdoor under the carpet)

8) Your output should be a Declarative Diagramming script I've described to you previously, strictly following its syntax.

Do you understand these rules?

Yes, I understand the rules for creating a dungeon level map using Declarative Diagramming script. Thank you for providing such detailed instructions.

3: Map Request

Here, you can adjust the prompt to fit your requirements. Keep in mind though, that ChatGPT has some kind of limitation on the output text length, so too large of a dungeon will be truncated.

Now, using Declarative Diagramming script syntax and dungeon creation rules I've described to you above, create a first level of the dungeon for a fantasy tabletop role-playing game.

The map should contain at least 15 interconnected rooms, one room with obvious entrance to the dungeon, one room hidden entrance to the dungeon, and 2-3 rooms containing obvious and hidden ways to reach the second level.

The theme of the dungeon: an abandoned medieval castle.

Here's the Declarative Diagramming script for the first level of the abandoned medieval castle dungeon, as per your instructions:

# Dungeon Level 1: Abandoned Medieval Castle

# Entrances
gatehouse: Main entrance to the castle
guard_post: Secret entrance through a hidden door behind the bookshelf

# Exits to Level 2
tower: Hidden spiral stairway leading to the tower of the castle (leads to level 2)
basement: Trapdoor in the floor leading to the basement (leads to level 2)
dungeon: Narrow passage leading to the dungeon below (leads to level 2)

# Rooms
courtyard: Open area in front of the castle
great_hall: Large hall with high ceilings, tapestries and ornate decorations
throne_room: Room with a large throne at the far end
kitchen: Old kitchen with a rusted stove and empty cupboards
pantry: Storage room filled with empty barrels and sacks
storage_room: Room filled with cobwebs and old furniture
barracks: Living quarters for castle soldiers
guest_room: Room with an old bed, a wardrobe and a nightstand
library: Room with dusty bookshelves and a wooden table
chapel: Small chapel with a statue of a saint
armory: Room with racks of rusted armor and old weapons
dining_hall: Long room with a large wooden table and benches
stairwell: Narrow stairway leading up to the tower of the castle
dungeon_cell: Small room with a barred window and a locked door

# Connections
gatehouse -> courtyard: Wide stone bridge over the moat
courtyard -> great_hall: Massive oak doors leading into the hall
great_hall -> kitchen: Wide corridor with banners hanging from the walls
great_hall -> stairwell: Narrow staircase leading up to the tower
great_hall -> throne_room: Large door with a golden handle
great_hall -> armory: Corridor lined with weapons and shields
kitchen -> pantry: Small passage with shelves of empty containers
kitchen -> storage_room: Door at the back of the kitchen
pantry -> dining_hall: Short passage with a wooden door
storage_room -> barracks: Dark passage with a hidden entrance to the barracks
barracks -> guest_room: Long corridor with many doors
barracks -> library: Large room with many wooden bookcases
library -> chapel: Door at the back of the room
throne_room -> great_hall: Wooden doors leading back to the great hall
stairwell -> tower: Spiral staircase leading to the top of the tower
dungeon -> dungeon_cell: Dark passage with damp walls and floor
dungeon -> basement: Steep descent down into the depths of the castle

# Room Details
gatehouse: Gatehouse (massive wooden doors and a portcullis)
guard_post: Guard post (hidden bookshelf door)
tower: Tower stairwell (hidden trapdoor leading to level 2)
basement: Basement (old wooden trapdoor leading to level 2)
dungeon: Dungeon (low ceiling and stone walls)
guest_room: Guest room (four-poster bed and a chest)
chapel: Chapel (stained glass windows and flickering candles)
dining_hall: Dining hall (large wooden table and benches)

Output ↩

Copy the output into a map.d2 file, and run the command d2 map.d2. Alternatively, there's an online D2 Playground.

That's it! If there are no syntax errors, you will see the newly created map.svg file. Now, you can examine it and see if anything need to be adjusted. I recommend doing most of the adjustments in .d2 file, running it through the parser again afterwards.


Troubleshooting ↩

Sometimes, despite the rules, ChatGPT will create a linear dungeon. In that case, point out the mistake:

That's too linear. Make more interconnections between rooms.

Sure, here's a revised version of the dungeon level map that incorporates more interconnections between rooms.

Address other mistakes in the same manner.

After a couple of tries, you'll get a good enough output to work with. You can then use Inkscape, Dia, or any other vector editor of your choice to rename labels, adjust the nodes and connections, or to create missing ones.


Bonus ↩

And, as a bonus here's a dungeon level map based on the presented output. The name of the castle is also a ChatGPT's suggestion.

Raw D2 Diagram:

raw diagram

Edited D2 Diagram:

edited diagram

"Castle of Gwendolyn Pendragon's Triumph":

Castle of GPT Full size map at ArtStation and DeviantArt.

Discuss this post on Reddit


  1. https://chat.openai.com↩

  2. https://d2lang.com↩

  3. https://inkscape.org↩

  4. https://wiki.gnome.org/Apps/Dia/↩

  5. https://krita.org↩

#ai #art #chatgpt #gamedev #guide #mapping #software #ttrpg