Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wave Function Collapse
#1
In the process of putting together some examples and tutorials for upcoming updates to the GX game engine project I've been working on for a bit, I thought it might be cool to look at some procedural map generation examples.  Historically, I've primarily worked with games that use "hand-drawn" maps.  GX has a map maker program that can be used for this.  There are a whole host of games types though that use procedural generated maps, so that for each play you have a new world to explore.

Anyway, in the process of looking into this further I began experimenting with the wave function collapse algorithm.  It's a pretty neat way to generate maps from a sample one that is created manually.  That map is then analyzed and used as a template or rule set for then generating new maps that have the same basic features.  For a more in depth discussion of how this all works I would recommend this article.

Here is my initial attempt at implementing the algorithm in QB64/QBJS.  You can run it from the embedded version below.  If you want more room to see the output you can also launch it in a new tab from this link.


To try it out in QB64 just download and unzip the wfc.zip file that is attached to a location on your filesystem.  Then compile and run the main.bas file.  (This program uses relative paths, so make sure you have the "Create exe in same directory as source" option selected.)

This is definitely still a work in progress.  For this to be used for generating very large maps, some additional optimization will need to be applied.  I would also like to look at being able to render multiple layers, as well as potentially just generating a specific region of the map at a time which would allow you to potentially create different "biomes".

If it works out and seems useful I may add it as an optional include in future releases of GX.


Attached Files
.zip   wfc.zip (Size: 335.08 KB / Downloads: 304)
Reply


Messages In This Thread
Wave Function Collapse - by dbox - 06-24-2024, 07:57 PM
RE: Wave Function Collapse - by justsomeguy - 06-24-2024, 08:30 PM
RE: Wave Function Collapse - by dbox - 06-24-2024, 09:34 PM
RE: Wave Function Collapse - by bplus - 06-25-2024, 02:37 AM
RE: Wave Function Collapse - by KingLeonidas - 06-25-2024, 03:35 AM
RE: Wave Function Collapse - by Pete - 06-25-2024, 03:37 AM
RE: Wave Function Collapse - by dbox - 06-25-2024, 03:30 PM
RE: Wave Function Collapse - by bplus - 07-08-2024, 11:25 PM
RE: Wave Function Collapse - by dbox - 07-09-2024, 01:18 AM
RE: Wave Function Collapse - by bplus - 07-09-2024, 12:50 PM
RE: Wave Function Collapse - by dbox - 07-09-2024, 04:23 PM



Users browsing this thread: 14 Guest(s)