Totestra: A new PerfectWorld2 fork

This thread looks pretty much dead to me, but I'll try my luck.
Did you people experience issue with this script when some resources not being generated on the map? E.g., I created a map of two continents with Totestra, and a quick look at the map revealed the absence of Dye and Deer resources.
How do I battle this issue of this otherwise awesome script?
 
Did you people experience issue with this script when some resources not being generated on the map?

In the upper right hand corner on each page of this thread, there is a tool marked "search this thread". For example, click on "search this thread" and search for the keyword "resources".

For example, in the very first post in this thread, there is the following text:

The following can now be set from the Civ 4 menu:
[...]
Resource distribution: Whether to evenly spread out resources (less historically accurate; more Civ-game-like) or to have a given resource only on a given continent (more historically accurate; faithful to Cephalo's intentions), or to make a map full of resoueces
(less balanced, but some people may like playing this kind of game)
 
Great work on this, thank-you for making this script.

How can the script be altered to provide more trees on the map? My maps get a lot of open spaces.
 
Hi,
really the best script!
one issue i found with tropical climate
so i added some lines

if clim == 1: # Tropical
self.tropicsLatitude = 46
self.DesertPercent = .10 # added
self.PlainsPercent = .30 # added
self.SnowTemp = .20 # added
self.TundraTemp = .30 # added
self.ForestTemp = .35 # added
self.JungleTemp = .50 # added
self.iceSlope = 0.33 # Less ice

i'm not sure if this are the best values and all make sense, but now there will be jungle and the resources that require it
 
Hi,
really the best script!
one issue i found with tropical climate
so i added some lines

if clim == 1: # Tropical
self.tropicsLatitude = 46
self.DesertPercent = .10 # added
self.PlainsPercent = .30 # added
self.SnowTemp = .20 # added
self.TundraTemp = .30 # added
self.ForestTemp = .35 # added
self.JungleTemp = .50 # added
self.iceSlope = 0.33 # Less ice

i'm not sure if this are the best values and all make sense, but now there will be jungle and the resources that require it

I have, for the first time in five years, updated the Totestra map script; it now has these changes. Not only can it be downloaded at the usual location (with the name Totestra-2017-03-29.py), http://samiam.org/civ4/Totestra.html, it can also be downloaded at a Github repo I have set up for this map script: https://github.com/samboy/Totestra-mapscript/
 
Last edited:
I am only getting maps that are 100% grassland. I remember this happening before with PerfectWorld2 (many years ago), but do not remember the fix (and have not been able to find that thread via searching). I am using the map in conjunction with FFH. Any ideas on how to get the map to continue on and populate oceans and mountains and all the fun stuff?
 
First of all, a minor update to totestra.py: It now has a new map seed (“Atlixco”) which makes an interesting world when a huge 3:2 map is selected. This file (Totestra.py) is in the attached zip file (for developers with the Git tool, this zip file also has a Git log of all of the released versions of Totestra since 2012, going all the way back to Perfect World 2.06)

Second of all, I can not offer real help, but some hints for people who have asked questions over the years:

Can this map script be made to work with Map Script Tools - like Perfect World does?
Sure. Just start reading and writing the code to make it work with map script tools yourself. Open source is like the real world: You’re not going to get what you want handed to you on a silver platter.

I am only getting maps that are 100% grassland.
This indicates an error occurred when making the map. The map script works for me, so this is a problem with using that particular mod or your setup.

To debug this, we first must turn on debugging of error messages. Look for Civilization4.ini (\My Documents\My Games\Beyond the Sword\Civilization4.ini usually) and edit the file to have these lines:

HidePythonExceptions = 0
ShowPythonDebugMsgs = 1
LoggingEnabled = 1
MessageLog = 1​

Once this is done, there should be files in \My Documents\My Games\Beyond the Sword\Logs\ with names like PythonDbg.log. These files should have information on my the script is failing and generating grassland instead of a map. At this point, one can play around with the file to try and fix the issue in question (learning Python will help a lot here).
 

Attachments

  • Totestra-mapscript.zip
    249.7 KB · Views: 194
Last edited:
*Bump*

Just a heads up that I have created a variant of Totestra (which uses a different random number generator than Perfect World, so no longer generates the same maps Perfect World does; this ensures that both Mac and PC users will get the same maps given the same seed) which can run stand alone. While the stand alone mode has no options, except the map seed, and it only shows the plot map (the location of land, hills, and mountains), this allows people without Civilization IV to enjoy the map generator, and it makes it a little easier to automate the process of finding really good map seeds.

To run it stand alone, be sure to be at a command line, have Python2 installed, then type in something like: python TotestraRG32.py 5
This will generate the "T5" random map, which is the same map as the "T5" pull-down seed option. Note that, when run standalone, the map generator will generate a plot map then exit. The map is all of the default options, which can not be changed (in particular, in the stand alone mode, we only generate 144x96 huge medium patience world maps)

This allows us to make random worlds without needing Civilization IV installed.

Because of the Python “if __name__ == "main”” trick, the same script can either run stand alone (as long as one has the older Python 2 interpreter installed) or as a Civilization IV map script.

As mentioned at the top of this thread, this is available in the second posting here, or at https://github.com/samboy/misc-civ4-mapscripts/releases/tag/2019-07-06

Here is how a map (“T5”) looks when generated in stand alone mode:
T5-Ascii.png


And here is the same map as it looks when playing it in Civ4:
T5-Ingame.png
 
Last edited:
I have also written a tool which can convert the ASCII output of TotestraRG32 when run standalone in to a PNG file:

Code:
#!/usr/bin/env python

# Donated to the public domain 2019 by Sam Trenholme

# This requires python3 and the "pypng" module
# This code has been tested with Python 3.6.8

# This code takes the output of "totestraRG32.py" when run in standalone
# mode and generates a PNG file of the generated world, which is put in the
# file out.png
import sys,re, png

world = []
for line in sys.stdin:
    pngline = ()
    if(len(line) >= 145):
        mapline = line[0:144]
        for pixel in mapline:
            if(pixel == '+'): # Plains
                pngline += (32,128,32)
                pngline += (32,128,32)
            elif(pixel == 'n'): # Hills
                pngline += (128,128,32)
                pngline += (128,128,32)
            elif(pixel == 'A'): # Mountains
                pngline += (0,0,0)
                pngline += (0,0,0)
            else: # Water
                pngline += (0,0,128)
                pngline += (0,0,128)
        world.append(pngline)
        world.append(pngline)

outfile = open('out.png', 'wb')
outpng = png.Writer(288,len(world))
outpng.write(outfile, world)
print("out.png written")

This takes, on the standard input, the output of TotestraRG32. It generates a PNG file, out.png, which is a PNG conversion of the ASCII height map.

I discuss how to use TotestraRG32 and the above Python script to bulk make a bunch of maps as PNG files over at GitHub:

https://github.com/samboy/misc-civ4-mapscripts/tree/master/plotmap2png

Attached is an example, map, #285, showing how these PNG files look.

totestrarg32-T285.png
 
Last edited:
2019-07-13 update: I have made a version which is completely compatible with Totestra (same RNG, multi player support, etc.), but has optional RadioGatún[32] support, as well as support for running in stand-alone mode without Civilization IV installed.

See attached file (which also has the tool to make .png files from the stand alone output, as well as the full Git history of the file going all the way back to PerfectWorld2).
 

Attachments

  • Totestra-mapscript-2019-07-13.zip
    408.2 KB · Views: 179
I have fixed one long-standing bug in Perfect World: The Totestra code now randomly places huts on the map, making sure each hut is at least three squares away from other huts. This allows the quantity of huts to be user-settable by editing the script; it also guarantees that a given map seed will always have the same hut placement.

The code also places more huts in the deserts than elsewhere; this is consistent with Civ4’s way of placing more barbarians in deserts, and players are more encouraged to explore deserts in the opening of the game.

Since this code changes Totestra’s behavior (it affects player starts), I have only updated the RadioGatún[32] version of the code to have the script generate the huts.

See the attached file for the Python map script.
 

Attachments

  • TotestraRG32.zip
    55.2 KB · Views: 191
Last edited:
TotestraRG32 Update: I have fixed a long standing bug in PerfectWorld2/Totestra, where about 1% of maps failed to generate because of a “rainfall infinite loop”. I have also added tests to make sure the underlying RadioGatún[32] random number generator is behaving correctly.
 

Attachments

  • TotestraRG32.zip
    55.5 KB · Views: 246
I have been working on getting Totestra to work with Python3 while still running as a Python2 Civilization map generator. This work is non-trivial: While I have gotten the script to run in Python3, there’s a lot of implicit conversions in the Perfect World code which act differently in Python3, causing the script to terminate before it can generate a map.

It’s probably too much bother to convert, although I would be a lot more motivated to do it if the original Perfect World author was willing to GPL his code (release it under an open source license) or even release it under a BSD style license.
 
Hi - is there any way that I can increase the size of the "new world"? On large maps like 75% of the landmasses are used for old world civs with a really small "new world". Ideally the result I'm going for is two "old world" continents with 5-8 civs on each, and then 2 similarly sized "new world" continents as well as smaller islands. But I can never seem to get that result with this map generator.
 
Hi - is there any way that I can increase the size of the "new world"?

The original (MT19937 RNG) Totestra map script (attached) with the “Caulixtla” random seed has a really large new world. To select it, go to “custom game”, select the map “Totestra” (again, attached), select a “large” or “huge” map, “medium” sea level, and choose a civ placement of “keep new world empty” or “everyone on same landmass”, and, at the bottom of the map script option list, select the map seed of “Preset #3 (Caulixtla)”. Adjust other parameters to taste.

Is there a way to make this script generate maps with more terrains and features? In my mod there is March as an extra terrain and some other custom terrain features.

The MapScriptTools version of PerfectWorld has support for Marsh terrain. Check it out here: https://forums.civfanatics.com/threads/mapscripttools.540261/
 

Attachments

  • Totestra-2021.zip
    55.9 KB · Views: 57
I have created a simplified version of Totestra called “T2”. This discards a large number of changes from Perfect World, and only includes the most relevant features (allow everyone to start on same landmass; have more resources by default on map w/ resource control option; remove coastal mountains; etc.) The maps will be the same as generated by Totestra with the same features selected.

One useful feature this map script has which stock Totestra doesn’t have is the ability to make extra huge 192x128 maps. The option for these big maps is a little hidden, but can be seen in the options (since bigger maps take longer to generate).

The code may be more maintainable compared to stock Totestra.

To install, place the extracted T2.py file in the relevant “PublicMaps/” (maybe “PrivateMaps/” if using it with a mod) folder in one’s Civilization 4 files.

Edit T2.zip updated on 2021-08-07 to 1) Have the ability to make smaller in addition to bigger height maps, to save time on older computers 2) Have the ability to put all players on the second largest landmass, in addition to putting everyone on the largest landmass.

Edit 2 I should explain why it’s useful to change the height map size when we already have the ability to adjust the map size via the standard “size” control. The way Perfect World/Totestra handles size is like this: It makes a really large (144 wide, 96 high by default) map which it then runs plate tectonics and weather simulation with to act like a reasonably realistic planet. Then, once it has this 144x96 map generated, PW/Totestra then scales down this really large map to the size requested by the user (44x28 for duel, 60x40 for tiny, 80x52 for small, 96x64 for standard, 120x80 for large, and 144x96 for huge) This way, if we have the same seed but select different map sizes, we get more or less the same planet generated.

What “bigger maps” does is change the size of that underlying height field. This allows us to make maps which break the 144x96 cap on map sizes and have maps as large as 192x128. (This results in a different map being generated for a given seed.) T2 scales up all of the smaller map sizes (56x36 for duel, then 80x52, 104x68, 128x84, 160x104, and finally 192x128 for huge) when a bigger map is selected. This option is a little hidden because it takes a lot more time (and memory, so make sure to only make a really huge map right after starting a new Civ4 session or a memory allocation failure may happen) to make this bigger map.

I also was able to add an option to make this underlying height field smaller (96x64 instead of the default 144x96); this is for running the generator on older computers when it’s more important to fairly quickly generate a smaller map than to generate a large or huge world. All the smaller maps are scaled down; e.g. a duel map is only 32x20.

Edit 3 T2.py is now the mainline version of Totestra.py. The older Totestra.py is still available in the “old/” folder of the Zip file in the first post in this thread.
 

Attachments

  • T2.zip
    46.4 KB · Views: 69
Last edited:
Top Bottom