println(sugar); } if(probability(0.6)) (Fruit(0.01,1,0.1)) else if(probability(0.4)) ();The sugar availability is calculated by summing all leaf assimilates before deciding on fruit formation. 6) Fruit Growth Competition Multiple fruits compete for available resources using an age-based weighting system (L. 209-225): fr:Fruit ::> {
float totalSugar = sum((* lf1:Leaf *)[as]);
long fruitCount = count((* fr2:Fruit *));
// Simple age-based competition (younger fruits get more resources)
float ageWeight = Math.exp(-0.05 * fr[age]);
float totalAgeWeight = 0;
for ((* fr2:Fruit *)) {
totalAgeWeight += Math.exp(-0.05 * fr2[age]);
}
float sugar = (totalAgeWeight > 0) ?
(totalSugar * ageWeight) / totalAgeWeight : totalSugar / fruitCount;
Younger fruits receive proportionally more resources through exponential age weighting, simulating their stronger sink strength.
7) Visual Feedback
Internodes change color based on their sugar content, providing visual feedback of the transport process:
itn.(setShader(new RGBAShader(itn[as]*2000.0, itn[as]*1000, itn[as]