DarwinBotsManual
Open the app EspañolES

Chloroplasts and vegetables

How a bot with chloroplasts gains energy from the sun, when there is sunlight, why a crowded field yields less, and how vegetables are repopulated.

The sun is, along with the seeding of new vegetables, the only source of energy in the world (see Energy, body and waste). Any bot that has chloroplasts (.chlr) can use it: vegetables are born with them, but an animal can also buy them. This page explains how much they yield, when there is sunlight, and how the simulation keeps vegetables in the field. The sysvars for this topic are in Chloroplasts and light.

Photosynthesis

At the end of each cycle, in the sun phase, every living bot that has energy and chloroplasts gets its share if two things hold:

The gain for one cycle is computed like this:

gain = base × (4 × (1 − occupancy)² × 1.25 × chloroplasts/16000
               − (chloroplasts/32000)²)
       − age × chloroplasts / 1000000000

The gain is split between energy and body according to Photosynthesis: fraction to body: with 0.75, which is what the app ships with, a quarter goes to .nrg and three quarters to .body (at 10 to 1). With tides (Tides (cycles; 0 = off)), the gain also rises and falls with the tide period, between nothing and the full gain.

How much it yields

With solar energy per cycle at 10, as the app starts, a vegetable's gain in energy per cycle is as follows (the body goes up a little less than a third of that):

ChloroplastsAlone, in a huge fieldAmong 30, in a 4000×3000 field
4000+0.9+0.6
8000+1.7+0.9
16000+3.4+0.5
32000+6.4−0.7

In an empty field, more chloroplasts always yield more. In a full one, past a certain point they yield less, and with 32000 the vegetable loses. On top of that, chloroplasts make the bot bigger: 30 vegetables of 32000 chloroplasts cover the whole small field, and .light drops to 0.

That's why many Bestiary vegetables buy chloroplasts only as long as the light allows. This is the gene of Alga minimalis 3.0:

' Buys chloroplasts while it has fewer than the free light
cond
 *.chlr *.light <
start
 160 .mkchlr store
stop

Running it with chloroplasts costing 0.2 each (the F1 rules), a lone alga in the field buys until it is left with about 110 energy, close to the floor of 100 below which a purchase is canceled. Thirty algae in a small field, on the other hand, stop on their own near 15400 chloroplasts, where the free light catches up with them.

Having chloroplasts

Buying (.mkchlr) costs New chloroplast per chloroplast, and the purchase is canceled entirely if it would leave the bot with less than 100 energy. Removing (.rmchlr) is free and gives nothing back. In addition:

A bot can adapt to the day and night cycle. Chloroplastus, from the Bestiary, buys 1 at a time during the day and sheds 1 at a time at night, as long as it has more than 500:

' Lightens up at night
cond
 *.daytime 0 =
 *.chlr 500 >
start
 1 .rmchlr store
stop

Day and night

If nobody changes it, it is always daytime. There are two ways to get night:

The bot finds out through .daytime, which is 1 by day and 0 at night. For one with chloroplasts, it is 1 only if it is also in the lit strip. At night .light is not recalculated: the last daytime value keeps being read.

The sun strip

With Random sun (weather), the sun lights a vertical strip of the field, from top to bottom, that moves on its own. Its width goes from a quarter of the field to the whole field, and it starts at a little over a third. The strip shifts by 0.05% of the field width per cycle and its width slowly grows or shrinks. Every so often (on average, once every 2000 cycles) it chooses again: toward the left, toward the right or standing still, and whether it widens or narrows. A strip that goes off one edge continues from the other. For a fixed vegetable, that means long seasons of sun and shade; one that moves can follow the light.

Vegetables

A vegetable is a bot of a species you marked as vegetable when setting up the simulation. It photosynthesizes like any other bot with chloroplasts; what changes is how the world treats it:

Repopulation

In each cycle, the engine adds up the chloroplasts of all the living bots and divides by 16000. If the result is below Repopulate below (chloroplasts), it counts one waiting cycle; when it reaches Cycles between repopulations, it seeds Vegetables per repopulation new vegetables and starts counting again. Each one is born at a random spot inside its species' zone, with 1000 body and the species' initial energy.

Watch the unit: the threshold counts chloroplasts, not bots. With the app's value, 15, seeding kicks in if there are fewer than 15 × 16000 chloroplasts in the whole field. Twenty skinny vegetables, 4000 each, add up to 5 and trigger seeding all the same. And the animals' chloroplasts count too.

The species of each new vegetable is picked at random among the vegetable species that still have some living bot with chloroplasts. If no vegetable is left alive, all of them are eligible.

The cap

Vegetable cap is also measured in units of 16000 chloroplasts. When the field's total goes over that cap, vegetables can neither reproduce nor buy chloroplasts; above 90% of the cap, only one in eleven reproduction attempts goes ahead. The cap doesn't affect animals.