Planet Simulator

Bobert13

Prince
Joined
Feb 25, 2013
Messages
346
Edit: Here's a link to LamilLerran's updated version: http://forums.civfanatics.com/attachment.php?attachmentid=407307&d=1461956938

Description:
Tectonic Landmasses meet Geostrophic Weather.

Built on top of Cephalo's Perfect World 3 (well, my updated version of it) with code inspired by Tectonic Map Script by Haftetavenscrap and Tectonics by LDiCesare.

Currently, Continents, and Pangea are both working and playable within reasonable measures however as this is the initial release I do consider this a beta.

Installation:
Extract the map script from the archive available here and place it in the following directory:
\My Documents\My Games\Sid Meier's Civilization V\Maps

Configuration:
As with the original Perfect World 3 I have done my best to keep much of the script very configurable via the MainConstants section at the top of the script. Simply open the script with any text editor and go to town. You should find all of these constants to be relatively well commented.
 

Attachments

  • Planet Simulator.7z
    33.4 KB · Views: 3,890
  • Planet Simulator pic1.jpg
    Planet Simulator pic1.jpg
    247.4 KB · Views: 9,018
  • Planet Simulator pic2.jpg
    Planet Simulator pic2.jpg
    239.4 KB · Views: 7,553
  • Planet Simulator pic3.jpg
    Planet Simulator pic3.jpg
    242.9 KB · Views: 6,855
  • 2014-05-28_00001.jpg
    2014-05-28_00001.jpg
    341.7 KB · Views: 6,083
  • 2014-05-28_00002.jpg
    2014-05-28_00002.jpg
    355.6 KB · Views: 5,529
  • 2014-05-28_00003.jpg
    2014-05-28_00003.jpg
    318.5 KB · Views: 4,496
Thanks Bobert. I'm reinstalling the game after a while, and wanted to see if PW or Communitas had any updates, but I'll give yours a spin.
 
Thanks, I've been using the script for a few games and it seems to generate nice maps. In fact last game I spawned on a continent that looked just like Africa! That was pretty cool by itself, but one of the other main continents looked like South America on top of that. Like so:



I guess that's Atlantis in the middle. :dunno:

Other than that, can you include a setting for not generating 1-tile islands or heavily cutting down on them, since the AI is obsessed with going for them and it hurts not just my eyes but probably the AI's performance to settle such useless cities.
 
The island chains are more-or-less fundamental to the map generating properly, so writing in an option to drastically reduce or eliminate them could take some time. Additionally, three or more resource/bonus tiles and those island cities can actually be quite strong (and I intentionally altered the way some of these tiles spawn to encourage grouping).

With all of that being said, I will look into it if I ever get any free time that I can devote to my Civ V stuff. I have a number of tweaks and changes on my "todo" list for this map, and I believe the version currently hosted here still has a bug where forest spawns on desert (though I've fixed that in my most current WIP version). Reducing coastal mountains and getting some more inland ranges is also on my radar.
 
The posted maps are really beautiful. I really love that you have both a land and a sea game in the same map.

I always liked PerfectWorld3 and Techtonics - much less "bland" then the base Continents script with actual mountain ranges, deserts, etc., that matter. I don't play much anymore but I run a lot of autoplays in developing my fantasy mod. I think I will try this out for a while as setting for Éa.
 
Hallo there. Can you tell me how do you eneble that screen with | Glance At Map |
| Preview new map |
| Restart (new map) |
etc...

That would be the mod Reseed! by DonQuiche. It's available here on CivFanatics and on the Steam Workshop.
 
After so much lurking I decided to register just to give you some credit for this awesome script. I've played with your modded version of the PerfectWorld3 script since I discovered it but this one is just so much better. I've tried Tectonics too but I've always prefered PerfectWorld3 - now Planet Simulator has appeared and it looks like unbeatable to me.

Compared to other similar scripts this one manages landmasses better and has a better chance of creating 3-4 continents separated by ocean (and always makes a minimum of two separated continents, so Astronomy is always relevant - if you choose the Continents setup), it can create both blocky and snaky continents in the same game, manages deserts very well (creates actual deserts and not "desert patches") and always presents some variation. Heck, you can even choose if you want something Pangea-ish or Continent-ish. And it's so awesome sometimes it creates unprecedented maps like this one:

http://i.imgur.com/vuN2uLD.jpg


Only two ocean-separated landmasses but that inland sea is pure gold. I've run multiple tests with Civ 5 SDK and 90% of the maps are what I consider a great map (other scripts only achieve 50% at maximum, half of the time they create unwanted Pangeas or make Astronomy useless), so take that as a huge achievement.

I could keep going all day and night, but I've already wrote too much. In short: thank you very much and keep up with the AWESOME work.


PS: Could you tell me how to edit the script to have more mountains, hills and lakes in my maps? I've tried looking at the lua but some options are not clear enough to me, so any help would be very appreciated.
 
Thank you for your feedback Danny. It's greatly appreciated. For hills and mountains, lower mconst.hillsPercent and mconst.mountainsPercent. I should probably invert these to make them more intuitive (for a case where you'd want 7% of dry land to be mountains, instead of inputting 0.93 you would input 0.07).

For lakes, I did not implement a configurable main constant for them however... If you search the variable LakeUntil in the function AddLakes() and change it's value it should increase the number of lakes you get (most of the time). I currently have it set to = H/8 (where "H" is the map height). My lake placement requirements are relatively stringent and depending on how rivers and deserts (as we prefer oases in deserts) spawn on any given map (among a number of other factors) it simply may not be possible to place more lakes than what it spawns.

Additionally, near the bottom of AddLakes() there should be a line that looks like so: if iters > 499 then. This line, and the code following, is responsible for preventing an infinite loop should the lake placement loop be unable to place the desired number of lakes. However, I use a RNG during that loop so increasing the number "499" may be desirable for you. As an aside, one small bullet on my "ToDo" list for this map is to revisit lake placement. Currently AddLakes() is a mess of poorly commented code with tons of unused code so if you'd like a cleaned up version to mess around with, let me know.
 
Thank you for your feedback Danny. It's greatly appreciated. For hills and mountains, lower mconst.hillsPercent and mconst.mountainsPercent. I should probably invert these to make them more intuitive (for a case where you'd want 7% of dry land to be mountains, instead of inputting 0.93 you would input 0.07).

I already thought it was like that but wanted to confirm it with you.

For lakes, I did not implement a configurable main constant for them however... If you search the variable LakeUntil in the function AddLakes() and change it's value it should increase the number of lakes you get (most of the time). I currently have it set to = H/8 (where "H" is the map height). My lake placement requirements are relatively stringent and depending on how rivers and deserts (as we prefer oases in deserts) spawn on any given map (among a number of other factors) it simply may not be possible to place more lakes than what it spawns.

Additionally, near the bottom of AddLakes() there should be a line that looks like so: if iters > 499 then. This line, and the code following, is responsible for preventing an infinite loop should the lake placement loop be unable to place the desired number of lakes. However, I use a RNG during that loop so increasing the number "499" may be desirable for you. As an aside, one small bullet on my "ToDo" list for this map is to revisit lake placement.

I achieved to get 20-21 lakes per map compared to the 10-11 lakes per map I got before. Basically as you said adjusting = H/8 to your preference does the work (ie, H/4 = twice as many lakes). The RNG option if iters > 499 then doesn't seem to do much, though. Also, I've touched a little the mconst.minOceanSize = 3 option (the default was 5, I changed it to 3) so I get more lakes of 3-4 tiles (with 5 I almost always got 1-tile lakes as smaller lakes than 5 got deleted) - the chances of getting a great lake of 5 tiles is almost the same and having the option to have mid-sized lakes too is great.

All in all, thank you very much for the answer. Got the script to fit perfectly my taste. :goodjob:


Currently AddLakes() is a mess of poorly commented code with tons of unused code so if you'd like a cleaned up version to mess around with, let me know.

That would be great indeed. :D
 
I already thought it was like that but wanted to confirm it with you.



I achieved to get 20-21 lakes per map compared to the 10-11 lakes per map I got before. Basically as you said adjusting = H/8 to your preference does the work (ie, H/4 = twice as many lakes). The RNG option if iters > 499 then doesn't seem to do much, though. Also, I've touched a little the mconst.minOceanSize = 3 option (the default was 5, I changed it to 3) so I get more lakes of 3-4 tiles (with 5 I almost always got 1-tile lakes as smaller lakes than 5 got deleted) - the chances of getting a great lake of 5 tiles is almost the same and having the option to have mid-sized lakes too is great.

All in all, thank you very much for the answer. Got the script to fit perfectly my taste. :goodjob:




That would be great indeed. :D

Spoiler :
Code:
function AddLakes()
	print("Adding Lakes - Planet Simulator")
	local Desert	= GameInfoTypes["TERRAIN_DESERT"]
	local Plains	= GameInfoTypes["TERRAIN_PLAINS"]
	local Snow		= GameInfoTypes["TERRAIN_SNOW"]
	local Tundra	= GameInfoTypes["TERRAIN_TUNDRA"]
	local Grass		= GameInfoTypes["TERRAIN_GRASS"]
	local W, H 		= Map.GetGridSize()
	local numLakes	= 0 -- How many lakes we've placed
	local LakeUntil	= H/8 -- The target number of lakes to place

	local iters = 0 -- How many iterations of the "while loop" we've gone through
	while numLakes < LakeUntil do
		local k = 1 -- start at the first key (in landTab{}) each iteration. landTab{} is a table used to track plots that are above sea level.
		for n = 1,#landTab do
			local i = landTab[k] -- plot index for the plot we're trying to add a lake to
			local x = i%W	-- x and y coordinates of the plot at index "i"
			local y = (i-x)/W
			local plot = Map.GetPlotByIndex(i)
			if not plot:IsCoastalLand() then
				if not plot:IsRiver() then
					local placeLake = true
					local tiles = GetCircle(i,1)
					for c=1,#tiles,1 do -- iterate through the list of neighbouring tiles returned by GetCircle()
						local zplot = Map.GetPlotByIndex(tiles[c])
						if zplot:GetTerrainType() == Desert then
							placeLake = false -- prevent lake placement next to or on desert
							break
						end
					end
					local r = PWRandInt(1 , 512) -- an RNG dice throw used to create a more randomized smattering of lakes
					if placeLake and r == 1 then
						-- the following 12 lines are used to track the plot that's getting made into a lake.
						local terrain = plot:GetTerrainType()
						if terrain == Grass then
							for z=1,#grassTab,1 do if i == grassTab[z] then table.remove(grassTab, z) end end
						elseif terrain == Plains then
							for z=1,#plainsTab,1 do if i == plainsTab[z] then table.remove(plainsTab, z) end end
						elseif terrain == Tundra then
							for z=1,#tundraTab,1 do if i == tundraTab[z] then table.remove(tundraTab, z) end end
						elseif terrain == Snow then
							for z=1,#snowTab,1 do if i == snowTab[z] then table.remove(snowTab, z) end end
						else
							print("Error - could not find index in any terrain table during AddLakes(). landTab must be getting ed up...")
						end
						-- remove the tile from any "area", set it to water, and increment numLakes
						plot:SetArea(-1)
						plot:SetPlotType(PlotTypes.PLOT_OCEAN, true, true)
						numLakes = numLakes + 1
						-- remove the plot from landTab{} and decrement k so we don't skip a plot on the next iteration (due to how table.remove re-indexes).
						table.remove(landTab, k)
						k=k-1
					end
				end
			end
			k=k+1 -- increment k
		end
		iters = iters+1
		-- prevents an infinite loop should the map not have enough viable lake locations to meet our target OR the RNG used above rejected the viable locations too often.
		if iters > 499 then
			print(string.format("Could not meet lake quota after %d iterations. - Planet Simulator",iters))
			break
		end
	end

	-- console printout of how many lakes we added and we run CalculateAreas() here for Civ to use in the things it still handles during map generation.
	if numLakes > 0 then
		print(string.format("Added %d lakes. - Planet Simulator",numLakes))
		Map.CalculateAreas();
	end
end

I didn't test it, but I'm pretty confident there aren't any typos. Simply copy and paste everything in the spoiler box above over ALL of the AddLakes() function.
 
Great! Seems to work like a charm. :goodjob:

By the way, testing further it looks like your script doesn't spawn mountains near hills too frequently. Actually, mountains seem to spawn pretty frequently on the coast and too spare around instead of spawning in blocks of giant mountain chains. It seems to be pretty detrimental for the Incas' UA, it's like hills try to spawn minimum 1 tile away from mountains instead of next to them as other scripts force them to do.

Also, re-reading the thread I've seen you mentioned you've fixed the bug where forests spawn in deserts. I've only seen it happen once (in the SDK) but it would be great to have that fixed in my "perect" script. Is it by any chance an easy fix so you could guide me to make it myself or it would be better to wait until the next version? If it's too much hassle forget about it and I'll simply wait, no need to waste more of your time in helping me.

Thanks as always for the great help.
 
It's a fantastic map script. I really like the land shapes, islands, and climate control.

But I have to second the post above: something isn't quite right with mountains. Or it may be working as intended but just not what I'd like. I'm used to seeing some nice mountain ranges from PerfectWorld3 and Tectonics. What I'm seeing instead is almost all mountains as "singles" or "doubles". On the map I'm currently looking at (Standard size), there is only one "mountain range" in the entire world that consists of 5 mountains in a row. As reported above, it does seem like mountains have affinity for coasts and an anti-affinity for appearing together with hills.

I know some players don't want any mountain ranges at all, so maybe this is intended...?

I see your post above on mconst.hillsPercent and mconst.mountainsPercent settings. I don't mind fiddling with these. But are they likely to get me "ranges" of connected hills/mountains, or just more isolated instances?
 
I third the sentiment on mountains needing work:
Reducing coastal mountains and getting some more inland ranges is also on my radar.

Last week I made some progress on rewriting fault type determination. I decided, it would be best, to make a new function before elevations are assigned, that will be responsible for A) moving subduction zones (coastal ranges) off the coast a tile or two (still mostly spotty mountains should occur from these) and B) prioritizing collision zones (where two shelves above sea level are moving towards one another quickly) to create some healthier inland ranges. I may also weight ranges based on convergence rate as the reason they're so spotty now is that mountains are all just a background noise elevation multiplied by a constant, adding weighting in should smooth and contiguate some ranges while leaving some broken white caps spread around.

Right now, hills are primarily being spawned either in place of mountains as parts of mountain ranges or along transverse faults (where two faults are moving past one another). This tends to concentrate them in lines which should make playing the Inca, for example, quite viable given a decent starting location. Keep in mind a lot of the hills in the maps do get hidden by trees and jungle. Once mountains are working how I'd like them, I'll look into foothills and go from there. A couple of things I'm weary of regarding hills are A) avoiding to much rough terrain; it makes for a tedious and ineffective early war game and B) avoiding complete homogenization; I'd like to see some concentrations of hills and flatlands etc..

As far as the constants go, "both?!". Raising the thresholds on hills and mountains should mostly concentrate the "new" hills and mountains into ranges along the faults (where mountains and hills exist already) but are also likely to create more spurious features where none currently exist.
 
Great! Glad to here that some good mountain ranges are in your plans. I'll play with existing settings to see if I can get closer to what I want.

Speaking of hightmaps, I remember that one of these mapscrips (can't remember which) would generate some cold climate effects not just by latitude but also by elevation. So you would see areas that looked convincingly like Tibetan highlands with mountains, hills & flat, but all looking "higher" than surrounding based on "plot temperature" (for example, tundra/plains mix surrounded by grass/jungle lowlands). It was a neat effect that communicated elevation without relying solely on hills/mountains. Or at least I think I remember that. This was in Civ4 version of the mapscript.
 
I can't be one hundred percent but it certainly sounds like Perfect World... It was quite a pain to adjust my elevation multipliers to come up with realistic-ish climate. That being said, I'm pretty confident I left the constant to turn off my terrain matching function in Planet Simulator. Without it, tundra and snow in lower latitudes is quite common, (though everything will be more "random", deserts, grasslands, etc.). It may be possible to lighten/remove only the overrides regarding spattered cold tiles in the subtropic and tropic latitudes. I believe the function is called Cleanup() and it simply goes through lists of terrain types and runs a spiral iterator on each plot to check it's immediate surroundings to see if it should be overriden to contiguate the dominate local climate.

Which reminds me I've been meaning to write a new version of my spiral iterator with a test function parameter. This would allow me to return a single boolean value or a number (an average for example) instead of a table of plot indexes... It should noticeably speed up the script.
 
Is it possible to change the amount of resources at the map spawning? Near the capital there is always 2 or 3 resources and on the rest of the continent not so much no matter what I set at setup. Can you tell me where do I change the amount of resources (luxury and strategic) that will spawn with a map?
 
The script utilizes the game's preexisting resource generation and includes the normal options that come with it (Sparse, Standard, Abundant, Legendary Start, and Strategic Balance).
 
is there a way to get all civs to start on one continent? I tried several games with the start on largest continent option, but I am still getting civs on other continents. I wanna have an empty new world to colonize later in the game
 
Top Bottom