Communitas map script

I don't think it's a bug, just a very weird Random number generator thing... but I found a very odd formation of stone...

Spoiler :
 
I just had a game with one rather cramped continent and 3 "Australias" (big-sized continent for one civ only) with one civ each, so I guess it's a bit dependent on luck. But yeah, more options are always good and that one should be doable fairly easily, it's just one more ocean rift, no?
 
Hi ya

Just starting up a game with the map now. Looks sensational. Was wondering if there is anyway to get more than just two continents. I play continents/continents plus and there's always only two large continents and nobody ever gets an island start. I'm not looking for an island start I'm just looking for a way to play a game with more than 3 continents at all??

Make sure you pick at least one pacific rift. That usually generates a few islands. You can also go into the lua file located in the mod folder and look at the settings there.

mglobal.landPercent = 0.35 - Increase this a bit if you want larger islands/continents

Also try these settings:

mglobal.twistMinFreq = 0.02
mglobal.twistMaxFreq = 0.04
mglobal.twistVar = 0.022

That will make the landmass appear more solid with less fractals.
 
* More luxuries on other islands than the starting continent(Terra). I see only 1 or 2 luxuries on other islands.

I believe that this is a vanilla BNW problem too and that luxury resource placement is done outside of the main map creation process itself. Improving luxury placement will probably be done in CEP itself but probably not for the standalone map itself or else it would break multiplayer and unmodded singleplayer (steam achievements!) compatibility.

I don't think it's a bug, just a very weird Random number generator thing... but I found a very odd formation of stone...

This is probably random chance since stone has a higher chance of spawning in deserts and small islands. Though if you notice any other odd formations let us know in the thread.
 
What about the lakes? There must be a way to make it spawn less lakes or use the default settings for lakes?
 
What about the lakes? There must be a way to make it spawn less lakes or use the default settings for lakes?

I've been looking at the lake code but it's all Thal's custom code (I believe) and you'll probably get a better answer from him later.

There's this at line 115:

PHP:
	mglobal.lakeSize				= 10	-- read-only; cannot change lake sizes

But his comment there is that it can't be changed. You can give it a try as that is definitely a value used while generating lakes.
 
A few ''complaints'' (Just kidding :p)

1. Lakes. Some tend to be Large lakes. Should they really be 1F1G? Is this designed for the Aztec floating garden (which adds 2F per lake tile)? Even 3F1G seems weak, no? How about 2F1G? Or even 2F 1 Culture =)

2. Oasis seems too few for the Tranquil Refuge pantheon to be balanced. It seems underpowered...The same applies to Isle and the pantheon. There is no reason to take the pantheon because Isles are so sparse.
 
2. Oasis seems too few for the Tranquil Refuge pantheon to be balanced. It seems underpowered...The same applies to Isle and the pantheon. There is no reason to take the pantheon because Isles are so sparse.

It's funny because both of those were overpowered in the early itinerations of the map. Kinda shows that balancing takes time. This may be best adressed in a "balancing beliefs"-thread since they compare more to other beliefs than the map a priori.
 
I don't think there were too few oases, in a game as Arabia I had 4 near my start position (2 within 3 range of my capital, and 2 others not far away). This gave a very large early game bonus to food and culture.
 
There has been a lot of discussion in the original PW3 thread. Bobert13 mentions that the random function he made that we used was flawed: http://forums.civfanatics.com/showthread.php?p=12702015#post12702015

PHP:
function PWRandSeed(fixedseed)
	local seed
	if fixedseed == nil then
		seed = (Map.Rand(32767,"") * 65536) + Map.Rand(65535,"")
	else
		seed = fixedseed
	end
	math.randomseed(seed)
	print("random seed for this map is " .. seed)
end
 
I have tried making a couple maps, both standard and large size, and standard and abundant resources, and in all cases I do not get any resources on the map. Any ideas what I'm doing wrong?
 
I have tried making a couple maps, both standard and large size, and standard and abundant resources, and in all cases I do not get any resources on the map. Any ideas what I'm doing wrong?

As this post shows, the resources are not assigned via this map, but are controlled by Firaxis' own lua code. Any 'problems' you are experiencing must be related to outside factors.

1) What have you changed in your setup from the last time you had a 'normal' map generated?
2) Have you cleared your cache and installed the latest version?
3) What is the map like without changing any of the 'Advanced' options?
4) Are you sure you haven't overlooked something simple like turning off the resource 'icons'?

Divide and conquer. Eliminate half the changes and see if there is any change.
Keep doing this until the last change is found and it must be the reason.
 
There has been a lot of discussion in the original PW3 thread. Bobert13 mentions that the random function he made that we used was flawed: http://forums.civfanatics.com/showthread.php?p=12702015#post12702015

PHP:
function PWRandSeed(fixedseed)
	local seed
	if fixedseed == nil then
		seed = (Map.Rand(32767,"") * 65536) + Map.Rand(65535,"")
	else
		seed = fixedseed
	end
	math.randomseed(seed)
	print("random seed for this map is " .. seed)
end

There certainly has been a lot of discussion going on over there. :D

I'd recommend starting around post #436 , where I bring up a few optimizations, and going from there. Most of what I covered in #436, you guys already implemented, parallel of what I was working on, but the stuff about lookup tables in the "3rd Edit" is beneficial to script run-times. Just now, I posted some new spiral iterators that are tangibly faster than Plot_GetPlotsInCircleSimple. I'm not sure if you're aware of this, but GetPlotsInCircleSimple is not returning a true spiral; it's more of a rectangular shape.

Also, this is the "fixed" random you have quoted (just clarifying). It's not perfect IMO, but it should have 1:1 distribution and it still caps at the 31 bit maximum. It may be the best that CiV's Map.Rand is capable of. I've not tested it in multiplayer, but if Jaii der Herr's rand worked, then there's no reason why this shouldn't.

As an aside, I'm also looking into implementing an improvement of the "rivers flow from lakes" idea in this script. As it is, sometimes it works great, but when the river flowing into the lake meets one of the new "Y'd" starting points, that are intended to give the effect of a river flowing from the lake, it looks like a mess.

I've already tried an alternative where instead of adding a "Y" to the start of the river flowing out of the lake, I just reversed the flow of that river segment. That however led to a new graphical issue where it looked like every river flowing from a lake had a break at the point where the river segments were flowing away from each other.

Right now, I'm looking at restricting lakes to tiles at least two plots away from a shoreline and then re-routing the river(s) involved to avoid this possibility. The restriction on lake placement would prevent certain scenarios where it's impossible to re-route the rivers involved.

I'm pretty confident that once I get rivers and lakes resolved, I'll be releasing version one of my PerfectWorld3 derivative map-script. :D

Edit: I noticed you have odd map heights possible for your resized "Terra" maps in this script. Then, (while searching for a way to limit the world size options available for my script [I want to get rid of Duel and Small as they have issues and my tectonic landmass generation doesn't scale down to those abysmally tiny sizes very well]) I stumbled across this thread where the author of a map script apparently pulled his script from the downloads section and asked, that anyone who had a copy delete it, because he found out there's issues with the game's AI behavior related to maps with an odd height... I have no idea what issues he's talking about, but if they haven't been addressed, you should maybe round your map heights up for the "Terra" option.
 
@DeepSoul
Each art tileset looks good for different areas. I use Europe art for wet areas (jungle and snow) because it has the wettest looking climate. Most deserts have the America tileset (rocky hills), while Africa is used for the largest two deserts (sand dune hills). The Asia tileset is used for some mountains and islands.

@agc28
Lakes are 2:c5food: in the vanilla game, which is not useful since citizens cost 2 food. I figure 1:c5food: 1:c5gold: is somewhat more useful since it turns the 2f cost of a citizen into one gold. I could make lakes 2 food 1 gold if you think it's necessary... I'm hesitant to change gameplay much in a map.

@Bobert13
It's unfortunate how limited the river artwork is. One odd problem is the main 3d view doesn't match what shows up on the strategic view, which can actually cause inconsistent graphics.
 
@Bobert13
It's unfortunate how limited the river artwork is. One odd problem is the main 3d view doesn't match what shows up on the strategic view, which can actually cause inconsistent graphics.

Other than the strategic view showing these river starts at lakes as river ends, I'm not sure I know what you're talking about. :p

If you've applied all of my "ghost tile" fixes from the PW3 thread (setting recalc flags whenever you change a plot type, Xshift, and force flat tiles near the seem), the only possible instance where "ghost tiles" can appear is if the resource generator decides to plop sheep on one of the flat tiles we forced near the seem. When this happens, it forces a hill, and RecalculatAreas() doesn't fix it properly; however, it's pretty easy to look at the tile and know that it's a sheep-hill tile. I've been meaning to track down RecalculateAreas() and see why it fails on the seam...

Is this something we could expand?

If someone can find what is telling the engine to draw x river art for river segment y at plot z, then yes. I spent about three hours the other day digging through the source code files (using notepad++'s "Find in files") and could not find anything relevant. It's more than possible that I either missed it, or that it's hidden in XML/SQL somewhere, or that it's part of the graphics.dll (in which case, the answer is no as the source for that is not available and probably never will be).

If anyone ever finds this, it's just a matter of making a new case for river starts that flow away from a water plot, and making some artwork for it. The art could be as "simple" as duplicating the river outflow art and then reversing the flow of the water. I'm no artist, nor do I have, even an inkling of, knowledge regarding the game's XML/SQL tables.

One thing that's been brought up, in a thread I posted in the C&C forums about this, is just changing the artwork for river starts outright. I'm not sure if it's possible to create a new river start that looks good flowing away from a lake, and looks good flowing away from other types of terrain though (hills and mountains for example).

I was going to track down the river art assets and then use "Find in files" to search the game's files for any XML/SQL that references them, but I got sidetracked with bugs. One in particular is the good ole siltify lakes infinite loop. I can sit there and spawn a map with a fixed seed 100 times in WB, and at least one of those spawns will run into this bug. I've figured out that when this happens, elevationMap.sealevelThreshold is getting set to a value less than 0.0000001 (which should technically be zero with signed 32-bit floating points). I believe this problem stems from the way Cephalo is setting the thresholds. He makes a sorted list of every value relevant to the threshold, then determines an index number to pull from that list based on the threshold. If he's including zeroes in the list of relevant values (there's a boolean parameter for the function revolving around including zeroes), it's statistically possible for the index he's pulling to contain a zero (if the threshold is 44% and your map contains 23 ones and 77 zeroes, the 44th index of a sorted table will contain zero). I went so far as to replace the sorted table approach with a purely math-driven approach (avg value * percent), however, that dramatically changes the output of the mapscript. I'm looking into creating an offset to mitigate the changes caused by a math-driven threshold...
 
Most of the graphics engine is not accessible to modders, and the river creation stuff is probably in there too.

My brother pointed out an obvious way they could have done river starts: make it begin on the previous hex, instead of halfway along its current edge. They could have shown rivers flowing down from hills or mountains. It also would have let us show rivers flowing out of lakes. Sadly, the art team didn't make it that way.
 
Most of the graphics engine is not accessible to modders, and the river creation stuff is probably in there too.

My brother pointed out an obvious way they could have done river starts: make it begin on the previous hex, instead of halfway along its current edge. They could have shown rivers flowing down from hills or mountains. It also would have let us show rivers flowing out of lakes. Sadly, the art team didn't make it that way.

It would be possible to replace the river start artwork though, correct? I know people have made new farm artwork, etc. so... Where I'm going with this is if we can make a start that looks good when two rivers start at the same junction but flow away from each other, we can make rivers flow out of lakes and look convincing. Alternatively, we could possibly make a new start that does appear to be on the next plot. How this new river start would behave when the plot is mountains or hills is still a wildcard to this approach though.

Spoiler contains a bunch of text and some code with a broken formula because I NO MATHS GUD.
Spoiler :
On the subject of mathematical thresholds... I may need some help figuring out a formula that scales with map size properly. This is the rewritten function:
Spoiler :
PHP:
function FloatMap:FindThresholdFromPercent(percent, greaterThan, excludeZeros)
	local mapList = {}
	local threshIndex
	local percentage = percent
	local sum = 0
	local avg
	local threshold
	
	if greaterThan then
		percentage = 1-percentage
	end

	if percentage >= 1 then
		return 1.01 --whole map
	elseif percentage <= 0 then
		return -0.01 --none of the map
	end
	
	if excludeZeros == true then
		--'Keep the old threshold determination when returning zero isnt possible'
		for i=0,self.length-1,1 do
			if self.data[i] ~= 0.0 then
				table.insert(mapList,self.data[i])
			end
		end
		
		table.sort(mapList, function (a,b) return a < b end)
		threshIndex = math.ceil(#mapList * percentage)
		threshold = mapList[threshIndex-1]
		
	else
		--'Use a mathematical formula to determine a threshold when returning zero is possible. (only sea level is called without excludeZeros by default)'
		for i=0,self.length-1,1 do
			sum = sum + self.data[i]
		end
		
		--'#######################################################'
		avg = sum/((self.hieght^2 + self.width^2) * percentage) --'this is where Im having problems...'
		--'#######################################################'
		threshold = avg
		print(string.format("seaLevelTheshold is %f",threshold))
	end
	
	if threshold == nil then
		print("returning a nil value during FindThresholdFromPercent. - YAPD")
	end
	
	--print(threshold)
	return threshold
end

I've tried a number of things for my threshold formula though none of them seem to scale very well... The formula shown is definitely no good. If I find a formula that works (near) perfectly for huge maps, it destroys even standard size maps (much less small and tiny maps).

The following formula seems to work really well for huge maps, though I have no earthly idea why "percentage^8" works...

avg = sum/(self.length/percentage^8)

I do know that 8 is 1/10th of the map height so I tried exponentiating to the mapHeight/10 and for tiny maps, ^2 almost works, but even spawning large maps ^6.4 falls apart (my islands resulting from my elevation map generation disappear).
 
Most of the graphics engine is not accessible to modders, and the river creation stuff is probably in there too.

My brother pointed out an obvious way they could have done river starts: make it begin on the previous hex, instead of halfway along its current edge. They could have shown rivers flowing down from hills or mountains. It also would have let us show rivers flowing out of lakes. Sadly, the art team didn't make it that way.

This should actually be possible to do since the artwork can overflow into other tiles out of the hex as shown by the atoll replacement mod I made. If I can find the artwork that the river starts use I can make another proof of concept.

Nevermind, it looks like river generation is done in a completely different way than most of the terrain is (except for strategic view art assets).
 
Top Bottom