Python Tutorials (back to the list of tutorials)

## Generative and Self-Optimizing Agents (Swarm-Generated Tensile Structure)(requires iGeo version 0.9.1.5)

### Swarm Formation by Force Fields

This tutorial shows examples of combining active and generative agents (swarm agents and branching agents) and passive and optimizing agetns (physics simulating particle, tension and compression agents) to generate geometry which could be built with tensile and compressive materials in vertically suspended structure or horizontal suspension bridge structure like the two examples below.

A(g)ntense by ATLV

Venice Beach Canopy by ATLV

First, the code below generates swarm formation curves by two different swarm classes and by force fields generated randomly in the codes. Multiple force fields are combined by compound fields to respond the closest force field. There are a compound attractor field and a compound curl field for MyBoidA and also for MyBoidB. The rotation directions of the curl fields are opposite for MyBoidA and MyBoidB.

```
Warning:  include(codepy/igeo_tutorial58_1/igeo_tutorial58_1.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_1/igeo_tutorial58_1.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

### Swarm Formation and Force Field from Input Geometry

The example code below uses an input Rhino file to generate force fields and set initial positions of swarm agents. Two sets of points on specific layer names are imported and the code puts swarm agents of MyBoidA and MyBoidB at the point locations. Curves on the six different layers are imported to generate force fields. Curve attractor fields, curve tangent fields, curve curl fields for MyBoidA and MyBoidB are instantiated. The sample input file used in the code is this file.
field_lines1.3dm

```
Warning:  include(codepy/igeo_tutorial58_2/igeo_tutorial58_2.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_2/igeo_tutorial58_2.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

### Self-Optimizing Physics Simulation Agents

The next example adds two classes; Node class and SectionAgent class. Node class is a particle-based class which stays only on a specified plane. SectionAgent is instantiated once at the setup method and observes all swarm agents at its interact method. When a swarm agent pass through a specified section plane, (1) generate Node instance at the intersection, (2) collect all nodes on the same section plane and calculate Delaunay triangulation and (3) connect nodes on the Delaunay edges with IStickLine agents which simulate compression stick structure. When a new node is created, the swarm agent stores it and connects it to the previous node with ITensionLine agent which simulate tension wire structure.

As result of nodes staying on a plane, being separated by compression structure, and pulled by tension structure between sections, nodes, sticks and wires are moved to equilibrium locations under the forces perpendicular to the section planes.

```
Warning:  include(codepy/igeo_tutorial58_3/igeo_tutorial58_3.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_3/igeo_tutorial58_3.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

The sample input file used below is below.
field_lines2.3dm

```
Warning:  include(codepy/igeo_tutorial58_6/igeo_tutorial58_6.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_6/igeo_tutorial58_6.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

### Self-Optimizing Physics Simulation Agents for Bridging Structure

The code below changes the direction of the section in SectionAgent towards X axis and the formation of swarm trajectory is controlled by force fields generated from the imported Rhino file as shown in the earlier example. In the previous example, nodes at the start points of swarm agents are fixed. In this example the nodes on the last section (defined by maxSectionNum) are fixed as well as the start points. The sample input file used below is below.
field_lines1.3dm

```
Warning:  include(codepy/igeo_tutorial58_4/igeo_tutorial58_4.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_4/igeo_tutorial58_4.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

### Branching Swarm Agents and Self-Optimizing Agents

The last example below adds branching behavior to the swarm agent. The nodes, tension and compression structure agents are generated in the same way with the previous examples by SectionAgent but the agent connects nodes of branched swarm agents back to the same parent node to have branched tension structure as well. In this example, swarm agents fly from bottom towards top and the first node is not fixed but the last node at the top plane is fixed to simulate suspended structure at the top.

```
Warning:  include(codepy/igeo_tutorial58_5/igeo_tutorial58_5.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_5/igeo_tutorial58_5.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

The sample input file used below is below.
field_lines3.3dm

```
Warning:  include(codepy/igeo_tutorial58_7/igeo_tutorial58_7.html): failed to open stream: No such file or directory in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66

Warning:  include(): Failed opening 'codepy/igeo_tutorial58_7/igeo_tutorial58_7.html' for inclusion (include_path='.:/usr/local/php5_6/lib/php') in /home/content/58/5926958/html/igeo/tutorial/tutorial.php on line 66
```

(back to the list of tutorials)