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 acid to transform into energy.

## Functioning

### 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 fullness 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.

d
i
g
e
s
t
i
o
n
P
o
t
e
n
t
i
a
l

=
s
i
z

e

2
D

∗
m
e
t
a
b
o
l
i
s
m
s
p
e
e
d
∗

a
c
i
d
L
e
v
e
l

/

f
u
l
l
n
e
s
s

{\displaystyle {digestionPotential}=size\_{2D}\*metabolismspeed\*{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 **fullness**), the total digestion potential will be calculated as such:

d
i
g
e
s
t
i
o
n
P
o
t
e
n
t
i
a
l

=
s
i
z

e

2
D

∗
m
e
t
a
b
o
l
i
s
m
s
p
e
e
d
∗
(
100
%
(

a
c
i
d
L
e
v
e
l

−

f
u
l
l
n
e
s
s

)

{\displaystyle {digestionPotential}=size\_{2D}\*metabolismspeed\*(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).

d
i
g
e
s
t
i
o
n
R
a
t
e

m

=

d
i
g
e
s
t
i
o
n
P
o
t
e
n
t
i
a
l

m

∗

r
e
a
c
t
i
v
i
t
y

m

{\displaystyle {digestionRate}\_{m}={digestionPotential}\_{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

m
i
n

(

E

m
a
x

−

E

m
i
n

)
∗

a
f
f
i
n
i
t
y

m

{\displaystyle 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

p
l
a
n
t

=
−
50
%
(
50
%
−
−
50
%
)
∗
70
# %
20
%

{\displaystyle E\_{plant}=-50\%+(50\%--50\%)\*70\%=20\%}

Meat:

E

m
e
a
t

=
−
30
%
(
85
%
−
−
30
%
)
∗
30
# %
4.5
%

{\displaystyle 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.

##### Efficiency Malus

If the stomach's acid level is greater than its fullness, an efficiency malus is then applied, proportional to the base efficiency shown above, given by the following formula:

E
m
a
l
u
# s
(
a
c
i
d
L
e
v
e
l
−
f
u
l
l
n
e
s
s
)

/

2

{\displaystyle Emalus=(acidLevel-fullness)/2}

Thus a bibite with a diet gene of 0.0, a stomach fullness of 80% and a stomach acid level of 100% would have an efficiency malus of 10%, meaning it would digest plants at 45% efficiency rather than 50%.

### 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.

##### Maximizing Energy Gain Through Digestion

Assuming fixed material and bibite properties, we are left with two variables we can change to influence energy gain: acid level and stomach fullness. In the case of an acid level greater than its fullness, we can provide simplified versions of the above formulas to abstract away those constants:

d
i
g
e
s
t
i
o
n
R
a
t

e

a
c
i
d
,
f
u
l
l
n
e
s
s

=
100
a
c
i
d
−
f
u
l
l
n
e
s
s

{\displaystyle digestionRate\_{acid,fullness}=100+acid-fullness}

e
f
f
i
c
i
e
n
c

y

a
c
i
d
,
f
u
l
l
n
e
s
s

=
100
−
(
a
c
i
d
−
f
u
l
l
n
e
s
s
)

/

2

{\displaystyle efficiency\_{acid,fullness}=100-(acid-fullness)/2}

e
n
e
r
g
y
G
a
i

n

a
c
i
d
,
f
u
l
l
n
e
s
s

=
(
100
a
c
i
d
−
f
u
l
l
n
e
s
s
)
∗
(
100
−
(
a
c
i
d
−
f
u
l
l
n
e
s
s
)

/

2
)

{\displaystyle energyGain\_{acid,fullness}=(100+acid-fullness)\*(100-(acid-fullness)/2)}

We can now plug in a value for acid level or for stomach fullness, making it easy to find the optimal counterpart: for example, we might want to compute the optimal stomach fullness for an acid level of 100%:

f
f
u
l
l
n
e
s
# s
(
200
−
f
u
l
l
n
e
s
s
)
∗
(
50
f
u
l
l
n
e
s
s

/

2
# )
−
f
u
l
l
n
e
s

s

2

/

2
50
f
u
l
l
n
e
s
s
10
,
000

{\displaystyle ffullness=(200-fullness)\*(50+fullness/2)=-fullness^{2}/2+50fullness+10,000}

We then derive:

f
′

f
u
l
l
n
e
s
# s
−
f
u
l
l
n
e
s
s
50

{\displaystyle f'fullness=-fullness+50}

We now need only find the root to get the optimal stomach fullness for an acid level of 100%, which is 50%.