Devlog #3: Path generation


Hi guys!

This path generation stuff is taking me way longer to figure out than I thought. I think it is mostly done, though there is one problem where the algorithm can get stuck in edge cases where it can't go anywhere.

The algorithm is basically just a random walk, with a few rules, like don't place paths parallel to other path tiles and don't try to connect with already loaded chunks. It works by scoring three options (left, straight and right) and choosing the direction with the highest score. The score is partly random, but there are bonuses if the direction is in line with the current direction (so it doesn't turn all over the place) and if it is in line with the target direction. The target direction is set at the beginning and is basically just to help the path move towards the unloaded chunks.

The blue squares are "entrance points" and are tiles on the edge of chunks that the algorithm starts from. When the path gets up to the edge of an unloaded chunk, it saves an entrance point so that when that chunk is loaded, it has a path to start from that is already connected to everything else.

I also want to allow the path to branch every now and then, but I don't think that will be too difficult, since the algorithm is already in place I just need to make it start from a random path tile every now and then.

I am hanging out with friends tomorrow so I won't have as much time, but I at least want to get this path generation done. Again, I hope to get to work on enemies, but we'll see how we go.

See ya!

Leave a comment

Log in with itch.io to leave a comment.