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. windwind12

    windwind12 Chieftain

    Joined:
    Nov 29, 2003
    Messages:
    7
    That is what i want to know ... i have test it and it work perfect :D

    Good work!
     
  2. NBAfan

    NBAfan boss

    Joined:
    Aug 30, 2007
    Messages:
    3,351
    It will work, you just won't get the new terrain or new features.;)
     
  3. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I just released a new map generation project for Dwarf Fortress. It uses alot of the same technology as PerfectWorld but you can actually see what the maps look like internally. I thought it might be interesting for anyone who follows this thread. Check it out at the Bay 12 Games forum
     
  4. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    I have a problem. My friend and I used to find we always started on different continents in PW1 in a multiplayer game, and now since upgrading a while back it seems we always start on the same continent in PW2. Obviously we would like it to be random whether we spawn this way or not in any given game.

    I couldn't figure out why it was doing this at first, because I assumed it was trying to spawn human players together as a special case and searching for isHuman() tests in the script turned up nothing. However just now I realized the problem: we always start with us in slots 1 and 2 by default when creating a new game, and put AIs in slots 3-15 or whatever. So I ran some more tests and even in single player, if I put a specific AI leader/civ in slot 2 he seems to always be on the same continent with me. The PW 2.06 code is clearly trying to randomize the order of the player list before placing anyone so I'm not sure why this is happening, but I'll figure it out. Unless Ceph beats me to it. :p
     
  5. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I would ask whether you are playing with the 'New World' option on, and then how often there are any other continents besides the main one that are not in the new world? You're right, I definately tried to randomize that.
     
  6. nosre

    nosre Chieftain

    Joined:
    Apr 3, 2010
    Messages:
    4
    I am trying to generate the largest size map and it has been sitting on "initializing" for more than a half hour now. Is it possible for it to freeze, or is it legitimately taking that long? I used the default options. My computer is not mind blowing, but it's solid.

    Sorry if this has been answered already, I checked through the first and last half dozen pages :)
     
  7. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    We always use Start Anywhere. It works fine when I use PW 2.06, unedited, directly in vanilla BTS; seems to only be an issue with the combination of my full mod and my custom version of PW, which makes no sense because I didn't change anything in either one of them that should in any way affect that. ... Results don't lie though, so obviously I did. I'll find it...

    Once in a while it seems to go into an infinite loop on me, at which point I have to force quit Civ or hard restart the machine, but this is rare, maybe one time out of every 10 to 20 maps. When it works it finishes in a little over 2 minutes on my machine, which is about the same as yours from the description.
     
  8. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I'm thinking that on a really slow computer, 10 minutes should be the max generation time. There may be an occasional endless loop condition possible, but it's rare enough that I haven't seen one that I haven't fixed already, or um.. thought I fixed already.
     
  9. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Let me know if there's something goofy I did that causes unintended interactions. That process of placement should be completely isolated though. It's just a scrambled list!

    Hey wait a minute... There is a default option to move same team players to the same continent. One of the default map normalization functions does this. Can't remember what it is now. If you changed something and it crashed for some reason, it will silently use the default function. If you do alot of modding you might wanna leave the Python error popups on. You can also check your Pythonerr.log file.
     
  10. nosre

    nosre Chieftain

    Joined:
    Apr 3, 2010
    Messages:
    4
    I must have found one, because I tried again just now and it took about 2 minutes to generate the same size map. There was one difference, I lowered the amount of civs from 17 or 18 to 13.
     
  11. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    We don't play on the same team so it's not that... very good idea though. :) I always had Python errors on, except my game's .ini file got reset to all its default values somehow recently, no clue how, but I hadn't gotten around to changing them all back yet and sure enough Python errors were set to silent, grr. That also didn't matter for this it turned out, but thanks for prompting me to fix it. :)

    Sorry this took so long, I had to spend the last day or two figuring out a nasty new crash bug in my mod that was interfering with my ability to run start location tests. So with that finally solved I ran a bunch more, and it still seems to put me and the slot 2 AI on the same continent way more often than it should, 75% of the time or so, but it definitely seperates us some of the time too, so I guess it's just random afterall. The reason I brought this up at all is because in actual multiplayer I swear we were on different continents at least 10 times in a row back on PW1, and on the same continent every time so far in PW2, but it could just have been really bad luck, sample size isn't quite big enough to infer with certainty.

    The comment by the playerlist shuffling code says you lifted it from Highlands.py; I guess I'd just ask if there's any possibility there's something wrong with that code, given that you didn't write it yourself. Probably not though heh.

    Wow, 2 minutes, I nailed it! :p

    Interesting theory that it might have to do with total number of Civs it has to place starting locations for, but it could be any number of other reasons too and just coincidence that it worked one way and didn't the other on two tries for you. I have no idea what causes the problem, I'm just saying. But yes we've generally used 16 Civs on Huge maps and it seems to get stuck about one time in ten, give or take, maybe a little more often than that, but not too bad. My 1-in-20 number above was prolly a bit low though heh.
     
  12. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    However, I don't believe that the default starting code shuffles the players. So if it's defaulting for any reason, that might explain what you were seeing. Also, that comment about being lifted from highlands is actually waaay outdated. My code has evolved from that by alot.

    @nosre: It's possible that crowding the map could cause an endless loop. I generally never do alot of testing of extremes. I tend to stop once I'm confident that a normal game can be played. I might try using a smaller map and overloading it to see if I can make it happen often.
     
  13. LunarMongoose

    LunarMongoose King

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    Geez the vanilla map code is a mess... Yes I see that now heh. More tests confirm my mod is definitely using your code though, and I can't reliably reproduce the problem at this point, so I'm just going to chalk it up to bad luck and the suckiness of the MP-compatible random number generator. Which btw we've thought to be extremely flaky for some time now due to the combat results it gives us, which often seem only loosely related at best to the actual combat odds shown. I wish someone would write a better random system so I don't have to... I hate complicated math. :p

    Plus I guess if you generally have one main continent that is bigger than the rest, the total odds of any two people winding up "on the same continent" is actually going to be higher than 50% because of its presence. That's interesting, now that I think about it. I may have to add some code to try and disperse human players with a certain probability. :)

    Edit - Though I've plugged some actual maps into my calculator now and the odds are actually coming out on the low side of 50% more often than the high side, with the results tending to stay in the 30-70% range (for 16 Civs on a Huge map with Break Pangeas). Meh.
     
  14. Fame Throwa

    Fame Throwa Chieftain

    Joined:
    Jul 19, 2008
    Messages:
    11
    I installed the most recent version of PW2 but the map is all buggy. It is nothing but flat grasslands with resources and a few rivers and small lakes scattered about.There isn't a single hill or ocean or forest on the whole map, except in the BFCs. Its so weird, what's up with that?
     
  15. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    That's what happens when the map crashes during generation. Is that happening to you every time?
     
  16. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,879
    Location:
    DE/NL/FR
    Cephalo, i need some help to make your mapscript compatible with my mod.
    I know, because of the changed settings and values, etc., there will some things just be strange, but i first want to see if it can produce somehow playable maps.
    To get other mapscripts to work i've before just copied the function generateTerrainAtPlot in and changed the part where water was generated so that instead desert is set there.
    But in this mapscript it does not work, so i need some advice where the terrain is generated.
    I've already tried to search for isWater(), but i can't see where an equivalent is in your script.


    Thanks in advance :).
     
  17. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Believe it or not I'm starting to forget exactly how this mapscript works, but somewhere in here there should be a generateTerrain function that will place coasts etc. First I create my own data maps that determine where terrain will be placed, then at the end of the process I just sorta copy my data maps to the real map in the generateTerrain function.
     
  18. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,879
    Location:
    DE/NL/FR
    Found the function, thanks for the advice :).

    Did you code something special for the resources?
    At 2 maps i generated with the script one essential resource was not present, and that's a problem. I've seached for BONUS_, but didn't find anything.
     
  19. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I do alot of things special for the resources, but in this case, unlike terrains and features, they should be handled generically from the XML. After generation, you might check the PythonDbg.log to see if there are any messages regarding that resource. It could be a lack of room, depending on the bonus class and various other XML settings. I would be surprised if the resource would place fine on the stock maps and not on PW.

    If I remember correctly, even if there is no room according to the rules, the map should force place one resource by disregarding the rules.
     
  20. The_J

    The_J Say No 2 Net Validations Retired Moderator Supporter

    Joined:
    Oct 22, 2008
    Messages:
    31,879
    Location:
    DE/NL/FR
    Thanks for the answer :).

    :think: strange.

    I had some problems before with the resource distribution and therefore changed some of the XML values to fix it (...but i still don't really understand what they do; strange behaviour with different scripts), but they show up on the normal scripts (i've directly tested afterwards tested it with the continents script), so i thought there might something be hardcoded in it.
    I guess i have to run some test generations to see if it was a one time effect :think:.
     

Share This Page