1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Problem with procedural generating

Discussion in 'Programming' started by Seb8299, Oct 26, 2016.

  1. Seb8299

    Seb8299 Guest

    Hello,
    I've started to program a new game and tried to make a generated 2d top down map but I've no idea how to program one of these. Can anyone help me with this problem?

    I've made lots of experience with game maker and I'm familiar with arrays and for(i=0,i<10,i+=1) commands.
     
    Last edited by a moderator: Oct 26, 2016
  2. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,977
    Procgen is a huge topic and depends on what you want to generate; a dungeon, a continent, a game field, etc. But at its simplest it could be just looping through your map grid and randomizing content of each cell (which has its pitfalls like potentially walling in player's starting position).
     
    Seb8299 likes this.
  3. DariusWolfe

    DariusWolfe Member

    Joined:
    Sep 23, 2016
    Posts:
    32
    Yeah, you're going to need to provide a lot more detail on what you're looking for.

    One generic bit of advice is that you're going to want to take into account neighbors for just about any sort of procedural generation. I created a really, really basic 3D game that actually generated the rooms as you played, but it was a bear to ensure that it didn't block off previously placed entrances; There was a lot of "look up, down, left and right, make sure your randomized choice meshes well with any previously existing options"

    If it's generated once at the beginning, it's a bit easier, because you can block incompatible options, or have an instance regenerate itself if it conflicts with existing options.
     
  4. my version of a randomly generated dungeon uses a ds map that generates the middle cell,
    then adds the address of the neighboring cells that are randomly determined to be connected to a ds queue,
    then the script generates the cells at the beggining of the queue by accessing the neighboring cells, determining if they have been generated yet, if they have been, then connect or not connect depending on the data already there,
    if not generated choose(0,1) on that direction and if its a 1 add the address of the cell in that direction to the queue, and repeat for all cardinal directions :)
    using a single dsmap with a byte representing north,east,south,west (binary 0101 representing east and west doors open) as a single hexidecimal ($5)
    and using bitwise operators to extract the data works most efficiently for me.

    this version ive found leaves no errors at all :)

    im sorry that block of text is a bit info dense. i dont have my script immediately available to show so i just explained the theory
     
  5. Seb8299

    Seb8299 Guest

    I would have some kind of a 2d array which has procedurally generated values in it. Then I can assign room tiles to build my map or save this values for a later recreate from the same map.

    I know that the values in the array must be dependent on other random values to interpolate them in each position but I don't know how to code this exactly.

    Like I have:

    ...1 | 0.5 | 0.25 | 0.33
    0.7 | 0.33 | 0.45 | 0.78
    0.5 | 0.22 | 0.34 | 0.5
    0.7 | 0.44 | 0.26 | 0.19

    but just bigger ;-)

    and I can say:

    0 <= water < 0.33
    0.33 <= sand < 0.5
    0.5 <= grass < 0.8
    0.8 <= mountain <= 1
     
    Last edited by a moderator: Oct 27, 2016

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice