Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Rooms" map generation mode #5

Merged
merged 5 commits into from
Feb 7, 2023
Merged

"Rooms" map generation mode #5

merged 5 commits into from
Feb 7, 2023

Conversation

msakuta
Copy link
Owner

@msakuta msakuta commented Feb 7, 2023

We want to generate a map with connected free space and "interesting" terrain such as multiple paths and challenging routing. However, none of the methods so far was perfect.

  • Perlin noise is good at generating natual looking terrain, but it doesn't guarantee connectivity and sometimes miss a significant portion of map area by disconnection.
  • Maze is an attempt to improve it, but it tend to "congest" around the center of the map and not so interesting.

Now we introduce yet another map generation mode called "Rooms".

The algorithm

It is named "Rooms" because the objective is to produce rooms connected with corridors.

First, we generate a set of room "seeds" in a grid pattern. Note that each room is colored by different label in the visualization below because they are disconnected.

image

Second, we generate connection between rooms.
There are many ways to do this, but in our case, we start from the center and explore ramdonly outwards, similar to Dijkstra algorhtm.

image

Third, expand some of the rooms to introduce some variation of space.

image

Fourth, modulate the room positions randomly to add some variation.

image

Finally, add some Perlin noise to add even more variety and natural looking style.

image

It can auto-scale as the map resolution increases, but there is a practical limit where the map gets too big that the game won't finish in reasonable time. That said, it's cool to see many agents can navigate this huge maps in real time.

image

@msakuta msakuta merged commit 16f4b95 into master Feb 7, 2023
@msakuta msakuta deleted the rooms branch February 7, 2023 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant