Totestra: A new PerfectWorld2 fork

What do u think about adding a bit more rivers (not much, maybe 10-20% more) and some lakes?

Cephalo already made it possible to edit the amount of rivers by editing one of the numeric parameters. If you're comfortable using a text editor, you can edit the following line in Totestra.py:

Code:
        #This value is used to decide if enough water has accumulated to form a river.
        #A lower value creates more rivers over the entire map.
        [B]self.RiverThreshold = 4[/B]

Try making this 3 or 2.

Totestra.py can not be edited using Notepad (it uses UNIX line feeds) [1], but can be edited using notepad++ or wordpad/word if one is careful to save the edited file as a text document.

- Sam

[1] Since you asked: Msys 1.0.10, the last version of msys with vi, uses an old minimal version of vim without DOS line feed support.
 
Oh! Tnx. Im using Notepad++ for editing. I might do it today.
 
I havent meddled with the code to add more rivers and im still using the previous version (the one before the one mentioned in the previous post) and i can say that there are enough rivers. Since i played a decent amount of games using ur script i can only say those maps i complained about were some kind of a statistical error. Im enjoying the script to be honest ;).
 
Sam -- downloaded the python file and took a look at it. Impressive amount of work in there to craft the maps. Generated 6-10 maps and looked them over. Overall, I like the result, but they seem, to me, to end up with an rather large number of mountain peaks in E-W lines along a coast and an occasional big block of peaks generally right near/or on the coast as well.

This created at least one, sometimes several, blocked areas which I would rather not have. It also sometime created areas along the coast that were 'walled off' for quite a few squares--not necessarily bad if it happens occasionally, but it seemed to me like it was happening pretty frequently.

I looked at the code but didn't see an obvious spot that would determine the number of peaks allowed on the map or a plate. If there's code to break up blocks of peaks I missed it. I did tweak a couple constants that seemed like they might influence it, but I'm not convinced it did anything much.

Could you tell me how I'd go about reducing the peaks? A simple mapwide reduction by maybe 30% might work.

Thanks.
 
they seem, to me, to end up with an rather large number of mountain peaks in E-W lines along a coast and an occasional big block of peaks generally right near/or on the coast as well.

Please give us some service tags showing the problem; the very first post in this thread tells you how to get one. I'll get back to you once you have your service tags ready.

- Sam
 
Final update: I have fixed the issue with large continents being split at the international date line (we now place the international date line where there is the most ocean) and have added an option to remove coastal mountains and reduce other mountains.

I have finished my Totestra fork at this point. I hope people enjoy the maps it generates.
 
Please give us some service tags showing the problem; the very first post in this thread tells you how to get one. I'll get back to you once you have your service tags ready.
The only one I've got saved has a tag
40491445fcdc6f76b8c1b

That one I played on and it worked but it does show some of what I referred to.

Dick
 
40491445fcdc6f76b8c1b

You might like today's update to Totestra, then. Cephalo, many moons ago, wrote some code to reduce the number of mountains. Unfortunately, due to a typo, this code never ran. I have updated that bit of code to run again, and have added some code that further reduces mountains and removes all coastal mountains.

Then name of this option is "reduce mountains" and here's a screenshot of a landform in your map showing what the change does.

I think you will like this change.
 

Attachments

  • B4MtnFix.jpg
    B4MtnFix.jpg
    55.8 KB · Views: 336
  • AfterMtnFix.jpg
    AfterMtnFix.jpg
    60.9 KB · Views: 408
I looked at the code but didn't see an obvious spot that would determine the number of peaks allowed on the map or a plate.

Here's some of what the code looks like:

Code:
        #In addition to the relative peak and hill generation, there is also a
        #process that changes flats to hills or peaks based on altitude. This tends
        #to randomize the high altitude areas somewhat and improve their appearance.
        #These variables control the frequency of hills and peaks at the highest altitude.
        self.HillChanceAtOne = .50
        [B]self.PeakChanceAtOne = .27[/B]

I had to move it down from where Cephalo had it near the top because these values change on rocky maps.

You can also further reduce peaks with the newly activated "reduce mountain peak" code:

Code:
                if self.plotMap[i] == mc.PEAK and mc.smoothPeaks == 1:
                    allPeaks = True
		    peakCount = 0
		    nextToOcean = False
		    #print "peak at %d %d" % (x,y) #DEBUG
		    # While we're here, let's eliminate seaside peaks
                    for direction in range(1,9,1):
                        xx,yy = GetXYFromDirection(x,y,direction)
                        ii = GetIndex(xx,yy)
                        if self.plotMap[ii] != mc.PEAK:
                            allPeaks = False
			else:
			    peakCount += 1
                        if self.plotMap[ii] == mc.OCEAN:
			    #print "nextToOcean %d %d" % (x,y) #DEBUG
                            nextToOcean = True
                    if allPeaks == True or peakCount > [B]3[/B]:
                        self.plotMap[i] = mc.HILLS
		    if nextToOcean == True:
			self.plotMap[i] = mc.HILLS

What this code does is as follows:

  • If a given point on the map is a mountain peak and we're smoothing peaks then:
  • Count the number of mountain peak squares next to this square
  • See if there are any water squares next to the mountain peak (they are mc.OCEAN squares right now because PW/Totestra makes them coastal squares later on)
  • If there are 4 or more mountain squares next to this square, make the mountain a hill
  • If there are any water squares next to this square, make the mountain a hill

Reduce peakCount > 3 to a lower number to get even fewer mountains on the map.

- Sam
 
Now that I have finished Totestra, let me briefly summarize how Perfect World/Totestra makes a map. Here is the "main loop" which does the majority of the map rendering in Totestra:

Code:
def generatePlotTypes():
    # Core height map generator
    gc = CyGlobalContext()
    mmap = gc.getMap()
    mc.width = mmap.getGridWidth()
    mc.height = mmap.getGridHeight()
    mc.minimumMeteorSize = (1 + int(round(float(mc.hmWidth)/float(mc.width)))) * 3
    PRand.seed()
    hm.performTectonics()
    hm.generateHeightMap()
    hm.combineMaps()
    hm.calculateSeaLevel()
    hm.fillInLakes()
    pb.breakPangaeas()
##    hm.Erode()
##    hm.printHeightMap()
    hm.rotateMap()
    hm.addWaterBands()
##    hm.printHeightMap()
    cm.createClimateMaps()
    sm.initialize()
    rm.generateRiverMap()

(Note that, in Python, lines that begin with '#' are ignored. So Cephalo's code doesn't actually perform erosion; he decided he didn't like the way it looks)

To understand Perfect World's code, an important idea to understand is the "height map". This is a square grid of numbers; each square in the grid has a number between 0 and 1 that represents the height at that point. It represents, if you will, a sandbox where a given point in the sandbox has a level of sand.

What Perfect World does is perform simulated plate tectonics to this abstract height map which doesn't have any real water or land yet. It then adds water to the map; the amount of water added depends on the "ocean level" setting on Totestra. PW/Totestra then throws simulated meteors at the land (the simulated meteor in Cephalo's code acts more like a variable sized circular stamp, actually) in an attempt to break up large land masses (this is what pb.breakPangaeas() does), then Totestra performs some code I wrote which performs a circular rotate on the height map. I do this rotate so continents are less likely to be split at the international date line (the edge of the map where it wraps).

After rotating the map, Cephalo's code does a lot of simulated weather to determine whether a given square should be a desert, plains, grassland, with a river, and so on. All of this information is combined and finally converted in to a Civ4-compatible map.

Cephalo feels that just putting hills once an elevation reaches a certain value, followed by putting mountains at an even higher elevation doesn't make sense for a Civilization map, so his code determines the altitude change and adds hills and mountains based on that information.

At the default "islands" and "map ratio" settings for Totestra, a 144x96 height map is generated. This is scaled down using ShrinkMap() in to the desired size. ShrinkMap() only scales down; it does not effectively scale up, so the maximum size of a default map is 144x96.

The "islands" ("Continent amount") option in Totestra increases the size of the underlying height map. This results in the map having more islands, since the tectonic plates on the height map stay the same size, and the map ends up having more plates on it. This is why it takes more time for Totestra to make a map with more islands on it.

"map ratio" not only changes the size of the resulting map, it also scales the height map as needed so that the land forms on the final map continue to look natural.

Cephalo goes in to a lot of detail explaining what Perfect World does in the Perfect World thread.

I hope this information gives people who wish to continue making changes to Perfect World/Totestra guidance on where to start.

- Sam
 
I think you can safely add K-Mod. I played a lot of K-Mod games using this script and it works. I dont know why it shouldnt work anyway since K-Mod just fixes AI and some basic mechanics to make the game more challenging and fun.
 
I have added K-Mod to the list of compatible mods. I will test some others and add even more results.

Also, I have no idea if Mars, Now! is playable with so much water on the map and with resources becoming other things on the map, but the map does generate and the player does start.
 
Also, I have no idea if Mars, Now! is playable with so much water on the map and with resources becoming other things on the map, but the map does generate and the player does start.

mmhh...playable...yes, but it's not very flavourful in regards to the scenario ^^.
Just checked one map, looks interesting, but I'd not consider playing it with my mod (but I think if I get the Civ4 fever again, that I'll then have to test it with BtS :)).
 
mmhh...playable...yes, but it's not very flavourful in regards to the scenario ^^.
Just checked one map, looks interesting, but I'd not consider playing it with my mod (but I think if I get the Civ4 fever again, that I'll then have to test it with BtS :)).

I am impressed with Mars, Now because its code is clean enough that it doesn't barf on a map script for Factory Civ4/Warlords/BtS.

Of course, so people don't get the wrong idea, I've downgraded Mars Now and FutureMod from "YES" to "MAYBE"; yes, they make a map that the player starts in. No, it may not the best gaming experience for that mod to actually play out such a map.
 
This looks great.

Thank you very much for your effort. I'll be trying this when I start my next game. :goodjob:
 
I am impressed with Mars, Now because its code is clean enough that it doesn't barf on a map script for Factory Civ4/Warlords/BtS.

The exact opposite is the case ;)...:blush:.
I was lazy and did not change any internal names, so in the XML it's still TERRAIN_GRASS, FEATURE_FOREST and BONUS_WHEAT, etc. :blush:.
That's why it works, but it's definitely not clean.


Of course, so people don't get the wrong idea, I've downgraded Mars Now and FutureMod from "YES" to "MAYBE"; yes, they make a map that the player starts in. No, it may not the best gaming experience for that mod to actually play out such a map.

Good decision :yup:.
 
You might like today's update to Totestra, then. Cephalo, many moons ago, wrote some code to reduce the number of mountains. Unfortunately, due to a typo, this code never ran. I have updated that bit of code to run again, and have added some code that further reduces mountains and removes all coastal mountains.

Then name of this option is "reduce mountains" and here's a screenshot of a landform in your map showing what the change does.

I think you will like this change.

You are correct -- I like that very much. :) Still has some mountains but the coastal chains aren't there and the big blocks are broken up. Excellent job -- than you very kindly for the quick response! :thumbsup:

I noticed the
self.PeakChanceAtOne = .27
parameter and tried fiddling with it but I couldn't convince myself I was really seeing a lot of change in the maps, maybe because I didn't take it to any kind of extreme.

In any case, I think the addition you made really helps tune Totestra to whatever tastes the player might want -- and makes it the best overall script/map code out there.

Thanks again for all the hard work with this! :goodjob:

Dick
 
I noticed the
self.PeakChanceAtOne = .27
parameter and tried fiddling with it but I couldn't convince myself I was really seeing a lot of change in the maps

This mainly affects areas where the height field is high. Other areas have mountains not because the sea level is high, but because the change in altitude is higher in that area (usually where two tectonic plates met).
 
Top Bottom