OpenApoc does not generate the full range of OG maps for each mission

Created on 28 Jun 2019  ·  3Comments  ·  Source: OpenApoc/OpenApoc

As referred to specifically regarding Slum Maps in #396 it appears the problem with OpenApoc not generating the full range of maps for each building and area type is across the board

There are a considerable number of options that OpenApoc should be able to create, but it does not appear to

@Istrebitel 's youtube videos also show that in his OpenApoc builds at least, the map generator was creating more varieties of combat zone... This never appears to have made it to trunk or has been disabled since it was tested

Further investigation is required

Ideally, we should offer all the map combinations that OG did, but also allow more possibilities and variety of map sizes

It appears maps were scaled according to squad size in OG, but with a "random" element that meant that small squad numbers could rarely still end up on a very large map....

!BUG! low priority Enhancement Feature Request Help Wanted

Most helpful comment

Further update from istrebitel

Yeah I think I almost got to that - larger maps for larger enemy counts.
The way spawning agents works is that maps are separated into LOS
blocks, which are used for pathfinding, LOS calculations and for
spawning all at the same time. Every tile in a map block belongs to
one of the LOS blocks, which are all box shaped. Then there's a global
setting whether you can exit or enter the map on certain edge, for
every map. Based on this, LOS block is either eligible or not to spawn
units of certain allegiance. There is a set of values set in the block
that govern this. Those values should be described somewhere on the
forums or in the txt files attached to the project. If I remember
correctly, there are block spawn values for player units, alien units,
hostile units, civilian units, maybe civilian x-com personel has a
separate one, maybe not, that I don't remember, and I do remember
there is a special block for spawning queen.

So, the way to chose map size based on squad size would be to either
intelligently study the blocks and see which block provides how many
spawning opportunities and judge based on that, or maybe the vanilla
just had a hardcoded hack akin to"if more than X then use Y size"

Also one thing to note, I don't think I solved this problem, the way
some blocks are made, spawn points of hostile parties can be in LOS of
each other, like MARSEC warehouses, for example, you can often see a
lot of marsec security spawn points from entry points. The game
somehow ensures that there is never such a situation that you spawn in
LOS of an enemy. You can spawn back to back, meaning,once your units
move a bit they see each other, but you cannot spawn with enemy
already in LOS. Logically, it should follow that the game somehow
excludes spawn points or LOS blocks based on wether this block is
observed by already spawned unit. Logically then, it may happen that a
theoretical open field map is generated, which on paper has enough
spawn points to spawn all the participating units, but then does not
have enough blocks to spawn every unit because any unit spawned sees
the whole block. I think in vanilla there were no such open field
blocks, so this would never happen, but with modding this most likely
will and we have to be ready for that.

All 3 comments

Here's the response from Istrebitel on map generation

from what I remember, there's a list of blocks in the original game files, like, 9 or 18 different blocks for slums, with each block having min and max number of occurences, and map size itself being defined having a min and max possible size. Then the generator randomly picks and matches blocks together which results in a random map.

To force OpenApoc to generate maps of huge or tiny size you'd edit these "amount of blocks XYZ" numbers, wherever it reads them from, or just quickly change them in code (read a static instead of reading from file, i.e., always generate a 4x4x1 map of slums, instead of generating whatever's set for slums in the files).
More detailed explanation would be:

  • Every map has its own chunk size
  • Every map is built of blocks. Blocks are templates - different kinds of slum sectors, for example, or different kind of x-com base blocks. These are put together randomly to form a map
  • Blocks have a variable size in chunks. For example, there is a tileset, luxury appartments i think, which has a 1x1x2 block (a lift), a 1x2x1 block (a corridor) and many 1x1x1 blocks (appartments themselves). UFOs are simple 2x2x2 maps which feature only one 2x2x2 block. Etc.
  • Every block has a min and max occurence. For the luxury appts example, a lift block will have a min occurence of 1, otherwise a map without this block could get generated, and floors would be
    inaccessible without terrain destruction as there's no lift, only appartments and one-level corridors
  • Every map has a min and max size on all axes, in chunks (or maybe it just randomly adds or subtracts 1 to typical chunk size? I don't remember)
  • The algorithm of map generation is unknown, was not reverse engineered, so I built it from scratch, and it seemed to work close to vanilla
  • AFAIK, my algorithm first goes and makes a list of manadatory blocks and places them all randomly
  • Then it makes a list of remaining blocks (remaining max occurence>0) and places one of these blocks randomly until map's done
  • If it can't place, it shuffles around to make room, like tetris (but usually this never happens)
  • If it can't make a map, it retries with other sizes
  • Then gives up and spits error (usually this is never reached with vanilla map templates)
  • When it placed all blocks, it then generates the map itself
  • creates the map object and fills the map with objects based on the blocks (the walls, decorations, item spawn points etc.)

Further update from istrebitel

Yeah I think I almost got to that - larger maps for larger enemy counts.
The way spawning agents works is that maps are separated into LOS
blocks, which are used for pathfinding, LOS calculations and for
spawning all at the same time. Every tile in a map block belongs to
one of the LOS blocks, which are all box shaped. Then there's a global
setting whether you can exit or enter the map on certain edge, for
every map. Based on this, LOS block is either eligible or not to spawn
units of certain allegiance. There is a set of values set in the block
that govern this. Those values should be described somewhere on the
forums or in the txt files attached to the project. If I remember
correctly, there are block spawn values for player units, alien units,
hostile units, civilian units, maybe civilian x-com personel has a
separate one, maybe not, that I don't remember, and I do remember
there is a special block for spawning queen.

So, the way to chose map size based on squad size would be to either
intelligently study the blocks and see which block provides how many
spawning opportunities and judge based on that, or maybe the vanilla
just had a hardcoded hack akin to"if more than X then use Y size"

Also one thing to note, I don't think I solved this problem, the way
some blocks are made, spawn points of hostile parties can be in LOS of
each other, like MARSEC warehouses, for example, you can often see a
lot of marsec security spawn points from entry points. The game
somehow ensures that there is never such a situation that you spawn in
LOS of an enemy. You can spawn back to back, meaning,once your units
move a bit they see each other, but you cannot spawn with enemy
already in LOS. Logically, it should follow that the game somehow
excludes spawn points or LOS blocks based on wether this block is
observed by already spawned unit. Logically then, it may happen that a
theoretical open field map is generated, which on paper has enough
spawn points to spawn all the participating units, but then does not
have enough blocks to spawn every unit because any unit spawned sees
the whole block. I think in vanilla there were no such open field
blocks, so this would never happen, but with modding this most likely
will and we have to be ready for that.

Please see #396 for other stuff relating to this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quickmind01 picture Quickmind01  ·  3Comments

makus82 picture makus82  ·  3Comments

nbe-renzel-net picture nbe-renzel-net  ·  3Comments

BeornTB picture BeornTB  ·  3Comments

muton-commander picture muton-commander  ·  3Comments