Build a Tiled level map from a prompt
This guide shows a workflow that gets good levels out of an AI in Tiled: let it look at the tileset first, agree on layers, describe the level in plain words, let the terrain tools handle edges, then render and fix. It assumes the setup is done and the server runs in full mode.
1. Start from a tileset the AI can see
The model cannot guess which tile ID is a wall corner. Give it the tileset and let it look:
Create a 48x32 orthogonal map with 16 px tiles. Add the tileset
C:/assets/tiny_dungeon/tilemap_packed.png as "dungeon".
Call get_tileset_preview for "dungeon" and list which IDs are
floors, walls, doors and decorations.
get_tileset_preview returns the tileset image together with a grid of tile IDs, so the model can match what it sees to IDs. If the tileset has a .tsx with terrain sets, add the .tsx instead of the bare image: the AI can then use place_wang_terrain.
2. Plan the layers
Ask for a layer plan before any tiles are placed. A common split:
| Layer | Type | Content |
|---|---|---|
Ground | tile | Floor, grass, water. |
Walls | tile | Walls and cliffs; often what your engine uses for collision. |
Decor | tile | Props that sit on top: tables, torches, rugs. |
Objects | object | Spawn points, doors, chests, triggers, camera bounds. |
Tools: add_tile_layer, add_object_layer, add_group_layer, reorder_layer, set_layer_property (opacity, lock, offset, parallax).
3. Describe the level
Describe the layout like you would to a level designer: rooms, connections, landmarks, sizes in tiles. Asking for a short ASCII sketch first works well, because you can correct it before tiles are placed.
Level 1 of a dungeon crawler, 48x32 tiles:
- entrance hall at the bottom center, 10x6
- a long corridor north to a 4-way junction
- west: a library room with bookshelves; east: a flooded room
- north: the boss room, 14x10, two pillars
Sketch it as ASCII first (# wall, . floor, ~ water, D door),
wait for my OK, then build it.
4. Floors and walls with terrain tools
For large areas, fill_rect and set_tiles_batch are fast. For anything with edges (walls, shorelines, cliffs) let the terrain tools choose the pieces:
- Tileset with Wang sets:
place_wang_terrainwith a grid of terrain colors. Neighbours are updated so edges join up. - Tileset without Wang sets: define rules once with
define_autotile_rules, then paint withplace_terrainorplace_terrain_rectusing names such aswallandfloor.
Details and a bitmask cheat sheet: auto-tiling with Smart Tiles and Wang sets.
5. Objects and properties
Gameplay data belongs on the object layer, with a class and custom properties your engine reads:
On Objects add: a point "player_spawn" in the entrance hall;
rectangle objects of class "door" on every doorway with property
locked=false; a tile object chest in the library with property
loot="key_boss". Set the map property "music" to "dungeon_01".
Tools: add_object (rectangle, ellipse, point, polygon, polyline, text, tile), update_object, set_property, set_properties_batch, set_map_property. Properties can target the map, a layer, an object or a tile.
6. Render, check, iterate
Ask the AI to look at its result rather than trust it:
Render the map to C:/maps/level1.png with return_image, and list
anything that looks wrong (gaps in walls, doors into walls,
unreachable rooms). Then run validate_map and fix the issues.
render_map_to_image renders the whole map to a PNG without a dialog; with return_image: true the picture also comes back to the model. validate_map reports empty layers, unused tilesets and missing images. get_semantic_map gives a compact text view that is cheap to re-read after each change. Save with save_map when you are happy, and keep the file under version control.
render_map_to_image. Tiles: Screaming Brain Studios (CC0).Tips for bigger maps
- Work room by room. Smaller requests are easier to check and cheaper to redo.
- Prefer
set_tiles_batchover manyset_tilecalls; it is one round trip. - Lock finished layers (
set_layer_propertywithlocked) so later steps leave them alone. - Name things consistently (layers, object classes). Your engine import and later prompts both rely on the names.
- If you change something by hand in Tiled, tell the AI to re-read the map (
get_map_info,get_semantic_map) before it continues.
Get Tiled MCP Pro
$10 once on itch.io, free updates.