CPA Prototype


If you can take a look at total compounds (locked + free), what’s happening? are compounds disappearing, effectively starving the ecosystem?

What list of processes are you using (if you aren’t already, I suggest this one)?


Yes that’s a good idea. I’ll make some kind of accounting function which checks there isn’t a leak. I’ve been using my old compounds and processes list from the old forum.

I think we should bite the bullet and fix a final compounds and processes list. Is there any reason we can’t do this now? I think it will be important to actually balance the equations to avoid accountancy problems with creation or destruction of compounds.

CPA Master List

The accounting is actually quite complicated. The reason being that because compounds are transformed it’s not trivial to work out if stuff is disappearing. The results are a little better though.

Huh you can ctrl v a screenshot straight into a post. That’s kind of cool.

Anyway I think I want to start again with a proper compounds and processes list. It gets complicated really fast. It needs more accounting built in. I’ll make a new thread.


That’s the logic that led me to produce the list I linked :stuck_out_tongue:. In these equations I made sure to keep carbon balanced, ignored the production and incorporation of water since the amount of water turned over through chemical reactions is always very small compared to the amount of water a cell requires for all sorts of other reasons (ie, a scenario where water is a limiting factor in a reaction is a scenario where the cell has a whole lot of other problems), and used ATP not so much as a chemical compound, but as a unit of energy accounting, to quantify the number of ATP-equivalent units of energy usably produced, or required, by each reaction.

So, for example, you will note that the fat reactions don’t preserve pyruvate, but that’s ok since carbon is preserved, and excluding photosynthesis, ATP is generally lost in reaction cycles, as it should be, since the Gibbs potentials are what drive these reactions in a certain direction in the first place.

How are you driving reaction rates? I imagine you are doing a simple rate law thing. This is a problem with the current game too, since reaction rates in living cells are controlled heavily by gene expression, ligands, etc, and are thus not simply driven by the quantities of each reactant and product. The question is, how do we quantify those regulating factors?


Stable populations whooop. This is with birth and death so they are able to absorb compounds from the environment, process them into protein and fat, make more of themselves with protein and fat and then have those members die (spilling the protein and fat back into the patch).


This is what it looks like with bacteria processing spilled compounds !!! HYPE!


It seems over a long time the populations become very stable. There is the initial transient period and then they stabilise so fixed values, just like in the one compound example.

I guess part of this is they just burned through all the Hydrogen Sulphide and then once that was gone they relied on photosynthesis alone.


Ok so I put in an Ocean Stabilisation routine which basically sets an ocean wide value for a compound and over time moves the amount in the patch towards that value. For example it will mix sulphur made by the microbes away to nothing and replenish the hydrogen sulfide (assuming they live near an ocean vent). What this means is that if the microbes are net producers of something (like fat) then they can’t just build it up and sort of store it in the patch. Here are the results.


That looks fantastic! Amazing job. I particularly love how it’s a periodic function. So population goes up and uses up all the compounds, and then everyone starts to die, releasing more compounds. Awesome.

If I may ask, are the reaction rate dependent on concentrations as you and moopli were talking about, or are they constant? Or have you not gotten to that point yet?


Thanks. The reaction rates are based on the thresholds idea we were discussing. So if a compound is below it’s lower threshold the process that produces it will start going. If it’s above it’s high threshold any process that uses it as an input will start working and if it’s above it’s vent threshold then it gets vented. I made a typo, I typed a1 - b rather than a(1 - b) and I think it’s probably the best thing I’ve done on this project. If a compound is low then it will try to start the process that produces more but if the inputs to that process are also low that process will slow down. So if you’re low on everything the cell will do nothing rather than running all processes trying to correct all the deficiencies. It works beautifully and was a complete accident.

Code is in the repo if you want to have a look. The “step_function” function determines the response to being above or below the thresholds which is stored as compounds_free_action. Then “run_organelles” just searches for the largest of these.


Nice. Now, if I were to implement this, how exactly does the interface work? I mean, what information do I need to supply (if any) to the CPA system and what data does it output? You mentioned that there are bacteria processing spilled compounds, are these just “internal” bacteria (a vague species being that process a certain amount of X into Y every second), or actual discrete entities?

The reason I’m asking is that I believe it was decided that the CPA system dictates how often we see each microbe and bacteria species. This, in turn, tells us what compound clouds are being produced and in what amount.

I understand if you’re not at this point yet—you’ve done a huge amount already—I was just curious.


Interesting questions.

Basically the interface is all output. We’ll need a really clear way of representing what species are in your patch and how well they are doing relative to each other. This is a really good data visualisation challenge, you can see from the prototype there is so much information it’s easy for the graphs to be unreadable.

The input is choosing what organelles your species has in the editor. This is the only control you have over your species in the CPA system. The hope is the models will be good enough that you will choose what works for you swimming around and that will translate into doing well in CPA. I guess if the processes are the same in the CPA and swimming around then you should get a good feel for that part of it.

The bacteria were a cleanup mechanism, so if you spill protein they chew it up to prevent species living as scroungers. However that’s not really necessary anymore. The Ocean Stabilisation will handle that just fine so actually bacteria probably need a rethink. They could just live alongside you in your patch, they could have a specific role, we’ll have to think it through.


Bacteria, in the game stage, are for more than just preventing things from accumulating in the environment – they add more stuff to interact with and swim between, what with the plans to have myriad types of large bacterial colonies that form particles you have to swim around, or webs of cyanobacteria-like filaments you can swim between.

Also, if you’re planning on keeping the ocean stabilization mechanism, how will we handle, say, mass oxygenation events, or other things where the biosphere should drastically change levels of some compound, when we’re putting our thumbs on the scales to artificially stabilize things? I don’t think we can keep the ocean stabilization as more than just a stopgap :confused:


I was thinking about that. So basically the way it works now is that, for each compound, there is an ocean level and every step the level in the patch is moved 1% closer to the ocean level. How about just moving the ocean level 0.01% towards the patch level at the same time? (Or some other, smaller, fraction which represents the ratio of the mass of the patch to the mass of the ocean). That would keep track very nicely of the effect the microbes were having on the ocean. Moreover it would allow some transport between patches, if the ocean level of O2 starts at 0 but one patch is a net producer then slowly the whole ocean will start to oxygenate.

I figure that would be pretty elegant for what we want to do.

We could even just add an “Atmospheric Stabilisation” where each turn the atmosphere and the ocean move towards each other 0.01% (of course only gasses would be in the atmosphere, not protein! (though I used to work in a Pizza Hut and it’s atmosphere was like 25% pepperoni by mass)).


I like that idea, it’s good to have a buffer for the non-biological compounds. We could even add some implicit processes which cause biological material (say, ATP, etc) outside living organisms to chemically break down as time passes – simply make sure that when they break down they decompose into constituent compounds at a good ratio, and you’re golden. Together, those would basically be the ocean-stabilization system you have going, just with some more nuance.


From another thread “Also, the cell still stockpiles CO2, which sometimes kill you since you don’t have any room for oxygen, so keep that in mind.”

Under the threshold system, there is a low threshold where the microbe will try to absorb compounds, a high threshold above which it will try to use up compounds and a vent threshold above which the microbe will just vent the excess instantaneously. This means stockpiling is no longer a problem as each compound has it’s own set of thresholds.

The problem this raises, however, is how to relate the thresholds to one another. Say you add a vacuole what effect should that have? Should it increase all your thresholds for all compounds? Should you be able to choose a specific compound for it to store?

Normally it really doesn’t matter what your thresholds are because compounds are just passing through the bins as they are processed and storage isn’t really important. However it is very important during a period when a resource is scarce. Maybe there is a day night cycle or maybe there are periodic bacterial blooms which use up all of one compound. In these cases what you are storing, and how much of it you have, becomes very important.

Edit: @seregon will hate this because it’s discontinuous but…

We could have a low vent threshold and a high vent threshold. When the level of the compound gets to the high threshold it instantly vents down to the level of the low threshold. Obviously disgustingly discontinuous but it would work really well with the compound clouds because the microbes would produce a reasonable sized cloud every once in a while rather than trying to produce a little cloud every timestep.

I suppose in the CPA system the release could be spread out over time to get the continuity back whereas in the swimming around it could be instant.


I like that idea – a discontinuous system with two vent thresholds, if integrated over all the organisms in aggregate, and assuming that the organisms have a relatively-wide distribution of how much of the compound they have, would give you a continuous venting curve, which can keep seregon happy.


I’ve been thinking a little bit about Auto-Evo implementation, what do you think of this? So basically the system is to offer a species 5 possible changes and let it pick the one which is “most beneficial to it” over a certain time span. I think the following would probably work as a way of implementing this.

  1. When it is a species turn to be evolved make 5 clones of the patch it is in.
  2. In each of these patches alter the species in some way (in fact there should probably be a control where the species is not altered to discount the possibility all 5 changes are negative).
  3. Run all these patches forward to the next Auto-Evo time using exactly the same algorithms as the other patches.
  4. Select the patch in which the species in question has done the “best” and delete all the others.

I think this would work quite nicely, cloning the patch is probably quite straightforward.

I put the term “best” in brackets because it needs some delicacy. For example if the population is oscillating you can’t simply take a single value as it might be in a trough. A time weighted average might be better. It might be best to weight the average towards values near the end of the time span where the changes have had most effect.

So if the population number is P(t) for t = t1, t2, t3 … tn then have a value like

Average Population = Sum_t P(t) / (1 + (tn - t))

Finally there is one more delicacy which is that if there is to be a flow of compounds between patches (like light cascading down through a stack or ocean currents moving compounds) then that system will need to be set up in such a way that it can route the compounds in parallel to these 5 patches while they are being tested. Moreover if there is a patch which takes an input from the one being tested some thought will need to be put into working out which of the 5 patches’ output it will be connected to.


I can add a few more problems to the list:

  1. It’s a huge multiplier on the amount of computation required to run it.
  2. Patches will often have enough mixing that a species will have a range over multiple patches, and won’t necessarily diverge in the two, meaning it’s a lot more complicated to figure out what we need to simulate multiple futures for

I think we will have to use heuristics by necessity – for example, if we can approximate the partial derivatives of the goal function w.r.t. the evolved parameters, that will be good enough to get nearly the same result without a simulation. Sure, there’s the problem of confounding factors and interactions between various parameters, but I think we could figure those out bit by bit and slowly make a more realistic projection, or maybe, if we decide it won’t be enough for realistic choices, reduce the amount of work the best-of-possible-futures simulation would do.


The problem is that knowing the derivatives is only really valuable in a linear system. The map from the parameter space to the population level is highly non-linear and discontinuous and so it will provide no useful information. It’s like what will happen if you add a mitochondria? Well the effect of faster sugar processing is linear and could be predicted but the fact that you are now slower and now a predator will catch you that couldn’t before which boosts it’s population which increases the interactions you have with it which reduces your population even further can’t be.

When it comes to having “too many patches” we’ll need to work out how many that is. If it’s 500 then having even 100 of them devoted to being clones working out Auto-Evo results is fine. If the max number of patches is like 6 then yeah we can’t clone one 5 times.