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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
MaxGamz
Party member
Posts: 107
Joined: Fri Oct 28, 2022 3:09 am

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

Post 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.
User avatar
darkfrei
Party member
Posts: 1215
Joined: Sat Feb 08, 2020 11:09 pm

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

Post 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
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
MaxGamz
Party member
Posts: 107
Joined: Fri Oct 28, 2022 3:09 am

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

Post 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
User avatar
pgimeno
Party member
Posts: 3691
Joined: Sun Oct 18, 2015 2:58 pm

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

Post 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
User avatar
BrotSagtMist
Party member
Posts: 665
Joined: Fri Aug 06, 2021 10:30 pm

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

Post 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.
obey
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests