[Map Script] PerfectWorld.py

This is probably a very simplistic suggestion by your standards, but...

Does python use a base of 0 for indexes? If so, then for a list with N elements, legal indexes are 0 thru N-1, not 1 thru N. Since the error message lists the same length and index I’d guess that’s the issue.

The infrequency of the error would be confirmed because it would occur only when a random index equal to the last (really the last +1) element is indicated.

Yes it does use a base 0 for indexes, but the python randint function is supposed to return a value between 0 and N-1. I did some testing on this and my test loop ran for 20 minutes without a problem. So randint(100) should be between 0 and 99 inclusive. So when I say randint(len(list)), I should get a valid index providing the len function is giving me an accurate length. There might be a mistake in there somewhere still but I can't find it.
 
Yes it does use a base 0 for indexes, but the python randint function is supposed to return a value between 0 and N-1. I did some testing on this and my test loop ran for 20 minutes without a problem. So randint(100) should be between 0 and 99 inclusive. So when I say randint(len(list)), I should get a valid index providing the len function is giving me an accurate length. There might be a mistake in there somewhere still but I can't find it.
One quick fix might be to put the block of code within a loop. Something like this:

... preceeding code
Top of loop
generate a random number
if legal random number value
break out of loop
bottom of loop
...
use range checked random number...

I know it looks stupid - screams "I don't know what I'm doing" - but if it catches the undefinable error condition... :)
 
My only gripe with the maps I get now is that they tend to be... heavily forested. And very green. It fits the bill for a good starting spot, but it tends to be a little boring when you can't find much variety in starting spots.

That's actually refreshing to hear :) my usual complaint is from people left out in the desert to eat rocks. Starting plots were definitely the hardest part about this script. You can use the tuning variables at the beginning of the script to make the map a bit drier, but I can say that most people wouldn't like it that way. Many things are adjustable with these variables.
 
One quick fix might be to put the block of code within a loop. Something like this:

... preceeding code
Top of loop
generate a random number
if legal random number value
break out of loop
bottom of loop
...
use range checked random number...

I know it looks stupid - screams "I don't know what I'm doing" - but if it catches the undefinable error condition... :)

I think I left it in there in the hopes that I would someday figure out what's going on. I bet I made a mistake in there. My golden rule is that every time I suspect that the operating system is broken, the misbehavior I'm seeing is always my fault. Once you go down the path of fixing your bugs indirectly, things can sometimes get very painful and complicated.
 
That's actually refreshing to hear :) my usual complaint is from people left out in the desert to eat rocks. Starting plots were definitely the hardest part about this script. You can use the tuning variables at the beginning of the script to make the map a bit drier, but I can say that most people wouldn't like it that way. Many things are adjustable with these variables.

Ah. Excuse my ignorance, but how would I be able to change the variables on starting plots, and for resource clumping?

I really love the way the maps turn out, I'm just not used to running my first city with 4 seafood resources and mountain timber. :)
 
Ah. Excuse my ignorance, but how would I be able to change the variables on starting plots, and for resource clumping?

I really love the way the maps turn out, I'm just not used to running my first city with 4 seafood resources and mountain timber. :)

The starting plot finder is not actually tuneable, probably because I made it about as good as I was able to. The reason that you have 4 fish resources is because you have less valueable land area to expand into in relation to your competitors, and you get the fish as compensation for that. I have found that when you get so many starting food resources, you may still be in for a challenge on this map because it means that you have less good terrain. It doesn't always compensate exactly fairly, but this was about the best I could do given the nature of the map. The real world is anything but fair after all, and making the map look realistic while providing a fair game of Civ4 was extremely challenging.

As for other resources clumping, that is all actually controlled in the XML. The reason that you see more clumping in PW than you do with the stock maps is because most of those are based on the Fractal generator that places terrains kindof willy-nilly. When the terrains are so broken up, the clumping that is written in the default code usually has no opportunity to show itself. In this regard PW places resources according the normal XML rules with the same algorithm as the default process, but it's not broken up by abrupt scattering of terrain types. I actually like this because it promotes less self sufficiency and more trade.
 
Hm.. Good points. I suppose I'll continue to give PerfectWorld a chance, seeing as it's one of the better maps I've tried for balancing out some of the Revolution aspects.
 
Generate maps and check them out with the worldbuilder, until you get one you like.
 
If there is a next version of this, might I suggest a few options for the map? Like number of continents, or new world start options? Maybe amount of islands, sea level, things like that.
 
What's the best way to reduce the amount of forest? It's not clear to me from looking through the adjustable parameters at the front of the script which (if any) will reduce the percentage of land that's forested.
 
What's the best way to reduce the amount of forest?

Why would you want to? Forests can always be cleared as a chop-rush, and I just love a an extensive grassland-forest area full of hills and rivers: you can build a high-production city with a few farms, and still have lots of forests left to provide free specialists with the National Park. Forests, especially on hills, are great for defense too. Who would want to start with less of them?
 
What's the best way to reduce the amount of forest? It's not clear to me from looking through the adjustable parameters at the front of the script which (if any) will reduce the percentage of land that's forested.

I actually neglected to make that tunable. Sorry! Personally, I kind of like it because those heavily forested areas are usually the best places to start, and having to go bronze working ASAP maybe slows those players down slightly.
 
I actually neglected to make that tunable. Sorry! Personally, I kind of like it because those heavily forested areas are usually the best places to start, and having to go bronze working ASAP maybe slows those players down slightly.

It seems to me that the following two lines in the jungle/forest planting code control this:

Code:
if rm.rainMap[i] > terr.plainsThreshold*1.5:#jungle
              
if rm.rainMap[i] > PWRand.random() * terr.plainsThreshold * 1.5:

If I change the 1.5 in each line to a larger number, I should get less forest and jungle, correct? That seems like the most straightforward way to me, based on my limited reading of the code.

Great map script, BTW.

One small interface bug I noticed is that if I change the values of self.AllowPangeas and self.AllowNewWorld in the script file, that the in-game options don't reflect the changes.
 
It seems to me that the following two lines in the jungle/forest planting code control this:

Code:
if rm.rainMap[i] > terr.plainsThreshold*1.5:#jungle
              
if rm.rainMap[i] > PWRand.random() * terr.plainsThreshold * 1.5:

If I change the 1.5 in each line to a larger number, I should get less forest and jungle, correct? That seems like the most straightforward way to me, based on my limited reading of the code.

Great map script, BTW.

One small interface bug I noticed is that if I change the values of self.AllowPangeas and self.AllowNewWorld in the script file, that the in-game options don't reflect the changes.

Ugh, a hard coded number! What shame I have brought to myself. :blush: Yeah that's it. I could probably use a tuning variable there.

As for changing the options in the script. Be careful that the file isn't cached. That can make things confusing. Also, Vista can cause a similar problem if your installation is in the Program Files directory.
 
Thanks for the confirmation.

Regarding your last comment, are you saying that the in-game options should correctly reflect the state of the script settings? When I set "self.AllowNewWorld = False", I was still seeing "Start in Old World (Default)" selected in the interface, even though it seemed like civs could start anywhere. (But I didn't do a lot of testing.)
 
Thanks for the confirmation.

Regarding your last comment, are you saying that the in-game options should correctly reflect the state of the script settings? When I set "self.AllowNewWorld = False", I was still seeing "Start in Old World (Default)" selected in the interface, even though it seemed like civs could start anywhere. (But I didn't do a lot of testing.)

I just looked at it again and I see that I did not update the string to reflect changes. The string description always stays the same. I think when I wrote it, I meant the (default) part to indicate that it would be where you set it. If you choose option 0, the first option, nothing actually happens. If you set it to option 1, the second option, it will change the variables to what the string says it will. So it should still work, it just looks funny.
 
It seems to me that the following two lines in the jungle/forest planting code control this:

Code:
if rm.rainMap[i] > terr.plainsThreshold*1.5:#jungle
              
if rm.rainMap[i] > PWRand.random() * terr.plainsThreshold * 1.5:

If I change the 1.5 in each line to a larger number, I should get less forest and jungle, correct? That seems like the most straightforward way to me, based on my limited reading of the code.

I forgot to mention that the 'jungle' level of rainfall means wall to wall trees. No chance of not being trees.
 
I need a little help... I extracted the file to the correct folder , but for some reason every time I try to load it once the loading bar says "Initializing", the game freezes and I have to shut down the program. I can tell it freezes because the mouse never goes into the "loading globe" thing, but stays the regular mouse. I've tried it from the regular screen (with BUG and Blue Marble added) and with the RevolutionDCM Mod. Both of them crash when I try to load. Is there anything wrong with the file, am I doing something wrong?

Just for information's sake I'm using BTS 3.17
 
I need a little help... I extracted the file to the correct folder , but for some reason every time I try to load it once the loading bar says "Initializing", the game freezes and I have to shut down the program. I can tell it freezes because the mouse never goes into the "loading globe" thing, but stays the regular mouse. I've tried it from the regular screen (with BUG and Blue Marble added) and with the RevolutionDCM Mod. Both of them crash when I try to load. Is there anything wrong with the file, am I doing something wrong?

Just for information's sake I'm using BTS 3.17

Try generating a duel size map. If that works, then it's just a matter of waiting. This script is very,very slow.
 
Try generating a duel size map. If that works, then it's just a matter of waiting. This script is very,very slow.

Oh, ok, its probably just my impatience :D
 
Top Bottom