Page 1 of 1

How would I made a randomly generated map for my game?

Posted: Mon Aug 14, 2023 3:34 pm
by MaxGamz
I can understand making a random tile map which I don't find too difficult, but I am having trouble figuring out how to implement noise so that my map isn't too random. For example, I am interested creating a maze game and I don't want love to accidentally create a maze with no exit.

Re: How would I made a randomly generated map for my game?

Posted: Mon Aug 14, 2023 7:05 pm
by darkfrei
MaxGamz wrote: Mon Aug 14, 2023 3:34 pm I can understand making a random tile map which I don't find too difficult, but I am having trouble figuring out how to implement noise so that my map isn't too random. For example, I am interested creating a maze game and I don't want love to accidentally create a maze with no exit.
The maze with 100% achieveblity: viewtopic.php?p=253993#p253993

Re: How would I made a randomly generated map for my game?

Posted: Mon Aug 14, 2023 8:39 pm
by MaxGamz
darkfrei wrote: Mon Aug 14, 2023 7:05 pm
MaxGamz wrote: Mon Aug 14, 2023 3:34 pm I can understand making a random tile map which I don't find too difficult, but I am having trouble figuring out how to implement noise so that my map isn't too random. For example, I am interested creating a maze game and I don't want love to accidentally create a maze with no exit.
The maze with 100% achieveblity: viewtopic.php?p=253993#p253993
Thanks for the tool! This can come in handy

Re: How would I made a randomly generated map for my game?

Posted: Tue Aug 15, 2023 10:39 am
by pgimeno
Mazes have the problem of being extremely non-local. This means that if you create a maze, the solution may pass through some cell at a very far distance, so that if that cell is covered, the whole maze is unsolvable. This non-locality is the reason why you usually don't use noise to generate a maze. It's possible, however, to make several tries until one of them has a solution - a flood-fill algorithm would be able to find out if there's a route from the entrance to the exit.

Surprisingly enough, I've discovered that mazes based on Truchet patterns (I mean of this kind:)

Image

tend to connect very large areas of the screen, no matter the size of the pattern. If you use a Truchet pattern, it would probably take very few tries to find one that connects the entrance and the exit, and they are very quick to generate - flood-filling will probably be the slowest part. You can make an "upright Truchet" too; it takes just a bit of thinking to figure out how to arrange the tiles to make them upright. It will be likely that there are multiple paths to the exit too.

Apart from that, there's a thread dedicated to mazes: viewtopic.php?f=5&t=19873

Re: How would I made a randomly generated map for my game?

Posted: Tue Aug 15, 2023 8:19 pm
by BrotSagtMist
There is no law that the map and way through the map have to be generated at the same time.
My usual approach here is to just make a way with some curves and then throw it onto a complete random junk map.
That way you get a guaranteed working solution without having to deal with verifying that it works.