scpcb icon indicating copy to clipboard operation
scpcb copied to clipboard

Fixes/improvements to map generation

Open ChronoQuote opened this issue 2 years ago • 9 comments

836ab8e6df72436ee55be20e2481adbf2c496791 Fix CalculateRoomExtents

shrinkAmount was applied before the potential min/max swap, resulting in room extents being larger than intended if the swap occurred. This fix resolves some instances of room overlap but not all.

6565fea09c37a7642edf7863fe91e6d8c9c27c06 Fix room2C forcing

After generating the facility layout, the game tries to force a room2C (corner tile) into each zone that doesn't have one. To do this, it finds a room1 (dead end tile) and checks whether there's space to extend it one tile forward then one tile sideways, forming an L shape. But it wasn't checking the correct spots to determine whether there's space, so sometimes the L would graze by another room1. Luckily, room shapes are recalculated when rooms are created, so the room2C would end up being a room3 (T-shaped tile) and the grazed room1 would end up being a room2 (hallway tile). However, room assignment still expected the additional room2C and room1, and so those tiles' room assignments got pushed to the next available room2C and room1, meaning not only that those rooms likely ended up in the wrong zone, but also that the very last room2C assignment (usually room2ccont, the electrical center, required to beat the game) and the very last room1 assignment (usually gateaentrance, required for two endings and for the MTF to spawn) never occurred.

I used a seed checker I created to check 10000 seeds before and after the fix. The fix reduced the ratio of unbeatable seeds from 5.28% to 3.72%. I hope to use this branch to reduce this ratio even further (without rewriting the whole map system).

Here's seed "n790" before the fix: image

Notice that coffin and room2cpit, both HCZ rooms, are in EZ. Also notice that gateaentrance and room2ccont are missing. These problems were all caused by the forcing of a room2C just north of the room4 (four-way tile) in the center of the image.

Here's what that area looked like before the forcing: image

The room1 north of the room4 is selected as a candidate for extension into an L shape. To determine which way the room1 could be extended, the game checks these four spots: image

The southern spot is occupied, so the extension would be northward. To determine whether there's space, the game first checks these three spots: image

They're empty, so to determine whether there's space to extend east after extending north, the game checks these three spots: image

Some are occupied, so to determine whether there's space to instead extend west after extending north, the game checks these three spots: image

They're empty, so the extension is performed, resulting in what we see in the final image.

With the fix, after the extension direction is determined, these are the spots that get checked for forward extension: image

And if they're empty, these are the spots that get checked for sideways extension: image image

In this case, the forward extension check fails.

Here's what "n790" looks like after the fix: image

Much better!

ChronoQuote avatar Sep 05 '22 11:09 ChronoQuote

Is the custom map size up to date? Better to make MapSize as constants

Jabka666 avatar Sep 05 '22 15:09 Jabka666

98409ede0b8fe774ef61f880e39392ffc92b2ab0 Fix custom map sizes

  • Fix GetZone incorrectly using MapWidth instead of MapHeight
  • Make random hallway width dependent on MapWidth to fix maps remaining narrow despite a high MapWidth; the multipliers 0.6 and 0.85 were chosen as they are the only multiples of 0.05 that allow the two expressions to resolve to 10 and 15 when MapWidth is at its intended value of 18
  • Split "map size" options.ini option into "map width" and "map height" options to increase customizability

Before: Fix custom map sizes (before 1) Fix custom map sizes (before 2)

Notice the zone sizes and amounts of checkpoint (green) rooms. Also notice how much of the width-40 map the facility actually occupies.

After: Fix custom map sizes (after 1) Fix custom map sizes (after 2)

ChronoQuote avatar Sep 05 '22 20:09 ChronoQuote

Will you remove disableoverlapcheck parameter for room966?

Rooms with geometry far below or far above them, like room049 or room3storage, have disableoverlapcheck = true. For some reason, room966 has this random geometry below it: image I heard it's actually a piece of room049, but I don't know why a piece of room049 is in room966. I think it should be removed from the mesh before disableoverlapcheck = true can be removed.

ChronoQuote avatar Sep 24 '22 13:09 ChronoQuote

  • Optimized room;
  • Removed extra r\Objects;
  • Disabled disableoverlapcheck parameter because I removed a lower extra part. I took room966 from UE, so a room with red lights is slightly changed. Because of that I moved security camera and NVG positions and replaced monitor image in SL_monitors. Before: Untitled3 Untitled4 After: Untitled Untitled2

Jabka666 avatar Oct 01 '22 09:10 Jabka666

  • Optimized room;
  • Removed extra r\Objects;
  • Disabled disableoverlapcheck parameter because I removed a lower extra part. I took room966 from UE, so a room with red lights is slightly changed. Because of that I moved security camera and NVG positions and replaced monitor image in SL_monitors.

I think you should've put this room966 update in a separate branch. This branch is for map generation fixes. The fact that room966 has disableoverlapcheck=true is pretty inconsequential and doesn't need to be fixed in this branch if it means changing the way room966 looks.

Because your room966 has a different amount of room lights (7 instead of 5), the RNG function will be called a different amount of times when room966 is generated. This means seeds will now contain different rooms than they used to.

ChronoQuote avatar Oct 22 '22 21:10 ChronoQuote

  • Optimized room;
  • Removed extra r\Objects;
  • Disabled disableoverlapcheck parameter because I removed a lower extra part. I took room966 from UE, so a room with red lights is slightly changed. Because of that I moved security camera and NVG positions and replaced monitor image in SL_monitors.

I think you should've put this room966 update in a separate branch. This branch is for map generation fixes. The fact that room966 has disableoverlapcheck=true is pretty inconsequential and doesn't need to be fixed in this branch if it means changing the way room966 looks.

Because your room966 has a different amount of room lights (7 instead of 5), the RNG function will be called a different amount of times when room966 is generated. This means seeds will now contain different rooms than they used to.

Isn't that easier to reduce lights amount?

Jabka666 avatar Oct 23 '22 10:10 Jabka666

Isn't that easier to reduce lights amount?

Not sure what you mean. Feel free to edit the room so that it has 5 lights instead of 7 if you would like to. I was just suggesting that these room966 changes be in a separate PR.

Edit: Jabka and I agreed to revert the changes.

ChronoQuote avatar Oct 23 '22 17:10 ChronoQuote

Btw, you can add "room2toilets" to forced rooms list in entrance zone. Generator creates most of maps with no toilets at all, making 100% walkthrough impossible due to "by researcher james..." achievement.

Sooslick avatar Feb 07 '23 12:02 Sooslick

8c7381b Revert "Merge pull request #3 from Jabka666/Fix-for-room966"

This reverts commit 2909285, reversing changes made to f47eafd.

13a51b6 Fix/improve ranges of room-forcing code

After preliminary map generation, some code tries forcing more room1s, room4s, and room2Cs into each zone if necessary. The room1 code scans for empty spaces to turn into room1s, while the room4 & room2C code scan for rooms to extend in such a way to create a room4 or room2C.

The ranges of the room1- and room2C-forcing code were a bit small, so some seeds didn't generate enough room1s or room2Cs even if there was space. Many important rooms (like room2ccont) are room1s or room2Cs, so this is arguably one of the biggest issues with the live game.

Meanwhile, the range of the room4-forcing code was quite big, so extensions would sometimes be performed past zone boundaries or into the outer edges of the map, which (via some other factors) led to issues like SCP-895's chamber being placed deep in the Entrance Zone, or SCP-372's chamber taking the place of the start room.

These changes make the ranges of the room-forcing code as large as they can be without causing issues, thus solving/mitigating the problems mentioned above. See commit for more info.

Range of the room1-forcing code before and after these changes: room1 Regions Before room1 Regions After An extra condition had to be added to ensure that a room1 could only be forced into the bottom row of zone 1 or 2 if it is attached to from above instead of from the side or below. The bottom row of zone 0 is still off-limits because forcing a room1 there could change the position of the start room, which was an issue with the room4-forcing code. Stats from 100000 random seeds before and after these changes: room1 Stats Before room1 Stats After

Range of the room2C-forcing code before and after these changes: room2C Regions Before room4 & room2C Regions After This code looks for a room1 in these regions to extend into a hook-like shape containing a room2C (see the first comment on this PR for details). A boundary is colored blue if the code is allowed to extend across it, or red if not. Previously, all boundaries were blue, which might be why the regions were made so small. A handful of extra conditions had to be added to achieve the red boundaries of the new, larger regions. (And although it's not clear from the picture, a room1 can't be extended out and around the corner of any of the new regions. Pretend the red lines are infinitely long.) Stats from 100000 random seeds before and after these changes: room2C Stats Before room2C Stats After (No more seeds missing the electrical center!)

Range of the room4-forcing code before and after these changes: room4 Regions Before room4 & room2C Regions After This code looks for a room3 in these regions to extend into a room4. Boundaries are colored as before. Previously, all boundaries were blue and the regions were quite big, which led to the issues with room4-forcing mentioned earlier. A handful of extra conditions had to be added to achieve the red boundaries of the new regions. While the issues are now fixed, the spawn frequency of room4s has unfortunately decreased, but luckily no room4s in the game are tied to progression or achievements. Stats from 100000 random seeds before and after these changes: room4 Stats Before room4 Stats After A way to increase the spawn frequency of room4s again in zone 0 could be to find a way to fix the position of the start room so that a room3 extending into the bottom row isn't an issue.

Example seeds before and after these changes (open for more detail): c3jdfxea Was missing room2ccont, 008, room035, and coffin.

03deisj coffin was deep in zone 2 and room1lifts was accessible from zone 1.

v80yd02 roompj took the place of start and zone 1 had no room2C.

ChronoQuote avatar Sep 15 '23 20:09 ChronoQuote