1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[Map Script] PerfectWorld.py

Discussion in 'Civ4 - Map Scripts' started by cephalo, Aug 23, 2007.

  1. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  2. emptyd

    emptyd Chieftain

    Joined:
    Mar 4, 2008
    Messages:
    6
    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... :)
     
  3. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  4. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  5. Psycho_Ivan

    Psycho_Ivan Warlord

    Joined:
    Oct 6, 2008
    Messages:
    218
    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. :)
     
  6. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  7. Psycho_Ivan

    Psycho_Ivan Warlord

    Joined:
    Oct 6, 2008
    Messages:
    218
    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.
     
  8. Woody1

    Woody1 Prince

    Joined:
    Feb 19, 2002
    Messages:
    468
    Location:
    Texas
    Generate maps and check them out with the worldbuilder, until you get one you like.
     
  9. The Capo

    The Capo godless Heathen

    Joined:
    Jan 29, 2001
    Messages:
    9,302
    Location:
    Washington, DC
    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.
     
  10. dr_s

    dr_s Prince

    Joined:
    Dec 27, 2006
    Messages:
    536
    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.
     
  11. Pariah

    Pariah Outside Influence

    Joined:
    Feb 19, 2003
    Messages:
    881
    Location:
    Beyond, Between, Before
    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?
     
  12. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  13. dr_s

    dr_s Prince

    Joined:
    Dec 27, 2006
    Messages:
    536
    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.
     
  14. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  15. dr_s

    dr_s Prince

    Joined:
    Dec 27, 2006
    Messages:
    536
    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.)
     
  16. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    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.
     
  17. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I forgot to mention that the 'jungle' level of rainfall means wall to wall trees. No chance of not being trees.
     
  18. Joecoolyo

    Joecoolyo 99% Lightspeed

    Joined:
    Apr 8, 2008
    Messages:
    9,908
    Location:
    茨城県
    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
     
  19. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Try generating a duel size map. If that works, then it's just a matter of waiting. This script is very,very slow.
     
  20. Joecoolyo

    Joecoolyo 99% Lightspeed

    Joined:
    Apr 8, 2008
    Messages:
    9,908
    Location:
    茨城県
    Oh, ok, its probably just my impatience :D
     

Share This Page