How does level gen work?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wobbly
    Prophet
    • May 2012
    • 2633

    How does level gen work?

    Are there paramaters to adjust the size? Or the number of rooms? Is there an easy way to say, make the 1st ten levels small levels?
  • Huqhox
    Adept
    • Apr 2016
    • 145

    #2
    That's not a bad idea. Make the first 10 (or whatever) levels around half the size. You'd still have the gradual introduction for new players but without them getting bored exploring the whole of a full size level (which they will because that is how other games work)
    "This has not been a recording"

    Comment

    • luneya
      Swordsman
      • Aug 2015
      • 279

      #3
      Plus, even for those of us who plan to dive rather than exploring (strictly speaking, it doesn't matter which you do on the early levels, which are low risk-low reward propositions; I usually wait just long enough for the level feeling to tell me if an artifact or extreme ood treasure was generated, because hanging around isn't risky), big levels impede diving because you often have to explore the whole thing just to find the damn downstair.

      Comment

      • Nick
        Vanilla maintainer
        • Apr 2007
        • 9648

        #4
        lib/gamedata/dungeon_profile.txt has the names of all the possible level types - currently levels are roughly half classic, half modified, with the occasional cavern or labyrinth. Then src/gen-cave.c has generation functions for each of these, named classic_gen(), modified_gen(), etc.

        Level sizes are set at the start of the generation functions.
        One for the Dark Lord on his dark throne
        In the Land of Mordor where the Shadows lie.

        Comment

        • wobbly
          Prophet
          • May 2012
          • 2633

          #5
          Thanks Nick! Much appreciated, I'm sure I'll end up asking a lot of these annoying question about where things are (though I've worked out that most of them say what they contain when I open them).

          Anyway I tried comparing Os code here & woah a lot's changed.... but not? At least it seems to do the same thing organized much differently? So if I find the right no.s for O & find where they go in V it should generate an O-level? Anyway I've downloaded Sils code & while I suspect it'll have some hackery to generate forges I might be able to pinch the numbers from there & see if it'll generate a Sil sized level.
          Last edited by wobbly; July 7, 2018, 18:13.

          Comment

          • Pete Mack
            Prophet
            • Apr 2007
            • 6883

            #6
            I looked it up.

            Code:
            ^;
            is the inscription for 'do not attack' as of V2.8

            Comment

            • Ingwe Ingweron
              Veteran
              • Jan 2009
              • 2129

              #7
              Originally posted by Pete Mack
              I looked it up.

              Code:
              ^;
              is the inscription for 'do not attack' as of V2.8
              Just tried it.... Not quite. ^; inscription prevents walking, which I suppose works for the unintended digger situation, but little else. It won't work for the unintended ESP swap weapon or the pure pacifist.
              “We're more of the love, blood, and rhetoric school. Well, we can do you blood and love without the rhetoric, and we can do you blood and rhetoric without the love, and we can do you all three concurrent or consecutive. But we can't give you love and rhetoric without the blood. Blood is compulsory. They're all blood, you see.”
              ― Tom Stoppard, Rosencrantz and Guildenstern are Dead

              Comment

              • wobbly
                Prophet
                • May 2012
                • 2633

                #8
                Ok, turns out half of this is simple? There's already a scaling factor based on depth in there. Of course it ends up generating too many stairs & you get all of the dogs on top of you at once, but hey fun right? Not sure whether it's easier spliting the smaller levels off into there own category or trying to get the scaling factor to scale terrain & monster placement as well.

                Edit: Maybe I can scale it by using the scaling % as a % chance of rejecting a placement, that may not be too hard?

                Comment

                • wobbly
                  Prophet
                  • May 2012
                  • 2633

                  #9
                  so if I change:
                  Code:
                  /* Scale the level */
                      i = randint1(10) + p->depth / 24;
                      if (is_quest(p->depth)) size_percent = 100;
                      else if (i < 2) size_percent = 75;
                      else if (i < 3) size_percent = 80;
                      else if (i < 4) size_percent = 85;
                      else if (i < 5) size_percent = 90;
                      else if (i < 6) size_percent = 95;
                      else size_percent = 100;
                  	y_size = z_info->dungeon_hgt * (size_percent - 5 + randint0(10)) / 100;
                  	x_size = z_info->dungeon_wid * (size_percent - 5 + randint0(10)) / 100;
                  to
                  Code:
                  /* Scale the level */
                      i = randint1(10) + p->depth / 9;
                      if (is_quest(p->depth)) size_percent = 100;
                      else if (i < 8) size_percent = 75;
                      else if (i < 9) size_percent = 80;
                      else if (i < 10) size_percent = 85;
                      else if (i < 11) size_percent = 90;
                      else if (i < 12) size_percent = 95;
                      else size_percent = 100;
                  	y_size = z_info->dungeon_hgt * (size_percent - 5 + randint0(10)) / 100;
                  	x_size = z_info->dungeon_wid * (size_percent - 5 + randint0(10)) / 100;
                  it shouldn't generate a full size level for the 1st 17 dungeon levels?

                  Comment

                  • t4nk
                    Swordsman
                    • May 2016
                    • 336

                    #10
                    Originally posted by wobbly
                    it shouldn't generate a full size level for the 1st 17 dungeon levels?
                    Well it can still generate 99% size (95 - 5 + 9). And even 70% is not all that different from full sized level... There is also classic_gen(), where similar calculations don't seem to do much (just something about num_rooms). Maybe try a lot more aggressive scaling? For stairs, see calls to alloc_stairs(), you can use "i" to determine the desired number of stairs, e.g.
                    Code:
                    if (i < 2) alloc_stairs(c, FEAT_MORE, 1);
                    else if (i < 5) alloc_stairs(c, FEAT_MORE, 2);
                    else if (i < 12) /* and so on */;
                    A cleaner solution would be to introduce new profiles for small and medium levels. How's your C already? Generating dungeons is a good excercise, IMO

                    Comment

                    • Sky
                      Veteran
                      • Oct 2016
                      • 2321

                      #11
                      Didnt it once exist an option to "always generate interesting levels" ??

                      Not sure exactly what that did though, because in those days i would just die every five minutes.
                      "i can take this dracolich"

                      Comment

                      • Derakon
                        Prophet
                        • Dec 2009
                        • 9022

                        #12
                        Originally posted by Sky
                        Didnt it once exist an option to "always generate interesting levels" ??

                        Not sure exactly what that did though, because in those days i would just die every five minutes.
                        Some ZAngband-derived variants have an "always generate unusual rooms" option that causes all rooms to be vaults, moated rooms, or other templated rooms. Mostly vaults.

                        Way back in the day Vanilla (and many variants) had an autoscummer that would regenerate levels until the level feeling was high enough -- note that this level feeling incorporated both item quality and monster power.

                        Comment

                        • wobbly
                          Prophet
                          • May 2012
                          • 2633

                          #13
                          Originally posted by t4nk
                          Well it can still generate 99% size (95 - 5 + 9). And even 70% is not all that different from full sized level...
                          I guess the issue is a 70% sized level is not much smaller but 10/7x the monster density is a fair amount. I haven't looked at monster placement yet to see how much of an issue there is. There's actually a whole bunch of stuff that behaves a little oddly if I shrink those numbers too far. I'll see how much I can get away with without major fiddling.

                          Originally posted by t4nk
                          A cleaner solution would be to introduce new profiles for small and medium levels. How's your C already? Generating dungeons is a good excercise, IMO
                          Yeah I'll make it a separate profile. I'd like to do some playing here anyway, there's a bunch of stuff it can do that isn't used much. For instance you can add gens that will only crop up 1 in 200, so you can have profiles that you're unlikely to see in a single play through for instance. My C is non-existent, but a little less non-existent then a week ago. It's enough to be able to play around a bit there & compile.
                          Last edited by wobbly; July 15, 2018, 03:16.

                          Comment

                          • t4nk
                            Swordsman
                            • May 2016
                            • 336

                            #14
                            Originally posted by wobbly
                            I guess the issue is a 70% sized level is not much smaller but 10/7x the monster density is a fair amount. I haven't looked at monster placement yet to see how much of an issue there is. There's actually a whole bunch of stuff that behaves a little oddly if I shrink those numbers too far. I'll see how much I can get away with without major fiddling.
                            Hmm, that's a good point. It also occured to me that 70% size horizontally AND vertically will produce 1/2 sized level overall ((0.7 * x) * (0.7 * y) == (0.7 * 0.7) * (x * y) == 0.49 * x * y).

                            Yeah I'll make it a separate profile. I'd like to do some playing here anyway, there's a bunch of stuff it can do that isn't used much. For instance you can add gens that will only crop up 1 in 200, so you can have profiles that you're unlikely to see in a single play through for instance. My C is non-existent, but a little less non-existent then a week ago. It's enough to be able to play around a bit there & compile.
                            Looking at how dungeon generation works, it seems you need to do these things to add a new profile:
                            1) Add the profile to lib/gamedata/dungeon_profile.txt. Just copy and paste an old profile and rename it to something else (let's say, "small").
                            2) Add the profile to list-dun-profiles.h. For example, DUN("small", small).
                            3) Add the profile building function to gen-cave.c. Again, just copy, say, modified_gen() and rename to small_gen().
                            4) Maybe also change something in choose_profile() (generate.c)
                            5) Tinker with this stuff, until it does what you want...

                            Comment

                            • fph
                              Veteran
                              • Apr 2009
                              • 1030

                              #15
                              In the labyrinth generation, there is a line of code that scales the number of monsters by the level size:

                              Code:
                                  /* Scale number of monsters items by labyrinth size */
                                  k = (3 * k * (h * w)) / (z_info->dungeon_hgt * z_info->dungeon_wid);
                              It seems like this line ensures that a labyrinth has 3x the "monster density" of a normal level (correctly scaled with its area as t4nk and wobbly observed).

                              Maybe it can simply be copied also in the other profiles, without the 3?
                              Last edited by fph; July 15, 2018, 11:10.
                              --
                              Dive fast, die young, leave a high-CHA corpse.

                              Comment

                              Working...
                              😀
                              😂
                              🥰
                              😘
                              🤢
                              😎
                              😞
                              😡
                              👍
                              👎