• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
I can't generate the first batch I don't understand why, I got that : https://i.gyazo.com/3fb5855676c9418d736c148fa8492d79.png

Well you're out of memory. The program can use about 1 gigabyte of RAM (varies with the size of your map) so you need to make that much available to java. Personally I've never got an out of memory error using it. Another user reported no longer getting errors after installing 64 bit java instead of 32 bit. Otherwise you can use the tip posted here.
 
Alright it's late and I'm tired to delay this, so here is an update :
https://www.dropbox.com/s/p69o0ja257pdsry/CK2MapTools-V2.0.zip?dl=0

I expect there are still bugs.

Update notes for version 2.0 :
  • The tool now comes with a UI. It's basic and design is not my strong suit, but it should be better than a bunch of batch files.
  • Big refactor all around. Things should run slightly faster and on significantly less memory.
  • It is now possible to chain together mutliple batches. The UI is split in 3 categories : terrain, provinces and setup. For each one you can chain all the batches in that category, or run only a sub-selection, whatever you need.
  • Random world now works with toolmade maps in holy fury. It will generate a compatible alternate_starts/01_spread.txt when you generate adjacencies.
  • It is no longer necessary to modify the config.csv by hand, you can put the values direcly into the UI. The program will still use that file to load and save settings.
  • adjacencies generation has been greatly improved, it will only generate the minimum number of sea crossings necessary to link together all "islands".
  • sea zone generation now checks for "line of sight" and combines 2 methods to fill the water without going through landmasses.
  • A new tool is available, it can fill the settlements.bmp for you, saving a lot of time. It can also work from an existing map, filling only the empty areas. Can also generate sea zones.
  • DeJure map generation is now able to cross straits and major rivers. It reads from adjacencies.csv just like the game.
  • DeJure map generation can now generate empires by combining neighbouring kingdoms.
  • Tools now generate an unlimited number of backups when overwriting an input file. The old file is renamed using the current date and time.
  • It is no longer necessary to copy the provinces.bmp from the input to the output folder if you make manual modifications to it. All tools read from input and will copy to output.
  • Nomad government is supported (yellow color on government.bmp) but still doesn't work for me. Something else must be missing...
Here is an example of a map made using the tool, then run through Holy Fury's random world generation. It's a 6000+ province monstrosity that runs pretty bad but it's a proof of concept. The settlements, provinces and dejure maps were made by the tool :
z4pvuiV.jpg
 
Last edited:
It's great to see you make a UI! It might not look fancy but it's much more user friendly!
Really quick though, I noticed it generated a trade route in the input but we have no info on how to use that yet
Also do I place the output files in the LNLMOD folder with the .mod file again or did this rewrite new paths as well?
 
Last edited:
BTW, could you provide any concepts or directions to study myself the algorithm used for the generation of the colormap? Being new to the topic, and an autodidact, I'd like to understand that part of the program, but my wits are falling short it seems.

Yeah so at first what it did was for every pixel of the map, look at its terrain and climate, and put a predefined color there. The colors were picked by me by looking at the colormap from Paradox in various spots in the middle east, western europe and scandinavia. This was fine but it looked jarring wherever the climate abruptly changed. I tried to circumvent that by applying some blurring to the result image but it still wasn't good and it took too much time to process.

The new approach is two-steps. First it blurs the climate image a lot, and also cuts down its resolution by 4 times. This is done to speed up the loops. The main stuff is here :

Complicating matters is that I'm working with several images/arrays that are different sizes.
I'm going to assume Config.INPUT_MAP_SCALE = 2
Terrain.bmp is the reference, climate.bmp is 2 times smaller, and the temporary climateArray is 4 times smaller than that.

Code:
for (int x=0 ; x<loader.sizeX/4/Config.INPUT_MAP_SCALE ; x++)
   for (int y=0 ; y<loader.sizeY/4/Config.INPUT_MAP_SCALE ; y++)
   {
       int r=0,g=0,b=0,num=0;
The first loop (x,y) is going through every pixel in climateArray, which is 1/8 the size of the reference map (sizeX, sizeY)

Code:
     for (int rx=x-radius; rx<=x+radius;  rx++)
       {
           for (int ry=y-radius; ry<=y+radius;  ry++)
           {
               if (Coordinates.isValidCoordinates(rx*4*Config.INPUT_MAP_SCALE, ry*4*Config.INPUT_MAP_SCALE))
               {

                   if (Utils.getDistanceSquared(rx, ry, x, y) <= (radius*radius))
                   {
                       r +=Utils.getColorR(loader.bufInClimate.getRGB(rx*4, ry*4));
                       g +=Utils.getColorG(loader.bufInClimate.getRGB(rx*4, ry*4));
                       b +=Utils.getColorB(loader.bufInClimate.getRGB(rx*4, ry*4));
                       num++;
                   }
               }
           }
       }
       
       climateArray[x][y] = (r/num << 16) + (g/num << 8) + b/num;
The second loop (rx, ry), is going through every pixel in a radius of 16 pixels around the (x,y) coordinates, and calculates the "average color" of every pixel in that radius (That's 16 pixels in climateArray, so 64 in climate.bmp or 128 on terrain.bmp)
Coordinates.isValidCoordinates is just checking that rx and ry are not going to cause out of bounds exceptions.

For every pixel in that loop, I extract it's RGB components and add them to variables r,g and b. Then increment variable num. At the end of the second loop, I divide r,g and b by num and make that the color of climateArray at (x,y)

So it takes something that looks like this and turns it into something that looks like that.


The second step is choosing the color of the terrain.
Code:
for (int x=0 ; x<loader.sizeX ; x++)
    for (int y=0 ; y<loader.sizeY ; y++)
    {
        
        double polar, temperate, hot;
        hot         = Utils.getColorR(climateArray[x/4/Config.INPUT_MAP_SCALE][y/4/Config.INPUT_MAP_SCALE]) / 255.0;
        temperate     = Utils.getColorG(climateArray[x/4/Config.INPUT_MAP_SCALE][y/4/Config.INPUT_MAP_SCALE]) / 255.0;
        polar         = Utils.getColorB(climateArray[x/4/Config.INPUT_MAP_SCALE][y/4/Config.INPUT_MAP_SCALE]) / 255.0;
        
        double sum = (hot + temperate + polar);
        
        if (sum == 0)
        {
            polar = 1.0f;
            sum = 1.0f;
        }
        
        hot = hot / sum;
        temperate = temperate / sum;
        polar = polar / sum;
For each terrain type I have pre-defined 3 colors : one for polar climate (blue), one for "hot" climate (red) and one for temperate climate (green). I look at the climateArray corresponding to those coordinates to get what the climate is like, most likely somewhere between 2 of those climates.
So for example if a point in climateArray has the color (166;239;0) That means it is somewhere between "hot" and temperate, leaning more towards the later. I normalize this by dividing each component by the sum of all 3 :
166 / (166 + 239 + 0) =~ 0.41
239 / (166 + 239 + 0) =~ 0.59

Code:
r=(int) (60*polar + 120*temperate + 190*hot);
g=(int) (110*polar + 150*temperate + 170*hot);
b=(int) (75*polar + 60*temperate + 90*hot);
And to get the final color I just calculate the weighted average of each pre-defined color, so in my example 41% of the hot color and 59% of the temperate color, and the cold color just gets ignored.

After that I also add a bit of randomness to the colors, and then add some light additional blurring (also done by calculating the average color, but in a much smaller radius).
 
It's great to see you make a UI! It might not look fancy but it's much more user friendly!
Really quick though, I noticed it generated a trade route in the input but we have no info on how to use that yet
Also do I place the output files in the LNLMOD folder with the .mod file again or did this rewrite new paths as well?
No I kind of forgot to talk about trade routes... I am not sure if it still works with holy fury, I'll see what I can do.
The old testmap mod should still work as well. Remove the lines that remove events and decisions if you want to play and not just look.
 
Some info on making trade routes (WIP) :

When you generate thedejure_template, it also generates a trade_route_template. You can use this as a starting point but it's not necessary.

You can have multiple trade routes on one map. The tool looks for files called trade_route_<something>.bmp and creates a trade route for each such image. trade_route_template.bmp is ignored though. For example trade_route_amber_road.bmp will generate a trade route called amber_road.

Colors on the bitmap :
Green trade route start
White trade route... route (path)
Red trade post (added with Jade Dragon, not every province crossed by a trade route can have a trade post)
Blue trade route node

The algorithm functions much like rivers in that, for a trade route segment to be recognized, you need to draw an uninterrupted, unambiguous line from point A to point B.
Unlike rivers, the exact path followed by the white pixels does not matter. What matters is which provinces it goes through.

Trade routes in CK2 are defined in segments. Each segment goes from province to province, and they have a direction (this affects which provinces will get reduced income when the route is halted due to warfare)

So you define a starting point with a green pixel, then draw a white line from there to the next province and so on.
To define a province that can have a trade post, just place a red pixel anywhere in that province. It does not have to be on the path but it will act as a node if it is.
A "node" is equivalent to a river split. It marks the end of a segment and possibly the begining of 1,2 or 3 new ones (can't have more than 3 because a pixel only has 4 sides, and one of these is the incoming path)
There is no need to "merge" or "end" trade routes. The segment will end in whatever province the white path ends.

I decided that trade routes should not go through sea zones. This is something that is done in vanilla and it was something I tried, but I prefered not to. The reason is it does not mix well with merchant republic trade zones, and the trade view gets all messy. I suppose I could add that as an option, but for now it simply ignores sea zones.
It's still possible to have a trade route going through the seas, it will just hop from one coastal province to another. The game is capable of connecting provinces that don't touch.

"externals" (pseudo-provinces that are off-map and act as starting points for the silk route) aren't supported right now.
 
Last edited:
Wow. I've been away from the forums for a little while, was really happy to see an update but it truly exceeds my expectations! I haven't even tried it yet but it sounds amazing! Thanks for the mini-guide on trade routes too. I'll definitely be trying this out as soon as I get any free time and I'll post any feedback here. Great work and thanks for sticking with development of the tools :)
 
Cool update, however I am running into some problem and my map does not load. I try to follow your guide to my best but I am not sure where it get wrong.

-First I give the program a terrain.bmp in index color format. For input.bmp and settlement.bmp, I simply converted the terrain.bmp to regular RGB mode.

-In "Make Terrain", I only run with Fill Settlements Map and Generated Sea Nodes, everything run successfully.

-Then in "Make Province", I run it with all check box on except for Recolor only and Only land, and I was able to generate a provinces.bmp.

-Then I run "Make Setup" with pretty much default setting with all check box on.
Everything seem to run successfully.

Then I copy the content in the output folder to the LNL testmap mod after deleted the default content,the only file that I added by myself are topology, trees, and world normal height (those files should work since I has tested it on a different province set up).

What do you think I am missing?
 
Last edited:
Then I copy the content in the output folder to the LNL testmap mod after deleted the default content,the only file that I added by myself are topology, trees, and world normal height (those files should work since I has tested it on a different province set up).

What do you think I am missing?

I see no mention of rivers or colormaps, maybe that ?
 
I see no mention of rivers or colormaps, maybe that ?
I have colormaps, but I believe both River and colormaps is optional. I will try to add a river map and test it again.

Thank you for replying, I just want to double check with you to see if I use your program correctly.
 
What is causing this error?

Loading ./input/religions.csv
Loading ./input/holysite.csv
holysite.csv file not found or error parsing it : java.io.FileNotFoundException:
.\input\holysite.csv (Määritettyä tiedostoa ei löydy)
Assigning religions...
Assigning cultures...
Loading ./input/localisation.csv
Writing .\output\map\definition.csv
Writing .\output\map\positions.txt
Writing .\output\map\default.map
Writing .\output\map\climate.txt
Writing .\output\map\adjacencies.csv
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size:
0
at java.util.ArrayList.rangeCheck(Unknown Source)
at java.util.ArrayList.get(Unknown Source)
at ck2maptools.main.CK2MakeProvinceSetup.main(CK2MakeProvinceSetup.java:
1334)

C:\Users\Leevi\Downloads\CK2MapTools-v1.1.0\CK2MapTools>pause​
 
EDIT: I didn't see you were still using 1.1
The problem is you do not have any water provinces. This should no longer be necessary in later versions.
 
Last edited:
Hey I checked the thread but couldn't find anything on it: How do i define lakes on terrain bmp?
You don't really. Lakes are no different from major rivers or regular seas. If you want it to generate ports and be navigable by everyone, just make it a sea, otherwise just make it a major river.
 
Last edited:
JrWP6e0.jpg
Really quick... What causes this problem? I've been scratching my head trying to fix this for a while now.

Update: After checking my files, it turned out my province map has color space info written in.
 
Last edited:
First things first, this is really really good. It's easy to use and the files it generates all look really good - the provinces generation is particularly impressive in my opinion.

But I'm just wondering if there's perhaps a part missing to the generator? I've used it a few times (with your empty mod template) and always get a game crash at "Loading Flags", which has happened for two different worlds. I checked the logs and it threw up a lot of errors (mainly to do with events and DLC characters), even after adding flags. Despite this, your mod seems to have worked very consistently. I'm unsure of why we'd get different results; I've followed the instructions in full.

If anyone else ever has this issue, I solved it by simply making sure my game was running on the most recent version.
 
Hi again,
I'm getting the error java.lang.IndexOutOfBoundsException:Index: 139, Size: 137. Anybody know what this means?

Also, another question. I need to eventually change the shape of the counties to match my personal maps, but doing so seems to give me errors and block the tool from giving me the setup files, plus I also don't know how I would generate, replace, and integrate the de jure maps that would also need changing,.

Edit: I'm actually still totally unable to see counties on my map when I launch the game, is this because I don't have any localisation files? Like I said, the tool absolutely won't produce them.
 
Last edited: