Random map generator

By the way, when creatures are placed by RMG, i think it will be good to place them not totally random, but depending on terrain of faction (if not add voluntary field “terrain” to creature structure). Or make it an option.

There is such an option in template. Check Clash of Dragons.

By the way, now we have in templates records like “xl+u”, “m+l” for sizes of map.
This way there is no possibility to use custom size maps with more than one underground.
Is there are ideas how to make custom sizes possible?

My ideas:
Turn

"minSize" : "m", "maxSize" : "m+u",

Into

"minSize" : 64, "maxSize" : 72, "minDungeon": 0, "maxDungeon": 3 

So minSize is size in 64 squares, maxSize - in 72 squares. This will fit maps 64x72, 72x64, 64x64, 72x72.
minDungeon=0 means that it will fit map with no dungeons at all
maxDungeon=3 means that RMG can generate up to 3 dungeon levels choosing randomly (if in RMG dialog user selects “Dungeon”).

To buttons “S”,“M”,“L”,“XL” must be added “C” (custom size). In maps filters it will show all maps that are not S/M/L/XL.
In RMG settings tab when selected it will give dialog like “Choose resolution window”, where all availeble sizes allowed by current templates will be shown (with template name to the right) (or only non-standart sizes).

Like i make template with “minSize” : 1024, “maxSize” : 2048, than when pressing “C” i will get listbox with “1024x1024 (name of template)”,“1024x2048 (name of template)”,“2048x2048 (name of template)”, “2048x1024 (name of template)”.

What do you think?

We absolutely don’t need templates with this size in H3.

It was discussed many times - implementation of multiple levels is quite complex. How would Subterranean Gates work, for instance? What about Cartographers? Level switch button?

It also requires changes in map format and pathfinder.

New map format itself has support of multiple level by design.

That’s simple. Press once and get to dungeon 1. Press next and go to next level. Press last and return to dugeon 1.
Same with surface levels (if there will be some)

How they work in HMM3. we get x,y coord for entrance and search most close subterra gate in all dungeons (or in z+1 dungeon).

Let we have 3 gates on same x,y on 3 levels. How they should work?

On surface level 1 you enter gate, and it leads you to level n-1 (to subterra level 1).
On subterra level 1 you again press space and gate leads you to level n-2 (to subterra level 2).
On subterra level 2 you press space and get back in subterra level 1, then to surface.

What if subterra level 2 has only 1 gate, and subterra level 1 has 2 gates (map editor was not able to do good map)? You can make reverse check. Is this level 2 gate is closer to first gate on level 1 than to second gate, it will only work with first gate.

Another way is to have subterra gates like monoliths - add several types of them and use only subgates of same type.

This is the only way that will work with different amount of gates in levels. Also it will require many types of gates. IOW we need to implement advanced teleport mechanics for sub-gates first (make them equal monoliths but retain compatibility with original or make them configurable - explicit teleport channel). Only when it will work for 2 levels, we can go forth. (Same for cartographers)

Pathfinder will just work. Though as mentioned already subterranean gate would need rework.

New templates, 150 of them! With new Hota, WoG and Axolotl creatures:

Nice! How to get’em?

Today I ran profiler and optimized some suprising parts of code. Generation time for Jebus XL+U was cut down by about 60%.
Further 40% could be improved by rewritting WeightedRule class from CMapEditManager. It uses a lot of expensive string copying and comparison, which should be replaced with enum or something.

Can water generation be expected in near future?

Well, I don’t have much time recently - better just polish existing game instead of adding new features.

I know very little about RMG code, but since you started to optimize it I gave it a try with Valgrind. Most interesting part of object creation already have your comment, but other weird thing I found is that TerrainViewPattern::WeightedRule::isStandardRule use quite a bit (5%+) of CPU time since on large map it’s called like 40-50 million times.

Can something like STRONG_INLINE help a bit there?

This function should be replaced with just one cashed field.

Implemented.
Reduced string usage and added caching for flipped patterns -> about 50% performance improvement.

One thing I wounder about with current git version of RMG.

Why every player-owned town have some impassable object right under the entry (where hero stay)?

I din’t know really. So far my interest was only to ensure zone passability.
Maybe it’s just optimal to route path diagonally.