?>
GTX0 NewestRepliesHottestMy Active
NIFE UpdatesRoadmapRequests | HelpDiscuss Game Worlds


Procedural generation can sometimes give some crazy unexpected results
Posted: Posted March 19th by Xhin

I decided to take my existing "biome" code in here:
http://gtx0.com/read/some-procedural-generation-ive-been-making-video
and make the X/Y coordinates (or modulos of them) dictate the parameters of the function.

this has given me some really crazy results:

















There are 11 Replies
Page:
1 2 Load all posts
settingsSettings

At this point I'm basically just plugging random numbers and functions into the formulas.







I guess the next logical step is to randomize everything.

Edited March 19th by Xhin
Xhin
Nature is beautiful

Randomized the parameters of the function. This is creating all kinds of crazy stuff now:









Posted March 19th by Xhin
Xhin
Nature is beautiful

Well, I've achieved my goal. I have absolutely no idea what to expect from the terrain generation now.



























Edited March 19th by Xhin
Xhin
Nature is beautiful

I can just barely make out the expression on the bottom of the pictures. Can you explain in some detail what determines the color of each cell?

Posted March 20th by EN
EN

I'll try to explain how the generation is done in the bottom three replies, since that does seem to be the most interesting and varied algorithm at the moment (though I'm working on the other ones too sooo)

Palettes

Each "dimension" is assigned 3 colors, or sometimes it gets 5-7 or 4 grayscale colors. Whatever amount of colors it has forms the dimension's "palette".

You'll also occasionally get colors outside the pallette -- these correspond to things you interact with in-game.

RNG Seeding

I have a function that I'll call the "seeding function" from now on. You pass it a list of numbers and it does this:

  • Start with the "universe seed" (some number from 1-99999999, or some other large amount of digits, I forget what).

  • For each number in the list, multiply it by a unique number (right now I'm just using 7,11,13,9,19,23) , and then add this to the seed.

  • Take this number, raise it to the seventh power.

  • Modulo this by 19650218.

  • Seed the mersenne twister with this number.

    Basic terrain generation

    Each cell has an X and Y coordinate, as well as a "dimension number". These get passed in a list to the seed function. Then some random numbers are generated to tell which color is generated in the cell.

    This gives you some basic terrain:



    As you move around, more cells get rendered. Despite how complex the code has gotten and despite the twister being reseeded 441 times per screen, this generation is extremely fast and I've been able to build some tools to zoom around each dimension without any lag whatsoever.

    More interesting terrain

  • Pick a number of times to pick a variable -- right now I've got this set to between 5-7 times.

  • A variable can be X, Y, X+Y, X-Y, any of those four things modulo a number from 10-100, or a number from 1-30.

  • Each variable has an "effect mix" which is somewhere between 50-100% (it favors 100%). An effect mix just makes the cool generation happen that much of the time, and the really random (in the pic above) generation happen the rest of the time. It adds a bit of noise to the generation.

  • If the variable is X, Y, X+Y, X-Y or one of those modulo something (like X%75), the variable is based on the X and Y coordinate of the cell.

  • These numeric variables (and their effect percentages) go into a different function:

    Sculpting function

  • The sculpting function takes each number in the list in turn and turns it into a "size" variable. It then modulos the x and y coordinate by size*2, and if that modulo is bigger than the size variable, it stops the loop. If it doesn't stop the loop, it plugs the size variable into the next stage of the sculpting function. So depending on the x/y coordinate you get some variable amount of sculpting.

  • The next stage takes each size variable, and does the seeding function on the dimension and (x/size)*(y/size). Basically it takes the random generation and scales it up, assigning size number of cells to each cell in the original generation.

  • After all of this is done, there are some secondary effects, like generating "rocks" some random number of cells (sometimes big, sometimes tiny). With the blown up cells you end up getting "pipes" when the colors don't match up.

    Since the "size" here is variable, sometimes depends on the x and y themselves, and happens a variable number of times, the generation can vary a lot depending on what those original 5-7 variables are. I guess tl;dr I have no idea how it works either.

    Here's some more interesting things I've found:

































  • Posted March 20th by Xhin
    Xhin
    Nature is beautiful

    Panorama shot because this place is just cool:



    Posted March 20th by Xhin
    Xhin
    Nature is beautiful

    I am very interested in terrain generation but I have no idea how what you’re showing here works. It looks cool, though. But I wish I could figure out how to use it or learn from it to make my own cool-looking stuff.

    Posted April 16th by chiarizio

    @chiarizio:

    If you're trying to do something conworlds-based, you might be interested in this portfolio project I finished up recently:
    http://gtx0.com/map/
    Help files:
    http://gtx0.com/j/mapgame/
    Uses a very different set of algorithms, which are explained in some detail in these files:
    http://gtx0.com/j/mapgame/continent-sculpting http://gtx0.com/j/mapgame/terrain-generation-ratios

    Posted April 16th by Xhin
    Xhin
    Nature is beautiful

    Thanks, @Xhin: !
    I’ll look into them.

    Posted April 16th by chiarizio

    I tried it out several times. Not sure yet.

    Posted April 17th by chiarizio

    @Xhin:
    I can’t figure out what some of the parameters do; in particular “island spread” and the parameters before it.
    There are other cases where I think I get a handle on each of two parameters individually, but then can’t figure out how they interact.


    Posted April 22nd by chiarizio
    Load next page Load rest of pages
    Reply to: Procedural generation can sometimes give some crazy unexpected results
    Enter your message here

    Site Rules | Complaints Process | Give Feedback Facebook Page
    GTX0 © 2009-2019 Xhin GameTalk © 1999-2008 lives on