Bibite Stomach

The Bibites now have an internal storage space analogous to a stomach where they can store and accumulate materials waiting to be digested.

When a Bibite eats something, it is sent to the stomach, where it will be digested by the stomach's acide to transform into energy.

Capacity
The stomach has a maximum capacity of matter it can contain equals to half the bibite's surface (in u2 ). As a result, a "default" bibite (size gene and maturity of 1.0, resulting in a body surface of 42 u2) will be able to hold up to 21 u2 of matter.

Fullness
The fulness of the stomach is simply the fill percentage of the stomach, or the total amount of matter it contains divided by it's capacity.

Acid Level and Digestion Potential
Bibites have an Output Node in their Brain (called Digestion) that controls the level of activeness (acid level) of their stomach. Being a Sigmoid, it can only range from 0% to 100%. The total digestion potential is proportional to the stomach's acid level divided by it's fullness, as well as the bibite's size (2D) to make physical sense.

$${digestion Potential} = size_{2D} * metabolism speed *{acidLevel}/{fullness}$$

However, the total digestion potential is softly capped at 100%, meaning that over 100%, increasing the acid level doesn't increase the digestion potential as much. In fact, going above that threshold will also cause an efficiency malus (detailed lower).

Above the threshold (when the stomach's acid level is higher than the fulness), the total digestion potential will be calculated as such:

$${digestion Potential} = size_{2D} * metabolism speed * (100% +({acidLevel} - {fullness})$$

As a result, a bibite with it's acid level at 30% but a stomach only 25% full will only have a digestion potential of 105%.

Digestion rate
The exact amount of matter digested depends on the stomach's content. First, the digestion potential is split among all the matter it contains proportionally to their respective share of the total contained amount.

In other words, if a bibite's stomach only contains 10u2 of plant and 5u2 of meat, the plants will receive ⅔ of the digestion potential and the meat ⅓.

Then, for each different type of matter, their respective share of the total digestion potential is multiplied to their reactivity (u2/s) to determine their resulting digestion rate (u2/s).

$${digestion Rate}_m = {digestion Potential}_m * {reactivity}_m$$

Following our previous example, if that bibite had a total digestion potential of 60%, the digestion rate would be equal 40% ( ⅔ * 60%) of Plant Material's base reactivity. Since the default base reactivity of Plant is 1.0 u2/s  (it can be changed in the simulation's parameters) , this would result in a final digestion rate of 0.6 u2/s.

Affinity and Efficiency
The efficiency at which the stomach will convert matter into energy (or conversion efficiency) can easily be calculated using the particular material's min and max conversion efficiency and the bibite's affinity to that material.

Affinity
For now, the bibites can only digest plant and meat.

A bibite's affinity to meat is simply equal to the value of their diet gene (which ranges from 0.0 to 1.0).

A bibite's affinity to plant is then equal to 1 minus the value of their diet gene.

As a result, a bibite with a diet gene of 0.3, would have an affinity toward meat of 30%, and 70% toward plants.

'' Note: It is however planned to expand this system to make it more complex and allow parallel affinities to exist at a cost. ''

Conversion Efficiency
Then, the conversion efficiency of a particular material can be calculated from the min and max conversion efficiency of the material with the following formula:

$$E_m = E_{min} + (E_{max} - E_{min}) * {affinity}_m$$

Following our previous example, considering the default min/max efficiency of plant is -50% and 50%, and the min/max efficiency of meat is -30% and 85%, this allows us to calculate:

Plant: $$E_{plant} = -50% + (50% - -50%) * 70% = 20%$$

Meat: $$E_{meat} = -30% + (85% - -30%) * 30% = 4.5%$$

As such, a bibite with a diet gene of 0.3 would be able to obtain 20% of the energy of the plants it digest, and 4.5% of the energy from meat.

Energy Gain/Loss Rate
Now, the actual energy gain/loss rate (E/s) from the digestion of the stomach's content of a bibite is easily computed. It is simply given by the individual digestion rate (u2/s) of each material multiplied by their respective energy density (E/u2) multiplied by the bibite's conversion efficiency (%) with that material.