PerfectWorld3

@Heinous_hat: What do I do with the .lua file? :confused:
 
@Heinous_hat: What do I do with the .lua file? :confused:

You need to put it in your maps directory. You can use the one in the user folder (e.g. C:\Users\...\Documents\My Games\Sid Meier's Civilization 5\Maps) for single player. For multiplayer, it might have to go in the game installation maps folder... not sure, I haven't played any MP with custom scripts.

You can do that with any custom maps or scripts so you don't need to go through the mod menu and load the map as a mod. It will show up in the regular map selection menu.
 
I thought there were too much mountains so I tried setting the "Percent of dry land that is below the mountain elevation deviance threshold" to 0.95 but I still get large areas of mountains on my map. As I understand it, that would mean 95% of the land would not be mountains, but I could be wrong.

Your script has potential but I would like something with larger continents instead of those fractals you tend to get. Is it possible to achieve?
 
You need to put it in your maps directory. You can use the one in the user folder (e.g. C:\Users\...\Documents\My Games\Sid Meier's Civilization 5\Maps) for single player. For multiplayer, it might have to go in the game installation maps folder... not sure, I haven't played any MP with custom scripts.

You can do that with any custom maps or scripts so you don't need to go through the mod menu and load the map as a mod. It will show up in the regular map selection menu.

Thanks, I did not realize that a .lua file could be read raw like that.
 
How do I decrease the amount of hills and mountains? There isn't much space to build on.

Try tweaking these variables a little (higher) in MapConstants

mconst.hillsPercent = 0.50

mconst.mountainsPercent = 0.85


You could also try simultaneously raising mconst.landPercent for more total land area, but not too much or land masses start to merge.

Also, bobert13's code in post #377 will place hills adjacent to mountains. If you combine both methods, you can create more contiguous flat space while still having convincing ranges of hills/mountains to settle beside for their benefits.
 
Try tweaking these variables a little (higher) in MapConstants

mconst.hillsPercent = 0.50

mconst.mountainsPercent = 0.85


You could also try simultaneously raising mconst.landPercent for more total land area, but not too much or land masses start to merge.

Also, bobert13's code in post #377 will place hills adjacent to mountains. If you combine both methods, you can create more contiguous flat space while still having convincing ranges of hills/mountains to settle beside for their benefits.

Thanks for your reply. I edited my post a bit while you were posting. I also wanted to know if I can get larger and more homogeneous continents instead of the slim fractals.
 
Thanks for your reply. I edited my post a bit while you were posting. I also wanted to know if I can get larger and more homogeneous continents instead of the slim fractals.

Yup, caught that ;)

To change the shape of landmasses, you're probably going to want to adjust the Perlin Noise variables, towards the end of MapConstants...

mconst.twistMinFreq
mconst.twistMaxFreq
mconst.twistVar
mconst.mountainFreq

I can't offer any specific advice, haven't experimented with these yet. If you skim the thread, cephalo talks about it a bit (around post #367). You might try lowering Min and Max frequencies for bulkier continents (along with maybe a slight bump to total landmass). Need to do some reading and play around with them to be certain.

I would recommend using the WorldBuilder to quickly generate some maps after you make your edits to get a general idea of where your numbers are taking you.
 
That worked quite well but it's hard to get two separate continents like in Terra. With a little luck you could probably get something similar though.

I have another problem. Since I reduced the number of mountains I get snowy hills in the middle of warm regions. What's up with that?
 
That worked quite well but it's hard to get two separate continents like in Terra. With a little luck you could probably get something similar though.

I have another problem. Since I reduced the number of mountains I get snowy hills in the middle of warm regions. What's up with that?

The snowy hills could be the result of the script determining high altitude at that location and then hitting the cap you set for mountains. Just guessing... what value did you set?

If you want a guaranteed continental split, you might have a look at Thalassicus' custom script over in the Communitas sub-forum. The map can be used independently of the mod. It's partly based on Perfectworld3. He added ocean rift(s) which effectively divide the map with one or two (selectable) sections of ocean tiles. It also produces less hills/mountains in general and incorporates features from Continents Plus and Thal's own ideas.
 
I set the value to 0.95 and and that gives me about the same amount of mountains as if playing on a 3 billion years world. Is there any way you could modify the code to not give snow when there is a hill with high altitude? It's not very customizable as it is now. I'll check the communitas script out in the meantime. Thanks.
 
Hmm... 5% mountains is really low. If you're seeing mountains and hills on the order of the 'young planet' option (e.g. 3 billion yrs) available in some scripts, I think something else is amiss. If I raise the map constants for hills and mountain thresholds into the upper percentile range as you have, I get a very flat map...

For example, this is at mconst.hillsPercent = 0.80, mconst.mountainsPercent = 0.92 (showing only mountains and hills)


Bobert13's code to cluster hills around mountains is present in this example. I'm not certain whether the hills added by that condition are converted tiles or whether they fall under the constraint of the map constant. Have to check. However, the majority of the map is flat terrain.

There is also a loop in GenerateTerrain() where Rich makes the border of snow and tundra regions have hills (for aesthetic reasons). That bit is likely what's causing you to see snowy hills where there would otherwise be mountains.

But back to your overall desire for more flat space... are you actually seeing an unexpected amount of rough terrain even with high thresholds? Post a screen from WB and the relevant mapconstant values if possible.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    86.7 KB · Views: 1,028
I think there is enough mountains on that map but it needs more hills. I have mine set to 0.65 and I still can get big areas of almost only hills but also some big areas of very flat land, which isn't that fun to build on. I would like hills to be more spread out and not in big clusters, if it's possible.

After lowering mconst.mountainsPercent to 0.90 the visible snow in warm regions disappeared but I don't want that loop that generates extra snow, since I can't really see the aesthetics in it. Can I delete that part? I have noticed that mountains can have snow on them in the middle of the map and that's what was causing the problem.

I can't make a screenshot of the whole map since I can't zoom out all the way in the game and I have no Worldbuilder installed.
 
I think there is enough mountains on that map but it needs more hills. I have mine set to 0.65 and I still can get big areas of almost only hills but also some big areas of very flat land, which isn't that fun to build on. I would like hills to be more spread out and not in big clusters, if it's possible.

After lowering mconst.mountainsPercent to 0.90 the visible snow in warm regions disappeared but I don't want that loop that generates extra snow, since I can't really see the aesthetics in it. Can I delete that part? I have noticed that mountains can have snow on them in the middle of the map and that's what was causing the problem.

I can't make a screenshot of the whole map since I can't zoom out all the way in the game and I have no Worldbuilder installed.

I think Continents Plus (part of Firaxis' Explorer's Map Pack) is the closest thing to what you're describing, presently. Mountains are much less common compared to what works well in PW and hills are scattered about for good playability. It also generates island chains and has a fair number of selectable options in advanced setup. Either that or Communitas (once the kinks are worked out). Thal's intent there is primarily play balance blended with aesthetics as much as possible.

The main theme behind PW is generating huge maps that simulate rain shadow, drainage basins and (pseudo) realistic river systems. That relies heavily on the the presence of mountain chains, which obviously can be difficult areas to settle. If you attempt to reduce those features to a drastic degree, the map falls apart somewhat and loses it's purpose. I do think, though, that some of the new game mechanics in Brave New World lend themselves really well to solving the problems posed by this style of map. You can set up trade routes to import/export food and production for areas that are starved of either. Pretty cool and definitely a needed addition for crazy rough terrain like that in PW or Tectonics.

As for the routine I described that's causing the snowy hills... I don't know that editing/removing it will solve the problem. You'll likely just get flat snow since it seems that the snowy terrain itself is based on the elevation map. The extra routine just adds hills to snow and tundra borders to doll things up. The same loop also contains another check which keeps desert away from tundra (converts to plains). In any case, the routine is located at the end of GenerateTerrain() and has a descriptive comment.

Essentially, it looks like the map constant for mountains has a soft upper limit beyond which base elements of the mod won't work as intended (i.e. you're out of mountains on a map that needs mountains ;)) That's my take anyway.

I would definitely recommend grabbing the WorldBuilder from Steam to quickly examine maps as you make changes to see if things will be consistently to your liking. It seems you're highly picky (like me :))
 
That was a nice and thorough description with all the nails in place. I have looked at Communitas script and the landscape is to my liking except that it uses the africa tileset which I can't look at for long without feeling the urge to vomit. I hope there will be an option to change that in the future, or if I can change the whole tileset myself it would be all the better.

Continents plus is a good map but the placement of city states is somewhat ridiculous, since they are all placed on small island chains. They are not in the way but it's hard to build island colonies. That's why I have been chosing Terra lately. What I really wish for is a Terra world with your drainage and climate system but you can't get the best of booth worlds. :)
 
What the links for Communitas and World Builder? I don't see either in the workshop on steam.
 
That was a nice and thorough description with all the nails in place. I have looked at Communitas script and the landscape is to my liking except that it uses the africa tileset which I can't look at for long without feeling the urge to vomit. I hope there will be an option to change that in the future, or if I can change the whole tileset myself it would be all the better.

If you search the Communitas script for the function DetermineContinents() you should find (at line 5310 currently) this loop:
Code:
	for y=0, elevationMap.height - 1 do
		for x=0, elevationMap.width - 1 do
			local plot = Map.GetPlot(x,y)
			local i = elevationMap:GetIndex(x,y)
			local artStyle = continentMap:GetAreaByID(continentMap.data[i]).artStyle
			if plot:IsWater() then
				plot:SetContinentArtType(contArt.OCEAN)
			elseif jungleMatch(x,y) then
				plot:SetContinentArtType(contArt.EUROPE)
			else
				plot:SetContinentArtType(contArt.[B]AFRICA[/B])
			end
		end
	end

Just change AFRICA to whatever you like (EUROPE, ASIA or AMERICA) . Note, there is also a loop at the top of DetermineContinents() that sets all land tiles to AFRICA by default, however, this won't actually make a difference given the later conditions. Not sure if that serves any purpose or if he simply forgot to remove it. But changing the above will get you what you want for the bulk of the map. African and American deserts will still appear as with PW, along with Euro jungles and some other varieties for distinct climate areas (like tundra).

What the links for Communitas and World Builder? I don't see either in the workshop on steam.

Communitas is in it's own subforum in Project and Mod Dev. Direct link for the map is here currently. Worldbuilder you need to install via Steam (main application) under Library > Tools.
 
That worked like a charm. I also found some other settings similar to those in PW and after changing some stuff I got a decent map with the communitas script but there are still a few issues with it. Can I do the same thing with the tileset in PW? I didn't find the same code in the script and I can't figure out how to do it.
 
I think there is enough mountains on that map but it needs more hills. I have mine set to 0.65 and I still can get big areas of almost only hills but also some big areas of very flat land, which isn't that fun to build on. I would like hills to be more spread out and not in big clusters, if it's possible.

After lowering mconst.mountainsPercent to 0.90 the visible snow in warm regions disappeared but I don't want that loop that generates extra snow, since I can't really see the aesthetics in it. Can I delete that part? I have noticed that mountains can have snow on them in the middle of the map and that's what was causing the problem.

I can't make a screenshot of the whole map since I can't zoom out all the way in the game and I have no Worldbuilder installed.

Sounds like you want to be changing the mconst.mountainFreq setting. Raising it will result in more sporadic placement of elevation features during map generation. I can't recall what the default setting is, but in my most recent WIP version, I have it way up at 0.4. You'll probably find this too sporadic if you like the looooong mountain chains and such. Here's a snippet of my re-organized main constants with concise comments (some of them may be constants I explicitly added to my version so you won't have those):

Spoiler :
Code:
-------------------------------------------------------------------------------------------
	--Landmass constants
	-------------------------------------------------------------------------------------------
	mconst.landPercent = 0.31 		--Percent of land tiles on the map.
	mconst.hillsPercent = 0.60 		--Percent of dry land that is below the hill elevation deviance threshold.
	mconst.mountainsPercent = 0.94 	--Percent of dry land that is below the mountain elevation deviance threshold.
	mconst.mountainWeight = 0.7		--Weight of the mountain elevation map versus the coastline elevation map.

	--Adjusting these frequences will generate larger or smaller landmasses and features. Default frequencies for map of width 128.
	mconst.twistMinFreq = 0.02 		--Recommended range:[0.02 to 0.1] Lower values result in more blob-like landmasses, higher values make more stringy landmasses, even higher values results in lots and lots of islands.
	mconst.twistMaxFreq = 0.055		--Recommended range:[0.03 to 0.3] Lower values result in Pangeas, higher values makes continental divisions and stringy features more likely, and very high values  result in a lot of stringy continents and islands.
	mconst.twistVar = 0.14 			--Recommended range:[0.01 to 0.3] Determines the deviation range in elevation from one plot to another. Low values result in regular landmasses with few islands, higher values result in more islands and more variance on landmasses and coastlines.
	mconst.mountainFreq = 0.4 		--Recommended range:[0.1 to 0.8] Lower values make large, long, mountain ranges. Higher values make sporadic mountainous features.

	--These attenuation factors lower the altitude of the map edges. This is currently used to prevent large continents in the uninhabitable polar regions.
	mconst.northAttenuationFactor = 0.85
	mconst.northAttenuationRange = 0.08 --percent of the map height.
	mconst.southAttenuationFactor = 0.85
	mconst.southAttenuationRange = 0.08 --percent of the map height.

	--East/west attenuation is set to zero, but modded maps may have need for them.
	mconst.eastAttenuationFactor = 0.0
	mconst.eastAttenuationRange = 0.0 --percent of the map width.
	mconst.westAttenuationFactor = 0.0
	mconst.westAttenuationRange = 0.0 --percent of the map width.
	-------------------------------------------------------------------------------------------
	--Terrain type constants
	-------------------------------------------------------------------------------------------
	mconst.desertPercent = 0.27		--Percent of land that is below the desert rainfall threshold.
	mconst.desertMinTemperature = 0.31 --Coldest absolute temperature allowed to be desert, plains if colder.
	mconst.plainsPercent = 0.50 	--Percent of land that is below the plains rainfall threshold.
	mconst.tundraTemperature = 0.33	--Absolute temperature below which is tundra.
	mconst.snowTemperature = 0.26 	--Absolute temperature below which is snow.
	-------------------------------------------------------------------------------------------
	--Terrain feature constants
	-------------------------------------------------------------------------------------------
	mconst.zeroTreesPercent = 0.50 	--Percent of land that is below the rainfall threshold where no trees can appear.
	mconst.treesMinTemperature = 0.28 --Coldest absolute temperature where trees appear.

	mconst.junglePercent = 0.88 	--Percent of land below the jungle rainfall threshold.
	mconst.jungleMinTemperature = 0.66 --Coldest absolute temperature allowed to be jungle, forest if colder.

	mconst.riverPercent = 0.15 		--percent of river junctions that are large enough to become rivers.
	mconst.riverRainCheatFactor = 1.6 --This value is multiplied by each river step. Values greater than one favor watershed size. Values less than one favor actual rain amount.
	mconst.minRiverSize = 24		--Helps to prevent a lot of really short rivers. Recommended values are 15 to 40. -Bobert13
	mconst.minOceanSize = 5			--Fill in any lakes smaller than this. It looks bad to have large river systems flowing into a tiny lake.

	mconst.marshPercent = 0.92 	-- Percent of land below the jungle marsh rainfall threshold.
	mconst.marshElevation = 0.07 	--Percent of land below the lowlands marsh threshold.

	mconst.OasisThreshold = 7 		--Maximum food around a tile for it to be considered for an Oasis -Bobert13

	mconst.atollNorthLatitudeLimit = 47 --Northern Atoll latitude limit.
	mconst.atollSouthLatitudeLimit = -47 --Southern Atoll latitude limit.
	mconst.atollMinDeepWaterNeighbors = 4 --Minimum nearby deeap water tiles for it to be considered for an Atoll.

	mconst.iceNorthLatitudeLimit = 63 --Northern Ice latitude limit.
	mconst.iceSouthLatitudeLimit = -63 --Southern Ice latitude limit.
	-------------------------------------------------------------------------------------------
	--Weather constants
	-------------------------------------------------------------------------------------------
	--Important latitude markers used for generating climate.
	mconst.polarFrontLatitude = 65
	mconst.tropicLatitudes = 23
	mconst.horseLatitudes = 31
	mconst.topLatitude = 70
	mconst.bottomLatitude = -70

	--These set the water temperature compression that creates the land/sea seasonal temperature differences that cause monsoon winds.
	mconst.minWaterTemp = 0.10
	mconst.maxWaterTemp = 0.50

	--Strength of geostrophic climate generation versus monsoon climate generation.
	mconst.geostrophicFactor = 3.0
	mconst.geostrophicLateralWindStrength = 0.4

	--Crazy rain tweaking variables. I wouldn't touch these if I were you.
	mconst.minimumRainCost = 0.0001
	mconst.upLiftExponent = 4
	mconst.polarRainBoost = 0.00
	mconst.pressureNorm = 0.90 --[1.0 = no normalization] Helps to prevent exaggerated Jungle/Marsh banding on the equator. -Bobert13

On the subject of my code that adds hills around mountains, no they are not constrained by any of the constants. That piece of code operates after elevations have been generated and overrides elevation in tiles adjacent to mountains. In other words, it's adding more hills to the map than would otherwise be there.

The snowy hills appearing in warm areas issue is related to the elevation map itself and IIRC shouldn't have anything to do with the thresholds. Snowy hills mean there isn't enough variance between the highest elevations and the lowest elevations (including ocean) where desert everywhere means the opposite (too much variance). I have no idea what you were tweaking to run into this with an unaltered version of PW3 as I only ran into these issues during a total overhaul of the elevation generating code. I also haven't put my finger on why terrain generation has this hiccup if the elevation values aren't spread within a finite range of variance as some of the math in PW3 is a little beyond me.

Edit: If you were playing with the mconst.mountainWeight setting, that may have been what brought on the snowy hills in warm places issue.

2nd Edit: On the subject of optimization, off the top of my head, there's two "little" tweaks that can be made that greatly reduce the time it takes to generate larger maps. The first of these is to add the following lines to function FloatMap:Smooth() and function FloatMap:Deviate():
Code:
if radius > 7 then
	radius = 7
end
This belongs after variables are declared but before the for(y), for(x) iterations.

On huge maps this number can be as high as 16 IIRC, which is a huge number of table ops and such. Limiting the radius produces very similar results while greatly reducing the math and table ops involved when these functions get called (a lot). This is the easier tweak to implement and also produces the largest performance boost.

The second optimization is a little more involved as to really see any benefit you have to go through the code and find every instance where Cephalo is calling FloatMap:GetIndex() inside of a for(y), for(x) loop and replace that with a counter that starts at zero and increments at the end of every iteration of for(x). He's doing a bunch of math (multiplication and modulo IIRC) to actually calculate the index value of a given plot when the result of the math is simply that the index starts at zero and increments by one every iteration (y and x must both start at zero and increment positively for this to be correct! I don't specifically remember any cases where Cephalo starts y and x at height and width respectively and then decrements until zero but if you come across that, you must invert them for this optimization to produce correct results). Here's a comparison of function FloatMap:Smooth() before and after this minor optimization.

Spoiler :
Original:
Code:
	for y = 0,self.height - 1,1 do
		for x = 0, self.width - 1,1 do
			local i = self:GetIndex(x,y)
			dataCopy[i] = self:GetAverageInHex(x,y,radius)

		end
	end

Optimized:
Code:
	[COLOR="SeaGreen"]local i = 0[/COLOR]
	for y = 0,self.height - 1,1 do
		for x = 0, self.width - 1,1 do
[COLOR="Red"]--			local i = self:GetIndex(x,y)[/COLOR]
			dataCopy[i] = self:GetAverageInHex(x,y,radius)
			[COLOR="SeaGreen"]i=i+1[/COLOR]
		end
	end

There's at least 10 places in the code (probably closer to 15) where this minor tweak can be applied.

As an aside, getting LuaJIT (it has it's own thread here) has a larger affect on map generation than both of these tweaks combined. Short of one or two mods using deprecated Lua (some of which was fixed by the author(s)) I've ran into no issues with running the JIT .dll and it speeds up turn times as well (even if you always swap to strategic view before ending your turn).

3rd Edit: Another thing that can be done in regards to optimization is to make lookup tables of certain terrain types and then use those tables when placing features. As an example, I have a table of the index values of every desert tile. When I get to Oasis placement, instead of checking every single tile on the map to see if it's desert, I simply check every desert tile I stored in my table. On a huge map, I'm iterating on a few hundred table entries instead of over 10,000. This requires more changes and is more complicated than anything I've posted in this thread yet so giving an example or step-by-step instructions is a little more complex than what a forum, or typed correspondence in general, can facilitate. I currently have lookup tables of each terrain type, mountains, and one of every land tile and I use them quite a bit during feature generation. An argument could also be made for making a coastal waters table as well (for atoll placement) but PW3 uses the C++ GenerateCoastlines() function so getting that into the script would be tricky.

Is anybody still reading? :hatsoff:
 
Sounds like you want to be changing the mconst.mountainFreq setting. Raising it will result in more sporadic placement of elevation features during map generation. I can't recall what the default setting is, but in my most recent WIP version, I have it way up at 0.4. You'll probably find this too sporadic if you like the looooong mountain chains and such. Here's a snippet of my re-organized main constants with concise comments (some of them may be constants I explicitly added to my version so you won't have those):

blablablabla ;)

Is anybody still reading? :hatsoff:

Well, 0.4 is a bit high for my taste but it surely spreads out the mountains a bit. I managed to get rid of the unwanted snow "bug" but I'm actually more interested in the communitas script since that one has more interesting landforms. Since you guys know your code, do you think you can find a way to get more luxuries on other islands than the one you start on in with that script(with the Terra option)? The problem is that the thread is not very well supported at the moment.
 
Well, 0.4 is a bit high for my taste but it surely spreads out the mountains a bit. I managed to get rid of the unwanted snow "bug" but I'm actually more interested in the communitas script since that one has more interesting landforms. Since you guys know your code, do you think you can find a way to get more luxuries on other islands than the one you start on in with that script(with the Terra option)? The problem is that the thread is not very well supported at the moment.

All of my experience with CiV's map scripts is limited to PW3 and what I've picked up by looking over the map scripts that come with the game. PW3 uses the default luxury resource placement function so I've actually never even peaked at it. PW3's landmass generation is very tweakable and can have some dramatically different results based on the frequencies you set through the main constants. You're more than welcome to try the settings I have shown in my previous post (the landmasses produced are reminiscent of Continents Plus only without the stupid CS placement and a little less bland-feeling than Continents) or to use the comments found in my previous post to tweak them more to your liking. As far as work on the communitas script goes, you should speak with someone who's familiar with it.
 
Top Bottom