Implementation Economy

Cpt. Crispy Crunchy

Member
Contributor
Name: Economy
Summary: This module aims to provide a very generic framework to simulate an economy with consumers and producers. On top of that however, it provides a robust method to share/trade/exchange resources between entities. It does so under a very libertarian credo: Use any storage component you want.
Curator: Cpt. Crispy Crunchy
Location: https://github.com/Terasology/Economy

In order to simulate the population on a resource level I needed a solid market system. After a long 2-3 hours of discussion with @Cervator (thanks again for that! :) ) the system transcended into something uhh quite bigger. Now, while I can't fathom all the ramifications of it yet I hope that someone will find it useful.
As a simple use-case, it could provide conversion between two modules. In MC terms it could provide the conversion between BuildCraft energy and storages to IndustrialCraft energy and storages, but it could also provide compatibility to any other mod with custom storage and energy.
However, at the same time it can provide the mechanism involved to build a furnace block, inclusive of the processing of the burning material, the energy created from that, the actual raw item and the final product.
Additionally, you could set up a handler for multi-entity distributed storages. Send an item to a warehouse and the system could distribute it to the individual entities.
How does it do that? I prepared a little diagram to hopefully make it clearer than I could describe it with words:
(Formatting in this forum seems to be a bit messed up for me atm I'll have to just post the link)
https://github.com/Terasology/Economy/blob/master/marketsystem.jpg

So in order to use the module for your system you would just have to write the handler and register it in the StorageHandlerLibrary. The handler will tell the economy module how to interact with your system and translate the abstract resource packages into the actual items used by your module. The internal representation of resources just uses a Map<String resource type, Integer amount> for easy serialization and conversion.
Ah and it searches in all registered storage components in an entity when a resource package is requested!

Now, the current version was put together in one day and needs therefore a lot more of testing. Nonetheless, the basic idea and methods seem to work so far :).


Todo list:
  • add negative number checks to protect against exploitation
  • more testing
  • market interface
I will hook it up into DynamicCities and simulate some basic consumer and producers to see how it behaves in an actual application.

In the upcoming week, I'll hopefully work a bit with @rzats's nui-editor to fashion a simple market interface to provide player interaction :). Though I'm not quite sure if that will make it in this more generic module or in the DynamicCities module.
 
Last edited:

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Looking forward for more of this! :)

Another suggestion: the one diagram is sort of on the technical side. How about a diagram or a simple text scenario explaining an actual example with 2-3 different types of goods living in different modules and the involved classes with their purposes highlighted? I think that would be a huge help to really understand the overall functionality and what to do where.

Also curious about feedback from @Josharias and @xtariq when it comes to conversion of stuff.
 

Cpt. Crispy Crunchy

Member
Contributor
I set up a small wiki now :) -> https://github.com/Terasology/Economy/wiki . Feedback is very welcomed!
Needs a bit of extension of course if it comes to describing why it works.
For now I just hope it helps finding a starting point and maybe get a better understanding of it. I may create the necessary handler for core stuff in the near future, for now I just linked to the InfiniteStorageHandler :).
Anyways I'm very curious too if it will actually be used sometime by something else than DynamicCities.
 
Top