• Hey! Register here to create your account, engage with the community, and talk about what is new!

Path Generation on Grid

pablogameing4000

New member
Joined
Apr 3, 2022
Messages
7
Reaction score
1
So I'm making a dungeon crawler and I've built some map pieces that are supposed to spawn on different tiles on a 5x5 grid, but I can't figure out how to actually generate the path. I'm planning on having a few variations, but it would basically just be one main path with maybe one or two sides paths branching off occasionally. Any help on how to start would be GREATLY appreciated. (I was also thinking of having some 2x2 sized rooms, would that still work?)

Example path generation:
1651024554906.png
 
Solution
I'm not sure if I understand what you're trying to do, but here's how I'd make a tile-based dungeon generation system:
- Store the two location boundaries of every structure in a list (kind of like how you'd select them using WorldEdit.)
- Associate a block with every single different tile you have built (for example: a target block represents a 4-way branch, that magenta block with an arrow on it is a straight corridor, etc.)
- Code the generation algorithm that places these blocks on the grid. A few tips: when you generate a branch, call the same algorithm for every new path (but decide where the exit is going to be, and maybe even the maximum length of the paths), you've got to watch out for a few special conditions that restrict...

Jimmy_The_Knight

Well-known member
Joined
Dec 28, 2020
Messages
73
Reaction score
32
I'm not sure if I understand what you're trying to do, but here's how I'd make a tile-based dungeon generation system:
- Store the two location boundaries of every structure in a list (kind of like how you'd select them using WorldEdit.)
- Associate a block with every single different tile you have built (for example: a target block represents a 4-way branch, that magenta block with an arrow on it is a straight corridor, etc.)
- Code the generation algorithm that places these blocks on the grid. A few tips: when you generate a branch, call the same algorithm for every new path (but decide where the exit is going to be, and maybe even the maximum length of the paths), you've got to watch out for a few special conditions that restrict what the random generator can choose (paths can't go out of the map, if there's no way for the path to generate, then put a dead end or an exit there, etc.), and I recommend using functions instead of processes, because async generation is more likely to mess up (for example, when two tiles generate at the same time next to each other.)
- Now code the algorithm that goes through every block you've placed and copy-pastes in the right structures (use 'copy region' if you have overlord, else use 'repeat on grid' with 'set block', you'll probably have to wait a few ticks between every paste to prevent lagslays.)

Might not be the best way to do it, but I hope it's helpful in some way!
 
Solution
Top Bottom