SakeTami
Kyzrati
Kyzrati

patreon


Mapgen: Turning "Guaranteed" into GUARANTEED!

A rather well-known aspect of Cogmind's map generation among long-time players is that there are a handful of "semi-important" areas that may not actually appear in their respective maps even though you consistently encounter them across the majority of runs. They're not absolutely vital areas, and there aren't many of them, but they do get brought up in discussions when mysteriously absent since people expect them to be there, and see them there... most of the time.

While I generally like the idea of very occasionally not having access to a given expected feature ("forced adaptation" being a central goal of Cogmind design after all), leaving such instances to complete random chance rather than being an explicitly defined frequency (and probably less rare) inevitably means the experience is somewhat off. Moreover, these particular situations are not technically intended in the first place, just a side effect of rare map layouts and I'd simply accepted them as such because harnessing complete control could prove problematic... Not quite ideal on either point.

What I can do in such cases, and have in the past, is try to maximize the possibility that all "guaranteed" content will be there by 1) trying to ensure the map layout itself will be capable of inserting said content when the time comes and 2) increasing the priority of this sort of content to what eventually came to be known as "guaranteed" status (quotes included, I guess xD), essentially making sure that it gets first dibs on insertion into a new map, reducing the possibility of other random content blocking it out.

These two approaches combined tend to make it possible to fully guarantee some content, but some just don't work out. Others do: Technically RIF Installers under the 2.0 Garrisons have actually only been "guaranteed" to exist rather than 100% enforced, but it's basically impossible to not have one given the underlying map layout potential alongside giving them the "guarantee"-level priority.

Taking a step back real quick, here's a very short high-level summary of the Cogmind mapgen process to give a little more context:

Seeing as the first stage can be repeated as many times as necessary, truly guaranteed areas vital to a map are accounted for in that section, and if so then they will indeed exist. This includes areas such as the more obvious Materials exits to Mines, the Recycling entrance in Subcaves, the Recycling entrance in Storage, large 0b10 bases in Proximity Caves... As you can see these types of vital areas are often map connections, as they are rather integral to the level layout and the flow of exploration itself, or just outright intended to have a significant impact on the overall layout.

The second stage is where there's a much greater variety of content, but it is by then mostly subject to the already-defined map layout, embedded where possible and only allowed to make small local changes of certain types (I've written a lot about so-called encounter prefabs on my dev blog before, for example here, among other places).

So a problem arises when you want more naturally embedded content to be guaranteed, as the base layout may simply not be suitable. The answer is obvious: If one of these rare cases occurs, go back to the very beginning again. Easier said than done, of course, since that was never intended to be possible so you have years of architecture built on the assumption that a map would never need to be restarted after already reaching much further in the process.

Normally if you want this capability, you'll build it in right from the beginning, but having not done that I've generally tried to avoid the potential headaches that lie behind adding it, and it's never really been a major issue in the past anyway... Well, I decided to finally do something about it, for a couple reasons.

First, I needed something to write about and share since I've been working on top secret Beta 15 spoiler stuff for a while now xD

Second, in Beta 15 X1 I decided to finally split off that particular cache in that particular base from its owner, and doing so was better accomplished by using the encounter system rather than trying to squeeze it into the original map layout. I shrank it to make sure it would be more likely to fit somewhere, but as it turns out the generator cannot always find a suitable location and it therefore goes missing, and in fact has been doing so fairly frequently.

This is no good because that cache was intended as a guaranteed reward (even if the contents itself will vary somewhat), so there were two options: Just go back to the original design, or finally bite the bullet and allow mapgen to start from scratch again even after a bunch of content has been added and potentially affected the rest of the game data. (Aside: The main problem with the original design for that prefab was that it felt kinda weird taking from the cache with its owner right there, so there were always questions about it. While I'm sure there will still be the occasional question, the new arrangement will at least feel a lot more logical.)

Anyway, as with any such endeavor rooted in technical debt (not uncommon when you've been working on the same huge project for many years :P) I started by spending a couple hours reading through all the code that would be relevant, looking for issues that would likely need to be addressed. Upon finishing that review I was happy to learn that it didn't appear like it would be too big of a headache, at least not right away (too good to be true? xD). Then it took another day or so to implement a solution and put it through a bunch of tests... and it seems like we now have a truly guaranteed Garrison Access on -8/Materials, among other things \o/

It's not impossible there will be bugs in here (in fact it's probably likely :/), which is what kept me from doing it for so long (aside from the other reasons), but we'll see how it turns out and handle them as they come--automated tests uncovered some of the issues which I then resolved, but real playtesting might uncover more. Annoyingly these bugs would theoretically be more difficult to track down because they would only occur under even more unique and indirect circumstances, so I've tried to preempt this by adding information to make them easier to identify if that's the case.

Now that Cogmind is finally capable of identifying scenarios where a full mapgen restart is required later in the process, I thought it would be fun and interesting to have it collect a bit of data on just how prevalent these scenarios have been in the past. I ran 1,000 mapgen attempts of various target maps to count the number of times a failure occurred, and put together the following (abbreviations to avoid spoilers, as usual--if you know, you know):

Note that out of Cogmind's hundreds of encounters, only seven are "guaranteed" (now with 100% more GUARANTEE!), and some of those were already really never missing (e.g. RIF Installers, and I also ran a test on C potentially not having two seals but 1,000 maps all had both).

While there isn't massive need for this feature, at least it's now a thing and we don't have to deal with the potential confusion surrounding these scenarios, and could of course apply it to future map content if necessary.


More Creators