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)
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!