Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: [how-to] economy-related values and such  (Read 3887 times)

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
[how-to] economy-related values and such
« on: November 15, 2014, 12:14:17 PM »

Hi.

There are some values that new economy is using that might cause confusion for modders as most of them aren`t explained anywhere.

For example these two:

Quote

market.getDemand(Commodities.REGULAR_CREW).getDemand().modifyFlat(id, 100);
market.getDemand(Commodities.REGULAR_CREW).getNonConsumingDemand().modifyFlat(id, 99);

What`s the difference between these two? I`ve done some javadoc digging and eventually discovered somewhere that the first value sets a demand that will be consumed in order to produce stuff. Will it be consumed at some fraction or will the market wait for the whole demand to be met - i don`t know. Probably depends on how market condition script is written.

The 'getNonConsumingDemand' is a specified amount of goods that will be available for sale at this market. Will it be accounted for the demand met or not is probably also set up in conditions scripts.


Now these two are a true mystery:
Quote
   "defaultConnectionMult":1,
   "defaultConnectionFlat":1,

What they do i can only guess.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [how-to] economy-related values and such
« Reply #1 on: November 15, 2014, 12:38:38 PM »

As far regular and non-consuming demand:

The economy sim ultimately distributes commodities based on prices. High demand and high stability increase prices.

Regular demand is subtracted from stockpiles each economy interval. The details aren't quite as simple as that, so don't expect the average stockpile to be equal to production plus imports minus exports minus demand.

Non-consuming demand is a portion of the regular demand that's not subtracted from stockpiles.

For example:
market.getDemand(Commodities.REGULAR_CREW).getDemand().modifyFlat(id, 100);
market.getDemand(Commodities.REGULAR_CREW).getNonConsumingDemand().modifyFlat(id, 99);

This sets the demand for crew to 100, but only 1 crew is "consumed" every economy interval (which is configurable, 30 days by default). This crew consumption simulates crew loss due to retirement, accidents, etc.

Non-consuming demand is also useful if you want a location to have a stockpile of stuff that the player can buy. For example, space stations have a non-consuming demand for fuel - meaning fuel gets shipped there, but isn't consumed, so more of it is available on the market.


   "defaultConnectionMult":1,
   "defaultConnectionFlat":1,

The economy sim uses connection weights between markets to figure out at what price to ship stuff where.

For example, say Food at Tartessus is sold at 30 credits per unit, and it's considering shipping it to Sindria, where Food is bought at 50 credits per unit.

The cost of shipping it looks at will be 30 * <connection mult> + <connection flat>. Then, if that result is <50, it might decide to ship there, unless other markets offer a better margin.

The connection mult is affected by distance to the market, market size, piracy, and possibly other things. defaultConnectionMult is its default value. Setting it to 2, say, would cause a much greater disparity in prices - in effect, you're saying that shipping goods is very hard. What you'd end up with then are excess stockpiles on producer worlds and unmet demand on consumer worlds.

connection flat is, iirc, unused, beyond the default value. Manipulating the flat value can be useful to make it so that higher-price goods are "worth it" for the sim to ship, while lower price goods are not, if that's ever needed. I.E. an extra cost of 10 credits per unit means a lot to the price of Food but not as much for Luxury Goods.
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [how-to] economy-related values and such
« Reply #2 on: November 15, 2014, 01:33:10 PM »

Thanks. Things are becoming much clearer now.

Wanted to ask you about population, market size and stability.

The first seems to be not just simple 1,2,3,4 etc. numbers, but some progressing values close to what is said in population decriptions, right? Like 100 for pop1, 1000 for pop2, 10000 for pop3 and etc.

The second is what troubles me the most. It seems to be set only once at economy files and does not change during the game (i.e. it is not stability). What this size actually impacts? Number of trade/patrol/pirate fleets to be attached to this market and some specific parametres for market conditions (like unlocking certain population demands)?

The third can`t be set at start, right?

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [how-to] economy-related values and such
« Reply #3 on: November 15, 2014, 01:35:26 PM »

Regarding getNonConsumingDemand().

What will happen if there are other market conditions that demand the same commodity, but consume it entirely instead of sharing it at the market. Will the getNonConsumingDemand commodities be accounted for the other markets?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [how-to] economy-related values and such
« Reply #4 on: November 15, 2014, 01:38:22 PM »

Thanks. Things are becoming much clearer now.

Wanted to ask you about population, market size and stability.

The first seems to be not just simple 1,2,3,4 etc. numbers, but some progressing values close to what is said in population decriptions, right? Like 100 for pop1, 1000 for pop2, 10000 for pop3 and etc.

The second is what troubles me the most. It seems to be set only once at economy files and does not change during the game (i.e. it is not stability). What this size actually impacts? Number of trade/patrol/pirate fleets to be attached to this market and some specific parametres for market conditions (like unlocking certain population demands)?

The third can`t be set at start, right?

Estimate of population = 10 to the power of market size. You can set marketSize via MarketAPI, but it's not "nicely" mutable like other stats at the moment.

You can't set stability directly, no, since it's a compound value made up from various factors. You can, however, add market conditions that increase or decrease stability, so you can effectively tune it to be whatever you want for your market.

Regarding getNonConsumingDemand().

What will happen if there are other market conditions that demand the same commodity, but consume it entirely instead of sharing it at the market. Will the getNonConsumingDemand commodities be accounted for the other markets?

It'll just add up the total demand, subtract the total non-consuming demand from that, and then use the resulting value to reduce the stockpiles by.
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [how-to] economy-related values and such
« Reply #5 on: November 15, 2014, 01:43:01 PM »

So what exactly does the size do (the one you specify for each market) and what are the boundaries (0-10?).

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [how-to] economy-related values and such
« Reply #6 on: November 15, 2014, 02:02:43 PM »

Regarding commodities.

Here are the field ids used in commodities.csv:

name,id,demand class,base price,price variability,utility,decay,origin,tags,stack size,cargo space,icon,sound id,sound id drop,order

While most of them are somewhat selfexplanatory, but some i can only guess about.

Demand class is mostly being unique, so what is the point of this field? Can, for example, several commodities be considered as a single class (luxury, for example, or drugs) for demand puproses?

What are tags used for? I found some references for these in some market conditions that are commented out.

Utility and decay? I first though that utility means 'used by fleets', but it is set for all commodities. Decay does mean that we can eventually loose cargo for it loosing it`s trading conditions?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [how-to] economy-related values and such
« Reply #7 on: November 15, 2014, 02:23:14 PM »

Demand class and utility are tied together. Commodities with the same demand class satisfy the same demand. Utility is how much demand each commodity satisfies. The effective price is the base price times the utility.

Tags are used for... things. Different things. For example, stuff with the "military" is available on the military submarket, even if it's illegal on the open market. You can check the various uses by looking for where the TAG_XXXX constants from Commodities.java are used.


Decay is the fraction of the current excess stockpile that is lost every economy interval. It's a way to prevent runaway stockpiles.
Logged

Okim

  • Admiral
  • *****
  • Posts: 2161
    • View Profile
    • Okim`s Modelling stuff
Re: [how-to] economy-related values and such
« Reply #8 on: November 15, 2014, 11:07:00 PM »

Thanks.

And the last thing i`d like to ask about is price variativity field.

Is it a raw multiplier that sets the price margins (low/high)? Say, if i have food with 25 credits per unit and variativity set to 5 will the food costs vary from 5 to 125 never falling off these margins? Or this field works entirely different?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [how-to] economy-related values and such
« Reply #9 on: November 15, 2014, 11:40:24 PM »

The variability affects how price fluctuates with demand. I don't remember the exact formula, but it factors into an exponent somewhere. Variability 0 means no price variation at all. Variability 10 is something like 16x the price when no demand is met, and a comparably sharper dropoff after all demand is met.
Logged