Advanced Random Tutorial

2 favourites
From the Asset Store
Carousel Animation, make carousel of you image gallery or anything
  • My tutorial for the new Advanced Random plugin is now live:

    https://www.construct.net/en/tutorials/getting-started-with-the-advanced-random-plugin-30

    I'm looking forward to seeing some cool creations!

  • My tutorial for the new Advanced Random plugin is now live:

    https://www.construct.net/en/tutorials/getting-started-with-the-advanced-random-plugin-30

    I'm looking forward to seeing some cool creations!

    This is amazing Nepeo. This is great for procedural generation.

    I never thought Construct would support this. First game I guess that users would try is minecraft map generation.

  • This is really cool and very useful. I hope feature releases include some Demo Projects to see examples of how they work in action, so we can tweak values and play around to get a better understanding.

    I would like to see how this kind of noise can be applied to a tilemap object etc, to generate a map landscape etc.

  • tunepunk check out this project

    dropbox.com/s/azb5fxpcfrzp6m0/animated%20terrain.c3p

    It's quite simple to apply to a tilemap really. For each tile you generate a value using it's position, then you do some sort of comparison against the value to decide what tile to place. The example checks if the value is greater than 0.5, and places a tile if it is.

    There's a lot of ways to decide what sort of tile to use. You could:

    - check what the tile above is ( it generates top to bottom so that's easy ). If air then grass, if grass then dirt, anything else then stone.

    - use different ranges from the noise for different materials. 0.5 <= value < 0.6 for dirt, 0.6 <= value for stone.

    - if the first noise value is over 0.5 then generate a second unrelated noise value to choose a tile

    I also put a couple of other tricks into that example. I multiplied the noise by the height so that a higher value is more likely lower down. You can do similar tricks for creating an island or a lake. Also I'm using a slice of 3D noise to animate it, not very practical in it's current form but it's a nice demo.

  • One feature I would point out is that its tileable.

    dropbox.com/s/yiujv18rzbsflok/noiseY.c3p

  • Just a thought, wouldn't it be cool if the different noise types were indexed?

    Like: AdvancedRandom( index, X, Y, Z)

    Index 0 gives billo, index 1 cellular, etc.

  • Really cool tutorial, thank you!

    But when I read about advanced random plugin, first thing I thought of was seeded random. Are there plans to add this feature?

  • dop2000 Glad you liked it, I've wanted to make this plugin for quite awhile so it's nice to hear it's appreciated. The plugin technically includes a seeded random, which is used for creating the noise. We're experimenting with integrating it with the System random expressions, which would be better than duplicating them in a different plugin. It's awkward to deprecate expressions so we didn't want to expose it on the new plugin just to remove it later.

    newt Yup! It is effectively "infinite" ( within numerical precision limits ) and also continuous. So tiles should be completely seamless, no matter when they are created!

    I'm not sure what adding an indexed version would gain, it's drops the event count on example projects that allow you to switch between noise types, but in real usage I'm not sure why you would want behaviour like that? You can emulate that behaviour by wrapping the noise expressions in functions, then when calling the function using a variable for the name. The plugin would be doing the same thing but in JS.

  • I'm not sure what adding an indexed version would gain, it's drops the event count on example projects that allow you to switch between noise types, but in real usage I'm not sure why you would want behaviour like that?

    To make it easier to compost the different noises together.

    Like the first part of a loop gets the z of one noise, the next another.

    If its too much to add I'm sure it would be easy enough to serialise it using Array instances.

    Although that does bring up the idea of treating the noise as an array.

    Giving it a for each, etc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Another demo: Terragen... sorta

    dropbox.com/s/3dfr910kk3ywo1z/terrarangen.c3p

  • dop2000 Glad you liked it, I've wanted to make this plugin for quite awhile so it's nice to hear it's appreciated. The plugin technically includes a seeded random, which is used for creating the noise. We're experimenting with integrating it with the System random expressions, which would be better than duplicating them in a different plugin. It's awkward to deprecate expressions so we didn't want to expose it on the new plugin just to remove it later.

    Nepeo In C2 I'm using this plugin for seeded random. It somehow integrates with all the system random events and expressions (random, choose, pick random instance etc). It would be great to have the same functionality in C3.

  • > dop2000 Glad you liked it, I've wanted to make this plugin for quite awhile so it's nice to hear it's appreciated. The plugin technically includes a seeded random, which is used for creating the noise. We're experimenting with integrating it with the System random expressions, which would be better than duplicating them in a different plugin. It's awkward to deprecate expressions so we didn't want to expose it on the new plugin just to remove it later.

    Nepeo In C2 I'm using this plugin for seeded random. It somehow integrates with all the system random events and expressions (random, choose, pick random instance etc). It would be great to have the same functionality in C3.

    I expect they just replace the JavaScript Math.random method with a seeded variation, that would modify the behaviour of the System expressions. I've seen some libraries which do this. It would be good to still have it available though, to ensure a good source of entropy for seeding.

  • Have you noticed any best practices for using advanced random for procedural? I am implementing a modular herring bone wang style map layout. i have been successful but noticed that loading arrays from jsons seemed to derail the consistency of the seeds. Perhaps because there is delay to read the files causing things to occur on inconsistent ticks? Therefor I preload all randoms as the very first thing..

    nothings.org/gamedev/herringbone

    I was loaging the next layout prior to changing the seed. This is not really an issue it seems.

  • Gillis PRNGs are basically just a (incredibly long) sequence of random looking numbers, given the same internal state asking for 100 numbers will always give you the same 100 numbers. But if you put in an extra request for a number it throws everything off by 1. You would get the values 1-100 instead of 0-99. So if the predictability of the value is important to your game you have to be careful about how you change the order and number of random number requests you make.

    Creating an array of random numbers ( referred to as a permutation table ) can help. The coherent noise methods ( classic2d, etc. ) use a permutation table of the values 0 to 255 in a random order (see Fisher-Yates shuffle).

    value = table.get(x % 256) + (y % 256) value = table.get(value % 256) + (z % 256) value = table.get(value % 256) return value

    For anyone not familiar the % sign is the modulo operator, it keeps the value between 0 and 255 in this situation.

    8 % 256 = 8

    256 % 256 = 0

    300 % 256 = 44

    514 % 256 = 2

    An alternative is to reset the state of the PRNG to it's initial value before each batch using

    AdvancedRandom.SetSeed(AdvancedRandom.Seed)

    That is quite slow, so try and not use it on your hotpath. It involves hashing the seed, regenerating the PRNG state and recreating the permutation tables. If enough people need that I would consider adding an action that specifically resets the state, but faster than the above method.

  • Neopeo,

    This is an excellent explanation. I will apply this logic. I reached a similar conclusion based on trial and error and am having a lot of fun with this plugin. It is very powerful

    Thanks,

    Gillis

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