How does level gen work?

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

    #16
    Thanks will give that a whirl. Also starting to think what I want might be more like:
    Code:
    y_size = z_info->dungeon_hgt * (size_percent - 20 + p->depth / 4 + randint0(10)) / 100;
    x_size = z_info->dungeon_wid * (size_percent - 20 + p->depth / 4 + randint0(10)) / 100;
    That gives a range of 31%-82% on dlvl 1, the old sizes at dlvl 60, & around 20% bigger at dlvl 98 (the questor levels are set to 100%). The range is probably too big at dlvl 1 there so maybe I still have to split it off into another profile to get it right but I'll try this & see what happens

    Comment

    • wobbly
      Prophet
      • May 2012
      • 2631

      #17
      Code:
      y_size = z_info->dungeon_hgt * (size_percent - 20 + p->depth / 4 + randint0(10)) / 100;
      x_size = z_info->dungeon_wid * (size_percent - 20 + p->depth / 4 + randint0(10)) / 100;
      Ok dived through 20 levels & it pretty consistantly gave me around the max. size that'll fit on the screen. Sometimes smaller, sometimes a little bigger. Didn't manage to split it off into another profile, I got this on trying to compile:
      Code:
      DUN("small', small)
                   ^
      generate.c:65:25: nite: in definition of macro 'DUN'
        #define DUN(a, b) {a, b##_gen},
                              ^
      make: *** [generate.o] Error 1
      so I'm obviously doing something wrong there.

      Originally posted by fph
      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?
      Not unmodified (h and w are undefined in modified gen) but I'll see if I can work out the equivalent.

      Comment

      • wobbly
        Prophet
        • May 2012
        • 2631

        #18
        Ok it's this bit
        Code:
        /* General amount of rubble, traps and monsters */
            k = MAX(MIN(c->depth / 3, 10), 2);
        Code:
        /* Pick a base number of monsters */
            i = z_info->level_monster_min + randint1(8) + k;
        I'll work something out there

        Comment

        • t4nk
          Swordsman
          • May 2016
          • 336

          #19
          Originally posted by wobbly
          Ok dived through 20 levels & it pretty consistantly gave me around the max. size that'll fit on the screen. Sometimes smaller, sometimes a little bigger. Didn't manage to split it off into another profile, I got this on trying to compile:
          Code:
          DUN("small', small)
                       ^
          Looks like you have different kinds of quotes there? (double and single)

          Comment

          • Pete Mack
            Prophet
            • Apr 2007
            • 6883

            #20
            Yep. You want double quotes for a string (array of char) for that. Single quote for a single character.

            Comment

            • fph
              Veteran
              • Apr 2009
              • 1030

              #21
              Originally posted by wobbly
              Code:
              DUN("small', small)
                           ^
              generate.c:65:25: nite: in definition of macro 'DUN'
                #define DUN(a, b) {a, b##_gen},
                                      ^
              make: *** [generate.o] Error 1
              Ouch. You *need* a better editor. Anything with a decent syntax highlighting will color this line in a way that makes the wrong quote obvious. You risk wasting a lot of time unnecessarily otherwise.
              --
              Dive fast, die young, leave a high-CHA corpse.

              Comment

              • wobbly
                Prophet
                • May 2012
                • 2631

                #22
                Anything you'd recomend? Free and for windows?

                Got it to compile. There's a bit that needs to go in generate.h

                Comment

                • fph
                  Veteran
                  • Apr 2009
                  • 1030

                  #23
                  I'm not that expert on the Windows side of things, unfortunately, so probably you'd get better results by Googling around (e.g. https://www.slant.co/topics/795/~bes...r-c-on-windows)
                  I am now using Sublime Edit, which is sort-of free (has very occasional nag screens in the free version) and is available on Windows, too. I've heard good things about Notepad++, and Microsoft now has a free version of Visual Studio.
                  --
                  Dive fast, die young, leave a high-CHA corpse.

                  Comment

                  • wobbly
                    Prophet
                    • May 2012
                    • 2631

                    #24
                    Thanks will look round. Well I can change stuff and get it to compile so I can play here. You can enforce it to the early levels in generate.c just under where it picks the town. I might enforce a moria level and questor tag the balrog to see how that goes. There's stuff to play with for a bit.

                    Comment

                    • EpicMan
                      Swordsman
                      • Dec 2009
                      • 455

                      #25
                      Notepad++ is my go-to text editor. It has syntax highlighting, regular expression find and replace, and some pretty nice text manipulation tools in the TextFX plugin. It also has a compare plugin which is helpful.

                      Visual Studio is the only compiler I can use on my work computer, but be warned that it doesn't support a lot of newer (C99) C programming things that make compiling newer Vanilla or anything based on it a major problem. Notably, VS does not allow variable length arrays, i.e.
                      int size = 80;
                      char text[size];

                      You have to make a constant expression for it to work, i.e.
                      #define size 80
                      char text[size];
                      #undef size

                      Comment

                      • wobbly
                        Prophet
                        • May 2012
                        • 2631

                        #26
                        I'll look at notepad++
                        I've been compiling with mingw. Seems to work for me

                        Comment

                        • Gwarl
                          Administrator
                          • Jan 2017
                          • 1025

                          #27
                          Notepad++ is what I use in general, but I bite the bullet and use VS to work on composband code

                          Comment

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