• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Anthropoid

Major Game Slut
59 Badges
Sep 30, 2008
3.014
1.079
  • Crusader Kings II
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Mount & Blade: Warband
  • Victoria 2: A House Divided
  • Supreme Ruler 2020
  • Rome Gold
  • Victoria: Revolutions
  • Europa Universalis IV: Res Publica
  • Heir to the Throne
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Charlemagne
  • Arsenal of Democracy
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sunset Invasion
  • Europa Universalis III Complete
  • Crusader Kings II: Sword of Islam
  • Commander: Conquest of the Americas
  • Deus Vult
  • East India Company Collection
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Galaxy Edition
  • Crusader Kings II: Reapers Due
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Mass Transit
  • BATTLETECH
  • Hearts of Iron IV: Death or Dishonor
  • Cities: Skylines - Green Cities
  • Crusader Kings II: Jade Dragon
  • Stellaris: Galaxy Edition
  • Cities: Skylines - Parklife
  • Cities: Skylines - Snowfall
  • Crusader Kings II: Conclave
  • Cities: Skylines - After Dark
  • Crusader Kings II: Horse Lords
  • Crusader Kings II: Way of Life
  • Rise of Prussia
  • Cities: Skylines Industries
  • 500k Club
  • Victoria 2
  • Europa Universalis III Complete
  • Europa Universalis III Complete
I see there have been a few threads that deal with galaxies, but not one that specifically just focuses on the logic and syntax of the random galaxy generator scripts.

The question(s) I'm particularly interested in are: how can one influence the clumping of random spawns in any given galaxy. I'll generally refer to either "huge" or my own modded "enormous" galaxy script, but the idea is to arrive at some basic principles about how random galaxy generation works, and is thus moddable.

C:\Steam\steamapps\common\Stellaris\map\galaxy

Contains several files, most notably
Code:
-- BASE VALUES FOR GALAXY GENERATION

core_radius_perc = 0.25                -- Core radius is 30% of the galaxy radius
num_stars_core_perc = 0                -- Number of stars in core
stars_min_dist = 10.0                -- Min distance between stars

countries = {
    ideal_sq_dist_between = 75*75,    -- Ideal square distance between countries
    min_sq_dist_between = 50*50,    -- Min square distance between countries
}

fallen_empires = {
    num = 5,                        -- Number of fallen empires
    ideal_sq_dist_between = 150*150,-- Ideal square distance between countries
    min_sq_dist_between = 100*100,    -- Min square distance between countries
    max_military_fleet_count = 5,    -- Number of military fleets the empire will start with
    ships_per_fleet = 3,           
    --starting_tech
}

The other four files there contain attributes that primarily seem to be concerned with the shape of the galaxies, not with the spawning of empires.

C:\Steam\steamapps\common\Stellaris\map\setup_scenarios

Contains five files, one for each of the vanilla galaxy sizes (tiny, small, medium, large, huge). Here is an example of the code for the vanilla huge
setup_scenario = {
name = "huge"
priority = 4 #priority decides in which order the scenarios are listed
num_stars = 1000
radius = 450 #should be less than 500, preferably less than ~460
num_empires = { min = 1 max = 39 } #limits player customization
num_empire_default = 29
fallen_empire_default = 5
advanced_empire_default = 8
colonizable_planet_odds = 1.0

cluster_count = {
# method = one_every_x_empire
method = constant
value = 6
max = 10
}
cluster_radius = 150
cluster_distance_from_core = 300

num_nebulas = 10
nebula_size = 60
nebula_min_dist = 200

supports_shape = elliptical
supports_shape = spiral_2
supports_shape = spiral_4
supports_shape = ring
}

With that all said, I have created my own mod, that includes a new variant on galaxy size "enormous"
C:\Users\Anthropoid\Documents\Paradox Interactive\Stellaris\mod\anthropoid\map\setup_scenarios\enormous.txt

These were the initial values I used
Code:
setup_scenario = {
    name = "enormous"
    priority = 5                    #priority decides in which order the scenarios are listed
    num_stars = 1500
    radius = 490                    #should be less than 500, preferably less than ~460
    num_empires = { min = 20 max = 22 }    #limits player customization
    num_empire_default = 21
    fallen_empire_default = 7
    advanced_empire_default = 0
    colonizable_planet_odds = 0.05
    cluster_count = {
        # method = one_every_x_empire
        method = constant
        value = 2
        max = 3
    }
    cluster_radius = 225
    cluster_distance_from_core = 225
    num_nebulas    = 9
    nebula_size = 50
    nebula_min_dist = 200
    supports_shape = elliptical
    supports_shape = spiral_2
    supports_shape = spiral_4
    supports_shape = ring
}

To make a long story short, the exact functionality of the code from "cluster_count =" and "cluster_distance_from_core" remains a bit elusive.

Starting from the bottom of that set:
cluster_distance_from_core and cluster_radius : are fairly self-explanatory and function intuitively. However, the following may or may not work (I changed several assignment statements to this type of syntax, and have not yet pinned down which, if any, work this way and which do not)

Code:
cluster_radius = { min = 98 max = 196 }  #min 1/5 of radius, max 2/5
   
    cluster_distance_from_core =  { min = 147 max = 343 } #min 3/10 of radius, max 7/10

Moving up to the other attributes: max = value = and method = are particularly puzzling. Based on repeatedly starting new games with various integers plugged in here, the only thing I've been able to com up with is:
1. "value = x" seems to do nothing. Changing this value to 0, 1, 2, 3, 4 and leaving everything else the same, does not appear to be having any effect (though I honestly have not tested that thoroughly)

2. "method = constant" (the default assignment) would presumably apply a constant value to all cluster initializations. I tried "method = random" and that works too, but it doesn't actually seem to make it more "random" in concert with differing values in "value = x" and "max = y"

3. "max = y" this seems to be what is determining how many clusters of empires are spawned, although apparently in int eraction with other variables, because low values here (3, 4, 5, 6, 7, 8) seem to produce the same number of clusters. A "max = 9" does seem to produce NINE clusters with the 22 empires (based on my narrowed range in my enormous.txt) divided roughly evenly (although some overlapping).

As you can see, this is all quite complicated, and I thought if anyone else has fiddled with it, it might be worth comparing notes.
 
You would probably benefit from checking out error.log in ~/Documents/Paradox Interactive/Stellaris/log . Your cluster_radius/cluster_distance_from_core lines are, for example, invalid syntax.

Honestly, right now the map generator is frankly terrible from a modding stand point. There is simply not enough we can tweak, too much is hidden from us, and too much that seems to be hardcoded. This would be less of an issue if we could actually generate working static galaxies, but that process has serious issues as well.
 
Last edited:
You would probably benefit from checking out error.log in ~/Documents/Paradox Interactive/Stellaris/log . Your cluster_radius/cluster_distance_from_core lines are, for example, invalid syntax.

Thanks Zach. However, are you sure that syntax is invalid?

C:\Steam\steamapps\common\Stellaris\common\solar_system_initializers\example.txt has the following:
Code:
#
# All numeric values can be scripted as 'x = 10' or 'x = { min = 5 max = 15 }', except within the triggers and effects
#

and then a bit later in the same file:
Code:
    #create a planet
    planet = {
        count = 1                    #defaults to 1, if you have count = { min = x max = y } then a random number ( between x-y ) of planets will be created.

so it isn't immediately obvious why the following would be invalid syntax
Code:
setup_scenario = {
name = "enormous"
priority = 5 #priority decides in which order the scenarios are listed
num_stars = 1500
radius = 490 #should be less than 500, preferably less than ~460
num_empires = { min = 20 max = 22 } #limits player customization
num_empire_default = 21
fallen_empire_default = 7
advanced_empire_default = 0
colonizable_planet_odds = 0.05
cluster_count = {
# method = one_every_x_empire
method = constant
value = 2
max = 3
}
cluster_radius = { min = 98 max = 196 } 
  
    cluster_distance_from_core =  { min = 147 max = 343 }
 
Thanks Zach. However, are you sure that syntax is invalid?

It gives an error in the log, so yes I'm fairly certain.

C:\Steam\steamapps\common\Stellaris\common\solar_system_initializers\example.txt has the following:

That comment is for system initializers, it's not valid in every game context. I do wish it were valid in map scenarios as hardcoding both these values leaves a lot to be desired.
 
Thanks for clarifying that Zach!

Bummer.

Would still be nice to know for sure what "value =" and "max =" are actually doing.