Procedural map generation with locked doors, keys

Hi. I’ve been looking over the web for a sidescroller (platform…Mario, etc.) level generator with not a lot of luck. Are there any scripts or ways using Tiled to a procedural level generator? Maybe sprinkle in some bad guys, treasures, etc. But most importantly, different keys that fit for different locked doors. Having stairs and ladders would be a big plus too.

My hope is that there is something available like that and I can replace the default images being used in such a script with my own art.

EDIT: I guess when I say procedural. The levels should be completable and stores some states of pathfinding of some sort. I don’t exactly have a game design or core mechanic in mind yet. Which is kind of working backwards, but I do want something that can be procedural so I don’t have to design the levels myself by hand. I want a system to do it for me. If I have a engine that can at least generate a level for me, I’ll work around it.

I think I want to maybe integrate pathfinding into this; maybe there’s an ideal number of moves a player can make to solve the level, a worst case and a best case. So this is somewhat a puzzle game. If a player can figure out how to complete a level in X amount of moves, they’ll get points depending on how good they do.

I likely want to integrate dice into this. This will be some sort of board game/video game hybrid.

So I have an approximation of what I want to do, but it’s still fluid. At the end of the day though, I need an engine that auto-maps the levels:

  • Start location
  • End location
  • Flat platforms
  • Holes in platforms (so jumping can be involved)
  • Treasures
  • Random monster types
  • Grid based level
  • Ladders
  • Stairs
  • Red key = unlocks red door, blue key = unlocks blue door, etc.
  • Ideal number of moves (best/worst case using some pathfinding algorithm)
  • Ability to change difficulty level, so level 1 is super easy, last level is tough, etc.
  • Bosses? Sure


1 Like

It can be done with scripting in Tiled, but I’m not aware of an existing script to do it for you - and I’d be surprised if there was anything general-purpose that you could use.

Procedural level generation is very dependent on your exact needs for your game, it needs to account for your specific mechanics (including the details of your physics, in the case of platformers) and tilesets. I’d recommend designing some levels by hand first so you can refine the game design to the point where it’s no longer nebulous, and then work out some algorithms to generate levels. Once you’ve done that, creating a script to build the levels for you, either completely at random or with some guided input from the designer, will be largely a lot of grunt work and not too difficult.

Designing the algorithms is very much the hard part, especially for a platformer where gravity complicates things. For this reason, for platformers, it’s much more common to hand-design many rooms or room-segments and piece them together procedurally, rather than generate the rooms tile-wise from scratch. The latter can be done, but it’s incredibly difficult to get results that are enjoyable to play and sufficiently varied.

Enemy placement is generally tightly controlled. In a good platformer, enemies play off the environment, so it’s more common to define configurations for each enemy, and place them whenever those configurations appear (e.g. place the Bullet Bill-esque enemies along long flat stretches or where the player has to clear long gaps). This means that from-scratch procedural generation has to be very tightly controlled by the designer to make sure that it can generate areas where the enemies can appear.

Similarly, bosses and their arenas generally need to be hand-crafted, but their small number means this usually isn’t too time-consuming. Procgen games with bosses usually have fixed-ish points where bosses appear (for better pacing), and either have specific bosses for each location (e.g. Chasm) or a subset of bosses that can appear there (e.g. Binding of Isaac).

This topic is really beyond Tiled (Tiled in this case is merely the vehicle and script engine in which the work happens). If you want to dig into it, I recommend looking into the many articles out there on procgen for games like Spelunky and Chasm, both of which mix together hand-crafted parts. There are entire academic papers written on generating Mario levels from scratch (which should be a hint that this is a massive and difficult topic).

Thanks for your insight. I’ll take a look at your suggestions.

Great topic and I like your first post. @eishiya in relation to Tiled you’re right possibly.
@mike777 you seem to have a Game Design in mind. I’m going to give best advice, as you seem to know what you want.

Try extending on each feature in your bulletpoint list. It’ll be tough but basically it’s a valuable exercise if you want to try it out. (I personally keep a doku wiki with pages and sub headers for each part of my game features, notes and processes and it is worth it.) You can always change and edit things as you progress, don’t be shy.

Next you’ll see how features may cross-link and get an idea of how to produce them, by exploring your notes.

Programming level-generator scripts is extremely hard because of the algorthms involved. Though definitely read Spelunky by Derek Yu as @eishiya sort of mentioned. He reveals his main algorthm was actually rather simple, along with his thoughts on game design and how he achieved seamless level generation. It’s a good read and in terms of level-generation may help you. Think brushes, tools, abstract things.

If you are to attempt this level generator with what you have already, (maybe someone with coding experience can help you) it’s easier to extend on your already defined ideas. Get it out of your mind and onto paper, or better - a document. Game Design mistakes are made when the Designer doesn’t “output” anything feasible.

I’m curious about how much you know on coding. But there, lecture over.

Hi @SquareMezzmer ! Thanks for the response.

I’m curious about how much you know on coding. But there, lecture over.

I’m a software dev actually! I’ve had simple games in the iOS App Store; I’m mostly a web dev (c#, rest, JS, html, etc.). I could and have started to write something but I was hoping to find some existing scripts.

All in all, I know the other post talked about physics, etc. but I’m actually trying to find something for a pen and paper game. I’m trying to come up with a game that blends a side-scroller but as a pen and paper game. I do graphic design and art (more my interest than programming), so I was hoping to find an existing script (of course I’d hope to tweak it if it’s open-source, or available for commercial use), that can generate a puzzly sort of platform levels. I can hit generate and it gets created. I’d make some scripts that map a set of grid squares to a completable level and each square in the level generates my custom art and can be export as a PDF.

I looked all over, and all over the web. There’s a lot of hex and general map generators out there but nothing that serves my purpose or even close. There’s plenty of random maze generators out there but nothing with locked doors, keys, etc. I could in effect, generate a random maze and turn it on it’s side and visually make it a sidescroller.

The pen and paper game though brings up another set of problems all together.

  • Capturing the excitement of a actual video game,
  • Fog of war
  • The hook of the game itself… I was looking at different path finding options. Maybe each level has a Target number, say 5. Can you get to the exit in 5 moves. That sort of thing.

So the game design itself hasn’t been completely worked out. I just know a few different elements I’m looking to simulate. So I was hoping if I found some script that does a good chunk for me, I can tweak it to fit what I need. At the end of the day, I want to be able to click “generate” as many times as I want and have this brought to pen and paper. :slight_smile: