1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. Photobucket has changed its policy concerning hotlinking images and now requires an account with a $399.00 annual fee to allow hotlink. More information is available at: this link.
    Dismiss Notice
  3. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  4. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  5. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  6. Dismiss Notice
  7. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

[Map Script] PerfectWorld2.py

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

  1. cephalo

    cephalo Chieftain

    Joined:
    Jul 26, 2007
    Messages:
    1,919
    Location:
    Missouri, USA
    I am definately working on it, but it will take some time. I've never used the Lua language and also I've developed alot of new techniques that I have yet to use on a Civ map. Hopefully it won't be more than a month or so.
     
  2. rspeer

    rspeer Spearman

    Joined:
    Apr 5, 2006
    Messages:
    101
    Actually, I've noticed that Civ5's Terra seems to incorporate ideas from PerfectWorld. So the first question to ask before "When will there be PerfectWorld for Civ5?" is "What should PerfectWorld for Civ5 do differently from Terra for Civ5?"

    EDIT: Might as well give the first answer. Terra doesn't simulate tectonics, so while it has mountain ranges, it doesn't tend to create large landmasses that are separated by a mountain range (like Europe and Asia), which PerfectWorld of course does.
     
  3. grumbler

    grumbler Chieftain

    Joined:
    Oct 29, 2001
    Messages:
    492
    Location:
    In front of the screen
    That's good to know. Anything this year would make me happy. :)
     
  4. cephalo

    cephalo Chieftain

    Joined:
    Jul 26, 2007
    Messages:
    1,919
    Location:
    Missouri, USA
    Civ5 Terra looks to me alot like Civ4 Terra. The climate seems somewhat scattered about in a fairly even distribution. Notice how the trees pepper the map without much change in density. Also the rivers don't seem to flow in a natural way. They usually start in the middle and radiate outward to the sea, or sometimes they start near the sea and cross the whole continent. It looks better when you use actual drainage paths on a heightmap.

    My next map is going to be quite different than both Terra and PW2. Internally it will be completely different. I've learned a few tricks, although much of it is still experimental.

    I've been reading the start placement code for Civ5, and Sirian did an excellent job with it. I'm thinking that I might not have to mess with the starting code at all at least initially. That will save some time.
     
  5. Jarlaxe Baenre

    Jarlaxe Baenre Secular Humanist

    Joined:
    Feb 17, 2010
    Messages:
    1,735
    Location:
    Calgary, Alberta, Canada
    Cephalo, could you do a PW3 for BtS? For the people who love PW2 but aren't buying CiV?
     
  6. rspeer

    rspeer Spearman

    Joined:
    Apr 5, 2006
    Messages:
    101
    Yeah, I got a little overexcited about Terra. It's not Civ4's Terra, but it's not PerfectWorld either.

    I've looked deeper into the code. It *does* make ridgelines from tectonics, though not with as striking results as PerfectWorld; but the climate model is basically random and just happened to get good results a few times.

    Regardless, there is a lot of code in there that may be helpful to you. Many of the map scripts build on useful shared functions in assets/Gameplay/Lua, and just reading that code (some of it is well documented) may get you started on map scripting in Lua. For example, MultilayeredFractal is a nice way of manipulating maps a continent at a time, which I took advantage of to write a map script really quickly while knowing a minimum of Lua.
     
  7. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    I too would love to see this

    a thought occurs, would there be even a remote chance (even 10.0x10^-200,000,000,000?) that it could be CvPerfectWorld.h/.cpp?

    :please:
     
  8. Jarlaxe Baenre

    Jarlaxe Baenre Secular Humanist

    Joined:
    Feb 17, 2010
    Messages:
    1,735
    Location:
    Calgary, Alberta, Canada
    Please not... I believe that file would be in the SDK, which would make it useless for a fair amount of players, and at the same time adding little.
     
  9. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Wouldn't it be much faster?

    Also, if those files were added to the SDK for the "standard mods" (i.e. BBAI, RevDCM, RoM etc) then there could be a much smaller, much quicker PW (a tiny .py that just called the SDK functions), if properly exposed to python, think of the possibilities

    Geostrophic Wind Patterns-> Natural Trade Winds (Age of Sail ships could move faster if they followed the Wind Pattern, slower if they went against it)

    Geostrophic Wind Patterns-> Fallout spread following wind patterns instead of nine tiles centered on the target tile

    those are just two, I'm sure there are more, I'm just a little brain-dead currently
     
  10. Fuyu

    Fuyu Chieftain

    Joined:
    Nov 5, 2009
    Messages:
    1,220
    Location:
    Austria
    PW in SDK would be faster but there would be no additional "possibilities" unless you actually store wind patterns to the tiles themselves. Which would be just insane.
     
  11. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Are you saying insane->good :yup:
    or insane->bad :shake:

    If you take all of the variables from the beginning of the .py and figure out tags for them, then attach those tags to Civ4TerrainInfos, I wonder if it would be possible to do ocean currents? Wouldn't that also allow for a finer control as well? It would actually facilitate modders ability to use PW and customize it. Another thought is that by making them their own .cpp/.h you could alternate, "this game I feel like having a less-than-perfect world, so I'll use basic civ4 terra map generation" and then the next game if you feel like using PW, just flip the switch, it would essentially become a Game Option
     
  12. Jarlaxe Baenre

    Jarlaxe Baenre Secular Humanist

    Joined:
    Feb 17, 2010
    Messages:
    1,735
    Location:
    Calgary, Alberta, Canada
    I'd much rather just have a slow-loading mapscript than have a cool mapscript I'll never be able to use.
     
  13. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Why would you never be able to use it? If you play civ, you use a DLL, everyone that plays Civ uses a DLL, I am simply asking if it is possible to add functionality to something that everyone uses, if it is a question of compiling a DLL with this (if it existed), I'm sure that it would be getting used by many of the SDK-modders and if you couldn't find a base DLL + PW, I'd be willing to compile it for you (if it existed)

    Would there be anyone else who would be interested in a PerfectWorld_SDK?
     
  14. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Another thought that I just had...

    If the rumors I have heard are true (that the Civ5 SDK is just a pared down Civ4 SDK), then wouldn't an SDK-version of PW be usable by both Civ4 and Civ5? Kill two birds with one stone. Do the SDK files and one small .py for Civ4 and a LUA file for Civ5, instead of doing a whole revision of PW.py and a new LUA PW
     
  15. mechaerik

    mechaerik Tuturuu!

    Joined:
    Oct 28, 2008
    Messages:
    7,064
    Location:
    Los Angeles
    JB is on of those mac compooters.
     
  16. rspeer

    rspeer Spearman

    Joined:
    Apr 5, 2006
    Messages:
    101
    TheLadiesOgre, what would that possibly gain? (Speed is not particularly an issue for something you run once per game.)

    The map scripts and all their support functions are already written in Python/Lua. To write a map script in C++, you'd either have to reimplement all the map functions in C++, or you'd have to ask the Python or Lua interpreter to do most of the work anyway. And then you'd get something that only ran on one version of the game on Windows.

    Part of programming is using the right tools for the job, not using one tool for every job.
     
  17. tdfriese

    tdfriese Chieftain

    Joined:
    Oct 30, 2010
    Messages:
    76
    Location:
    Chicago
    Excellent job, Cephalo. This is by a longshot the best map generator out there; bravo.

    In the interest of making something great, better, I'd like to offer some observations.

    In pw2, it seems that rainfall is a bit too heavily dependent on distance from bodies of water. Thus, the interior of nearly every continent has desert, which leads to a bit of a donut effect, where continents have rings of desert in the middle and then plains around it. Two important suggestions:

    1) pw3 needs some semblance of winds or an easy cheat: heavier dependence on latitude for making deserts: check out on the link below how the Saharan and Arabian deserts butt up against bodies of water and yet receive very little precipitation. What's going on? Cool high altitude air masses sink at these latitudes, warming up and desiccating the landscape. At this latitude it is VERY difficult to have anything but desert. I think if pw2 tried to model Africa it would place a bunch of plains on the Atlantic Coast.

    2) The converse effect is that the Amazon rainforests continue unabated from the Atlantic all the way to the foothills of the Andes. This is because warm ground-level air masses rise at the equator, cool, and subsequently rain as they lose moisture. I think if pw2 tried to model South America we would end up with desert or at least plains in the Amazonian interior.

    3) Lastly, a bit of global ocean currents would be a great help. Why, for example, despite steep hills are there deserts on the Pacific coast of southern California and Baja California? The reason is that there is an upwelling of very cold deep ocean water very near to the shore. Cool air masses from the Pacific warm as they go onto land, and, even when forced over mountains, remain too warm to produce a rainy windward zone.

    http://en.wikipedia.org/wiki/File:Deserts.png
     
  18. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    726
    Gender:
    Male
    Location:
    Boston, MA, USA
    So you're saying desert should be less likely at low latitudes and more likely at high latitudes? I find that fascinating, b/c my strong-rooted assumption had always been just the opposite, due to it being hotter at low latitudes; I was still following, at an instinctual level, the childhood fallacy that deserts are temperature-based and not moisture-based, even though I knew this intellectually.

    I was further citing, as evidence in my own mind, the Sahara, which I had thought to be fairly near the Equator. Your map shows otherwise however. :)

    In any case, such a simple linear factor on desert formation should be fairly easy to mod into PW2, as would be reducing the water proximity effect. Wind patterns and ocean currents are a much bigger deal from a programming standpoint though.

    I do love Ogre's idea for trade winds hastening wooden ships, but realistically I don't think this would be a practical game mechanic... Even if you could model it successfully with the map generator and store the info in the tiles, how are you supposed to convey the wind information to the players so they can use it intelligently? Without being able to see a whole wind overlay on the world map, you'd be reduced to cursing at your screen when your fleet mysteriously can't escape its pursuers or chase down its victims, for a seemingly random reason.

    As for ocean currents, sure I'd love to see them modelled in PW2 (too bad they can't be made to affect submarines as above, hehe), but I don't know anything about how they form, why they flow where they do, and if they should have any additional effects beyond adding coastal deserts.

    While we're on the subject btw, shouldn't all Pangaea games have large interior deserts, and a sudden shift to 100% ice tiles everywhere towards the end of the game? Just curious. :p
     
  19. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    IIRC, unless you implement your own variations on the functions, all mapscripts use functions that are already in the SDK, I am talking about porting the PW variations of the functions into the SDK and then using them for all of the varied things that modders might think up.

    Also, correct me if I am wrong, but if the functions were already in the SDK could they not then be called by Python/Lua and performed much more quickly as there would be less to compile on the spot (which AFAIK is the reason why PW takes so long to execute with all of its code which needs compiled).

    By the way, sorry it took me so long to reply, I somehow completely missed your post.

    In addition to a globe view overlay, couldn't it be displayed in the tile hover text like the latitude/longitude? If ocean currents could be done as well, then couldn't they both be tile hover text (as well as globe view overlay)? Think of the movement modifier you'd get if you had both the ocean current and the trade winds going in your favor or both going against you.

    Ocean currents form due to water temperature and salinity, they sink at the poles and rise near the equator, as far as their actual surface movement I think it has something to do with the rotation of the planet (unsure though as I am not a planetary scientist).
     
  20. cephalo

    cephalo Chieftain

    Joined:
    Jul 26, 2007
    Messages:
    1,919
    Location:
    Missouri, USA
    There is a variable near the beginning of the script called 'geostrophic factor'. If you turn that way up, you'll get a larger influence from geostrophic winds rather than the monsoon winds which are responsible for the 'donut'.

    *However* I've recently discovered in my work for Civ5 that my geostrophic climate generator my be broken on this map, so you may occasionally get weird results by turning that up. I'm using a much better system for diagnosing map data with colored bitmaps this time (in PW2 it was text based kinda like ascii art.) and it's uncovering alot of rough edges in my old way of calculating things. :)
     

Share This Page