Advanced Random Cells

0 favourites
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Is there any way to get cell data from the cellular, or Voronoi noise in the Advanced Random plug?

    The xy values don't seem to be that useful for those types of noise.

    What would be nice is the xy of the cell center, and xy of the vertices.

  • I also ran into this logical roadblock when dabbling with procedural generation. How to get nodes and edges from a procedural Voronoi map? The data is there but how to get to it to utilize it...

    I think if I had continued I would tried layering it on top of another procedural map, for example terrain/elevation, to further further modify the elevation values or add terrain features to suit a particular biome, based strictly on the value returned by the Voronoi noise at each coordinate.

    Another idea I had, if using the Voronoi noise pattern to define spaces like on a board/tactical game for example, would be to use some sort of flood fill algorithm on any given spot until the returned value changes. Then at least I would be able to get the top/bottom/left/right bounds of any cell area, and maybe use the center of that as a node position. Defining edges between nodes should be simple enough from there.

    For a more accurate node position, you might be able to count and weigh the number of tiles/pixels in any particular cell and see how many fall in each quadrant relative from the "center". That might be just running the actual Voronoi noise algorithm backwards, I don't know. The formula should be out there.

    No ideas on how to get vertices and their edges though, to draw borders between cells or implement something like a river between biomes...

    Sorry if this doesn't help much, just thinking out loud. I didn't get very far in my experiments myself. I suspect you'll find more insight at /r/proceduralgeneration/ than on these forums, even if they aren't familiar with Construct. They would probably have more ideas and experience on how to use and apply the results by themselves even when the generation of the noise is obfuscated.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • From what I know about Voronoi a "simple" method would be to create a point cloud where they're all constrained a certain distance apart, like circles. You then take each point and find all the points around it. Those points would then tell you the vertices if you look at where the circles would intersect.

    And when I say simple, I mean its actually a little complicated to do and record for that matter.

  • DiegoM Any idea if that data can be exposed in the plug?

    I don't want to reinvent the wheel.

  • Thought about this some more... Since cellular noise and Voronoi noise using the same seed results in the same cells, you can run a search from any given point using the cellular noise data. Check each adjacent pixel (or other arbitrary resolution) from that point to see which has a higher value, loop until you reach the highest value. That would be the origin of that cell, which can be transposed on to the Voronoi noise map.

    If you have a set of node coordinates for each cell, you can use Delaunay triangulation to build a second set of coordinates, which would be the vertices. From those you can define edges which would be the cell borders.

  • If I had to guess I'd say it is possible to add what you want. If I were to do it though, I would need to first understand the subject. I really have no idea about noise and it has never been something which I found particularly interesting.

    If there wasn't anything else for me to do, I wouldn't mind giving it a try. But I already have a bunch of other things waiting to be done.

    So I guess you will need to re-invent the wheel? It would probably be faster than waiting for me to figure out all that stuff.

  • Ahh, OK I was hoping the noise plug might have had the data already.

  • I got the cell centers. Next to get the vertices. dropbox.com/s/dr6abkphr8k4egd/Noise%20graph.c3p

    reddit.com/r/proceduralgeneration/comments/mriko7/reverse_worleyvoronoi_noise

    Basically followed the first reply for finding the local minimum by checking each adjacent pixel iteratively. Might be resource intensive to do so in real time? But should be negligible if you do it one time on start of layout to build an array with all the node coordinates.

    The second reply would be how to proceed to get vertices.

    Third reply seems to be an elegant way to extrapolate the nearest minimum or maximum by just comparing the neighbors of a single point and their slopes. I vaguely understand the concept, but haven't really wrapped my head around how to implement it.

  • Thanks. I'll take a look at it, but I'm pretty sure I'll have to make my own point cloud, and go from there.

    R0jOhound made a nice even distribution project a while back, and I'm taking a look at it for a starter.

  • Turns out creating a polygon is a bit tricky. I can figure out the vertices, but getting them in order is another matter.

    I used for each in order angle(vertex.x,vertex.y,cell.x,cell,y) asending, and it gave interesting results.

    Picasso would be proud.

    dropbox.com/s/oitrhexfiaruche/voronoistart.c3p

    I'll do a non half-assed version using raycasting later.

  • I found en.wikipedia.org/wiki/Fortune%27s_algorithm when reading about Delaunay triangulation, I don't know if you're familiar with it, but I think that's what you want for deciding which lines to draw to make polygons.

    Also after sleeping on it, I realized building the point set from the plugin is easier than I imagined. In the example project, every value is plotted one pixel at a time into the canvas object already anyways. It should be simple to add a check for each pixel when drawing it. If it has no neighbors with a value lower than it, push that coordinate into an array. You'll then have an array with all the cell centers coordinates within the bounds of your relevant noise area, which you can use to moveto, snap to, draw on, run Delaunay triangulation or Fortune's algorithm on, ect.

    If you're following www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/, and want more control over the randomness distribution, I believe you need to run the Lloyd relaxation algorithm on the points before the noise is generated and then apply your own noise algorithm on those points afterwards. This won't work with the advanced random plugin, because that noise map would not take into account the new "relaxed" points. On the other hand, it LOOKS like (Nepeo?) already baked in one or two iterations of it into the advanced random plugin for cellular/Voronoi noise, since those don't look quite as clumpy as completely random nodes.

  • Not sure which plug is Nepeo's. I don't see anything on the addon exchange, not to mention its hard to figure out what plugs are still viable after the modules update.

  • I meant I suspect the official advanced random plugin was developed by Nepeo, since he was the one that wrote the blog post for it when it came out. But I think he's not with Scirra anymore?

  • Ahh, of course. Can't even find where to get support for the official plugs.

  • I've updated the example to include populating and displaying an array with the cell node coordinates.

    Unfortunately, after researching various Delaunay triangulation algorithms, I've found them to be beyond my ability to implement.

    I did find a JS library of Fortune's algorithm, which should work nicely. github.com/gorhill/Javascript-Voronoi/blob/master/rhill-voronoi-core.js

    Now to learn how to utilize external libraries in C3...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)