So, this "utility" is something that spun out of my desire to have a world with a central ocean surrounded by a good-aligned jungle, because i can't tell the game directly which squares i want to be good or evil aligned, someone suggested that i do that by carefully adjusting the size of the generated biomes by PWDF, but since PWDF doesn't allow for any "Hard coding" other than a simple brush (you can't input a heightmap for anything other than actual height) i decided to make this program, as painting pixel by pixel on a 257x257 implies painting 66049 by hand(instead of using a bucket tool, and the big brush wasn't much more helpfull either).
The results of this whole experiment were... mixed, while it did allow me to
relatively quickly design the world i wanted with regions that did not mix, 257x257 is such a big map that almost all regions will end up being more than a 100 tiles in size, which defeats the whole purpose of this, as creating small and medium regions that do not cross with each other on such a large map is about as much work as painting them by hand on PWDF.
It was a lot more useful on smaller worlds (65x65), as regions tended to be all medium (close to 90 tiles but less than a 100).
So after going down this rabbit hole and back, I figured I'd share it with everyone, in case there's any madman who would need such an specific tool as well.
While the program is allegedly made with c++, it really just a c program with a c++ library, I initially intended to make it a proper c++ program but gave up midway and wound but with this frankestein, you may be wondering why I chose c of all languages to make this or why it doesn't have any visual interface, and the answer is because that's what I had available, I only know how to code basic c and some concepts of c++, and I learned to do all that with the Linux console.
You'll have to download the source code from github and run make to generate the executable, as c "executables" are not really portable.
You'll also need g++, this is the version that I used, anything above (and I figure a good deal below) that should work: g++ (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411
While you don't need to download it, as it is already bundled with the source code, I would like to share a link to the library that made this way easier (and arguably possible at all):
http://easybmp.sourceforge.net/Download:
https://github.com/CrainFartor/Dwarf-Fortress-Heightmap-Translator/releases/Once you use it, you'll have to manually copy the preset values from the output file to your world_gen.txt, you can further modify this preset with PWDF, so long as you don't override the presets you've generated on this program with PWDF maps.
Instructions:This are the instructions on how to use the program (they are the same message you get if you run ./DFHM -H):
General usage: ./DFHM <mode> <size> [program instructions]
Available modes: Heightmap (or simply H) --- Biome (or simply B) -- only the first letter of the mode argument is evaluated
Heightmap usage: ./DFHM Heightmap <size> <output type> <image> <output file>
Where <size> is a supported DF world size and <output type> <image> <output file> are the program inputs and outputs you can skip the <output file> member, the program will use the default output in such case
Supported sizes: 17 33 65 129 257, preset generation of non square maps is not supported
To specify a type you can either write the whole name or use a switch only the first letter will be evaluated in either case:
Valid types: <Full type> <Switch>
Elevation -E
Rainfall -R
Temperature -T
Drainage -D
Volcanism -V
Savagery -S
The input image can be any 8bit-depth .bmp, but the program expects a file where all pixels R, G and B values are the same per pixel (a greyscale image)
Example heightmap usage: ./DFHM Heightmap 257 Elevation image1.bmp Altitude.txt
Biome usage: ./DFHM Biome <size> <Image> <output file>
Where <size> is a supported DF world size and <output type> <image> <output file> are the program inputs and outputsyou can skip the <output file> member, the program will use the default output in such case
Supported sizes: 17 33 65 129 257, preset generation of non square maps is not supported
The input image can be any 8bit-depth .bmp file but it is meant to be use with images where pixel data corresponds in the following manner:
RED: corresponds to the savagery scale
BLUE: corresponds to the rainfall scale
GREEN: corresponds to the drainage scale
Example biome usage: ./DFHM Biome 65 biomes.bmp presets.txt
How to calculate what values to assign to each color:The program comes with a utility called Quick3 (wich you also have to make) that will take any value you want for a tile, and convert it to a 0 to 255 scale so you know what value you should put in that tile.
Otherwise you can do this simple 3-rule with the calculator:
Val_in_rgb = (Val_in_original_scale * 255) / Max_val_in_original_scale
For Drainage, Rainfall, Savagery and Volcanism the original scale is 0-100
For elevation the original scale is 0-400
For temperature the accepted values (presumably in ºC(?)) are -30 to 140 but you'll have to calculate this with an offset so your scale will be:
0-170 with 0 corresponding to -30, 30 corresponding to 0, and 170 corresponding to 140.
Example for savagery:
Val_in_rgb = (50 * 255) / 100 (will give a savagery of around 50, which would be wilderness).
Val_in_rgb = ~127
Example for elevation
Val_in_rgb = (400 * 255) / 400 (will give an elevation of 400, which is the absolute maximum and will be were most mountain peaks will be located).
Val_in_rgb = 255
Example for temperature:
Val_in_rgb = (15 * 255) / 170 (will give a temperature of -15, which is pretty close, if not definitely, freezing).
Val_in_rgb = ~22
Usefull values for generating biomes:format: BiomeName: <Red_value> <Green_value> <Blue_value> -> <Savagery> <Drainage> <Rainfall>
X is savagery, and generally doesn't change biome type, temperature can change biome type though:
Calm: <0-76> Wilderness: <79-165> Untamed Wilds: <168-255>
Sand desert: <X> <0-81> <0-22>
Rocky Wasteland (flat): <X> <84-124> <0-22>
Rocky Wasteland (hilly): <X> <127-165> <0-22>
Badlands: <X> <168-255> <0-22>
Grasslands (flat): <X> <0-124> <25-48>
Grasslands (hilly): <X> <127-255> <25-48>
Savanna (flat): <X> <0-124> <51-81>
Savanna (hilly): <X> <127-255> <51-81>
Marsh: <X> <0-81> <84-165>
Swamp: <X> <0-81> <168-255>
Shurbland (flat): <X> <84-124> <84-165>
Shurbland (hilly): <X> <127-255> <84-165>
Connifer forest: <X> <84-255> <168-188>
Broadleaf forest: <X> <84-255> <191-255>
Example results:Here is an example of a Biome mode input with "sharp" colors:
and here is the resulting 257x257 world: And here is the same input, after we blur it a bit to avoid such sharp changes:
and here is the resulting 257x257 world: