For my project of urban-cinema I tried to establish a well connected building which reacts and response to the environment and to its surroundings. It was highly important to allow a parametric, flexible pathways from a central point. A root or a plant may serve as an allegory for this type of branching structure. I was contemplating 3 strategies: Agent-base design (swarm behavior), L-systems and recursive systems. Agent-base design is responsive and can create an elaborate forms, however it is a decentralize system, and has no hierarchy. L systems contain a good thematic branch algorithm and hierarchy - but they are tend to be too rigid and uninfected by the surroundings. Recursive systems respond to the environment - and can have a hierarchy. This was my base strategy for the beginning.
I planned the algorithm according to 3 layers:
base branching: The branching starts from a central point. It has a certain direction (generated from a field of randomness) and characteristic: number of nodes (or branching points), length of branches, minimum distances from one node to the other.
Polygon borders: Borders are defined by closed polygons. The branching algorithm avoids going into any of them. For every placed node a check is being made to make sure it is within "safe zone" - if it does, it stays, otherwise - it is deleted. Those borders could be used as the perimeter of the site, open spaces or unapproachable obstacles.
Mesh obstacles: For 3D obstacles I used meshes. This can represent buildings, abstract volumes or topography. The branching structure will grow over (or under) the obstacle once it recognize that the node is within a mesh. Once it does, it relocate the node to the upper face above it. Once the next node is outside the mesh - it comes back to the zero surface (the ground).
Using all three layers to the script ensures that the curves would keep crawling on the ground surface and avoid the borders, and it has a mechanism to react to obstacles in a smart way - and return to the ground once such position is possible. For further elaborate model - there is the possibility to duplicate the branch into several randomize branches, although at the moment no algorithm was developed to calculate the relation between the different curves.