Process System


#1

After a bit of philosophical debate with my pillow, i came up with an economical model for the process system.

The problem: we have compounds, and processes that turn some of the compounds into other compounds. We want to know how much of each process we want to make in order to get the most useful compounds possible.

My propossed solution: we give each compound a supply value, a demand value, and use them to calculate a price. Each “useful” compound (as in the ones that have a final functionality in the game, like ATP and oxytoxy) would get their demand or prices inflated by some arbitrary value. Each process would then try to generate the most profit possible by transforming compounds (think of process as factories, buying raw materials and transforming it into more expensive stuff to then sell).
A big problem with this would be that the profits are linear with the amount of stuff converted, so the process would always be either turned off completely or working at max capacity. Some smoothing function (maybe based on future predictions about the effects of the production to the compound prices?) could fix that issue. Or having some other cost in the process.

The supply values are the easiest to deduce: it’s how much of each compound the microbe has (with maybe some future predictions if we feel like complicating stuff).
The demand and price, however, are more complicated, since they strongly related to eachother, and i dont’t know how to calculate them, or if that is even possible.
However, we could start giving some placeholder price to each compound and adjust it overtime according to offer and demand values, with the demand being fixed by the processes.

So, at each update interval, the prices of each compound would get lowered or increased depending on whether the supply was lower or greater than the demand of said compound.
Then each process would adjust it’s transformation rate to maximize it’s profits.

There are some problems with this model though:

  1. This does not account for storage space. Having the price reduced by some “storage tax” or having some fictional “storage compound” could help with that, i guess.

  2. There are some inefficiencies in the system, generated by the prisoner’s dilemma. Having some sort of Cournot competition could alleviate the problem, but that could be getting to complex for what we’re trying to achieve.

  3. The smoothing function has to be easie to both calculate and minimize.

Any thougths about this?


#2

Cool idea, I like it.

Do you think any of these ideas might help?

  1. You could have each compound have a bin with some amount of compounds in it (like the protein bin has 15 protein in it, for example). You could have each basic compound have a very good supply (so there is always a lot of oxygen / nitrogen / CO2 available etc). Their bins could be refilled frequently. You could have each “useful” compound have their bins emptied frequently (because the compounds are used). This would make a nice gradient for the compounds to flow through the system.

For example sugar might be emptied a bit and then there would be incentive to make more from CO2 (using photosynthesis) as there is abundant CO2 and a lack of sugar.

  1. You could give each species or each cell (not sure what level you are thinking of running at, it works much the same either way) have something like 10 actions per turn. So if it spends all 10 actions making sugar, for example, then that process will be 100% on and all others off. However it might be most profitable to spend 5 actions making glucose (50% on) and 5 making protein (50% on). That would help you smooth out the “100% on or completely off” issue.

Another way is just to accept each process will flick on and off, however over a lot of timesteps it will average out. So if 25% of the time it’s 100% on and 75% of the time it’s off that adds up to a long term average of 25% on.

Hope this is helpful! That last sentence mashed my brain up a bit ha ha.

60% of the time, it works everytime!


#3

My idea was to have the basic compounds’s supply increase automatically each time the player absorbs them (by clouds or by taking other cells). This would be done externally. I’m guessing in the species level it would be increased by a constant, plus some random noise.
In theory, those basic compounds would almost always have a lower price than the more complex ones (except maybe if the more complex ones were very abundant or occupied more space, but those would be desirable features).
Likewise the useful compounds would be emptied naturally (by spending atp, shooting oxytoxy, etc.) which would increase their price (something i forgot to mention was that the useful compounds price should decrease when their supply increases, otherwise we could end up with a microbe producing a lot of oxytoxy and no atp ^^).
The action points idea could work, but it would favour creatures with less, but more heavily invested processes (for example if a cell has 2 mitochindrion it could produce 100% respiration which would mean both organelles would get fully worked, but 1 mitochondrion + 1 chloroplast would get their points divided between the two, which would mean they’re only working at half capacity on average).
Tho as you say, maybe the processes working fully or not working it’s ok, it certainly makes the code easier ^^


#4

Interesting.

If the basic compounds are being refilled and the complex ones are being emptied do you think

price = (complexity * storage) / number of compounds

would work? Where storage is the amount of space available for that compound, number of compounds is how many there are currently and complexity is a factor which increases with the size of the molecule.

So for example CO2 might have storage 100, complexity 1. So if the cell has 100 of them the price will be 1 per unit.

For Glucose the storage might be 20 and the complexity might be 10 (because glucose is a much bigger molecule than CO2). So if the cell has 5 Glucose then the price is 40. Therefore it’s profitable to take 6 CO2 and make 1 glucose out of them.

It would be profitable until the Glucose level was up to 15 (price = 13.3) and the CO2 level was down to 40 (price = 2.5). At that point it’s no longer profitable to take 6 CO2 and make 1 Glucose.

This would mean storage is not a hard cap. It’s more like a bulging bag where you can stuff more into it but it gets harder and harder the more you put in.

Don’t know if this is the kind of thing you were imagining.


#5

The problem with that is that we would have to hardcode each compound “value” (in this case the complexity), which is something i was hoping to avoid, having the system assign each compound a value automatically instead. It also doesn’t take demand into consideration (the system could be trying to make very complex yet useless compounds for example if those compounds were used in a process the cell doesn’t have, or if they were agents when the cell doesn’t have an agent gland).

I don’t really think the prices can be calculated exactly (especially not in a fast way), but my plan was to have them be calculated iteratively on each update frame.
My idea was to have the prices of the compounds be a functions with parameters the old price, supply and demand, the usefullness of the compound (if applicable) and possibly the storage space (making it a compound could be a possible alternative).
Something around the lines of Pn+1 = Pn * (1 + Dn - Sn) / Sn (P = price, S = supply, D = demand), although that could screw things up when either price or supply are 0.

The other problem i have right now being how to calculate demand, because since the processes have a max capacity, having the demand be just “what i just spent” could deflate the prices a lot (since the prices wouldn’t have an effect on the demand while this system assumes they do).
Something that could be done is to assume that the cost of each compound is linear in relation with it’s supply (which in such a short timescale might be accurate enough), and saying that ech process would “like” to produce at a capacity that maximizes the profits.
Which is the same to say that (benefit(x) - cost(x))’ = 0 (with a check to verify that cost < benefits beforehand), where x is the desired capacity.
And since the benefits have the form:

B(x) = (sum) compoundAmount * x * price(compoundAmount * x)

then the derivative of that would be:

B’(x) = (sum) compoundAmount * (price(compoundAmount * x) + x * price’(compoundAmount * x))

And if we consider price(x) = Pn+1 + (Pn+1 - Pn) / (Sn+1 - Sn) * (x - Sn+1) (the equation of a line that passes through the current and the previous supply/prices)

And so price’(x) would be: (Pn+1 - Pn) / (Sn+1 - Sn)

So finally:
B’(x) = compoundAmount * (Pn+1 + (Pn+1 - Pn) / (Sn+1 - Sn) * (compound amount + x - Sn+1) + x * (Pn+1 - Pn) / (Sn+1 - Sn))

Or simplified like this:
B’(x) = compoundAmount * (Pn+1 + (Pn+1 - Pn) / (Sn+1 - Sn) * (compound amount + 2x - Sn+1))

The cost equation would be equivalent, but with minus signs in front, and since this are just lines finding the x should be easy.
(of course my math is awful so maybe i screwed up somewhere).
And then the demand would be the sum of all of the process capacities from the processes that use this compound, multiplied by the amount of compound they use.

Hopefully something of what i wrote makes any sense! :slight_smile:


#6

I’m not sure I’ve completely communicated what I mean.

So the complexity value isn’t required. Imagine the formula is

price = 1/number_of_compounds

If the cell uses a protein then the number_of_compounds goes down by one and so the price goes up. This means it’s profitable to make protein out of amino acids and this means it’s profitable to make amino acids out of pyruvate etc. The demand get’s pushed back through the system. Over time, if no compounds are used, the system will settle into an equilibrium where it is not profitable to make anything. As soon as something gets used it makes it profitable to refill that bin.

This system gets round both supply and demand and all you need is price. Prices rise when something is scarce and fall when it is abundant.

The complexity value was just to tweak the numbers so that large compounds have higher prices than small ones. Without it the price of glucose will be like 1/6th of that of CO2 (because you need 6 CO2 to make 1 glucose) however it’s not important.

The cells will make things they don’t need but only until they have some amount (where the price is low enough it’s not profitable to make more) and then they will stop making them and never make more. So this isn’t a long term problem. If you have a storage value for each compound you could get round this by setting that value to 0.


#7

That does simplyfy the algorithm a lot, however i’m not sure if it would be eficient enough at managing compounds, so some testing will be needed.


#8

As I say totally up to you what you want to do. I tend to say a lot on these subjects as I find them pretty interesting. :slight_smile:


#9

I finally finished the process system documentation, after way too much procrastination.
Here it is.

Thrive-ProcessSystemimplementation.pdf (79.6 KB)