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] PerfectWorld2.py

Discussion in 'Civ4 - Map Scripts' started by cephalo, Feb 17, 2009.

  1. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    This map uses midpoint displacement to generate the landforms, so the hmWidth and hmHeight variables have to always be evenly divisible by the hmMaxGrain variable, which must be a power of 2. The max grain blocks must be repetitively divisible by 2 all the way down to 1. i.e. 16 - 8 - 4 - 2 - 1.
     
  2. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I just released 2.02!

    I found a problem with the monsoon code that was creating those strange bands of heavy rainfall. I added an adjustment variable to make the uplift in the low pressure zones to better match the geostrophic rainfall. 99% of the monsoon rain was clustering right near the point of lowest pressure, so I evened it out.

    Also, I played around with some erosion code to try and get more jungle on the map, and the result was that the lack of altitude diversity created visible latitude bands of temperature change which was not good. The effect was exactly the same as if I turned the heat loss due to high altitude off. It turns out the forces that break up those latitude bands in a nice way were the very same that greatly limited jungle. If I kept the strong altitude cooling and turned down the jungle temperature, jungles would creep up toward the arctic circle rather than moving inland. If I used weak altitude cooling to move the jungles further inland, then you would get obvious bands of pine trees and then tundra which looked pretty bad.

    The solution that I think works is to add a curve to the rate of heat loss due to altitude. It allows more of these competing desires to come through. How much jungle you get still depends on other factors as well, so nothing is guaranteed. If you have no landmasses near the equator you will get very little jungle. If most of the land masses are near the equator you will get huuuge jungles. Continent configuration is still a big decider, but I think this change is a big improvement.
     
  3. Romaq

    Romaq Chieftain

    Joined:
    Feb 4, 2009
    Messages:
    10
    Thank you for your response. :) The 'four times the area space' map I'm using works well. Would it be feasible to implement my proposal of an 'xl size multiplier' given the max grain? Even just writing out the "self.hmHeight" in the code to have +1 added in the wrapping portion of the script would be a big start in that direction. :)

    I didn't tamper with the max grain blocks in my hack. I have noticed 'banding' of light and dark ocean, and it sounds as if that may be what you just fixed in your code, but I'm not clear on that. Would the interaction between the hmMaxGrain and the hmHeight/ HmWidth values preclude an easy means to make an 'xl size' map variable?
     
  4. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    The final grid sizes can be any size smaller than the heightmap size. The heightmap size has to be multiples of the max grain. If you double the hm size, and leave the hmMaxGrain, you will get a map with smaller, more numerous continents, and continent shapes that are more irregular. If you want the same feel, but double the size, you might double the hmMaxGrain to 32. It's all subjective.

    The problem with playing on a map that huge is that it makes for a loooooong game, where you are taking very long turns moving gigantic armies. I kinda like big maps, and the default PW maps are already quite a bit bigger than the stock maps. Doubling them would be way to much game for me, that's for sure! :D

    There shouldn't be any dark ocean unless you are using a mod. Seven05's World Piece mod actually has a 'deep ocean' that looks pretty cool with PW, but the normal game only has coast and ocean. Coast simply follows the coast, there shouldn't be any banding in the water.
     
  5. [to_xp]Gekko

    [to_xp]Gekko QCT junkie

    Joined:
    Dec 16, 2005
    Messages:
    7,942
    Location:
    Seyda Neen, Vvardenfell
    the last version is very much nearing perfection :D

    the only thing I'd like to see changed is the way ice works in toroidal maps... right now, sometimes all the land clumps in the southern/northern portion of the map, which means there's a lot of ice and tundra and little useful land...

    also, ice instead of creating a stripe should be more or less circular to look like a pole imho. the way it's done in Seven05's Erebus Continent is great, climate even gets warmer as you move to east/west from the pole, so snow clumps in the middle of the map and tundra tends to sorround it.
     
  6. Romaq

    Romaq Chieftain

    Joined:
    Feb 4, 2009
    Messages:
    10
    Again, thank you for your response. Yes, it does make for a rather long game. I'll follow your suggestion of doubling the grain value. :)
     
  7. Navee

    Navee Chieftain

    Joined:
    May 31, 2009
    Messages:
    5
    This script is great, I can't find much wrong with it, but there is one fairly major bug.

    Perfectworld2 does not work in multiplayer. It generates a huge flat grassland with interspersed rivers for the entire world. After checking this thread I have only seen a couple of passing mentions to this, so I'm not even sure if you are aware of it.

    If it is at all possible to fix this script for multiplayer, that would be great. I suppose you can generate a map in singleplayer and then load it up in multiplayer, but that is kind of a hassle. Otherwise, it is pretty darn near, well, perfect.
     
  8. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    It should work in multiplayer unless I introduced a new bug. If you could check the PythonErr.log that would be helpful. Usually when I mess up multiplayer it causes a synch error. All grassland is an actual map crash, usually caused by something else.
     
  9. Navee

    Navee Chieftain

    Joined:
    May 31, 2009
    Messages:
    5
    Any size from duel to huge causes the grassland if I start it in multiplayer. That includes just starting a DIP game with an AI which is what I am doing to test.
    I can start in single player with no problems, then load that game in multiplayer with no problems.

    PythonErr.log has quite a few errors involving Perfectworld, the file is attached. (txt format to agree with the forum)
     

    Attached Files:

  10. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Yeah, I'll have to fix this. Thanks for the error file. I think the problem is that I'm initializing the map constants in a weird place so that the choices you make for those will reflect the defaults in the map. Maybe the multiplayer setup doesn't call things in the same order. I definately want this to work in MP. I'm guessing I broke it in 2.01.
     
  11. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Well, I just got home from work and I tried a DIP game with an AI, and it worked for me. What version of PW2 are you using? Is there a mod involved? Can anyone else confirm this problem?

    Sometimes, if you use alot of mods, the ini file can put your Civ4 in a weird state when it starts up.
     
  12. Navee

    Navee Chieftain

    Joined:
    May 31, 2009
    Messages:
    5
    2.02, I tried with and without Rise of Mankind. I have had Blue Marble enabled for every test because I don't think I can disable it easily.

    I had a friend try hosting a game before with the same result, I can get someone to run a couple of extra tests tomorrow. I saw someone post something about this a few pages ago but he didn't put any detail into his post and I think you missed it. He just said "doesn't work in multiplayer" or something.

    Blue Marble is about the only consistent oddity I can think of, do you have it?
     
  13. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I don't know anyone in RL who plays Civ, so multiplayer is always a difficult test scenario for me. I wonder, when you are setting up the game, are you able to select the custom options like toroidal etc? If so, I might be mistaken in regards to the cause.
     
  14. Navee

    Navee Chieftain

    Joined:
    May 31, 2009
    Messages:
    5
    I am able to select toroidal and flat. Everything is exactly the same in the multiplayer setup screen as the single player custom game screen. Except once the map is generated, it works in single player, it is a flat grassland in multiplayer.

    Two testers have confirmed that it works for them in multiplayer, one has confirmed that it does not.

    The two that it worked for were not using blue marble.
    I am using blue marble, so was the other tester that failed.

    It seems that a combination of multiplayer and blue marble breaks PW2, unless you use it yourself, or we can get someone else who does to confirm. Either that or it is something entirely different that only happens to a few people.
     
  15. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I don't use Blue Marble, mainly because I want to know how PW looks to most people, since more people are likely to use regular Civ, while I'm tuning things. I wonder if it's a Blue Marble thing. Does Blue Marble have an option to quickly disable itself?

    Another thing that might cause an issue is if you have multiple copies of the map in different folders. For example, if you have one in your PublicMaps and another in your mods PublicMaps, and your mod is allowed to see both folders. The game might try to use a different instance than the one that was initialized at the selection screen maybe.
     
  16. ColdFever

    ColdFever blue

    Joined:
    Sep 14, 2001
    Messages:
    478
    Location:
    Luebeck, Germany, civilized.de
    Yes, the Blue Marble installer offers an easy "Uninstall All" button next to the "Install" ones. And unfortunately I can confirm that the Perfect World map script does have this problem with Blue Marble in multiplayer, as I just tried with some PBEM games. As creator of Blue Marble I have no idea why this happens, because Blue Marble just replaces certain graphics files via the "CustomAssets" path Firaxis reserved for this. This should not affect any map script, but obviously it does in this case.

    I experimented a bit and found that for a strange reason the problem with PW2 only seems to happen with the first PW2 map generation. If I generate a MP game with another map script (or even PW2) before, then exit to the main menu and start a new MP game, the 2nd PW2 map creation attempt works. Something tells me this could be a problem with the Civ4 engine: With BM graphics installed Civ4 has a somewhat longer MP game initialization time at the MP first game, on my computer this "1st time MP loading delay" takes about 20 secs. This always smelled like a Civ4 mod engine bug to me, but so far nothing else has been affected. Perhaps this "loading delay" now could confuse PW2? Are you using any time dependent scripting?
     
  17. Daedraug

    Daedraug Chieftain

    Joined:
    May 18, 2007
    Messages:
    45
    Location:
    France
    I confirm this might be the issue. I had the same problem as Navee; a flat grassland in multiplayer. We deleted all versions of the map in every folders, and just kept one. Now it works, and some of us are using Blue Marble.
     
  18. Navee

    Navee Chieftain

    Joined:
    May 31, 2009
    Messages:
    5
    Bingo, I just tried generating, exiting to main menu, and generating again. Fever is right, it works fine the second time around.
    I only have one copy of PW2, the problem still persists.

    Uninstalled Blue Marble (ugh I forgot how ugly vanilla Civ is), PW2 works perfectly. Reinstalled Blue Marble, multiplayer is broken again. I think we have found our culprit.

    Perhaps until when/if you can figure out what doesn't agree, you should put the "generate the map once before starting your multiplayer game" workaround in the first post.

    Upon looking closer at the loading, the first time you load it does as Fever said. There is a few second delay before loading begins when Blue Marble is installed. After this delay, initialization/map generation is almost instant, probably because it isn't actually generating anything.

    The second time around after exiting to main menu, there is no Blue Marble delay and the "initializing"/map generation step takes much longer, since it is actually generating.
     
  19. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I'll have to install Blue Marble and work with that for a bit. One thing that I'm doing which is kinda cornball is I'm initializing my globals in the GetNumCustomMapOptions function. That's the earliest function in the process that I could find, and it allows me to set the custom map options up differently depending on how the globals are set up in the script. I always felt like it might not be the best practice, but it seemed to work well at the time.

    I definately want this to work with Blue Marble. I'll have to investigate. Thanks everyone for your help on this.
     
  20. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I installed Blue Marble, and I found something interesting. As mentioned, if you generate a second map it works. But, if you then switch to single player, it breaks again. If you generate a second map in single player it again works. Switching again to multiplayer will break it a third time.

    It's possible that by calling my initializing function before map generation starts, I am relying on no Python garbage collecting happening. Since BM uses more memory than normal (guessing on that actually) it may be causing a garbage collection on my unclaimed data.

    I'm not sure what to do about it actually. How important is it for the custom options to reflect the current default settings? Should I get rid of that to avoid problems in Blue Marble?

    I also noticed that every once in a while PW goes into an endless loop on rainfall distribution. I'll have to fix that too.
     

Share This Page