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:
- it is daytime (see Day and night);
- the bot is inside the lit strip. Without Random sun (weather), the strip is the whole field.
The gain for one cycle is computed like this:
gain = base × (4 × (1 − occupancy)² × 1.25 × chloroplasts/16000
− (chloroplasts/32000)²)
− age × chloroplasts / 1000000000
- The base is Solar share per cycle divided by 3.5. In pond mode (Pond mode (light by depth)) it depends on depth: it is Light intensity divided by the depth raised to the power Depth gradient (depth grows by 1 every 2000 units downward), and then divided by 3.5.
- The occupancy is the part of the field covered by bots, the complement of
.light. Squared, it punishes heavily: with half the field covered, the first term is worth a quarter of what it is in an empty field. - The negative term grows with the square of the chloroplasts: more chloroplasts yield more, but less and less.
- The rate by age is small: 1 per cycle only with 32000 chloroplasts and 32000 cycles of life. It is charged outside the strip too, if it is daytime.
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):
| Chloroplasts | Alone, in a huge field | Among 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
stopRunning 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:
- They are lost on their own. Half a chloroplast per cycle when there are few, a twentieth with 8000 and a two-hundredth with 16000.
- They weigh. Each chloroplast adds almost 1 of
.massand enlarges the radius, so a bot with many barely moves and blocks more light. - They are shared out. When reproducing, the child takes its percentage (Reproduction). Inside an organism they can be shared with
.sharechlr, only between close relatives. - They digest waste. A bot with chloroplasts slowly converts its waste into energy and body (see Energy, body and waste).
- They are incompatible with viruses. If a bot with chloroplasts tries to make one with
.mkvirus, it loses them all (Viruses).
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
stopDay and night
If nobody changes it, it is always daytime. There are two ways to get night:
- The clock. With Day/night cycle turned on, day and night alternate. Each stretch lasts Half period (cycles) cycles plus one (with 3, four cycles of sun and four of darkness); only the first day of the simulation lasts one less.
- The world's total energy, which adds up the energy and ten times the body of every bot, corpses included, plus that of the energy shots in flight. With Sun ON below a threshold the sun comes out if it drops below On threshold; with Sun OFF above a threshold it sets if it goes over Off threshold. That way a population that grows too much is held back, or one that is dying off is rescued. What the threshold does with the clock is decided by Threshold mode: force only that cycle, change the state until the next threshold, or restart the clock from there.
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:
- It is born with Starting chloroplasts chloroplasts (16000 if you don't change it).
- It doesn't suffer shock (Energy, body and waste).
- Its children are vegetables too.
- Its population has a cap, and the simulation tops it up when it runs short.
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.