[Map Script] PerfectWorld2.py

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

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.
 
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 :)
 
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.

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

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.

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.
 
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 :)

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

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

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

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.

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.

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.
 
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. :)

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

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

That's what happens when the map crashes during generation. Is that happening to you every time?
 
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 :).
 
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 :).

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

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.
 
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:.
 
Top Bottom