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

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    Last update: March 30, 2017

    Please be aware that this is a finished project and I have no plans to update Totestra at this time

    2017 update: I do accept third party patches, such as the one q3max made, but otherwise will not update this script nor answer questions posted here (Yeah, I know, they disabled “search this thread” which means long threads will become even longer as people ask the same questions over and over). The script is now available at https://github.com/samboy/Totestra-mapscript/releases

    Before posting in this thread, please be aware that I will no longer answer questions or provide any other support. Instead, one can read the FAQ and the "Support" section below The FAQ is here: http://samiam.org/Civ4/TotestraFAQ.html

    Totestra is a map script--a program that makes random maps for Civilization IV. It is based on Cephalo's excellent PerfectWorld2 map script, and uses plate tectonics, meteor, and weather modeling to create a remarkably realistic earth-like planet. It is an update to PerfectWorld that adds more parameters that can be set inside Civ IV to the map generator, as well as fixing some long standing bugs with Cephalo's map generator. One goal of Totestra is 100% compatibility with PerfectWorld2; given the right parameters, Totestra will make the exact same map that PerfectWorld2 did.

    My motivation for making this map script is fill in the gaps since Cephalo has not made any updates to PerfectWorld2 for eight years.

    Here is the obligatory screenshot of a map made with this script:



    And a high-resolution version of the same map:




    Goals

    My goal with this fork has been to address issues people have had with the script which Cephalo has never addressed.

    Unlike Cephalo, I feel basic settings should be changed from Civ4's menus instead of editing the script. I like having the knobs on the front instead of in the back of the unit. :)

    The following can now be set from the Civ 4 menu:

    • The ocean level
    • The climate
    • How many islands the map will tend to have
    • Whether to use a fixed or random map seed
    • Whether to make a full quality map, or a "fast and dirty" small map.
    • The map's width:height ratio.
    • 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)
    • The player's handicap level
    • New civilization placement option: Have all civs start on the same continent
    • Issue with large continents being split at the international date line reduced
    • Option to eliminate coastal mountains and reduce other mountains

    I plan on eventually fixing the long-standing issue with continents being split at the edge of the map. DONE

    This script is currently derived from Cephalo's last (and probably final) release of PerfectWorld2.py (version 2.06), and does not incorporate any third party changes. (This is because of my open source roots; copyright is easier to handle when I derive only from Cephalo's code)

    Known issues

    While I do not plan up updating Totestra at this time, there are some known issues:

    • There appear to be issues with regenerated maps having multiple service tags on them. For people who want help with such a map, just post all of the service tags on the map in the support request. The workaround is to not regenerate a map.

    Service tags



    One frustration Cephalo has had is bugs he could not reproduce. This in mind, maps generated with this map generator store all settings to recreate the map as a hex-encoded string. This sign, which I call a "service tag", is put in an out-of-the-way place in arctic ice. It's a code which not only stores the seed used to make the map, but all other parameters, such as the climate, water height, number of islands desired, and so on.

    By storing this information on the map, I can more easily fix bugs people report with generated maps, because this service tag will usually give me all the information I need to reproduce the bug. 2017 update: I no longer fix non-security bugs but third parties are welcome to provide patches.

    Here is the binary format of a service tag:

    Spoiler :

    Code:
    A service tag is an 84-bit description of a given map.
    
    The lower 53 bits are the map seed.
    
    The upper 31 bits describe the parameters given to the map generator.
    They are:
    
    BLLC.CCNA.MPPR.RRII.WWYY.YYYY.HHED.D##S [The rest is for the 53-bit seed]
    
    B: Minimize large continents being split at international date line
    L: Land percent
    C: Climate
    N: New world (0: Start anywhere reasonable; 1: new world or same landmass)
    A: Allow Pangeas
    M: Eliminate coastal mountains and reduce other mountains
    P: Patience
    R: Map ratio
    I: Island factor
    W: Map wrap
    Y: Vertical map size
    H: Player handicap (bonus resources)
    E: Everyone on same landmass (0: No 1: Yes [New world also has to be set])
    D: Map Resource distribution
    #: 2-bit "parity" of all other digits in service tag; error check
    S: Map seed
    
    The two-bit parity is calculated using a fairly complicated algorithm I cooked up, based on constructions commonly used in cryptography, which gives a pretty good distribution that appears random:

    Code:
    def a91a15d7(x):
            def sbox(a,b,s):
                    a &= 3
                    b &= 3
                    index = (a | (b << 2))
                    out = s
                    out >>= (index * 2)
                    out &= 3
                    return out
            if x < 0:
                    return -1 # ERROR
            out = 0
            index = 0
            while(x > 0):
                    q = (x & 3)
                    s = sbox(q,index,0xa91a15d7) # From RadioGatun[32] of "parity"
                    out += s
                    out ^= q
                    out &= 3
                    index += 1
                    index &= 3
                    x >>= 2
            return out & 3
    
    The parity's input is the service tag with the parity bits set to 0.


    Support

    2017 update: I no longer provide any support except for integrating third party patches in to the Totestra codebase. Note that I may or may not accept a given patch and that I provide absolutely no other support.

    Before discussing this map generator, some ground rules: I am an old school rude, grouchy, and sometimes pedantic UNIX (OK, Linux) guy. I do not like addressing the same concern a zillion times and I do not like poorly formed bug reports. I also do not like wasting time humoring "blue sky" feature requests. Nor do I like getting PMs or emails with support requests. 2017 update: I’m not providing support any more.

    That in mind:

    • Read the FAQ first. http://samiam.org/Civ4/TotestraFAQ.html
    • Be sure to use the latest version of Totestra.py
    • Make sure to include either a screen capture of the map's service tag or a copy of its text.
    • If, when trying to load the script, it gives you nothing but grassland, this means the script failed for some reason. Make sure to post the relevant lines of PythonDbg.log and PythonErr.log so we can try and figure out what's broken with your Civ IV install
    • I can not look at any reports of issues with strange looking maps, strange player placements, etc. unless I know the exact parameters that made the map in question. To get this information, look for a "service tag" sign on the northern polar ice caps.
    • I will not implement whatever pet feature you want to have implemented. One goal is for this generator to make the same maps as Cephalo's code. You have the source and I don't think Cephalo will mind if you implement it yourself.
    • All support requests or comments need to be posted here in this thread. Do not PM, email, or use any other contact method to discuss with me this map script. 2017 update: I no longer provide any support at all.

    The script can be downloaded here:

    http://civ4.vk.tj/

    To install the script, download then copy the file Totestra.py to the PublicMaps directory, which should be at /Users/yourname/Documents/My Games/Sid Meier's Civilization 4 Complete/PublicMaps or somewhere similar. (Cephalo fixed the bugs which required PerfectWorld2 to be in a system directory a long time ago.)

    - Sam
     
    Last edited: Apr 3, 2017
  2. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    Here is a mod compatibility chart for Totestra on the mods I have tested it with. Being listed as compatible merely indicates that the map builds and generates a player start for my "reference test" map; it does not indicate that the game is balanced or even playable:

    • Fall from Heaven 2: YES (Furthermore, Cephalo made the Erebus map script)
    • Gods of Old: YES
    • Fairy Tale: YES
    • Next War: YES
    • Rise of Mankind 2.91: YES (There's also a ROM version of PerfectWorld)
    • K-Mod YES (En Dotter report)
    • TAM/The Ancient Mediterranean: YES
    • Tamriel / Elder Scrolls: YES (I get the impression that there are multiple "Elder Scrolls for Civ4" Mods out there; the one I tested is called tamriel.rar and has a size of 41,496,628 bytes)
    • Legends of Ancient Arabia: YES (Requires XML file fix at http://samiam.org/Civ4/Arabia.html to make fully playable games)
    • Master of Mana: YES (BUT it gives an annoying error message when starting the map; MoM includes a port of Perfect World2 which may work better)
    • Barbarians: YES (Warlords mod; smaller maps only)
    • Bare bones: YES (Warlords simple mod; it appears to exist as a framework for modders to start from. Nevertheless, you can play a Totestra-generated map with it)
    • Realism Invictus: YES (Must use "Play now!" and trudge through all of the options instead of "Custom map")
    • Community Civ V: YES (Appears to require admin privileges to play)
    • World War II 1939: YES (Requires admin privileges to play; world map is revealed at game start)
    • Mars, Now! MAYBE (I'm not sure how playable such a map really is, but it does generate and starts the player)
    • Future Mod 2b: MAYBE (Map undergoes "global warming" transformation and resulting game may not be playable)
    • Caveman to Cosmos: MAYBE (Appears to require admin privileges to play; also includes C2C version of PerfectWorld; some claim this won't work but it worked for me)
    • Mongoose Mod: MAYBE (worked in older versions, crashes with MM 4.1)
    • BUFFY/Hall of Fame: NO (While the HoF mods can generate and play a map with Totestra or Perfect World, these maps are disqualified for Hall of Fame games. Also, requiring admin privileges to play a game is something I really don't like)
    • Final Frontier: NO (But I had to try! And, of course, Cephalo made the Spiral Galaxy map script for FF)
    • Dune Wars: NO (But Cephalo did make the Arrakis map script)
    • Planetfall: NO
    • Rhye's and Fall Random: NO
    • Multiverse: NO (It might work if I didn't delete other BtS mods; if someone else tests it with positive results, let us know)
    • Pie Ancient Europe IV: NO (Mod enters a verified infinite loop when generating the map)
    • Pie Ancient Europe III: NO (Mod enters a verified infinite loop when generating the map)

    I also have a copy of this compatibility chart at http://samiam.org/Civ4/Compatibility.html

    --------------------------------------------------------------

    I have spent a couple of hours updating this map script today.

    • It is now possible to set the climate as well as the ocean level from inside of Civilization IV's GUI.
    • I am also making progress with the ability to make a "quick and fast" map. This has still not been as extensively tested as the default "Somewhat" patient setting; properly formed bug reports are welcome. "Slow and higher quality" maps also appear to be buggy.

    The script can be downloaded from here:

    http://civ4.vk.tj/

    Remember:

    • Please post all support requests about this script here.
    • Please do not file bug reports about getting "nothing but grassland" without enabling full logging in the relevant .ini file, and posting the full PythonErr.log and PythonDbg.log files here.
    • Please do not file bug reports about unusual features in the map without the map's service tag included, either as a screen capture or in text form.
    • I will probably not implement feature requests.

    I will continue work on the code a week from today, on May 19.
     
  3. Danwood

    Danwood Chieftain

    Joined:
    Mar 21, 2008
    Messages:
    238
    Love the script, personally it's the only map script i would play with.

    One thing i've noticed is that setting to cold climate, the ice caps are not wider like they should be in real life, or in vanilla bts.

    That's all for now, will give more ffedback as soon as i spot something worth mentioning.
     
  4. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    That's easily enough fixed. I'll fix it after I get the bugs in the "quick and dirty" maps fixed (they trigger a lot of corner cases which rarely occur in Cephalo's default settings); I'm going to have to disable "slow but good" maps for now until I figure out why they cause the generator to go in to an infinite loop (fixing this is a matter of having infinite "while" loops raise an error should a "loop limit" counter become too large).

    Another idea which I will probably not implement is to have a "climate amount" which will determine just how tropical/cold/arid/rocky we make a map. They may be done once I get the maps ratios to be adjustable without things blowing up.

    Some other blue sky ideas which I would love to have the time to implement but will almost certainly never get around to doing: 1) Make the map generator stand-alone, so we can have it run while we're not looking at the screen and waiting for the map to be drawn. 2) Make it possible to have the map generator make non-Civ-4 maps, such as maps for Freeciv, C-evo, Alpha Centauri, Civ 3, or Call to Power 2 (it's probably possible to adapt the "shrink" routine to fit the heightmap on an isometric or even hexagonal grid).


    I'll work on it again Saturday. Thanks a lot for checking out the script.

    - Sam
     
  5. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    May 19, 2012 update: I have fully tested and am declaring stable "fast and dirty" map rendering (it renders fine with the three preset seeds I use for testing). I have disabled "slow and extra-fancy map rendering"; there have been far more complaints about how slowly PerfectWorld renders maps than complaints about how quickly it renders maps.

    In addition, I have fixed the issue with ice being generated; ice is now smaller on smaller and/or hotter maps, as well as bigger on colder maps.

    Download link at the top of this page; please be sure to enable full logging and include a map generation log (or, at least the seed and settings used to make the map) before reporting issues with the map generator.

    I will work on it again in a couple of days.

    - Sam
     
  6. Danwood

    Danwood Chieftain

    Joined:
    Mar 21, 2008
    Messages:
    238
    Great, thanks for the update!
     
  7. Lenowill

    Lenowill Chieftain

    Joined:
    Sep 10, 2009
    Messages:
    174
    I just re-downloaded for the update. The date of the file (inside the file in its comments up top) still says it's May 12's version. Is that just an oversight or did the new file not get uploaded yet?

    [Edit: Nm, just noticed the dated text at the bottom of the website page, I'm guessing it is the correct version.]
     
  8. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    Opps...I forgot to update the changelog when I made the May 19 improvements. I'll put the changelog here:

    • Extra-slow maps disabled; they just put PerfectWorld in to an infinite loop
    • "Fast and cheap" maps tested; they work with all three preset seeds so I'm declaring these maps stable. Please note that these more quickly generated maps can not be any size bigger than standard (actually a little smaller), and that the number of continents can not be adjusted
    • Iceberg code overhaul: Polar icebergs are now more common in cold and/or large maps, and less common in smaller and/or warmer maps.

    Current to do:

    • Convert map options from arbitrary numbers in to symbolic names. For example: OPTION_MapSeed instead of "0". DONE
    • Allow map aspect ratio to be set. Right now, maps have a fixed 3:2 ratio; the map is always 1.5 times more wide than tall. Allow 2:1 (maps twice as wide as tall), 1:1 (square maps), 2:3 maps (taller than wide), and 1:2 (even taller) maps. There was one user in the old PerfectWorld thread who preferred 2:1 over 3:2 maps. DONE
    • Fix issue with "international date line" (wrap-around seam) cutting continents in the middle. The fix is to use the column with most water for the left edge of the map by rotating the map. Make it possible to disable this (by editing the file), since it is a minor spoiler. This solves an issue two different people have reported with PerfectWorld (1: Not having this sometimes can look ugly on the minimap. 2: It can make for really bad flat maps, since a continent is cut off halfway through) DONE
    • The script supports cylinder, flat, and toric maps. To make it complete, add "Uranus"/"Wrap Y" maps (it wraps going north/south but not east/west). DONE Actually, I made the fourth option a toric map with PerfectWorld2's method of generating ice bergs.
    • I don't think we should pamper users who are used to using certain strategies to win at emperor level. If someone wants a handicap with their starting position, they can ask for it in the options. My philosophy: The purpose of Perfect World is to model reality. Guns, Germs, and Steel by Jared Diamond talks about how real-world "starting positions" were anything but fair, and to try and make them fair without user intervention goes against real history. DONE; user specifies their own handicap
     
  9. Danwood

    Danwood Chieftain

    Joined:
    Mar 21, 2008
    Messages:
    238
    I'm using this script with K-Mod (the BEST AI mod for civ4, imho, can't play with anything different)

    This awesome mod overhauls the Global Warming, making it much more gameplay friendly, interesting and fun. It now melts the ice caps which serve as a "GW protection".

    Would be simply awesome if the wrapping would be Toroidal, but WITH the ice caps still there, so that when the caps melt the pole can be finally crossed.

    I wander if that's possible, maybe in an optional version just for K-Mod GW system?


    Thanks :)
     
  10. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    Here's the part of the code that adjusts things for toric maps:

    Code:
            if selectionID == 1: #Toroidal
                self.hmHeight -= 1
                self.WrapY = True
                [B]self.iceChance *= 0.1[/B]
                self.northWaterBand = 0
                self.northCrop = 0
                self.southWaterBand = 0
                self.southCrop = 0
                wrapString = "Toroidal"
    
    (Cephalo, if he is up to it, may chime in and explain exactly why it is we have to change the heights in toric maps and can not have water bands or cropping; I honestly don't know.)

    The bigger the iceChance multiplier number is, the more ice there is in the poles on toric maps. 1.0 would give the map the same amount of ice as flat or cylindrical maps.
     
  11. Danwood

    Danwood Chieftain

    Joined:
    Mar 21, 2008
    Messages:
    238
    Thanks, it worked :)
     
  12. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    I have made an update to the map generator today:

    • Overhaul of selection code; symbolic names are now used instead of numbers. This doesn't affect the script's behavior, but makes it a little easier to read.
    • Map ratios now can be selected. It is now possible to select a tall map, a square map, a "normal" (3:2) map, or a 2:1 "widescreen" (or, if you prefer, "equirectangular projection") map. ("Quick and fast" small maps have a fixed 3:2 ratio)

    As always: http://civ4.vk.tj

    (Note to self: It looks like the "Allow Pangaea" option has been broken. I'll look at it in the next update Fixed in May 24 update)
     
  13. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    I have added service tags to generated maps, which is a sign near the polar ice caps which contains a 21-digit hexadecimal string with all of the parameters used to generate a given map (map seed, number of continents, ocean level, island count, etc.).
     
  14. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    May 23 update:

    • Handicap level is now set by the user instead of being tied to difficulty.
    • Bug with "allow Pangaea" fixed
    • More map ratios added: 7:1 (Ring world) and 3:3 (extra-huge square map)

    As always, http://civ4.vk.tj Have fun!
     
  15. Danwood

    Danwood Chieftain

    Joined:
    Mar 21, 2008
    Messages:
    238
    What is handicap level? is it the probability to spawn in a unfavorable zone like desert or small islands?

    Anyway keep ut the great work!
     
  16. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    Handicap level is the number of bonus resources placed near the player's starting location. The higher the handicap level, the more bonuses are placed.
     
  17. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    May 24 update:

    In addition to the Perfect World options of evenly distributing players or keeping a continent empty for new world exploration, it is now possible to choose to have all civs start on the same continent.
     
  18. En_Dotter

    En_Dotter Chieftain

    Joined:
    Jul 15, 2010
    Messages:
    337
    Location:
    Serbia
    I just downloaded and tried this map using K-Mod. After turn 1 (settling stuff) i opened world builder to see whats up. I saw a lot of empty areas, empty in resources and/or rivers. Map seemed like a green desert to me. I saw maybe 3-4 food resources in total. Is that supposed to happen cus of some other map scrip mechanic or did my 1st random map just freak out? Is it cus of K-Mod and not the original BTS? I use blue marble adjusted for K-Mod as well.
    Map scrip looks promising, i really liked the land masses. Gonna try another randomization now. ;)
     
  19. En_Dotter

    En_Dotter Chieftain

    Joined:
    Jul 15, 2010
    Messages:
    337
    Location:
    Serbia
    Just did another random (map ID: 224810008f3d2735334af). Map is rather low on resources. Its similar to my first random but i forgot to write down the seed...
     
  20. vktj

    vktj Chieftain

    Joined:
    May 6, 2012
    Messages:
    199
    If you have a saved game with the first random seed code (look in the auto save folder, my Games\Civilization 4 Vanilla/Warlords/BtS/whatever mod\Saves\single\auto), open up that saved game, enter the world builder, then look around the north pole for a sign with the map seed code.
     

Share This Page