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

Planet Simulator

Discussion in 'Civ5 - Map Scripts' started by Bobert13, May 25, 2014.

  1. Magean

    Magean Prince

    Joined:
    Aug 7, 2009
    Messages:
    474
    Hi, I've been using and enjoying this script for a long while now. Yet, I wonder, does anyone more verse than I'm at decipher lua files know how to increase the likelihood of generating inland seas?

    At:
    Code:
    --removes "ocean" tiles from inland seas
        --this only affects inland seas made of a single oceanic plate. I like rare inland oceans, so I'm leaving it -LL
        ConvertInlandOceansToSeas(elevationMap)
    I've trying commenting the function into a comment line, it had no effect though.

    Thanks in advance!
     
  2. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    What was your expected result?

    The only thing that method does is turn deep water tiles into shallow water tiles. It's both for visual purposes, information purposes (knowing you're sailing or ported on a smallish inland sea), and it prevents atolls but promotes fish/luxury tiles.
     
  3. Magean

    Magean Prince

    Joined:
    Aug 7, 2009
    Messages:
    474
    Aright, thanks. I thought this line was shifting ocean tiles away from inland seas into oceans, effectively reducing both the size and likelihood of having inland seas.

    My goal was to increase the probability of having large lakes and inland seas.
     
  4. josephrandall

    josephrandall Chieftain

    Joined:
    Oct 10, 2015
    Messages:
    66
    Is there a code I can add to randomize if its Pangaea or Continents ?
    I have no Lua experience.


    Thanks
     
    Last edited: Nov 18, 2017
  5. psparky

    psparky Prince

    Joined:
    Feb 24, 2011
    Messages:
    428
    Gender:
    Male
    I made this change in my version, with the idea of adding to the mystery element. However, I found I could usually tell pretty quickly which one i had got.

    In routine GetMapScriptInfo add an entry for random to the map preset section:

    Code:
                    Values =
                    {
                        "Continents",
                        "Pangaea",
                        "Random"
                    },
    Then change SimulateTectonics to look like this:

    Code:
    function SimulateTectonics(W,H,xWrap,yWrap)
        local Plates = 10+math.ceil(H*0.625)
    
        GeneratePlates(W,H,xWrap,yWrap,Plates)
    
        GenerateFaults()
    
        local shelf = Map.GetCustomOption(6)
        if shelf == 3 then
            shelf = 1 + Map.Rand(2, "Random Shelf - Planet Simulator");
        end
     
        if shelf == 1 then
            print("Generating Continents style map")
            CreateContinentalShelf(W,H)
        else
            print("Generating Pangea style map.")
            CreatePangealShelf(W,H)
        end
    
        GenerateElevations(W,H,xWrap,yWrap)
    
        return PlateMap
    end
     
    ryanmusante and josephrandall like this.
  6. josephrandall

    josephrandall Chieftain

    Joined:
    Oct 10, 2015
    Messages:
    66
    Thanks psparky.

    One more question. For the continents map, is there any way to reduce the number of continents ? I don't like having one civ on a continent alone, very snowbally.

    I have played with this code, but no luck.

    function GenerateElevationMap(width,height,xWrap,yWrap)
    --local twistMinFreq = 128/width * mc.twistMinFreq --0.001/128
    --local twistMaxFreq = 128/width * mc.twistMaxFreq --0.002/128
    --local twistVar = 128/width * mc.twistVar --0.002/128
     
  7. psparky

    psparky Prince

    Joined:
    Feb 24, 2011
    Messages:
    428
    Gender:
    Male
    Sorry, that's beyond my understanding. The authors might still see this though so you might get a response.

    But yes, I agree that in terms of game balance, it's undesirable.
     
  8. PapaRockett

    PapaRockett Prince

    Joined:
    Jun 29, 2016
    Messages:
    432
    This map is the only one I use but I do have one pet peeve about it. The amount of desert tiles there are. I frequently spawn maps that have 3/4 of a continent just of desert. It wouldn't be so bad if there were actually RIVERS on the tiles but it's just barren. When AI settles on them it just cripples them. No way in hell I'm gonna settle on them.

    Please, if there's a fix for this, please let me know! Perfect map otherwise.
     
  9. josephrandall

    josephrandall Chieftain

    Joined:
    Oct 10, 2015
    Messages:
    66
    @PapaRockett

    Play around with these desert settings, depending on your map peference types. As you can see here ive lowered the desert tile amount.

    function MapConstants:InitializeTemperature()
    local temp = Map.GetCustomOption(2)
    if temp == 4 then
    temp = 1 + Map.Rand(3, "Random World Temperature Option - Planet Simulator");
    end
    if temp == 1 then --Cold
    print("Setting cold world constants - Planet Simulator")
    self.desertMinTemperature = 0.40
    self.tundraTemperature = 0.35
    self.snowTemperature = 0.29

    self.treesMinTemperature = 0.30
    self.jungleMinTemperature = 0.75

    self.atollNorthLatitudeLimit = 42
    self.atollSouthLatitudeLimit = -42
    self.iceNorthLatitudeLimit = 60
    self.iceSouthLatitudeLimit = -60
    elseif temp == 3 then --Warm
    print("Setting warm world constants - Planet Simulator")
    self.desertMinTemperature = 0.32
    self.tundraTemperature = 0.26
    self.snowTemperature = 0.20

    self.treesMinTemperature = 0.21
    self.jungleMinTemperature = 0.60

    self.atollNorthLatitudeLimit = 51
    self.atollSouthLatitudeLimit = -51
    self.iceNorthLatitudeLimit = 65
    self.iceSouthLatitudeLimit = -65
    else --Standard
    print("Setting temperate world constants - Planet Simulator")
    self.desertMinTemperature = 0.6 --Coldest absolute temperature allowed to be desert, plains if colder.
    self.tundraTemperature = 0.25 --Absolute temperature below which is tundra.
    self.snowTemperature = 0.1 --Absolute temperature below which is snow.






    function MapConstants:InitializeRainfall()
    local rain = Map.GetCustomOption(3)
    if rain == 4 then
    rain = 1 + Map.Rand(3, "Random World Rainfall Option - Planet Simulator");
    end
    if rain == 1 then --Arid
    print("Setting arid world constants - Planet Simulator")
    self.desertPercent = 0.33
    self.plainsPercent = 0.55
    self.zeroTreesPercent = 0.78
    self.junglePercent = 0.94

    self.riverPercent = 0.14
    self.riverRainCheatFactor = 1.2
    self.minRiverSize = 32
    self.marshElevation = 0.04
    elseif rain == 3 then --Wet
    print("Setting wet world constants - Planet Simulator")
    self.desertPercent = 0.20
    self.plainsPercent = 0.45
    self.zeroTreesPercent = 0.62
    self.junglePercent = 0.80

    self.riverPercent = 0.25
    self.riverRainCheatFactor = 1.6
    self.minRiverSize = 16
    self.marshElevation = 0.10
    else --Standard
    print("Setting normal rainfall constants - Planet Simulator")
    self.desertPercent = 0.25 --Percent of land that is below the desert rainfall threshold.
     
    ryanmusante and PapaRockett like this.
  10. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    It would take rewriting the CreateContinentalShelf(W,H) method to be able to control how many continents spawned. You'd need to add a landNeighbor check as seen in CreatePangealShelf(W,H) but it wouldn't be a simple copy and paste job. From the other side of preventing civs spawning on a continent alone, the script uses the game's default start placement and incorporating and modifying that is a nightmare.

    The code you copied there is all commented out (the -- denotes comments) so it gets ignored. I highly recommend using Notepadd++ or a similar program to delve into Lua as it both highlights syntax and objects (variable, comments, etc.) and has a much more powerful Find feature
     
    josephrandall likes this.
  11. Gothic_Empire

    Gothic_Empire AKA, Ramen Empire

    Joined:
    Aug 5, 2008
    Messages:
    1,493
    What would I have to tweak to make this script prefer to place hills next to mountains?
     
  12. GE0DZ

    GE0DZ Chieftain

    Joined:
    Sep 19, 2018
    Messages:
    1
    I've just found out about this mod today (using LL's version), does this work with multiplayer if everyone's using this script?
     
  13. ryanmusante

    ryanmusante Regular Supporter

    Joined:
    Jan 4, 2018
    Messages:
    1,078
    Ever found out how to do this? I'm interested as well to be able to improve this thing.
     
  14. Gothic_Empire

    Gothic_Empire AKA, Ramen Empire

    Joined:
    Aug 5, 2008
    Messages:
    1,493
    Sadly, no. :(
     
  15. Jiggly

    Jiggly Warlord

    Joined:
    Jun 19, 2018
    Messages:
    129
    How would I create an mostly desert map, with low resources? Goal is the have a low level of units late game (slow computer), fighting over sparse resources. Figured desert is best way to reduce food and hammers. If anyone could give me the exact numbers to feed into the edit file I would appreciate that as I am horrible at configuring files. Awesome mod!
     
  16. psparky

    psparky Prince

    Joined:
    Feb 24, 2011
    Messages:
    428
    Gender:
    Male
    I've noticed that there are virtually no forests on plains (using standard settings). I think what there is is the result of a cleanup phase to avoid things like tundra next to desert. Does anyone have any idea about how to change it so that forests are more evenly split between grass and plains, as you get in most other maps?

    Also, during my own investigations I came across the following code (I don't think it is directly related to problem above):

    local treeModifier = (math.abs(mc.topLatitude/rainfallMap:GetLatitudeForY(y))/mc.topLatitude)^1/2

    This looks like nonsense to me :confused:. I imagine the intention was to take the square root of the bracketed part, but it will actually raise it to the power 1, then divide by 2. Also, the expression in the brackets is basically abs(A/B)/A, which is just abs(1/B). I'm guessing this code is meant to make forests more or less likely as you move away from the equator, but it sure looks wrong :crazyeye: Kind of worrying thing to find in my favourite map script :eek:
     
  17. elotar

    elotar Chieftain

    Joined:
    Jan 16, 2014
    Messages:
    22
    I got an idea to look at it not as a bug, but as a feature - so we got jungles on plains and forest on grassland - do not know about realism, but it's quite fine for gameplay - choice is much more straightforward. :D
     
  18. elotar

    elotar Chieftain

    Joined:
    Jan 16, 2014
    Messages:
    22
    By the way the real problems I got with the script is:
    1. One-tile rivers
    2. Crap load of desert
    3. Not balanced distribution on continents preset (last game there was 3 nations on one continent, 1 on the other, and 6 on the last one).

    As I understand, it can be tweaked inside mod's settings, but I think it'll be much better, if standard settings were more suitable for a balanced game.
     
    saamohod likes this.
  19. Bobert13

    Bobert13 Prince

    Joined:
    Feb 25, 2013
    Messages:
    345
    Raise desertPercent, lower desertMinTemperature, lower the other numbers for other terrain types and probably lower tree and jungle percentages to avoid them spawning on strange tiles.

    Forests and Grasslands are largely tied to rainfall amounts so clearing forest nets you grasslands the vast majority of the time. It would probably take reworking how they spawn entirely to get them to spawn on plains frequently. Jungles deforested typically have poor soil hence Jungle forces the tiles underneath to convert to plains (as is default in all Civ V maps).

    Also, That math is top-tier work my friend. I don't recall writing it 4++ years ago, but it's doing it's job (keeping trees out of the snow band). And in Lua, the constant (1/2) is handled pre-compilation as it actually compiles on the fly. This isn't the only place int he scripte where I'm taking a root like this either. In other languages your observation may be correct.

    1. One tile rivers should be rare/nonexistant (depends on map size possibly). Lowering riverRainCheatFactor and/or raising minRiverSize should reduce these. I also do not like these.
    2. Deserts are good and the land totals for deserts are taken from Earth surface area totals IIRC. Lower them. :goodjob:
    3. You'll have this. It's not particularly common but it's more common than the default scripts as getting an Australia/seperated India-sized continent is pretty likely. Unforturnately, AssingStartingPlots.lua is a four letter word around here and trying to write a new script to handle that would be a huge undertaking in and of itself (like 6k+ lines in Communitas Mapscript IIRC).
     
    Last edited: Apr 22, 2019
  20. psparky

    psparky Prince

    Joined:
    Feb 24, 2011
    Messages:
    428
    Gender:
    Male

    Thank you for the reply! Regarding forests, from my reading of the code, I suspected that rainfall was the key and no easy change would be available. The reason I'm interested in this is not for the result of chopping a forest. I'm playing the popular Vox Populi mod which changes the way yields from forests are calculated so that it depends on the underlying terrain. A forest gives +1 production, so on grass it's 2F 1P while on plains it's 1F 2P. Having almost all forest on grass reduces the strategic element of deciding which to work and which to chop.

    What I plan to try is to add an extra late pass that replaces the terrain under some the forests with plains and see how that looks. As I mentioned, overall this is my favourite map script so I'd like to make it better from a gameplay point of view, even at the cost of some realism.

    With regard to the coding question, I've looked at the LUA manual and also tried an example and I believe you are incorrect. I also note that elsewhere (in this file at least) you use math.sqrt - there are no other examples of the x^1/2 code. It is true that compilers will usually evaluate constant expressions and subexpressions, but not in a way that changes the meaning. For example, if you write x*(3+5), most compilers would replace that with x*8. But if you write x*3+5 they cannot evaluate anything here without changing the meaning from (x*3)+5. In the actual case, the ^ operator has precedence so the meaning is (x^1)/2 - the compiler doesn't change that.

    In any case, as you say, the code is working OK, but probably not as intended.
     

Share This Page