[Map Script] PerfectWorld.py

I just published 1.08.

I really did not like the way I divided the world into two different hemispheres in 1.07. It made every map kindof similar and predictable. I replaced it with a simulated meteor shower that knocks out the bottlenecks on pangaea type continents. This way is better because the maps are less regular and more organic like they were pre-1.07. The effect is usually subtle, but sometimes you can discern a distinct impact crater. This looks cool and should give your Civ citizens reason to speculate how the dinosaurs died out.

Also I added a tuning variable to turn this feature off for those who do like pangaeas.
 
Is there a section of code or something I can comment out to remove the "new world" restriction?

I am looking at the continent id code and am a bit lost. I'm not much of a programmer but it seems like I might be able to do something here that will either comment out the new world code, or just assign the new world to the smallest continent (like a 1 tile island).
 
Is there a section of code or something I can comment out to remove the "new world" restriction?

I am looking at the continent id code and am a bit lost. I'm not much of a programmer but it seems like I might be able to do something here that will either comment out the new world code, or just assign the new world to the smallest continent (like a 1 tile island).

I should probably have that as an option. Stay tuned.

There will be another update as I have discovered a problem with my start plot evaluation. I am counting all the food that a city can produce as if it can grow to full size, when in some cases, it can't. If a player starts on all tundra the evaluator sees a city with 20 food, which is impossible since the city can't grow past 2. I had a quick fix that really worked well; I set the value of non self-supporting plots to zero (fine for starting area calculation), but this solution caused a huge avoidance of the coast, which also produce only one food unless you have a lighthouse. Rather than assume that a lighthouse is in the mod, or perhaps not something better, I'm going to take a couple of days to add a proper buildingInfo loop to check the yield changes.
 
This mapscript looks superb and i think it's great to play on it, but unfortunately it won't work for me.
Everytime i try it i get a map full of grassland with rivers. There aren't any other features besides a little forest around the startingplots of the civs.
See screenshots.
I have the mapscript in BtS-Root/PublicMaps, but it also didn't work in the CustomAssets-PublicMaps.
My Machine:
AMD Athlon XP 3000+
2GB Ram

What could cause the problem?
 

Attachments

  • Civ4ScreenShot0016.JPG
    Civ4ScreenShot0016.JPG
    202 KB · Views: 117
  • Civ4ScreenShot0017.JPG
    Civ4ScreenShot0017.JPG
    245.5 KB · Views: 145
This mapscript looks superb and i think it's great to play on it, but unfortunately it won't work for me.
Everytime i try it i get a map full of grassland with rivers. There aren't any other features besides a little forest around the startingplots of the civs.
See screenshots.
I have the mapscript in BtS-Root/PublicMaps, but it also didn't work in the CustomAssets-PublicMaps.
My Machine:
AMD Athlon XP 3000+
2GB Ram

What could cause the problem?

That's a map crash. I think the map has to go in Civ4/PublicMaps and not BtS/PublicMaps.
 
I should probably have that as an option. Stay tuned.

There will be another update as I have discovered a problem with my start plot evaluation. I am counting all the food that a city can produce as if it can grow to full size, when in some cases, it can't. If a player starts on all tundra the evaluator sees a city with 20 food, which is impossible since the city can't grow past 2. I had a quick fix that really worked well; I set the value of non self-supporting plots to zero (fine for starting area calculation), but this solution caused a huge avoidance of the coast, which also produce only one food unless you have a lighthouse. Rather than assume that a lighthouse is in the mod, or perhaps not something better, I'm going to take a couple of days to add a proper buildingInfo loop to check the yield changes.

That's a good idea. I want to suggest three things:

1) Cache the list of buildings that affect plot yields so you don't have to loop through every building for every plot.

2) Take era into account. Dikes should not be a big factor in an ancient era start.

3) Take uniqueness into account. Moai Statues do not always get built in the capital, because there is only one of them. I would recommend not counting national/world wonders or projects at all.

About setting the value of non-self-sustaining plots to zero: is this before or after improvements? If it's before, you're going to value a 1f/6h/6c tile as zero. If it's after, that tile's value depends hugely on whether it decides to farm it or not.

Maybe we need to do food, commerce and production separately? You basically need a lot of food and some production, whereas commerce is gravy.
 
That's a good idea. I want to suggest three things:

1) Cache the list of buildings that affect plot yields so you don't have to loop through every building for every plot.

2) Take era into account. Dikes should not be a big factor in an ancient era start.

3) Take uniqueness into account. Moai Statues do not always get built in the capital, because there is only one of them. I would recommend not counting national/world wonders or projects at all.

About setting the value of non-self-sustaining plots to zero: is this before or after improvements? If it's before, you're going to value a 1f/6h/6c tile as zero. If it's after, that tile's value depends hugely on whether it decides to farm it or not.

Maybe we need to do food, commerce and production separately? You basically need a lot of food and some production, whereas commerce is gravy.

All good points. Caching relevant buildings will allow a more thorough check and speed things up a great deal. I've done some initial research and the buildingInfo stuff is extremely complex. I hope I don't hit any snags. For example, some buildings require multiple techs, which might mean multiple eras. The xml has one prereq tech, then a separate list of techs (see Grocer). I hope that there aren't too many convoluted data structures like that out there. Also, with UB's added in Warlords, I might have trouble making this work with vanilla, since I don't want UB's involved in this calculation.

I'm not too worried about missing the occasional 'sweet spot' like 1f/6h/6c. I've come to believe that finding starting positions is a matter of avoiding really bad ones rather than finding the best ones. Missing something basic like lighthouse/coast will not work unfortunately. After improvements, bonuses and starting era compliant buildings are factored in, I'm thinking that excluding non-self-supporting plots can only improve things.
 
One problem with this is you're going to value hills as zero unless you count windmills (which are unbuildable early, and also might not be in the mod). Having some hills for production is usually very important.

Another interesting issue I ran into earlier with the script is when I was using a mod where Serfdom gave +1h to Farms. The script proceeded to value farms as if they were always 1f/1h, which is very high. (IIRC, the 1f is the bonus from Biology - I don't think it was counting the 1f from irrigation. This would mean if someone plays a mod that doesn't go up to that age, farms would be treated as worthless, and there would be no way to up the food count of a tile, thus making all plains worth zero. I may be wrong and it still treated freshwater tiles as being +1f from farms, however.)
 
That's a map crash. I think the map has to go in Civ4/PublicMaps and not BtS/PublicMaps.
Ah, that's an option i haven't thought of. I will try it and report. Thanks :goodjob:

/edit: No, it still don't work. :(
 
Ah, that's an option i haven't thought of. I will try it and report. Thanks :goodjob:

/edit: No, it still don't work. :(

Are you using any mods that have custom terrain types(like "lava") or something? Are you using a Mac? Can you make a duel size map?
 
I use the Blue-Marble-Mod, which is just a terrain-textures mod and some python-modcomps.
I run a PC, Athlon XP 3000+, 2GB RAM, WinXP SP2.

I will try a duell-size map.

/edit: No :(
But at least there are some lakes :D
 

Attachments

  • Civ4ScreenShot0019.JPG
    Civ4ScreenShot0019.JPG
    227.8 KB · Views: 108
I use the Blue-Marble-Mod, which is just a terrain-textures mod and some python-modcomps.
I run a PC, Athlon XP 3000+, 2GB RAM, WinXP SP2.

I will try a duell-size map.

/edit: No :(
But at least there are some lakes :D

Is anyone else having a map crash problem? There's a way to turn on python error popups in the CivilizationIV.ini file that is in your myDocuments/games/BtS directory. Set HidePythonExceptions to '0' and that should pop up with the reason the map is crashing. In the same file you might enable the logging system as well to see how far the script is getting.
 
1.09 is published.

The trouble I was having with the avoidance of the coast was due to a bug introduced in 1.07 that was assigning the value of only one plot and then multiplying it by the CoastalCityValueBonus variable. I had turned that variable up to 10.0 and it was still avoiding the coast, so I knew something was broken. :lol: Python let me use an old variable name since scope is not an issue. I swear so many of the things that scripting languages try to do for you to make things supposedly easier just end up introducing bugs. Type checking, etc. is a good thing, not a bad thing!

Once that was fixed, I suddenly had alot more control over my starting plot results and rather than worry about building effects and stuff, I just made a rule that if food + production + commerce < 3, then the plot has no value. This solved the problem of lots of tundra being an option for a starting plot and so I am very happy with it. I generated lots of maps and I was unable to find even one bad starting plot. Unless I made a recent mistake, this should be a good final version for PerfectWorld.

Also I added an option to turn off the 'New World' placement rules.
 
Is anyone else having a map crash problem? There's a way to turn on python error popups in the CivilizationIV.ini file that is in your myDocuments/games/BtS directory. Set HidePythonExceptions to '0' and that should pop up with the reason the map is crashing. In the same file you might enable the logging system as well to see how far the script is getting.

Just tested with version 1.09.

On startup of BtS i get an errormessage that the mapscript cannot load. -> See screenshot

The Pythonerror-Log is also attached.
 

Attachments

  • ScriptError_PErfectWorld.JPG
    ScriptError_PErfectWorld.JPG
    13.3 KB · Views: 89
  • PythonErr.log.txt
    PythonErr.log.txt
    467.9 KB · Views: 78
Just tested with version 1.09.

On startup of BtS i get an errormessage that the mapscript cannot load. -> See screenshot

The Pythonerror-Log is also attached.

Ok, 'random' is the random number generator that python uses. I wonder why it would not be able to import the random module. Could there be a naming conflict with the modcomps you are using? What directory exactly are you putting PerfectWorld.py in? What happens if you run plain old BtS?

Make sure the map is not in the My Documents\My Games\Civilization 4\PublicMaps folder, but the Civilization 4\PublicMaps folder.
 
I tried it with an empty/deleted BtS-CustomAssets and it also didn't work :(
I placed it into Civ4-Root/PublicMaps.
This really is a mystery for me....
 
I have the map in "My Documents\My Games\Beyond the Sword\PublicMaps" which is quite unlike instructed, but it still works fine. Of course this way it wouldn't be found for Warlords or Vanilla, but I don't have Warlords installed currently and don't play vanilla, so doesn't matter to me.
 
Back
Top Bottom