[Map Script] PerfectWorld2.py

cephalo

Deity
Joined
Jul 26, 2007
Messages
2,058
Location
Missouri, USA
Hi Folks!

This map script for vanilla Civ4,Warlords, BtS and most mods based on Civ4 generates a random, earth-like map, usually with a 'New World' with no starting locations that can only be reached with ocean going technology. Landforms are created using a random heightfield and a plate tectonic scheme. Climate is simulated using the interaction between the landforms and geostrophic winds. Though great pains are taken to semi-accurately simulate landforms and climate, the goal must be to make unpredictible, beautiful looking maps that are fun to play on.

Download the file here from the downloads database.

This script is a rebuilt version of my first map script, PerfectWorld v. 1.13. As this version is almost a complete rewrite, and is quite different from previous versions, I will keep version 1.13 available from it's original thread.

To use this map, put it in your Civilization 4\PublicMaps folder, not in your My Documents\My Games\Civilization 4\PublicMaps folder.

-- Map Options --
New World Rules:
Start in Old World(Default): Reserves some continents to act as a new world
Start Anywhere: Disables the new world functionality

Pangaea Rules:
Break Pangaeas(Default): Breaks up Pangaeas with a simulated meteor shower.
Allow Pangaeas: Allow pangaeas to exist. Keep in mind that this will likely eliminate any 'New World' as well.

-- Summary of creation process: --
First, a random heightfield is created using midpoint displacement. The resulting altitudes are then modified by a plate tectonics scheme that grows random plates and raises the altitudes near the plate borders to create mountain ranges and island chains.

In generating the plot types from a heightmap, I had found that using peaks for high altitude and land for less altitude created large clusters of peaks, surrounded by a donut of hills, surrounded again by a donut of land. This looked absolutely terrible for Civ, so I made it such that peaks and hills are determined by altitude *differences* rather than by absolute altitude. This approach looks much better and more natural.

The terrain generator gives the other needed visual cues to communicate altitude. Since air temperature gets colder with altitude, the peaks will be plots of ice and tundra, even near the equator, if the altitude is high enough. Prevailing winds, temperature and rainfall are all simulated in the terrain generator. You will notice that the deserts and rainforests are where they should be, as well as rain shadows behind mountain ranges.

Rivers and lakes are also generated from the heightmap and follow accurate drainage paths, although with such a small heightmap some randomness needs to be thrown in to prevent rivers from being merely straight lines.

Map bonuses are placed following the XML Rules but slightly differently than the default implimentation to better accomodate this map script.

I've always felt that the most satisfying civ games are the ones that provide a use for those explorers and caravels. Though the map generator does not explicitly create a 'New World', it will take advantage of any continents that can serve that purpose. No starting locations will be placed on these continents. Therefore, the likelyhood of a significant new world is very high, but not guaranteed. It might also come in the form of multiple smaller 'New Worlds' rather than a large continent.

Enjoy!

Here are some screenshots to illustrate some of the features of PerfectWorld2.

Here is a typical map overview, using the same random seed value to generate three different sized maps. Dual, Standard, and Huge.


Here is an example of how PerfectWorld2 creates an illusion of altitude differences. On the left you can see an area of high mountain peaks covered in snow. As you look to the right you can follow the rivers as they flow into the ocean through lower, warmer altitudes.


Rivers follow accurate drainage paths governed by the altitudes of each map square. Rivers in PerfectWorld2 are longer and more natural looking compared with previous versions. Here is a typical example.


The climate model simulates weather patterns caused by geostrophic and monsoon winds. Here is a picture of how high mountains can cause a 'rain shadow' effect by blocking moisture coming in from the ocean.


Version History
2.06 - Fixed a few bugs from my minimum hill/maximum bad feature function.

2.05 - Made maps of standard size and below a bit smaller. Changed the way I remove jungle to prevent excessive health problems. Tiles in FC on differen continents have zero value. Tiles on different continents will not be boosted with resources or hills. Water tiles have zero value for non-coastal cities. Water tiles will not be boosted with resources for non-coastal cities, land tiles will be boosted instead. (lookout Sid's Sushi!)

2.04 - Changed many percent values to be a percent of land tiles rather than total map tiles for easier, more predictable adjustment. Ensured a minimum number of hills in a starting fat cross. Disabled the normalizeRemovePeaks function a replaced it with a maximum peaks in FC function. Added bonus resources to FC depending on player handicap. Added a value bonus for cities placed on river sides.

2.03 - Fixed an initialization problem related to Blue Marble. Added some enhanced error handling to help me track down some of the intermittant bugs that still remain.

2.02 - Fixed some problems with monsoons that were creating strange artifacts near the tropics. Added an exponential curve to heat loss due to altitude, so that jungles can appear more readily without crawling to inappropriate latitudes.

2.01 - Changed the way I handled a vanilla version difference. Added toroidal and flat map options. Made tree amount more easily adjustable. Added a variable to tune the level of resource bonuses. Changed the rules for fixing tundra/ice next to desert. Added altitude noise to the plate map to improve island chains. Added a variable to control heat loss due to high altitude. Implimented a new interleaved bonus placement scheme so that bonuses are placed individually in random order, rather than all of each bonus type at once. Brought back the meteor code from PerfectWorld 1 and eliminated the east/west continent divide.

2.0 - Rebuilt the landmass and climate model using the FaireWeather.py for Colonization map script engine. Improved the river system. Fixed some old bugs.
 

Attachments

  • PW2altitude.jpg
    PW2altitude.jpg
    129.4 KB · Views: 53,637
  • PW2RainShadow.jpg
    PW2RainShadow.jpg
    122.1 KB · Views: 52,963
  • PW2River.jpg
    PW2River.jpg
    137.5 KB · Views: 53,543
  • Sizes.jpg
    Sizes.jpg
    117.1 KB · Views: 53,911
Well done! Those screen shots look absolutely beautiful and I cannot wait to try this out.
 
Looks very interesting. I'd like to run this with Fall from Heaven 2. Do you know by any chance if it happens to be compatible?

It should be yes. If not, then I made a mistake somewhere. Seven05 is also making a FFH specific map script using the FaireWeather engine also. Check the maps and modmod forum in the FFH section.
 
It's a beautiful map. I'm not sure I like the random tundra and ice hills sections in the middle of perfectly good temperate forrest regions though.

I like how the map seems to automatically adjust the size of it's landmass/continents based on how many civs you have chosen to be in a game. I started a game with 24 civs and it generated a nice map just enough room for 4-5 cities for everybody (Except 2 civs that got screwed on their random start, which happened to be on tiney islands. But one of those was Tokugawa. I'm sure the mercantile won't mind though :lol: )

In quick short simple terms, what's the main difference in this one from Perfect World1?
 
And here it is! Thanks for all your time you put into this. :)

EDIT: I hope you don't object if I bundle this up with FlavourMod for FfH again?

No objections, buuut there's gotta be some bugs in here. Too much new stuff.
 
It's a beautiful map. I'm not sure I like the random tundra and ice hills sections in the middle of perfectly good temperate forrest regions though.
High mountains! Those are high mountains!

I like how the map seems to automatically adjust the size of it's landmass/continents based on how many civs you have chosen to be in a game. I started a game with 24 civs and it generated a nice map just enough room for 4-5 cities for everybody (Except 2 civs that got screwed on their random start, which happened to be on tiney islands. But one of those was Tokugawa. I'm sure the mercantile won't mind though :lol: )
No adjustments of the kind you mentioned. Does that mean the map is too big for a normal game? Nobody should be starting on tiny islands, I'd like a screenshot if that's the case because that's a bug.

In quick short simple terms, what's the main difference in this one from Perfect World1?

Faster, more thorough climate generator. Better rivers. Better smaller maps. More tuning variables for different effects (but that's more of a modding thing). Most of the changes are under the hood I guess.

I'm hoping that it is a better map script, but it's kinda like getting a new haircut. It may well be a more fashionable haircut, but if you aren't used to it it can be kinda disconcerting.
 
Great maps. But I'd like fiddle a little with ressources, too scarce for me.
Is there a way to get this sort of change through your bonus placer in the script, or should I learn how to rewrite this whole part ?
I tried to play frankenstein with others scripts bonus placers sewed to yours, but of course it didn't work.
 
Great maps. But I'd like fiddle a little with ressources, too scarce for me.
Is there a way to get this sort of change through your bonus placer in the script, or should I learn how to rewrite this whole part ?
I tried to play frankenstein with others scripts bonus placers sewed to yours, but of course it didn't work.

By scarce you mean normal correct? If resources are really scarce there might be a problem. There should be alot of bonuses, just as much as the factory maps and maybe more.
 
It should be yes. If not, then I made a mistake somewhere. Seven05 is also making a FFH specific map script using the FaireWeather engine also. Check the maps and modmod forum in the FFH section.

Yes, it does work very well in fact! Great map! Thanks! :goodjob:

Would it be possible to make sure Brigit gets placed on a new world spot?
 
Yes, it does work very well in fact! Great map! Thanks! :goodjob:

Would it be possible to make sure Brigit gets placed on a new world spot?

Well, I would have to make a FFH specific version for that. Seven05 is making a very similar map specifically for FFH so I don't wanna step on his toes. In my experience with PW1 though, I have found that using a 'new world' with FFH will get so ridiculously full of animals and barbarians that it's almost unplayable. When no one is around to kill them they breed and breed and breed.
 
What's a factory map ?
Well, in any case, the maps are playable since ressources seems equally scarce for all players. But there is a clear difference with the big and small maps I usually play.
I just took these screens, from the two first maps generated.
This one is a Big and Small, the total of the bonuses around the starting locations of the three players is 20, with each time at least two food ressources that can be joined directly or by moving the colon in a adjacent case.
Spoiler :

This one is a PerfectWorld 2. the total is 9, and one food ressource in each starting location's fat cross.
Spoiler :
 
What's a factory map ?
Well, in any case, the maps are playable since ressources seems equally scarce for all players. But there is a clear difference with the big and small maps I usually play.
I just took these screens, from the two first maps generated.
This one is a Big and Small, the total of the bonuses around the starting locations of the three players is 20, with each time at least two food ressources that can be joined directly or by moving the colon in a adjacent case.

By factory map I mean the ones that come with the game.

By looking at these screen shots, I don't see anything obviously broken, but let me explain a little how the starting plot function works that is different than other maps.

The starting plots in the PW2 screens are very good starts with lots of grassland, which is somewhat rare on this map. The quality of the starting plot is measured by not only the fat cross but also the fat cross of any likely city spots you are likely to build first by virtue of path distance. The starting plot 'sweetener' code will give bonuses depending on the relative strength and expandability of each players starting plot. If you look at all the starting plots on a map, you should see some players in weaker positions with a lot of bonuses in their fat cross. If you don't see that, there might be a bug. Check your PythonErr.log file to see if something has failed.

EDT: actually this would be more obvious on a larger map with more players. On this small map, those three players are starting roughly equally, so that might be why there's no sweetening.
 
There's no log recently modified. I understand that this is not a bug, it's the way the ressources are normally implanted in your mapscript.
My request was simply based on a personnal preference - as i like the way the landmasses appear in perfectworld, i like all the couloured or shiny ressources that appear in others maps.
 
There's no log recently modified. I understand that this is not a bug, it's the way the ressources are normally implanted in your mapscript.
My request was simply based on a personnal preference - as i like the way the landmasses appear in perfectworld, i like all the couloured or shiny ressources that appear in others maps.

You might try commenting out the addBonuses and setStartingPlots functions near the bottom of the script. That will cause it to use the default routines. On small maps, that might be ok, but on larger maps you might find things to be grossly unfair and also the smaller islands won't have resources.
 
Got a number of Python errors while starting a new game.

Spoiler :
Traceback (most recent call last):

File "PerfectWorld2", line 4528, in generatePlotTypes

File "PerfectWorld2", line 1883, in initialize

File "PerfectWorld2", line 2459, in generateContinentMap

File "PerfectWorld2", line 2778, in PrintAreaMap

File "CvUtil", line 110, in write

RuntimeError: unidentifiable C++ exception
ERR: Python function generatePlotTypes failed, module PerfectWorld2
Traceback (most recent call last):

File "PerfectWorld2", line 4584, in addRivers

File "PerfectWorld2", line 4636, in placeRiversInPlot

AttributeError: RiverMap instance has no attribute 'NE'
ERR: Python function addRivers failed, module PerfectWorld2
Traceback (most recent call last):

File "PerfectWorld2", line 4961, in addLakes

AttributeError: RiverMap instance has no attribute 'flowMap'
ERR: Python function addLakes failed, module PerfectWorld2
Traceback (most recent call last):

File "PerfectWorld2", line 5091, in assignStartingPlots

File "PerfectWorld2", line 3613, in SetStartingPlots

File "PerfectWorld2", line 3772, in setupOldWorldAreaList

AttributeError: ContinentMap instance has no attribute 'newWorldID'
ERR: Python function assignStartingPlots failed, module PerfectWorld2
 
Got a number of Python errors while starting a new game.

The unidentified C++ error happens once in a while. I have no idea what it could be since it's quite rare and I can't reproduce it. If you get it frequently, let me know. The rest of the errors are all caused by the first.
 
Top Bottom