Author Topic: Metabolism  (Read 9808 times)

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Metabolism
« on: October 27, 2005, 05:34:47 PM »
Once again we come back to this.  It's been discussed so much, everyone is sick of it and just wants to see something done.  I think we are almost there.  What I'm describing below is pretty much a completely designed system that will go this way into DB version 3, unless some real issues come up in this discussion.

Nums is up to date on this and we discussed it in details.  He thinks the system is do-able.

NOTE: The system described below is not meant to be a replication of real physical or chemical laws.  It is just a general system designed for two purposes: a) to allow more diverse energy storage compartments and B) provide possibility of food specialization.

NOTE 2: If you have something to add to the proposed system, please don't! :)  Seriously though, please concentrate on evaluating the current system for faults.  We know it's not complete and we know things can be added, but let's get the minimal system up and running before we add something else on top of it.

OK, let's go.

PART 1: Chemicals
Chemicals will be represented as 8-strings of 1 and 0.  One means a chemical has certain group, 0 - does not.  There are total of 256 chemicals.  

Code: [Select]
Example: 11111111 has all of the possible groups, 00010000 has only one group, 00000000 has none of the possible groups (but is still considered to be a chemical).

In a reaction, chemical can either loose or gain a single chemical group.

Code: [Select]
Example: chemical 11110000 can lose one of the 4 groups it has, becoming 11100000 or 11010000 or 10110000 or 01110000.  Or it can gain one of the missing groups becoming 11111000 or 11110100 or 11110010 or 11110001.  
Through chemical reactions each chemical is connected to 7 other chemicals.  Therefore the whole metabolism can be viewed as 8-dimensional matrix with two values in each dimension.

We don't care where the individual groups are coming from or where they go, we don't keep track of them.  We assume there are tons of them in the environment.

PART 2: Energy

Each chemical will be assigned a certain energy value.  This value will not correlate with any chemical groups being present or absent.  One option will be for program to pick these values from a certain range at random.  Another option is for user to define what energy values correspond to each chemical.

PART 3: Equilibriums

Let's take a single reaction where chemical A is converted to chemical B (written as A<>B).  An equilibrium state for this reaction is such that the total amounts of energy are equal on the left and on the right.

Code: [Select]
Example: Let's say that energy of A is 1 and energy of B is 10.  Then if a bot has 11 molecules of and B total, then equilibrium is when 10 molecules are in state A and 1 in state B; 10 A=1 B.  Total amount of energy is equal on both sides.
When chemicals are present in equilibrium, bots can't get any energy from them.  Even though there is a high-energy compound B in the example above, it cannot be split to produce energy.

PART 4: Reactions

Energy can be extracted by a bot if two chemicals are not in equilibrium.  Now let's consider two possibilities, which are going to be treated differently.

A. The equilibrium is shifted toward high-energy compound (the total energy of high-energy chemical is higher than total energy of low-energy chemical).  This results in high-energy chemical being converted into low-energy chemical.  The difference in energy is given to bot as nrg to spend.  This happens until both chemicals come to equilibrium.

Code: [Select]
Example: Consider A<>B reaction.  Bot has 1 molecule of A (energy=1) and 10 molecules of B (energy =10).  The system is not in equilibrium, total energy on the left is 1 and total energy on the right is 10x10=100.  To bring system to equilibrium 9 molecules of B (energy=9x10=90) are converted into 9 molecules of A (energy=9x1=9).  The difference in energy 90-9=81 is given to bot as nrg.  At the end bot has 10 molecules of A and 1 molecules of B.  The system is in equilibrium.  No more energy can be extracted.
B. The equilibrium is shifted toward low-energy compound (the total energy of low-energy chemical is higher than total energy of high-energy chemical).  This results in low-energy chemical being converted into high-energy chemical. The energy for the conversion comes from complete utilization of low-energy molecules.  No energy is given to the bot to spend, but it gains a high-energy molecule, which it might spend at a later time.

Code: [Select]
Example: Consider A<>B reaction.  Bot has 110 molecules of A (energy=1) and only 1 molecule of B (energy=10). The system is not in equilibrium, total energy on the left is 1x110=110 and total energy on the right is 1x10=10. To bring system to equilibrium, energy of 50 molecules of A is completly utilized (the molecules are destroyed) to create 5 molecules of B.  Bot gains no energy.  The final equilibrium is 60 molecules of A and 6 molecules of B.  No more energy can be extracted.
NOTE: Please don't tell me that laws of conservation of matter and/or energy are broken.  Living organisms are not closed systems and can loose energy and matter as much as they care to.  As long as they don't gain energy from nothing we don't care what happens to them.

PART 5: Enzymes

For each chemical reaction we have two enzymes, one for forward reaction and one for reverse.  Enzymes affect the rate at which two chemicals move to equilibrium.  So, in essence it is just a multiplier for the amount of chemicals being processed during a single cycle.  The grand total of all rates for any given bot remains constant.  Mutations that increase the rate for any given reaction, automatically decrease the rates of all other reactions and vice versa.

In general enzymatic rates cannot be controlled from bot's DNA (see Control from DNA for more details).

Part 6: Interaction with environment.

Each chemical withn a bot will also try to achieve the equilibrium with its concentration in the environment.  The equilibrium here is reached when amount of chemical inside a bot is equal to the amount outside.  For each chemical there will be a single rate constant that will define how quickly the equilibrium is reached (in both directions).  The range for these constants will be from 0 (no secretion or adsorption) to 1 (immidiate equilibration with environement).

Part 7: Energy flow.

The energy flow within a bot will be a flow toward a complete equilibrium of all 256 chemicals in its body.  Nums thinks he can program it and I just have to trust him on that.
 
The whole energy flow in a simulation will depend on a energy/matter gradient.  The gradient will be created by giving large amounts of a certain chemical to veggies (similar to how feeding is done in current version).  It can be any chemical, even one with low energy, because the matter gradient will drive formation of high-energy chemicals, which can then be broken down to release energy.  Ideally we would want to give them a chemical with intermediate energy value, so that some of it can be immediately broken to release energy and some can be turned into high-energy storage chemicals.

It can be predicted that eventually the environment will get saturated with chemicals that none of the bots in the sim are able to utilize.  Two approaches can be taken.  One - allow bots to die in their own shit, if they can't evolve to utilize it.  Two - clean up the shit for them evry now and then.

Part 8: Physical properties.

At least some (and maybe all) chemicals will be assigned certain physical qualities, such as mass, volume, toughness, sliminess etc.  These will replace the current body, shell and slime fnctions.  If a bot wants to be tougher to resist incoming shots, it has to evolve to channel energy onto creation of chemicals with higher toughness rating.  If a bot wants to run quickly, then it has to avoid accumulation of chemicals with high volume.

Part 9: Control from DNA

As a rule we are not going to encourage and even allow control of enzymatic functions from DNA.  After all, if I could willfully tell my enzymes to create muscle from beer that I drink, I'd be one tough guy :)

BUT, we will allow some access to enzymatic rates from DNA.  There will be two new memory locations: .open and .close.  Bots will be able to store a single number into each, essentially fully opening and fully shutting down one reaction per cycle.


Ok, I think I'm done here  If I missed something, I'll edit the post later.
« Last Edit: October 27, 2005, 07:21:44 PM by Numsgil »
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #1 on: October 27, 2005, 07:47:15 PM »
About 60% of the above is adapted from here.

Technical detail:
-----------------------

There may be some technical issues we would need to address with 256 possible substances.  Like the fact that the number of possible interactions between all substances is 2 * 256! = 1.7156355506856853082381645433625e+507.  I'm confident I see how to resolve most of these issues.  But we may modify the number of substances (say, to 128) depending on how feasible this all is...

Quote
The energy flow within a bot will be a flow toward a complete equilibrium of all 256 chemicals in its body.  Nums thinks he can program it and I just have to trust him on that.

I do indeed think I can do it, but I want everyone to know it's not trivial.  There are some max flow/min flow algorithms I'm going to need to use, as well as probably some matrix math and numerical relaxation techniques...

Anyway, if you have a hard time figuring out how to do it, don't think you're stupid.  It really is hard ;)

Quote
Part 9: Control from DNA

As a rule we are not going to encourage and even allow control of enzymatic functions from DNA.  After all, if I could willfully tell my enzymes to create muscle from beer that I drink, I'd be one tough guy :)

BUT, we will allow some access to enzymatic rates from DNA.  There will be two new memory locations: .open and .close.  Bots will be able to store a single number into each, essentially fully opening and fully shutting down one reaction per cycle.

This is sort of where shvarz and I had trouble agreeing exactly.  I do think that allowing the DNA to control 256 different substances (and the corresponding 2 * 256! reactions  :wacko: ) isn't a good idea.

But some control is probably a good idea.

So I was thinking the DNA has the same controls it does now, more or less, and a "subconcious metabolism" DNA is created that handles the finer details of metabolism.  Think of it like a mitochondria.

In programming terms, this is simple encapsulation.  DNA communicates with the "mitochondria" DNA, which communicates with the actual workings of metabolism.  Users and evolution could modify the metabolism DNA much like regular DNA.

The mitochondria would have absolute control over the metabolism, much finer than just open or close.  That helps keep the DNA abstract, while allowing the bot to absolutely control its metabolism.

That's my thinking anyway.  Like I said shvarz and I weren't in agreeance on this point. (I believe he viewed it as a later modification perhaps, and not part of the core control.)

Quote
Part 8: Physical properties.

At least some (and maybe all) chemicals will be assigned certain physical qualities, such as mass, volume, toughness, sliminess etc. These will replace the current body, shell and slime fnctions. If a bot wants to be tougher to resist incoming shots, it has to evolve to channel energy onto creation of chemicals with higher toughness rating. If a bot wants to run quickly, then it has to avoid accumulation of chemicals with high volume.

I agree with mass, volume, sliminess, and shell.  I disagree on the point of Body, since body represents some intense molecular engineering by the bots that can't be represented as simple substances.  Closer to groupings of substances IMO.  Anyway, minor point...  (Again I think shvarz wanted to save something like this for a later edition...)
« Last Edit: October 27, 2005, 07:48:15 PM by Numsgil »

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Metabolism
« Reply #2 on: October 27, 2005, 09:34:19 PM »
Haha, Nums got his math wrong!   :lol:

The number of interactions is not going to be 2^256.  Remember, each chemical can turn only into 8 other chemicals, by changing one of its 1 or 0 values into another.  So the total number of reactions is 8x256= 2048.

if anything, we can pump up the number of chemicals...
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #3 on: October 27, 2005, 09:45:25 PM »
Hehe, have I mentioned that I'm only in theoretical math this semester?  The kind where you never see real numbers.  B)

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Metabolism
« Reply #4 on: October 27, 2005, 10:39:54 PM »
Quote
So I was thinking the DNA has the same controls it does now, more or less, and a "subconcious metabolism" DNA is created that handles the finer details of metabolism. Think of it like a mitochondria.

Would it still be possible to have some affect on the different resouces?

I was thinking of allowing the bots to reverse the mk/str (X resource) interactions and liberate some energy. This would be mainly allow the bots to have some gain from an enemy blasting their mkshell.

It would also allow the immediate creation of a venom tie feeder. Hopefully allowing more feeding diversity in sims would help out evolution.

Would this system include any sort of combined elements? Like if you combined shell and slime you could make something that blocks both.
« Last Edit: October 27, 2005, 10:56:44 PM by Endy »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #5 on: October 27, 2005, 10:55:00 PM »
I'm not sure exactly what you're asking.

Then again, I'm exhausted and probably should go to sleep soon, so maybeit'll make sense in the morning. ;)

Offline Endy

  • Bot Overlord
  • ****
  • Posts: 852
    • View Profile
Metabolism
« Reply #6 on: October 27, 2005, 11:08:24 PM »
Like for: mkslime, mkshell, strvenom, strpoison; you could store a negative number there to allow bots to recoup lost nrg(someone shot mkshell? will let's put that nrg to use :sly: ) and as a handy side effect be able to eat any venom stolen through ties.

Trying to think of easy ways to add more feeding methods to the DB's web, and balance out some of these attack methods. Kind of unfair having a bot spend only slight amounts of nrg to completly destroy another bot's major defense.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #7 on: October 27, 2005, 11:13:19 PM »
I dunno, that's an interesting point.  I'll leave this to shvarz as my brain is fried at the moment.

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Metabolism
« Reply #8 on: October 27, 2005, 11:38:19 PM »
Uhm, as I said - if you have something to add, don't do it here.  The proposed system is self-sufficient.  Feel free to critisize it, but move non-related suggestions to new posts.

The whole venom thing is just a temporary patch over something that needs to be done in a more general way.  So no point in making new rules for it.  We'll test this metabolism system and then, who knows - maybe some chemicals will turn out to be "poisonous" to most metabolic systems.  Then they will become venom by doing something that venom does, not by us assigning their venom-ness.
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Metabolism
« Reply #9 on: October 28, 2005, 07:24:13 AM »
I love this system! but jsut to enoy shvarz, I dont belive all chemicals search for Equilibrium, only chemicals that can go both way do it. else chemicals search for lower energy if they are able to pass the energy barrier preventing them from doing it
« Last Edit: October 28, 2005, 07:43:12 AM by Zelos »
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Zelos

  • Bot Overlord
  • ****
  • Posts: 707
    • View Profile
Metabolism
« Reply #10 on: October 28, 2005, 08:07:42 AM »
btw, how do you plan to control 0/1s? programming lanuages show what 0/1 sequens something is or?
When I have the eclipse cannon under my control there is nothing that can stop me from ruling the world. And I wont stop there. I will never stop conquering worlds through the universe. All the worlds in the universe will belong to me. All the species in on them will be my slaves. THE ENIRE UNIVERSE WILL BELONG TO ME AND EVERYTHING IN IT :evil: AND THERE IS NOTHING ANYONE OF you CAN DO TO STOP ME. HAHAHAHAHAHAHAHA

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #11 on: October 28, 2005, 09:13:15 AM »
Since I'll be using C++, we can control the 0/1s with C's built in bit manipulation routines.  But I don't know if that's cross platform or not...

Another way would be to contstruct a custom bit array.  I have a book that shows how, it's not terribly difficult.

Just need to be careful we don't use a whole integer for each bit (I think that's how bools work)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #12 on: October 28, 2005, 09:14:52 AM »
Quote
I love this system! but jsut to enoy shvarz, I dont belive all chemicals search for Equilibrium, only chemicals that can go both way do it. else chemicals search for lower energy if they are able to pass the energy barrier preventing them from doing it
In the system above, chemicals must move through enzymes, they can't go through reactions on their own.  So if no enzyme exists for a reaction, it can't happen, and the substance will have to find a different method for reaching equilibrium with the rest of the system.

Technical issue:
shvarz, how fine do the "bandwidth" of reactions need to be?  Like, can we represent them in [0,255] and use a single byte for each, or do we need to use a floating point number (8 bytes I think for each, I doin't remember exactly...) or a 2 byte number...

Do you get what I'm saying?  I'm still a little groggy.
« Last Edit: October 28, 2005, 09:16:51 AM by Numsgil »

Offline shvarz

  • Bot God
  • *****
  • Posts: 1341
    • View Profile
Metabolism
« Reply #13 on: October 28, 2005, 10:49:49 AM »
Mmmmmm.... grog....  :drool:

If I understand you correctly, then you are asking what is the range of amounts of chemicals that can move in from one chemical  to another in a single cycle.  
That depends on what range of concentrations is allowed I guess.  Seems reasonable to allow bots to have 32000 of each chemical. With real-word most-common values being 100-10,000.  And the amounts being moved per each cycle from 0 to everything (so that there is no way to overflow).  I guess that makes 0-32000.

Say, would that be too much extra work to make a metabolism simulator, where we could input our own values for chemicals and rates and then look cycle-by-cycle how they move in the matrix?  It should not be, right?  Once you have the math working, then it's just visual representation of stuff that's already there.  Only problem I see is how to show an N-dimensional space...
"Never underestimate the power of stupid things in big numbers" - Serious Sam

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Metabolism
« Reply #14 on: October 28, 2005, 12:06:32 PM »
Shouldn't be a problem at all really.  I'll see how visualizable it is when I have some code for it...

2 bytes it is then ;)