Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: [1] 2 3 4

Author Topic: Speeders's Common Sense Economy Mod (in dev)  (Read 25186 times)

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Speeders's Common Sense Economy Mod (in dev)
« on: December 05, 2015, 07:39:47 AM »

Well, I am making an economic mod...

I love player games as trader, and I traded stuff in real life too, and Starsector Economy is very boring and makes playing as a trader almost impossible. (instead you must play as Fedex person, doing missions and events only).

I wanted to change lots of things, but some of them aren't changeable now, for example the game has a Economy API, but there is no option to change the Economy engine, unless you change the entire campaign engine (this is allowed!), of course I won't do that, I like the rest of the campaign engine, and don't have time to switch out everything.

So, the features and ideas so far:

Feature done: Taxes varies with various market conditions.
Bigger places, and that has more stability enchancing permanent modifiers has higher taxes (Example: capitals... jangala for example has a military base, is a regional capital, and has a good amount of population, currently in the mod Jangala start with a tax of 34%)

stability by itself lower taxes (ie: places with more trading, and more security caused by the player and other fleets) with very low stability bump up taxes.

fringe places has less taxes (low population get less taxes, and some conditions, like "frontier" and "uncivilised" also get low taxes).

trade centers have lower taxes (free market, trade centers, etc...)

and relationship affect the taxes up to a certain amount, at 100 relationship you get up to a 50% discount in taxes... but at -100 relationship, your taxes are 3 times higher (so even if you managed to figure a way to enter the normal market at -100 relationship, trading on the normal market would be terribly expensive, thus you would be better smuggling anyway).

nexerelin feature I plan to implement today: Markets in the player faction have permanently 0 taxes (I mean, why you would pay taxes to yourself?)



Next feature I want to do: Implement a hidden warehouse value to markets, based on their conditions and population, and create a condition for "oversupply", that makes prices get lower if the warehouses are full, and if warehouses are full and the local market is grossly oversupplied (Example: I saw during my taxes test Jangala accumulate 600% of the local demand for food, and still charge outrageous prices) the price will take a dive (via event condition too).

Unfortunately part of the game that actually generate and consume the goods, and the "NPC" trading, is not moddable, thus why I would need to use a event condition.


Another idea: do something about markets not supplied with goods that are essential to them (example: markets with ore refineries without ore).

Further in the future idea: custom missions (of those you see in the comm channel), maybe other economic features (investing, building, something like that...)

Also I am trying to make the mod stay compatible with Nexerelin and Starsector+, so far so good... (in fact the mod don't even change your savefile for now, you can disable it and load that save and keep playing like if them mod never existed).
Logged

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #1 on: December 05, 2015, 07:46:17 AM »

Some thoughts on Alex's economy:

I noticed that Alex wanted to make the game more about risky stuff (ie: smuggling), and tried VERY, VERY hard to make the economy "stable"

Unfortunately, "stable" economies don't exist in the real world, and neither are fun to a trader, Alex economic engine features stuff like doing everything very slowly (it updates at most 10% of the price and stock per "turn" of the economy, and each "turn" takes 1 month... thus why events are needed to simulate blockades, and they only affect prices), and doing things in a very stable manner too (there are mininum prices, mininum amounts of stuff, maximum amount of trades, a "greed" variable that affects the prices of locally-made goods to be near the international price... thus why Volturnian lobsters aren't truly cheaper in Volturn...)

Many of these can disabled in the settings, and I already did a test disabling them, but I will need time to test it, the economy gets very "wacky" comapred to vanilla starsector, most of it in the good direction (ie: price fluctuations that make trade routes profitable even with high taxes), but some in the buggy sense (example: everyone decided that volturnian lobster costs only 20, and everyone has big volturnian lobster stocks... I have no idea why this happened).

But some heavy workaround modding will be needed to make things truly interesting.
Logged

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #2 on: December 05, 2015, 08:43:30 PM »

What did you change? I tried changing a few things, but it just made prices in general go up massively, more notably in locations which have large stockpiles. I have no idea how that happened. Ore costs 30+ where it is produced, and far less elsewhere. Similar issues with everything else, and prices in general seem to have increased by 50% or more.
« Last Edit: December 05, 2015, 08:51:10 PM by Ranakastrasz »
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #3 on: December 05, 2015, 08:54:51 PM »

Now that is interesting! I have no idea what you did to make those results!

I am still tweaking stuff on my side though... I am not satisfied yet, Volturnian Lobsters are being particularly troublesome.
Logged

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #4 on: December 05, 2015, 10:27:57 PM »

I will sleep now...

Anyway, I was testing some stuff, and put that the market updates every day (instead every month).

Whoa, the market behaves much more interestingly now! I mean, it behaves like an actual market, it reacts to what fleets are doing much faster, very cool.

Also I noticed no obvious performance problems \o/

Later I will try to install lots of faction mods, nexerelin (and if possible then, StarSector+...) and see if the performance is still good with 1 day market updates when you have all that stuff installed.


Still don't found a way to make lobsters stay on the legal market on volturn... but some are always present on the smuggling market, thus volturn lobsters became a sort of smuggler good (like drugs and organs).
Logged

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #5 on: December 06, 2015, 08:58:17 AM »

I think this is what I used.
I would still like a copy of your settings that got that somewhat sane price setup however.

Code
#
# start economy config
#
"economyIntervalnGameDays":30,
"economyMinFramesPerSecond":30,
"economyRollingAverageFactor":0.1,
"economyMaxStabilityPenaltyFromUnmetDemand":5,
"economyMaxStabilityFromMetDemand":3,
"economyMaxStabilityFromImportExportSmuggling":5,
"economyDemandMinGreedFraction":0.0,
"economyGreedToDemandPriceMult":0.0,
"economyAbsoluteMinNonZeroDemand":2,
"economyAbsoluteMinNonZeroSupply":1,
"economyPurchaseStockpileFraction":0.2,
"economySaleStockpileFraction":0.2,
"economyMinPurchaseAsDemandFraction":0.01,
"economyMinSaleAsSupplyFraction":0.01,
"economyMinStockpileSizeToSellAsSupplyFraction":0.1,
"economyMinStockpileFractionToLeaveWhenRemovingDemand":0.2,
"economyMaxPurchasesFromMarketPerDemand":10,
"economyMaxSalesPerCommodity":20,
"economyAbsoluteMinSaleOrOrderSize":1,
"economyMinDemandForPricing":0,
"economyMinStockpileForPricing":0,
"economyDecayMult":10,
"economyBasePriceMult":0.99,
"economyPriceMultPerStabilityPoint":0.002,
"economyExceptionOnMissingMarketEntity":true,

"economyMaxPlayerSmugglingStabilityPenalty":5,
"economyPlayerTradeImpactMult":10, # increases smuggling stability penalty and trade reputation changes
"economyPlayerSellIllegalImpactMult":5,
"economyPlayerSellMilitaryImpactMult":5,

"economyPlayerTradeVolumeForRepChangeMin":100000,
"economyPlayerTradeVolumeForRepChangeMax":1000000,
"economyPlayerTradeVolumeForRepChangeIncr":100000,
"economyPlayerXPPerCreditOfProfit":0.25,
"economyMaxRangeForNegativeTradeRepImpactLY":0, # 0 = same system

"economyAverageFractionOfStockpilePlayerCanBuy":0.2, # for price update tooltip display purposes only

# how far off the average prices have to be to be highlighted red or green
"profitMarginFlat":100,
"profitMarginMult":1.5,

#
# end economy config
#
« Last Edit: December 06, 2015, 09:53:41 AM by Ranakastrasz »
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #6 on: December 06, 2015, 11:51:34 AM »

Oh I see...

Your settings are interesting, I tried something similar to yours before.

Major interesting differences:

I have no idea what economyDecayMult do, so I don't meddled with it yet.

But "economyMinDemandForPricing" and "economyMinStockpileForPricing" I put at 1, I only speculate this, but if you put 0, you will break the economy majorly.

Those two variables in the code are intended to be used only for non-zero demand and stockpile, I don't checked in the game code what they do, but I assumed that if they were zero, you would see aberrant behaviour due to maths at 0 (example: divide by zero results in NAN or infinite, depending of what the coders involved wanted,  the power of zero is always 1, zero to power of something is always 0, but 0^0 is 1, the inverse of something *0=0 (theretically 0/0) is all values in math ever (because anything*0=0, thus 0/0 is "anything") and so on.

Finally, in my previous post I mentioned I mnade the economy run much faster, I did that by using 1 day to update (isntead of the default 30, it is the first variable).

Another notable variable is the RollingAverageFactor, when the economy updates, after making all the necessary calculatons, it save stuff with the formula (1f-rollingaveragefactor)*oldstuff + rollingaveragefactor*newstuff, meaning with the default value of 0.1 that a new price is 90% of the old price + 10% of the new price, and the stockpile is 90% of old stockpile + 10% of new stockpile, Alex intention was to make the economy stable, but at 30 days update it means the economy is "frozen" instead, for example if you kill ALL merchant ships in the market, it would take 66 months to the big enough stockpiles to reach zero (of course small stockpiles reach zero faster if you round numbers down, if you instead are rounding up it will never reach zero).

I tried using a very high rolling average factor (including 100%), the result was very interesting, but the simulation isn't good enough, so the result was a bit wonky sometimes, but after I made the simulation run once a day, I noticed I could set rolling average to 0.2 (my number now, but I will tweak more later) to have reasonable results (1 day update and 1.0f rolling factor results in the price changing from 50 to 700 in a day for example... this CAN happen in the real world, but is rare, the game simulator should not do this except with events).

With 1 day update, and rolling average of 0.2, it takes 42 days of blockade to zero the stock of a market, this sounds much more reasonable.


final note: I used "market blockade" as an example, but in-game this don't actually work, the calculations are done in the Economy.class file, you can't override it without overriding the entire campaign simulation (although I found the fact that you CAN override the campaign very impressive).

the Economy.class has a function called "makePurchasesForLocalDemand" that as you imagine is the function that calculates international trade based on demand, the relevant lines in its source to us are this:

Code
transaction.localCommodity.addToStockpile(transaction.quantity);
transaction.otherCommodity.removeFromStockpile(transaction.quantity);
transaction.localCommodity.getTransactions().commodityBought(transaction.otherMarket.getId(), transaction.quantity, transaction.pricePerDemandUnit * transaction.quantity);
transaction.otherCommodity.getTransactions().commoditySold(transaction.localMarket.getId(), transaction.quantity, transaction.pricePerDemandUnit * transaction.quantity);

As you can see, the function that make import purchases to meet demand instantly teleport goods around, meaning there is actually no way to block it.

This is the source of some of the most bizarre behaviours you see on the game economy (example: blockaded systems still having normal trading if the blockage is in hyperspace, blockades generating the "trade disruption" event, that change good prices, but not good amounts, thus you see a market that can't import food still having food... or the biggest importer of metal disrupted, yet the planet that sells the metal still has their stocks dwindling).

I am yet to find a way to circunvent this, while I can't find a way, I am modding other stuff.
Logged

Clockwork Owl

  • Admiral
  • *****
  • Posts: 790
    • View Profile
    • Starsector South Korean Community
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #7 on: December 06, 2015, 03:30:14 PM »

Those posts explain so much. I wonder why Alex did that... I mean... why should the economy be stable in the Sector.

Hope it gives some feedback to the base game.
Logged

Ranakastrasz

  • Admiral
  • *****
  • Posts: 702
  • Prince Corwin of Amber
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #8 on: December 06, 2015, 03:32:38 PM »

More notably, why would anyone think the economy would be stable, given the lore behind what happened? I mean seriously, the collapse of civilation is not going to cause stabilty.

More importantly however, is that the merchant fleets are literally impossible. If they were faction-owned supply shipments, supply convoys or something, sure, but as is, there is no way any of those merchant fleets could be economically viable.
Logged
I think is easy for Simba and Mufasa sing the Circle of Life when they're on the top of the food chain, I bet the zebras hate that song.

Cigarettes are a lot like hamsters. Perfectly harmless, until you put one in your mouth and light it on fire

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #9 on: December 06, 2015, 03:57:03 PM »

I remember a discussion about why the 30% taxes.

I think the extra-stability economy was designed for the same thing.

The 30% taxes purpose was to make player trading unprofitable, to force the player to use the events (food shortage and trade disruption), and to force the player to use smuggling.

I assume the stability has the same purpose (since it makes the prices don't vary much between markets).

But as someone that love trading, it makes the game very boring :/

Still, I should note that with a proper trading simulator in such environment, traders can make a serious killing, and the end result might be making the game too easy to get rich, it then gets hard to balance against the viability of combat builds.
Logged

Snrasha

  • Admiral
  • *****
  • Posts: 705
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #10 on: December 07, 2015, 09:50:06 PM »

Quote
nexerelin feature I plan to implement today: Markets in the player faction have permanently 0 taxes (I mean, why you would pay taxes to yourself?)

Reason why i wait this mod. Thank, if you finish!
Logged
I am pretty bad on english. So, sorry in advance.

Gladiator Society
Add battle options on Com Relay/ Framework for modders for add their own bounty.

Sanguinary Autonomist Defectors A fan-mod of Shadowyard.

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #11 on: December 07, 2015, 11:34:36 PM »

Those posts explain so much. I wonder why Alex did that... I mean... why should the economy be stable in the Sector.

Hope it gives some feedback to the base game.
Because until the game can actually construct facilities to fill gaps in the economy, it will always spiral to death unless it's either stable or overproducing everything.


Quote
nexerelin feature I plan to implement today: Markets in the player faction have permanently 0 taxes (I mean, why you would pay taxes to yourself?)
Because it makes sense: Don't you pay taxes on your revenue and purchases to your own country? Why would you do that? Oh right, because it pays for education, infrastructure, healthcare, police, military... And at the very least you need that last one in the sector.
« Last Edit: December 07, 2015, 11:38:11 PM by Tartiflette »
Logged
 

Clockwork Owl

  • Admiral
  • *****
  • Posts: 790
    • View Profile
    • Starsector South Korean Community
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #12 on: December 07, 2015, 11:52:25 PM »

Those posts explain so much. I wonder why Alex did that... I mean... why should the economy be stable in the Sector.

Hope it gives some feedback to the base game.
Because until the game can actually construct facilities to fill gaps in the economy, it will always spiral to death unless it's either stable or overproducing everything.
So that was why the supply prices skyrocketed all at once when I changed the settings huh?
Logged

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #13 on: December 08, 2015, 08:38:38 AM »

Quote
nexerelin feature I plan to implement today: Markets in the player faction have permanently 0 taxes (I mean, why you would pay taxes to yourself?)
Because it makes sense: Don't you pay taxes on your revenue and purchases to your own country? Why would you do that? Oh right, because it pays for education, infrastructure, healthcare, police, military... And at the very least you need that last one in the sector.

I mean player faction in the literal sense.

In nexerelin you can join many factions, in those cases you are a citizen, and you will pay less taxes due to relationship, but not much.

I mean you won't player tax if the faction is yours, literally (ie: you own the stuff). Because it would be paying taxes to yourself in the literal sense.

In nexerelin the id for the faction when you own the stations personally, is "player_faction" or something like that, this is what I meant.

If you instead join the imperium, hegemony, blackrock, you will pay reduced taxes due to relationship, but you will still pay taxes.
Logged

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Speeders's Common Sense Economy Mod (in dev)
« Reply #14 on: December 08, 2015, 09:03:47 AM »

Those posts explain so much. I wonder why Alex did that... I mean... why should the economy be stable in the Sector.

Hope it gives some feedback to the base game.
Because until the game can actually construct facilities to fill gaps in the economy, it will always spiral to death unless it's either stable or overproducing everything.
So that was why the supply prices skyrocketed all at once when I changed the settings huh?

There are two important factors in this:

First factor, not only the game don't add or remove production facilities, but also they work non-stop, the way a light factory is implemented in vanilla for example means it will keep making "domestic goods" no matter what, including if there are too much of it (and because the way prices are intended to be stable, they will reach a mininum value and never decrease, thus exports from that planet don't actually increase, resulting in a supply spiral), and also if there are not enough raw materials, a planet with light industry has a demand for metals and volatiles, and will buy it, and decrease it from the stockpile if present, but if noone sell those products to that planet, it will keep making domestic goods like there is no tomorrow, resulting not only in a oversupply spiral of domestic goods, but also a spiral of price for the demanded products, that will get higher and higher (until a sort of hardcoded limit).

Note this also has another consequence: the economy allow all business to operate at losses. example: the ore refinery currently uses 5000 ore (default price: 10) to make 2500 metal sheets (default price: 30). suppose that someone is attacking all fleets near the mining places, and cause the trade disruption event to jack ore prices to 50 (I've seen it happen many times). Planets with refinery will happily pay 50*5000 (250000) to produce goods in the value of 2500*30 (75000) resulting in a loss of 175000.


Second factor: The economy as a whole was designed in a way that the stock of products actually don't matter, although stations track their stocks, and stock is teleported around when the economy is updated, this is only used to make a miriad of other calculations in layers above, the "actual stock" number is used only to update other numbers ("rolling average" of stock, cargo on submarkets, cargo on trading fleets, prices, etc...). This mean the economy, even if Alex implemented the "industry", won't ever make sense.

Also this is why Alex wasn't understanding why people were upset with too much stock on stations, he knows how the game works, and players don't, he don't realized that to most people, seeing 7 digits of good stocks mean something is wrong, because he knows that his economy engine don't give a *** to that, the only thing that matters is the final price, and if there is enough stuff to the players complete missions and events, thus he kept writing that the economy wasn't broken, because prices were still behaving as he intended.

His fix was to make less stuff show up on the actual cargo of stations that the player can see, but since ever started making my mod I could see the actual stock numbers, and it is absolutely apeshit (example: food exporting planets frequently export 1 BILLION units of food, there is NOWHERE in the game enough ships to trade that, a single exporting planet would need 500.000 atlas ships to make one shipping!!!), and now sometims this is still bad for the player (in my testing I saw stations trading 2 million atlas ships worth of cargo, but the player-facing stock can fill maybe 3 ships at most...)

This mean that to balance the economy (specially on Nexerelin) the only way is to manually sum up all the supply values, and all the demand values, and keep adding and removing market conditions until those are balanced, the economy just can't handle oversupply, overdemand, out of whack prices, profits, losses, and so on.

Also by the way: lobsters generate 300 of supply each update (default is 1 month), thus why lobsters procurement contracts are ludicrous: in vanilla you have billions of food flowing around in a month, and to the player this means about 50.000 food available in total, lobsters are 300 a month (thus if it is reduced in the same way as food it would be available about 1 per month to the player, the black market is a workaround, having always a mininum amount available), thus no surprise a procurement contract for 1000 lobsters is impossible (you would need to wait something like 1000 months to accumulate the needed stock).
Logged
Pages: [1] 2 3 4