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

Stellaris Dev Diary #120 - New Economy System

Hello and welcome back to the Stellaris dev diaries! Today we're going to start talking about the next major update, which we have dubbed 2.2 'Le Guin' after Ursula K. Le Guin. Right now we're not ready to reveal anything about the precise nature of the update or whether it is accompanied by any DLC, other than to say that the Le Guin will have focus on trade and the economy, and that its release date is far away. Today's dev diary is going to be a bit on the foundational side, going over the new economic back-end we've implemented for 2.2.

New Economy System
The original economy system for Stellaris has always been something of a limitation for us. It's a sort of hybrid system, with resources being both scripted (and thus accessible to modders) and hard-coded (and thus inaccessible) in about equal measures. For example, under the old system ships would always cost minerals, as the code was set up for them to always cost minerals, and the only thing you could change was the amount of minerals they cost. Similarly, most things in the game that had an upkeep were hard-coded to use energy for upkeep, and again, only the amounts were able to be changed. A few things (such as for example Resettlement or the precise resources produced by a building) were more open than this, but generally the system made it quite hard to introduce new resources or change the way a particular empire might use a particular resource. The old system was also quite performance-intensive.

When we decided that we wanted to make the next major update be about the economy, the first thing we knew that we needed to do was to rewrite this system entirely. For the new system, we set out a number of goals:
1: The new system should make it easy to add new resources and swap the way resources are used
2: The new system should be as open to modding as we possibly could make it
3: The new system should improve performance

From this, we've created a new system that we call Economic Templates. Where previously there would be a jumble of different systems for how cost, production and maintenance of the different features in the game would work, there is now one unified system. Any single object in the game that can be owned by an empire and have an impact on the economy is called an Economic Unit. In the database files, an Economic Unit looks like this:

Code:
resources = {
    category = armies
 
    # Normal empires pay for armies with minerals
    cost = {
        trigger = {
            owner = { is_hive_empire = no }
        } 
        minerals = 100
    }
 
    # Hive Minds pay for armies partially with food
    cost = {
        trigger = {
            owner = { is_hive_empire = yes }
        }     
        minerals = 50
        food = 50
    }     

    # If Barbaric Despoilers, produce Energy while on enemy planets
    produces = {
        trigger = {
            owner = { has_valid_civic = civic_barbaric_despoilers }
            planet = { owner = { is_at_war_with = root.owner } }
        }
        energy = 3
    }     
 
    # Normal empires pay army upkeep with energy
    upkeep = {
        trigger = {
            owner = { is_hive_empire = no }
        }     
        energy = 1
    }
 
    # Hive Minds pay army upkeep with food
    upkeep = {
        trigger = {
            owner = { is_hive_empire = yes }
        }     
        food = 1
    }     
}

For those who cannot read our scripting language, this is an example I just created of how the new system can be used. It's for a regular assault army, which normally costs 100 minerals to build and has an upkeep of 1 energy, just as before. However, if your empire is a Hive Mind, the army will instead cost 50 minerals and 50 food, and costs 1 food in upkeep instead of 1 energy. Additionally, if you have the Barbaric Despoilers civic, armies that are located on enemy planets will produce 3 energy/month, paying for themselves and then some through wide-scale looting. This isn't an actual example from the internal build, but something I just created while writing this dev diary to show the possibilities that the new economic system opens up for for both us and modders - we could have fully biological empires that use food instead of minerals to build infrastructure, ships that produce research while in certain systems, leaders that give Unity... the possibilities are endless.
2018_08_09_1.png


Advanced Resources
With this system in place, we've been able to add several new 'advanced' resources to the game. They are as follows: Alloys, Rare Crystals, Volatile Motes and Exotic Gases. These resources are either manufactured from basic resources or found in rare planetary deposits (or both!) and are used to construct more advanced things in the game, such as ship components, megastructures, certain buildings and so on. There is also still a number of strategic resources such as Dark Matter and Living Metal that provide unique benefits, though precisely how many of these we will keep and how they are used is something we're still in the process of figuring out.

As part of these changes we're also in the process of reworking the top bar. Since we will now have rather too many resources to show them all, the top bar will now only show individual entries for resources that are important for your empire to always keep track of, with the rest shown as a consolidated entry that can be tooltiped for greater detail. Science is also consolidated into a total output of all 3 sciences, with tooltip showing the individual production of each. We're going to ensure that only relevant resources are shown individually, so most Machine Empires wouldn't have Food appear as an individual entry in the top bar, for example. We're also considering letting the player manually override this and decide which precise resources they want to keep track of within the available topbar space.

(Please note that the new topbar is nowhere near final and will have some ugly graphical issues. This is not how it will look on release)
2018_08_09_2.png


That's all for today! I know this dev diary was rather technical and perhaps primarily of interest to modders, but I felt it was important to explain the fundamental changes that have taken place in the game's back-end, both in relation to the changes coming in 2.2, and the possibilities that this opens up in the future for having empire types with radically different approaches to resource production and consumption. Next week we're going to finally start talking about the new Planetary Management system. See you then!
 
I wonder how well the new economic AI can analyze a highly moddable economy. Say it wants to build ships. Can it understand that it needs to build up all the prerequisite resource generators and the generators for those generators, in sufficient quantity, whatever they may be? Or even adjust its ultimate build goals based on availability of basic inputs at the other end of the production chain?

I'm making a new, far more scriptable economic AI so that it can be changed to handle new resources without needing to tweak code.
 
Hey @Wiz , this seems like a good opportunity bring up a long term bugbear of mine: I do not think the player empire's gross research output is particularly useful information (not immediately so, at least), and I think it should be replaced in the top bar with some other metric for research.

70% of the time, when I'm looking at my research scores the question I'm trying to answer is "How fast am I teching? Am I pulling ahead or falling behind?" (the other 30% of the time it's "Which branch am I most deficient in", when I'm specialising labs). The problem here is that the value of one point of research is so heavily dependent on context, a context which itself can be quite complex, that the raw number is next to meaningless. 20 points of physics research means something radically different to a one planet empire just after the start of the game than one that covers half the galaxy and is into repeatables.

Ideas for possible alternative metrics
  • % of the initial "base rate", after accounting for cost modifiers
  • Rolling average of achieved time to completion
 
I'm making a new, far more scriptable economic AI so that it can be changed to handle new resources without needing to tweak code.
WOOHOOO the new AI!
Maybe after all these changes and balance tweaks the new AI enchanced with more scripts and more features will start using weights right and will be good enough to play against players without those annoying buffs to resource production. Really hope so.
 
The market will ensure that it's always possible to get your hands on fundamental resources that you need for things like ship building, though it might end up quite expensive. More on that in another DD though.

Also ALL robot types can now trade, even with meatbags?
 
We're also considering letting the player manually override this and decide which precise resources they want to keep track of within the available topbar space.

I would be glad if you did that.
Of course I don't know how the game plays with the new bar, but at first glance I find it very odd to not see every science output seperately.
I personally would undo the consolidation of science output for my game, if it was possible.
 
@Wiz if you could also let us choose which planets and starbases appear in the outliner, that would be grand. I don't need to see 40 identical trading hubs and anchorages, but I might want to keep an eye on planets still under development that happen to be in sectors.
 
Oh my lord I can't wait to be able to play a fully biological devouring swarm that makes ships, infrastructures, and more out of the corpses of my enemies. I hope next week is on planet management and how all of that ties together with this new economic system. The hype is so real right now.
 
Also ALL robot types can now trade, even with meatbags?
We Robos dont trade with Meatbags. We take what rightfully is ours. :D

@Wiz if you could also let us choose which planets and starbases appear in the outliner, that would be grand. I don't need to see 40 identical trading hubs and anchorages, but I might want to keep an eye on planets still under development that happen to be in sectors.

I would prefer some Options to switch as Example in the planetmenu trough all my Planets. Like in Civilisation. Or a better Outliner like a Datatree where you can clap down the whole Tree and see only the Categories like Planets or starbase or Fleets or so and than you can go to planets and than you see all planets. This will be so great. :)
 
As I said, we're still figuring out exactly how strategic resources will fit into the system, so more on this in a future DD.
A quick thought, maybe not the best one but who knows: if you are adding a lot of proper (stockpile-able) resources, there is a possibility to exclude the strategic resources (or some of it) from the resource category. Lets say that there are planets that just HAVE a particular resource and the number is undetermined (0/1). The player who possesses is becomes allowed to e.g. build special ships.
However, the more the resource is exploited, the more player risks loosing it, similarly to how gold mines in EU4 work. So, sometimes you will be able to pull out things like increasing production by 500% and sometimes you will run out of the particular resource after the first use. Ideally, a player could get an alert if he is exploiting the strategic resource too much.
 
Besides Machine Empires, which I presume will make full use of the new stuff, are there any planned new empire types like that?

While not in the game yet, this will open the way for things like silicoids that eat minerals instead of food, or even an energy being/psychic race that makes its buildings out of energy.
 
This sounds awesome!
I guessing the market DD will explain more but will Trader Enclaves have an impact on this at all?
Also if you can gain one within your borders will that affect anything?
 
I would be glad if you did that.
Of course I don't know how the game plays with the new bar, but at first glance I find it very odd to not see every science output seperately.
I personally would undo the consolidation of science output for my game, if it was possible.

I'd like to see a x/y/z for science output, it does not have to be 3 seperate locations / values like it is now. But combined science output doesn;t show me much of anything useful. Also a increase over baseline when you mouseover on tech costs would be great.
 
so most strategic resource are canceled and the rest doesn't give simple buffs
easier to track
but what the remaining four will do?
and if top bar are full maybe make two rows
in high definition hardly a problem
 
Last edited: