This topic keeps coming-up, so here is a simple solution.
If you have other simple solutions, please feel free to post them in this topic.
This "continent map generator" is a bash script ( created and tested on a Mac. ) Copy the code from this post, or download the attached zip file and decompress it.
Also attached is a functional Freeciv 2.6.4 or later Scenario file including this generated map.
The script uses a simple process to create the map, and it's best shown in the pictures below.
The map starts out as a solid field of random characters representing mostly land and some lake tiles in Freeciv. Then the horizontal and vertical ocean areas ( the white spaces between and around the rectangles) are imposed. By the way, text characters are usually taller than they are wide, which results in a vertical stretching of what the final map will look line in Freeciv, if using square tiles.
![Image]()
The script loops through the map 4 times, 2 forward and 2 backward, picking tiles near water to become water.
![Image]()
Next is the result of loop 2. If you like big clunky continents, you can change the # in the script to stop at loop 2 or 3.
![Image]()
Below is loop 3's output.
![Image]()
And finally loop 4 has finished and there are no additional loops scheduled.
![Image]()
The last step in the script is to add the proper formatting for this map to be used in a Freeciv scenario ".sav" file.
![Image]()
Below it the text of the final map in Freeciv scenario [map] layer format.
![Image]()
^ Here's a screenshot of that upper-right island in Freeciv 2.6.4.
![Image]()
^ And a close-up of the minimap.
![Image]()
^ This pictures shows the top of the Freeciv scenario ".sav" file content.
![Image]()
^ And here I had just pasted the new map over the old map in the scenario. Both the old and new maps are 66 x 36 tiles ( you can change the size in the script very easily) so a simple cut-and-paste of the new map over the old map is fine and after saving the scenario file, it's ready to play.
And finally, below is the full text of the bash script that generated the map.That's it.
If you have other simple solutions, please feel free to post them in this topic.
This "continent map generator" is a bash script ( created and tested on a Mac. ) Copy the code from this post, or download the attached zip file and decompress it.
Also attached is a functional Freeciv 2.6.4 or later Scenario file including this generated map.
The script uses a simple process to create the map, and it's best shown in the pictures below.
The map starts out as a solid field of random characters representing mostly land and some lake tiles in Freeciv. Then the horizontal and vertical ocean areas ( the white spaces between and around the rectangles) are imposed. By the way, text characters are usually taller than they are wide, which results in a vertical stretching of what the final map will look line in Freeciv, if using square tiles.

The script loops through the map 4 times, 2 forward and 2 backward, picking tiles near water to become water.

Next is the result of loop 2. If you like big clunky continents, you can change the # in the script to stop at loop 2 or 3.

Below is loop 3's output.

And finally loop 4 has finished and there are no additional loops scheduled.

The last step in the script is to add the proper formatting for this map to be used in a Freeciv scenario ".sav" file.

Below it the text of the final map in Freeciv scenario [map] layer format.
Code:
t0000=" "t0001=" "t0002=" "t0003=" g "t0004=" ggg hgg "t0005=" gp ggfghmhph "t0006=" fp pfpfg hg hggpmphph "t0007=" h p hpggpg phgp hhmgfffphgfm "t0008=" hmg p gpphgmp fggg pggffgfpfgpf "t0009=" fgp ghgppphg hfmggg gfgggggpgff "t0010=" fgf hggghffhg hfgpgghpffpmggf "t0011=" ggmggh p f fphfgpfpfhppfgp "t0012=" fp hp gm h hg hgpgg "t0013=" m g hf f fg "t0014=" pf "t0015=" "t0016=" "t0017=" "t0018=" "t0019=" "t0020=" "t0021=" "t0022=" gf gg f "t0023=" fgggh gpfg pffg hm p "t0024=" hfhghghhhgfggfh h h gpp ggh g "t0025=" mhhhfmfgphpmpghg pggp gmfgg pgpf "t0026=" phgpfhfhph fgg fhfppp fpfgh gff "t0027=" hhggpffhpfg ghpg gppf ffpfhg gmp "t0028=" g gfghfphggh mpfmh hgpppgmpmgf p g "t0029=" m phh pgh gppp gffpffgf gfpm gp "t0030=" hf ggpf h fggppfhg g h "t0031=" f fp p "t0032=" "t0033=" "t0034=" "t0035=" "

^ Here's a screenshot of that upper-right island in Freeciv 2.6.4.

^ And a close-up of the minimap.

^ This pictures shows the top of the Freeciv scenario ".sav" file content.

^ And here I had just pasted the new map over the old map in the scenario. Both the old and new maps are 66 x 36 tiles ( you can change the size in the script very easily) so a simple cut-and-paste of the new map over the old map is fine and after saving the scenario file, it's ready to play.
And finally, below is the full text of the bash script that generated the map.
Code:
#!/usr/bin/env bash# This line is a comment, the line above is not.# Declare variablesdeclare zeroPad="0000" tiledeclare -a terrain_layer terrain_layer_Bdeclare -i x y c=0 r# The map size is determined by the xsize and ysize variablesdeclare -i xsize=66 ysize=36# Ouput a blank lineecho# Create terrain layerfor (( y=0 ; y<${ysize} ; y++ )) ; dofor (( x=0 ; x<${xsize} ; x++ )) ; dotile="g"r=$(( 1 + RANDOM % 17 ))if [ ${r} -ge 1 ] && [ ${r} -le 5 ] ; then tile="g" ; fiif [ ${r} -ge 6 ] && [ ${r} -le 9 ] ; then tile="p" ; fiif [ ${r} -ge 10 ] && [ ${r} -le 12 ] ; then tile="h" ; fiif [ ${r} -ge 13 ] && [ ${r} -le 15 ] ; then tile="f" ; fiif [ ${r} -ge 16 ] ; then tile="f" ; fiif [ ${r} -eq 17 ] ; then tile="m" ; fiif [ ${r} -eq 18 ] ; then tile="d" ; fi# 4 columns of water vertical middle centerineif [ ${x} -ge 31 ] && [ ${x} -le 34 ] ; then tile=" " ; fi# 4 rows of water horizontal middle centerlineif [ ${y} -ge 16 ] && [ ${y} -le 19 ] ; then tile=" " ; fi# 2 rows of water at map edges left, right, top, bottomif [ ${x} -le 1 ] || [ ${x} -ge 64 ] ; then tile=" " ; fiif [ ${y} -le 1 ] || [ ${y} -ge 34 ] ; then tile=" " ; fiif [ ${x} -ge 32 ] && [ ${x} -le 33 ] ; then tile=" " ; fiterrain_layer[${y}]="${terrain_layer[${y}]}${tile}"donedone# output original rectanglesecho "Before the loops:"for ((y=0;y<${ysize};y++)) ; doecho "${terrain_layer[${y}]}"done# Now loop forward and backward through the lines# and look for land tiles next to water# and change some of the land tiles to water too# and output the map after each loop# The number of loops is the loop<=4 below# Change the 4 to 3 if you like bigger continentsfor (( loop=1 ; loop<=4 ; loop++ )) ; do# print a line of dashesprintf -- '-%.0s' {1..100}; echo# print loop header with loop #echo "loop: ${loop}"for (( z=0; z<${ysize} ; z++ )) ; doif [ $(( loop % 2 )) -eq 0 ] ; then# even loop number, loop backward, ysize to 0y=$(( ysize - z ))else# odd loop number, loop forward, 0 to ysizey=zfiterrain_layer_B[${y}]=""for (( x=0 ; x<${xsize} ; x++ )) ; do# This is the tile which we might change from land to watertile="${terrain_layer[${y}]:${x}:1}"# Next are the 8 tiles of the ring around that tile# above the tileif [ "${terrain_layer[$((${y}-1))]:$((${x}-1)):1}" == " " ] ; then c=$((c+1)) ; fiif [ "${terrain_layer[$((${y}-1))]:${x}:1}" == " " ] ; then c=$((c+1)) ; fiif [ "${terrain_layer[$((${y}-1))]:$((${x}+1)):1}" == " " ] ; then c=$((c+1)) ; fi# beside the tileif [ "${terrain_layer[${y}]:$((${x}-1)):1}" == " " ] ; then c=$((c+1)) ; fiif [ "${terrain_layer[${y}]:$((${x}+1)):1}" == " " ] ; then c=$((c+1)) ; fi# below the tileif [ "${terrain_layer[$((${y}+1))]:$((${x}-1)):1}" == " " ] ; then c=$((c+1)) ; fiif [ "${terrain_layer[$((${y}+1))]:${x}:1}" == " " ] ; then c=$((c+1)) ; fiif [ "${terrain_layer[$((${y}+1))]:$((${x}+1)):1}" == " " ] ; then c=$((c+1)) ; fi# If only 1 neighboring tile is water,# then only a small chance of changing the tile to waterif [ "${c}" -eq 1 ] ; thenif [ $(( 1 + RANDOM % 10 )) -ge 9 ] ; thentile=" "fi# If 2 neighboring tiles are water, slightly better chanceelif [ "${c}" -eq 2 ] ; thenif [ $(( 1 + RANDOM % 10 )) -ge 8 ] ; thentile=" "fi# If 3 neighboring tiles are water, an even better chanceelif [ "${c}" -eq 3 ] ; thenif [ $(( 1 + RANDOM % 10 )) -ge 7 ] ; thentile=" "fi# If more than 3 neighboring tiles are water,# then change this one to water tooelif [ "${c}" -gt 3 ] ; thentile=" "fic=0terrain_layer_B[${y}]="${terrain_layer_B[${y}]}${tile}"doneterrain_layer[${y}]="${terrain_layer_B[${y}]}"donefor ((y=0;y<${ysize};y++)) ; doecho "${terrain_layer[${y}]}"donedone# print a line of dashes and an extra blank lineprintf -- '-%.0s' {1..100}; echo ; echo# output final terrain map formatted for insert into a Freeciv scenario ".sav" filefor ((y=0;y<${ysize};y++)) ; doecho "t${zeroPad:${#y}}${y}=\"${terrain_layer_B[${y}]}\""done# Print 1 last blank lineechoexit 0
Statistics: Posted by Molo_Parko — Fri Nov 22, 2024 1:44 am — Replies 0 — Views 5