Bay 12 Games Forum

Please login or register.

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

Author Topic: Anyone else remember that economy thing? Yeah ... (DFHacking gone wrong)  (Read 14155 times)

NCommander

  • Bay Watcher
  • Dwarven Military Master
    • View Profile
    • SoylentNews

So, I was fuzzing aorund with DF's memory and .... I kicked off the Dwarven Economy ... in DF2014






I knew the economy code was still semi-present in DF, though it supposedly caused the game to crash the instant it was kicked on.

It's not 100% functional; dwarves don't claim rooms, my guess because they never take the Go Shopping job to get one (I've yet to get this to kick off), but they do pay from their account for food, and will pay for pets. Shops are buildable but due to the same Go Shopping stuff, never claimed.

I'm still O_o;ing over it. Maybe when I finish with dwarfvet, I might see if I can get this fully functional (and rewritten to be less broken, k).
Logged
Quote from: TheFlame52
Fucking hell man, you aren't just getting the short end of the stick, you're being beaten with it.
Quote from: NRDL
Is your plan really to flush water into hell, and have the CARP marines fight them without threat of flame or disease?  If so, you are awesome, and one of the greatest DF military visionaries I've seen yet ( not that I've seen that many, or any, for that matter )

Emperor

  • Bay Watcher
  • Time is fleeting.
    • View Profile

All hail NCommander!

PTW
Logged

clinodev

  • Bay Watcher
  • Embark Profile Enthusiast, Kitfox & reddit mod.
    • View Profile

Well, heck. I'd play around with that! Hack, Urist, hack!
Logged
Team Bug Fix!

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

There are some data structures necessary for the economy that do not get populated anymore (specifically ones related to wages), and they currently are not known to DFHack so there are some things which simply won't work.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile

Yes I saw that under UI, the economy is still available if you activate it. A reminder for those excited about it: this feature was removed for good reasons.
« Last Edit: April 29, 2015, 02:01:12 am by Boltgun »
Logged

NCommander

  • Bay Watcher
  • Dwarven Military Master
    • View Profile
    • SoylentNews

There are some data structures necessary for the economy that do not get populated anymore (specifically ones related to wages), and they currently are not known to DFHack so there are some things which simply won't work.

Holy cow, Quietust himself.

*bows and is not worth*

Well, in seriousness, its not like DF2010 which just fell over on this face; my test fort with economy active ran for quiet awhile before it shutdown; I posted screenshots mostly to see if there was any interesting in trying to bring it back. I actually did a search on your name and economy to find your notes since I remember talking about it. I wanted to take a stab at filling in the missing data structures by getting DF to crash, and failed to actually *get* a crash.

My guess is the routine to initial the economy is not in DF at all anymore; an optimizing compiler would likely notice its dead code and make it *poof* into non-existence. Roughly speaking, this is what appears to work/not-work

 * Go Shopping never fires
 * Dwarves don't claim rent control rooms (possible due to the previous issue)
 * Noble ACCOUNT_EXEMPT works
 * Prices DO get adjusted, but no notification
 * Food and such is properly paid out
 * Immigrating dwarves have their account properly set at 200
 * Children don't appear to share their parents accounts anymore
 * Manager seems to go meet with the expedition leader

I can patch around 2 similar to how my animal caretaker plugin works, though without one, the economy doesn't really do much.

The wages table seems to get populated; I can see it just fine under the manager, and z->{Prices/Currency} work when I browse them, and have sane numbers attached. I'm just not sure to pay wages code is attached to anything; I can work around this if need be as well as attaching a tick timer to the game, looking at jobs, and then paying dwarves out instead of having DF itself handle the account.

My intent was actually to try and rewrite this feature from the ground up for the extent possible, and gauge any interest if possible; the current economy code really would only serve as a framework for what I was thinking of.
Logged
Quote from: TheFlame52
Fucking hell man, you aren't just getting the short end of the stick, you're being beaten with it.
Quote from: NRDL
Is your plan really to flush water into hell, and have the CARP marines fight them without threat of flame or disease?  If so, you are awesome, and one of the greatest DF military visionaries I've seen yet ( not that I've seen that many, or any, for that matter )

Girlinhat

  • Bay Watcher
  • [PREFSTRING:large ears]
    • View Profile

And yet a cat still ignores all dwarven decency...

BoredVirulence

  • Bay Watcher
    • View Profile

I'm interested. In fact, I'd be interested in helping, but this might be too deep down the rabbit hole (with DFhack) for me.
Logged

NCommander

  • Bay Watcher
  • Dwarven Military Master
    • View Profile
    • SoylentNews

Well, when I get some free time, since I know the offset of the economy_active flag from DFHack-40d, I need to play a game of 40d in which the economy kicks off, and set a write watchpoint on it to find the chunk of code that enables it, then work backwards from that entry point to determine the data structures it touches. As I see prices adjusting in my current DF2014+Economy game, I'm hoping that's all it would need; the biggest issue is since dwarves don't claim rooms, everything else falls apart.

Beyond that, its mostly defining and implementing new logic if I'm doing to actually do this.
Logged
Quote from: TheFlame52
Fucking hell man, you aren't just getting the short end of the stick, you're being beaten with it.
Quote from: NRDL
Is your plan really to flush water into hell, and have the CARP marines fight them without threat of flame or disease?  If so, you are awesome, and one of the greatest DF military visionaries I've seen yet ( not that I've seen that many, or any, for that matter )

Urist McCoder

  • Bay Watcher
    • View Profile

PTW
Logged

NCommander

  • Bay Watcher
  • Dwarven Military Master
    • View Profile
    • SoylentNews

So, I had to run errands for most of today, but while I was doing them, I was seriously able to think about how a new economy plugin could work, as well as learning lessons from the old one.

As implemented, the economy is supposed to essentially make your fortress a capitalist society. The problem with that a typical dwarven fort doesn't represent that sort of system; dwarves work together as a whole to accomplish goals, weather they're hauling, soldering, healthcare, etc. Without hauling, which didn't pay anything as far as I know, nothing happens, and these dwarves become destitute.

As I sketch some ideas, I only need a few bits and pieces from the existing economy code.

Here's roughly what I'm thinking.

  • The Fortress Account
    • The Fortress itself would have an account. The fortress account grows by creation of coins, or by taxing guilds (dwarves themselves shouldn't be taxed, once its paid out, its theirs to keep. All transactions within the fortress go from this account to the guilds, and then the dwarf. A subset of dwarves would be paid directly from the fortress accounts, such as haulers..
    • Coins themselves are owned by the bookkeeper, and not by individual dwarves; this prevents splitting, coin hauling, etc. They physically exist within the fortress, but throw them into a stockpile and call them good. No need to haul them everywhere. If possible, I'd also attach a value multiple to them to make them attractive for trading (i.e., paying for goods in cold hard cash).
  • Restoration of Guilds
    • 23a had guilds which dwarves belonged to and represented their works. This is a step in the right idea, but the old dwarvish economy didn't take it far enough, and was too rigid
    • Each job pays into the guild, NOT to the dwarf. So if you do 25 mining jobs, the wage for each job goes into the guild's master account until the end of the month; this is likely something that will only exist within DFHack itself, and not within DF's existing economy code
    • The economy DFHack plugin would keep track of the number of jobs done by each dwarf, and use that to track which guild they're part of. For instance, if a dwarf did mining for most of a month, they were part of the miners guild, even if their top skill was fish dissector. At the end of the month, the job count is zeroed out, and starts again. So if one month they do nothing but mining, they'd be a part of the mining guild, NOT part of the fishers guild. The following month, if they did nothing but make mechanisms, they'd be part of the engineers guild
    • Guild leaders can make mandates if they're not getting enough work, to do something relevant to their guild.
    • At the end of each month, the guild figures how much it should get generated, and makes a withdraw from the fortress account. Then each guild pays out to their members, based on skill, number of jobs a dwarf did for that guild, etc. I haven't worked out the specifics, but *every* dwarf in that guild will get something. So if a miner is badly injured in a cavein and can't work for a season, they will still get some dwarfbucks, though less if they actually did something for that guild.
    • Products created are property of the fortress, not of the guild; dwarves in effect are getting paid to create them; the fortress simply automatically buys everything it can
    • Not all money is paid out to dwarves, some stay within the guild itself
  • Unguilded Dwarves
    • Some dwarves won't be paid out from a guild since they're working for the fortress directly. This likely includes the noble special labors like "Update Stockpile Records", soldering, hauling, a few other things
    • If there isn't enough labor to establish a guild, i.e. one dwarf makes a few mechanisms, and no other engineering happens then they will be paid from the fortress accounts instead of a non-existent guild
    • Civil service doesn't pay well, but *does* pay consistently; enough to afford quarters and food. Minimum wage is calculated out from the cheapest of rooms available, plus cost of food, and a little on top
    • Children will get a small amount of money for food from the fortress account each season.
    • In effect, the fortress itself is a superguild.
  • Taxes
    • Unless one minted coins near nonstop, the Fortress Account would be quickly depleted after a few months. To prevent this happening, guilds are taxed to make up shortfalls in the fortress account. I'll likely need to implement an inflation mechanic to keep this working sanely.
    • Taxes are only levied if the fortress can't pay out; since the fortress can make some money on its own through the sale of items (food, clothes) and rent
    • Dwarves themselves aren't taxed. Once money is in their accounts, its theirs to spend on food, rent, and clothes.
    • We calculate out how much is required to come out of the fortress account, and leverage taxes against the most wealthy guilds (though a bit from all of them as well). Money from the guild is moved back into the fortress account; this happens automatically, no tax collector noble to muck crud up.
    • The fortress can go into debt if it simply can't cover its costs. This is a bad thing; likely a negative thought starting with the economy nobles, and working downward. Basically, if your fortress can't cover its own costs, stress levels go up. Minting coins is a solution, exports is another (maybe have"offerings" be goods being sold in the greater world, when something is offered, DB go into the fortress account; I could possibly tie this into trade agreements, but I don't know if DFHack has the necessary hooks to look at these programatically, and use it as a pseudo-supply and demand system).

The end result should be a system that doesn't starve your dwarves, but have them moving throughout the fortress, each earning a living, buying food they like if they can afford it, fancy clothes made of dragon leather, etc., else just falling into the rank and file. The economy shouldn't be something that requires micromanagement, more something that keeps the fortress acting like a living organism.

As of right now, to implement any of things, I need to do the following:
 - Build a reliable job detector; I already semi-do this for dwarfvet, I just need to ramp it up.
 - Create classes in a new plugin to handle the guilds.
 - Figure out how to set the price of items within the fortress; as of right now, they're all initialized to 1; I'm going to need to spend some time with gdb and the item structures. This is the only thing I don't know how to do right now. This is the only thing that requires the current economy code to be active, the rest can be done via DFHack tick handlers; worse case scenario, I can watch for the eat/drink jobs, and the items attached to them. Painful, but doable.
 - Define new nobles in the raws for guilds, and have them assigned automatically if a guild is created.
 - Get room purchasing to work, or failing that, auto-assign rooms based on a dwarves balance (may be saner way to go; prevents them from starving themselves because they bought a million db apartment for a month; dwarf logic isn't foolproof in this regard).
 - Generate mandates to prevent the fortress from going into debt to badly.

As a whole, the system needs to do the following:
 - Prevent useless labor from gumming up the works (coin stacking)
 - NOT require large amounts of micromanagement; guild leaders and the bookkeeper should generate mandates to keep things moving smoothly, but otherwise stay out of the way.
 - Make the fortress feel alive, and be fun to have enabled. Not something condemned to the disabled pile because it breaks the game in half.
 - Be fun, challenging and yet worthwhile. If you want dwarves to be truly happy with amazing mansions, you need to make sure they can afford it. A productive fortress is a happy fortress! By having a fortress flush with money, dwarves can afford loads of stuff (minimal wage will dictate what your civil service dwarves can afford; may extend this to all guilds as well).

I'm slightly worried I'm designing something too big, but knowing what I know from previous DFHack adventures, I honestly think this should be doable ...
« Last Edit: April 29, 2015, 05:40:46 pm by NCommander »
Logged
Quote from: TheFlame52
Fucking hell man, you aren't just getting the short end of the stick, you're being beaten with it.
Quote from: NRDL
Is your plan really to flush water into hell, and have the CARP marines fight them without threat of flame or disease?  If so, you are awesome, and one of the greatest DF military visionaries I've seen yet ( not that I've seen that many, or any, for that matter )

Urist McCoder

  • Bay Watcher
    • View Profile

This sounds awesome I have heard of the dwarven economy but it was long before I played. I would be happy to test (read play with it).
Logged

scamtank

  • Bay Watcher
    • View Profile

Ambitious, but do give us a heads-up if and when you run into an unscalable wall with the project. It's more considerate than just vanishing forever.
Logged

NCommander

  • Bay Watcher
  • Dwarven Military Master
    • View Profile
    • SoylentNews

Ambitious, but do give us a heads-up if and when you run into an unscalable wall with the project. It's more considerate than just vanishing forever.

Well, I'm pretty sure I can get help for some of it. I just wish my X86 assembly was up for scratch. I used to work on embedded ARM and later AArch64 things, I can read (and code) ARM assembly in my sleep, but x86 being a CISC instruction set + variable word size makes my brain hurt. Right now, if I harness the old economy code, I probably need a patch to nuke legendaries from being economy exempt.

I'm probably going to work on this when I get frustated with dwarfvet (today's 'fix spot usage' bug drove me nearly batty).
Logged
Quote from: TheFlame52
Fucking hell man, you aren't just getting the short end of the stick, you're being beaten with it.
Quote from: NRDL
Is your plan really to flush water into hell, and have the CARP marines fight them without threat of flame or disease?  If so, you are awesome, and one of the greatest DF military visionaries I've seen yet ( not that I've seen that many, or any, for that matter )

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile

This could work, I'd suggest trying not to tie it to gold coins but instead simmulate a dematerialized system that assumes that Dwarves write down their accounts. The economy caused tons of stacks of 1 coins and killed fps. Perhaps you could mint coins and have a 'store coins in vault' job that destroys the coin stack and put that into the account.

The civil service and child care ideas are particulary nice. I'll watch this closely, this is cool.
Logged
Pages: [1] 2 3 4