[Map Script] PerfectWorld2.py

The only thing that sometimes bothers me is the propensity for most continents to have a large desert area in the center. I like the tactical and strategic impact it has on the game, but I wouldn't mind seeing it occasionally replaced with a massive plains area (ala the Great Plains in the US) or vast jungle (ala the Amazon). These would still have a similar impact on strategy, but it would also add a little more variety to the maps generated.
You can do this a couple of ways, depending on what you want for results.

You can modify the rainfall amounts by area (continent), so you can do things like have the largest area use the rainfall unmodified (large desert in the middle) and then artificially increase the rainfall on all subsequent areas. You can also leave the rainfall alone but adjust the desert & plains percent on the fly for a similar effect. I did this with a modified version of the old Perfect World and it works well for getting a large 'great plains' area.

Or, you can dive into the climate code and adjust the effect temperature has on rainfall so that deserts are less likely outside of the hotest climate zones. This will give you more defined deserts but they will be 'bands' which will ruin some of the visual appeal of the maps.

Finally, you can adjust the values on the fly based on the individual area sizes. This gets a little tricky for anything other than pangaeas since the terrain are placed by iterating through the list of plots in order with no regard to what area they're in. I did something similar to this in my ErebusContinent map script for Fall From Heaven (it's based on Cephalo's Faire Weather script, so very similar to this one) however since I almost force pangaeas I cheated and based the modification to the desert and plains thresholds based on the size of the largest area.

Unfortunately, they all result in sacrificing the natural effect of Cephalo's climate model. But you should be able to play around and find that happy medium for your taste. :)

Oh, and they all require getting your hands dirty with python code, not just tweaking some values.
 
The mapscript does not appear as a map option for "PLAY NOW!" games. When I use this mapscript for a custom game, there are no "New World Rules" or "Pangea Rules" options (no such drop-down menus at all). The map takes an unusually long time to generate (five about minutes for a standard-sized map, compared to about one minute with pangea). The result is world filled with one terrain type (no oceans or coasts, but with a few one-tile lakes), with a disk of trees centered around each player's starting location. Many resources do not appear on the map at all (absent from the particular iteration I'm looking at now: Aluminium, Banana, Coal, Deer, Dye, Fur, Gems, Gold, Incense, Ivory, Marble, Oil, Pig, Rice, Silk, Silver, Spices, Stone, Sugar, Wheat, Wine, and of course all the water-based resources). I don't care about whether the mapscript can be used with "PLAY NOW!" (I only tried that to see if the missing options could be accessed in that mode), and I'm happy to wait five minutes for a good map, but what comes out is unplayable.

I downloaded PerfectWorld2.zip and extracted PerfectWorld2.py. I put PerfectWorld2.py in [path to Civ4]\Beyond the Sword\PublicMaps. When I got these odd results I then tried moving it to [path to Civ4]\PublicMaps, with the same results. I have Civ4 Gold+BtS, patched to v3.19; OS is Vista Home Basic. Other mapscripts do not have this problem. Where did I go wrong?
 
The mapscript does not appear as a map option for "PLAY NOW!" games. When I use this mapscript for a custom game, there are no "New World Rules" or "Pangea Rules" options (no such drop-down menus at all). The map takes an unusually long time to generate (five about minutes for a standard-sized map, compared to about one minute with pangea). The result is world filled with one terrain type (no oceans or coasts, but with a few one-tile lakes), with a disk of trees centered around each player's starting location. Many resources do not appear on the map at all (absent from the particular iteration I'm looking at now: Aluminium, Banana, Coal, Deer, Dye, Fur, Gems, Gold, Incense, Ivory, Marble, Oil, Pig, Rice, Silk, Silver, Spices, Stone, Sugar, Wheat, Wine, and of course all the water-based resources). I don't care about whether the mapscript can be used with "PLAY NOW!" (I only tried that to see if the missing options could be accessed in that mode), and I'm happy to wait five minutes for a good map, but what comes out is unplayable.

I downloaded PerfectWorld2.zip and extracted PerfectWorld2.py. I put PerfectWorld2.py in [path to Civ4]\Beyond the Sword\PublicMaps. When I got these odd results I then tried moving it to [path to Civ4]\PublicMaps, with the same results. I have Civ4 Gold+BtS, patched to v3.19; OS is Vista Home Basic. Other mapscripts do not have this problem. Where did I go wrong?

Well it's not supposed to do that obvoiusly. ;) Just for a quick check, make sure you don't have a map script called 'random.py' in your map folders. If you have this, rename it to something else, as that name conflicts with part of the Python system that PW uses.

Beyond that, there are some more steps we can take to diagnose this problem. I'll try to help you through it.
 
Thanks for the assistance. The closest thing I have to random.py is RandomScriptMap.py. To be sure, I emptied both \PublicMaps folders of everything except PerfectWorld2.py and tried again. The result was the same.
 
Thanks for the assistance. The closest thing I have to random.py is RandomScriptMap.py. To be sure, I emptied both \PublicMaps folders of everything except PerfectWorld2.py and tried again. The result was the same.

Ok, don't do anything drastic. These things are usually very simple. First, make sure there is only one copy of PerfectWorld2.py in one of the folders. Putting the same file in both locations will not work. Open your Civilization.ini file in notepad, and set this option to 1.

LoggingEnabled = 1

Generate a map. then look at the PythonErr.log file, in your BtS/Logs folder, with notepad. Then post the contents here so we can see why it crashed.
 
The log that was generated was 23 Mb of "Can't find module PerfectWorld2" errors. This made me suspicious, so I opened up PerfectWorld2.py and the last portion of the mapscript was corrupted. I redownloaded the mapscript, confirmed that it was not corrupted, and tried again. Everything now works as expected. Thanks again for your assistance.
 
Awesome map script, you deserve a huge round of thanks. It produces absolutely beautiful and yet very playable maps. Good job! :goodjob:

Only complaint I have is that you need to tweak the starting location resource distribution a bit better. I generated a few maps and checked them out in world builder, and sometimes I found a single unirrigated Wheat resource (nothing else at all in BFC, not even many forests), while one time I got 3 Fish, 1 Clam, 1 Pig, 1 Rice, and 1 Gem. I'm not complaining so much about the times when it gives a large number of resources, but ideally it should not be giving 1 single resource for any start. If you could code in something that would ensure a minimum of 2-3 resources per start, that'd be fine.

Apart from that one small issue though, this map script is brilliant. Once again, massive thanks for creating this! :D
 
Awesome map script, you deserve a huge round of thanks. It produces absolutely beautiful and yet very playable maps. Good job! :goodjob:

Only complaint I have is that you need to tweak the starting location resource distribution a bit better. I generated a few maps and checked them out in world builder, and sometimes I found a single unirrigated Wheat resource (nothing else at all in BFC, not even many forests), while one time I got 3 Fish, 1 Clam, 1 Pig, 1 Rice, and 1 Gem. I'm not complaining so much about the times when it gives a large number of resources, but ideally it should not be giving 1 single resource for any start. If you could code in something that would ensure a minimum of 2-3 resources per start, that'd be fine.

Apart from that one small issue though, this map script is brilliant. Once again, massive thanks for creating this! :D

Bear with me on that, you get all those extra resources because you are locked into a place that's hard to expand from. The starts that are resource poor are usually the easier ones. If you play it through you'll see that things work out pretty well. I also give bonus resources when the game is played at higher difficulties.

EDIT: You might try playing with the variables at the beginning of the script that control the handicapping. If you play on Noble you can boost the extra resources given for that difficulty. You can also boost the amount of resources overall across the map.
 
Okay, I can sort of see the logic there. However, even so, a single unirrigated wheat is rather on the light side. That would be one tough start to play, regardless of the surrounding land. ;)

But thanks again for a script that is pretty much near-perfect in my opinion. :)
 
Trying to track the cause of an assert failure in my debug dll, I was surprised to find it was caused by this map script.

This line of code shouldn't be used.
Code:
                sPlot.setImprovementType(gc.getInfoTypeForString("NO_IMPROVEMENT"))
If you need to remove all improvements from a plot, please use this instead:
Code:
sPlot.setImprovementType(-1)
This is more proper, and you wol't be telling the dll to get an attribute of a NONE type object.
 
Trying to track the cause of an assert failure in my debug dll, I was surprised to find it was caused by this map script.

This line of code shouldn't be used.
Code:
                sPlot.setImprovementType(gc.getInfoTypeForString("NO_IMPROVEMENT"))
If you need to remove all improvements from a plot, please use this instead:
Code:
sPlot.setImprovementType(-1)
This is more proper, and you wol't be telling the dll to get an attribute of a NONE type object.

That line of code was one of my earlier ones, and I guess I thought it fit with the patterns I was seeing. It is to remove goody huts from a starting plot, which crashes the game if it happens, if I remember correctly. Once I was satisfied it worked, I'm sure I just moved on. I'll fix it in the next version.
 
Cool, thanks. It's more of just a proper procedure thing, but it also makes a debug dll complain so it's just "not right". I mean it works, but you're basically saying "Give me the int value in the list for type "" (it might actually properly know to look in Improvements, I'm not sure how NO_$STRUCT works here), for object NoneType". The way Civ4 works for this, it returns -1 for the NoneType object when asked to find it's spot in a list, but I'm not sure if that's a compiler thing, or intrinsic to the way Civ4's classes are handled, and I wonder if it can't cause bugs on different OS's since it's obviously a nonsensical call (For instance XP will return -1 when it gets "null" returned for this type of call, but Vista and Windows 7 will crash); probably not though. Anyway it's not a big deal, but wanted to point it out to you, as I'm sure you'd rather fix it anyway.
 
Hi.

I usually play on huge toroidal maps with most settings customized.
Problem : the climate zones in my maps are sometimes cut on a horizontal line and displaced east and westwards on the continent.
The horizontal line may be at a constant latitude, I don't remember seeing it close to the center on the map.
I just noticed on my last map that there seem to be two lines of division. The southern one is obvious, between a forest and a desert, but there is another in the north.

Spoiler :


Is that a common bug ?
 
In the screenshot has to do with the south polar front, wind travels westward north of it, and eastward south of it. The difficulty in simulating this is that in real life it's a very rainy area, but in Civ there aren't many water map squares that can contribute water to it. So on the normal settings I usually try and fake it by creating blank water bands on the map edges that are clipped away by the time the final map is made.

It appears that the settings you are using are making my faking efforts more obvious. I'm guessing that's whats happening. Ocassionally you can see these artifacts on the default settings also, but not too often. I think it happens more on huge maps also.

EDIT: Just to refresh my memory, I generated a few huge toroidal maps, and I saw the problem alot. My climate model really has some difficulties with toroidal it seems. The north and south polar winds are angled away from each other, and really they aren't designed to be touching like they are on a toroidal map. I don't know how to handle it at this time.
 
I just had to redownload this, and I was wondering how it was that I add a few more islands to it? I think you mentined it before, but I can't seem to find where I asked.
 
Try setting self.hmMaxGrain to 8 or 4 and let me know if you like that better.

Code:
        #Size of largest map increment to begin midpoint displacement. Must
        #be a power of 2.
#        self.hmMaxGrain = 16
        self.hmMaxGrain = 4

Islands, islands everywhere, and not a ship to sink.
 

Attachments

  • Civ4ScreenShot0000.JPG
    Civ4ScreenShot0000.JPG
    148.6 KB · Views: 216
  • Civ4ScreenShot0001.JPG
    Civ4ScreenShot0001.JPG
    158.8 KB · Views: 207
Hi

Is this Map compatible with MODs? "Base 1.6"
Or i must change something ...
But there are new resources ...
Is this Multiplayer compatible ... but in 2008 it wasnt.

Thx
 
Hi

Is this Map compatible with MODs? "Base 1.6"
Or i must change something ...
But there are new resources ...
Is this Multiplayer compatible ... but in 2008 it wasnt.

Thx

If a mod has new terrain or new features, the map won't work. New bonuses are fine however.

This map is multiplayer compatible now.
 
Top Bottom