In this example, the light source is coming from the right. Hence the tree branches out towards the right. They are created from adding branches from previous branches, with the trunk being the first “branch”.
At the end of each branch, there is a 60% chance for the next branch to grow to the right, and 20% to the left and another 20% to the middle. This is done by generating a random number between 0 – 1 and if statements.
A route (from the trunk to the first branch, to the second… to the last) is completed first before the next route starts. Each route is entirely probabilistic.
For future exploration:
Currently, the implementation of a “light source” is only through defining the probabilities of growing right, left and center. I would like to be able to define a light source. The probability of growing towards the light source will depend on the distance the previous branch is from the light source. Closer = greater probability of growing towards it.
Also, currently, I am using a predefined angle of 30 deg when it branches out. I’d like to use the position of the light source as reference for the direction the branch should grow towards
Phototropism is essentially how a plant grows in responds to light, either positive phototropism (towards the light) or negative phototropism (away from the light). I’d like to explore on the factors that contributes to the extent a plant grows towards (or away) a light source.
At each junction, a plant can decide to grow a leaf towards the right or left. With even exposure to light, the probability is 0.5 for each direction. With exposure to light biased to the right for example, the there’s a higher probability for a leaf to grow there. We can experiment different light sources by defining the intensity and shape. E.g., an outdoor plant will receive direct sunlight which is round and have high intensity while an indoor plant will receive sunlight from a rectangle window which may have day curtains, having low intensity.
Assuming even light exposure, we generate a probability tree using an algorithm. Each route starts from the same position, and based on a probability to turn left or right at multiple junctions, a route will be formed with a limit of n junctions. Since each decision at each junction is a probability, each route created will take different paths.
After, we try to add on the effect of light. We can input a single light source as a point or an area. Since intensity = 1/d^2, the further a plant is from a source, the less intense the light.