I've been trying to make an algorithm to procedurally generate a path from a tile map attached below.

I'm just looking for a method to go about doing this.

Path Tilemap

EDIT: I want to make a path for a tile map like generate a path then output to a tile map. Pardon the drawing but this is kinda what I want it to look like: [Good Example I don’t want it to be something like this: [Bad Example

  • 3
    \$\begingroup\$ Procedural generation questions usually get better answers if you demonstrate some positive/negative examples. Try laying out a few paths with those tiles you'd consider "good" and try to describe what desirable properties they have. Then contrast those against negative examples/properties that a generator should avoid. With this in hand, users can suggest algorithms that produce more of the "good" type examples and avoid the "bad". \$\endgroup\$
    – DMGregory
    Oct 18, 2023 at 20:27
  • 1
    \$\begingroup\$ Generate a path from a tile map or for a tilemap? Procedurallying using a tile set for generated paths (i.e. autotiling) is very different than analyzing an image and extracting a path from it. The image you used looks like an autotiling tileset, but the text in your question says 'from' (i.e extraction) - can you clarifiy which of the two you're asking about? \$\endgroup\$
    – Pikalek
    Oct 18, 2023 at 22:34
  • \$\begingroup\$ It's hard to see what it is about the good case and the bad case that we need to be aware of. Do you want to avoid closed paths? Right angles? Crossing itself? Does it need to span from a specific corner of the map to another specific corner? Does it have to oscillate like in the good case? \$\endgroup\$
    – Romen
    Oct 20, 2023 at 20:38
  • \$\begingroup\$ From just one example, I could infer that you want a path that generally moves up and to the right, with roughly periodic deviations up and down, larger and farther apart at the start of the path and smaller and closer together near the end. Is that accurate, or is that over-fitting to this specific example? \$\endgroup\$
    – DMGregory
    Oct 20, 2023 at 21:21

1 Answer 1


I would look at the maze generation algorithms for inspiration (single path is not generally warranted, so randomly open some paths, the amount depends on the openness needed) and then apply the tileset to the generated graph's turn possibilities, straight, open, and split paths.

  • \$\begingroup\$ This looks more like a comment than a complete answer. It would be better if it detailed a specific maze generation algorithm suitable for being able to dial in the amount of branching as you describe. \$\endgroup\$
    – DMGregory
    Oct 19, 2023 at 1:17
  • \$\begingroup\$ Google will provide the OP with many choices. No single algorithm would be better. That is why it is left out. The removal algorithm was left random on purpose given the question. \$\endgroup\$
    – agone
    Oct 21, 2023 at 23:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .