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

Totestra: A new PerfectWorld2 fork

Discussion in 'Civ4 - Map Scripts' started by vktj, May 8, 2012.

  1. Yxklyx

    Yxklyx King

    Joined:
    May 7, 2008
    Messages:
    869
  2. saam

    saam Chieftain

    Joined:
    Jan 5, 2010
    Messages:
    3
    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?
     
  3. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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:

     
  4. DisposableHero

    DisposableHero Chieftain

    Joined:
    Dec 9, 2009
    Messages:
    76
    What settings were used to generate the example map in the first post?
     
  5. wotan321

    wotan321 Emperor

    Joined:
    Oct 25, 2001
    Messages:
    1,220
    Location:
    NC, USA
    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.
     
  6. q3max

    q3max Chieftain

    Joined:
    Feb 21, 2011
    Messages:
    1
    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
     
  7. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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: Mar 29, 2017
    sampo likes this.
  8. Mknn

    Mknn Prince

    Joined:
    Dec 17, 2007
    Messages:
    337
    Location:
    Houston
    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?
     
  9. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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).
     

    Attached Files:

    Last edited: Apr 18, 2018
    sampo likes this.
  10. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    *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: Jul 7, 2019
    sampo and Jarlaxe Baenre like this.
  11. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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: Jul 7, 2019
    TaylorItaly and sampo like this.
  12. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    Here is how that map looks in-game:

    Civ4-T285.JPG
     
    TaylorItaly and sampo like this.
  13. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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).
     

    Attached Files:

    TaylorItaly, sampo and Jarlaxe Baenre like this.
  14. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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.
     

    Attached Files:

    Last edited: Jul 20, 2019
    TaylorItaly and sampo like this.
  15. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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.
     

    Attached Files:

    sampo likes this.
  16. vktj

    vktj Warlord

    Joined:
    May 6, 2012
    Messages:
    211
    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.
     
    sampo likes this.
  17. givy

    givy Chieftain

    Joined:
    May 4, 2010
    Messages:
    11
    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.
     
  18. Zeta Nexus

    Zeta Nexus Deity

    Joined:
    Jan 23, 2014
    Messages:
    3,610
    Gender:
    Male
    Location:
    In a constant brainstorm...
    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.
     

Share This Page