Fractal Softworks Forum

Please login or register.

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

Author Topic: Economy issues with dynamically generated sector  (Read 5872 times)

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Economy issues with dynamically generated sector
« on: February 06, 2015, 09:55:04 PM »

So I've been fiddling with Exerelin, and after some trial and error, I was able to build on Zaphide's code to make a pretty decent-looking sector generator.

Unfortunately, I must've grievously offended Adam Smith in a past life or something, because the economy is really off base.

I can scarcely find supplies, fuel, heavy machinery or marines anywhere. Supplies and fuel do show up on the black market, but are often heavily overpriced.
Further, a market is doing well if it has 30% of its demand met. The ones I checked on my last run had: 31%, 45%, 14%, 19%, 6% and 1%.
(the seventh market hung when I went to the trade screen)
Code
809178 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Picking market updates
809178 [Thread-5] INFO  com.fs.starfarer.api.impl.campaign.events.TradeInfoUpdateEvent  - Adding Supplies(Hell)

    Observed prices:
    Spoiler
    • Heavy Machinery: ~700 (on a planet with double heavy autofac, mind)
    • Marines: ~1000
    • Luxury goods: ~660
    • Domestic goods ~170
    • Heavy metals: ~1000
    • Rare ore: ~10 - ~270
    • Hand weapons: ~400
    • Supplies: ~340 - ~500 - ~800
    • Fuel: ~20 - ~270- ~430 - ~600
    [close]

    Source code:
    git repo (can be checked out and played in 0.65)
    Sector generator
    Market condition picker

    How fix?

    I'm wondering if there are insufficient trade fleets to get everything to where it needs to go, but there are only 6-8 star systems with maybe up to 6-7 markets per system, and the trade fleet limit is the same as in vanilla. Should I raise it even higher?
    « Last Edit: February 07, 2015, 01:26:22 AM by Histidine »
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #1 on: February 06, 2015, 10:37:37 PM »

    Trade fleets don't factor in here - not much, anyway. If none of them make it, it'll reduce the amount of shipping the simulation does, but it'll still roughly work.

    First off, make sure none of your market sizes are above 6. 7 might also work, but just to be safe. I'm mentioning this b/c you mention the trade screen hanging, which could be related to this.


    Quote
    Heavy Machinery: ~700 (on a planet with double heavy autofac, mind)

    That entirely depends on the total supply/demand for heavy machinery in your entire sim. For example, if there's lots of demand elsewhere, local demand might go unmet as prices elsewhere are good enough to warrant shipping it there. For example, if your sector is producing 10k heavy machinery but demands 20k, you can expect demand to be about half met on average, and the producer worlds won't necessarily have more demand met - it depends on their stability and some other things.


    Also: if you want supplies and fuel to be shipped around, you need to add market conditions with demand for them, such as "orbital station" or "spaceport".

    You also definitely want to make sure you're always adding a planet type condition, since that's responsible for most food generation.
    « Last Edit: February 06, 2015, 10:39:33 PM by Alex »
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #2 on: February 06, 2015, 10:40:26 PM »

    Beyond that, basically, if you're seeing very high prices for something, just add a bunch of conditions that supply that something, and see if it fixes the prices. It should.
    Logged

    Dark.Revenant

    • Admiral
    • *****
    • Posts: 2806
      • View Profile
      • Sc2Mafia
    Re: Economy issues with dynamically generated sector
    « Reply #3 on: February 06, 2015, 11:39:56 PM »

    Yeah, your range seems to be 1-8 when it should be 0-7 (I'd start with 1-6 for a control case).  Your primary issue beyond that, I feel, will be that you use a naive condition picker that does not attempt to balance its results with the rest of the simulation.  Try to come up with a method that tries to keep the amount of stuff supplied/demanded in the global economy within reasonable tolerances; if a lot of markets end up with high demand for Heavy Machinery, have the system automatically generate more Autofactories.
    Logged

    Histidine

    • Admiral
    • *****
    • Posts: 4688
      • View Profile
      • GitHub profile
    Re: Economy issues with dynamically generated sector
    « Reply #4 on: February 07, 2015, 09:47:06 AM »

    Thanks for the advice.

    I've managed to fix some of the problems, but it seems an acute lack of crew is choking the supply chain - I'm routinely seeing planets with 100% unmet crew demand (and no exports listed).
    Any particular reason this would happen, or way to deal with it? (Maybe I'm adding too many market conditions)

    Also, if I add a whole lot of crew and commodities to each open submarket at sector generation, will that do anything?
    « Last Edit: February 07, 2015, 10:11:28 AM by Histidine »
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #5 on: February 07, 2015, 08:48:46 PM »

    Any particular reason this would happen, or way to deal with it? (Maybe I'm adding too many market conditions)

    Maybe this is too obvious to mention, but: add more crew-producing conditions? Like spaceport or military base.

    Also, if I add a whole lot of crew and commodities to each open submarket at sector generation, will that do anything?

    No, that won't feed back into the simulation - nothing like that will, unless it's explicitly coded to, which you can do via CommodityOnMarketAPI and related.
    Logged

    Histidine

    • Admiral
    • *****
    • Posts: 4688
      • View Profile
      • GitHub profile
    Re: Economy issues with dynamically generated sector
    « Reply #6 on: February 07, 2015, 09:09:52 PM »

    Any particular reason this would happen, or way to deal with it? (Maybe I'm adding too many market conditions)
    Maybe this is too obvious to mention, but: add more crew-producing conditions? Like spaceport or military base.
    I'm probably completely misunderstanding how non-consuming demand works, but those two conditions seem like they'd take huge amounts of crew out of circulation in at least the short term.

    Okay, if a condition adds 1000 demand for crew, and 990 non-consuming demand, I suppose 10 crew will cease to exist in the system at each market update. How does it handle the other 990? Will they be free to fulfil demand (consuming or otherwise) for other conditions on the market? Can the market decide to export them elsewhere?
    Logged

    Dark.Revenant

    • Admiral
    • *****
    • Posts: 2806
      • View Profile
      • Sc2Mafia
    Re: Economy issues with dynamically generated sector
    « Reply #7 on: February 07, 2015, 09:15:59 PM »

    Non-consuming demand means that the crew won't be used up by the condition, just demanded.  Since a Spaceport adds 40 crew supply, the net result is +30 per economy interval, plus a large stockpile to make up that 1000 demand.
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #8 on: February 07, 2015, 09:19:08 PM »

    Right, yeah. So it'll build up over time, but iirc it starts out at reasonable levels and should be relatively stable by the time the game starts, after stepping through something like 2 months worth of economy sim.

    There's no demand for "other conditions", the total demand for all conditions gets added up. So you might have 2500 demand for crew, coming from spaceport plus whatever, with some portion of it being non-consuming, and all conditions that care about crew demand being met will use the same met-demand fraction.
    Logged

    Protonus

    • Captain
    • ****
    • Posts: 444
    • AAAAAAAAAAAA
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #9 on: February 08, 2015, 07:50:34 PM »

    A lot of algorithms normally take place with the Dynamic economy for the whole galaxy, compared to seeing a lot of ships working simultaneously in order to make the dynamic output of the economy.

    The latter should require a lot of memory in order to make this happened, you'll probably end up having a wad of memory requirements beforehand. While the first, a lot of time. Emphasizing "A lot".

    But that's just me theorizing the mod's creation.
    Logged

    The cookies are a weird one, okay.

    Histidine

    • Admiral
    • *****
    • Posts: 4688
      • View Profile
      • GitHub profile
    Re: Economy issues with dynamically generated sector
    « Reply #10 on: February 09, 2015, 06:37:54 AM »

    So I tried writing a script to fetch some debug info, and, uh...

    Spreadsheet
    That is the supply, demand, stockpile, and average stockpile after demand for green crew on each market following a single sector population, after the patrol/pirate spawning scripts are loaded and before any trade fleets are spawned. As you can see, almost half my markets start with zero crew stockpiles, and many of the ones that don't have single digits at best. Absolutely none of my planets have a surplus, compared to about half of the vanilla ones.

    So... anyone want to check my code or otherwise come up with an explanation for how I managed to mess it up this badly?
    « Last Edit: February 09, 2015, 06:43:00 AM by Histidine »
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #11 on: February 09, 2015, 08:32:28 PM »

    Looking at demand for "green crew" is probably not a good idea. Demand for crew could satisfied by any combination of green, regular, veteran, or elite crew. The numeric demand value is based on the primary commodity of that type ("regular crew").
    Logged

    Histidine

    • Admiral
    • *****
    • Posts: 4688
      • View Profile
      • GitHub profile
    Re: Economy issues with dynamically generated sector
    « Reply #12 on: February 10, 2015, 05:56:19 AM »

    They don't start with regular crew either though.

    Anyway, I just wrote some code to add the stockpiles myself at sector generation (couldn't find where this is done in vanilla) and it more or less works fine now, so on to other things now. Thanks again for helping me out!
    Logged

    Alex

    • Administrator
    • Admiral
    • *****
    • Posts: 24130
      • View Profile
    Re: Economy issues with dynamically generated sector
    « Reply #13 on: February 10, 2015, 01:28:46 PM »

    Anyway, I just wrote some code to add the stockpiles myself at sector generation (couldn't find where this is done in vanilla) and it more or less works fine now, so on to other things now. Thanks again for helping me out!

    The stockpiles are generated automatically by the economy - at each tick, it'll take the current stockpile, add supply, subtract consuming demand, and update a rolling average of the stockpile.

    Setting the stockpiles yourself is pretty much a hack to cover up some as-yet-undetermined issues. As long as you're aware of that... :)
    Logged

    Histidine

    • Admiral
    • *****
    • Posts: 4688
      • View Profile
      • GitHub profile
    Re: Economy issues with dynamically generated sector
    « Reply #14 on: October 02, 2015, 09:36:57 PM »

    *bump*
    Okay, this is pretty much a cosmetic issue, but it's been bothering me so:

    Spoiler


    Are circular trade flows supposed to be a thing? (granted, the import:export ratios are >8x and 38x respectively)
    Do they happen when both markets produce the same commodity, even if one has much more than the other?
    [close]
    Logged
    Pages: [1] 2