> For the complete documentation index, see [llms.txt](https://scenegroup.gitbook.io/cavalry/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scenegroup.gitbook.io/cavalry/getting-started/key-concepts/context.md).

# Context

The secret sauce

Cavalry's architecture does some amazing and unique things. On the surface this means you can do more with less elements but what's actually going on under the hood?

The underlying concept to understand is that of an **Index**. An index is simply a number passed to another Element. A fundamental part of a Duplicator's role is to assign indices to the Shapes it generates. This index can be used by the Duplicator and other Elements to dictate position, rotation, color, number of sides...anything really.

Let's say you've used a Duplicator to create a column of 10 rectangles.

![](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-LgCVsa8CEHp6lauyE_9%2F-LgCYg9uav7XHqILCwJY%2Findex1.png?alt=media\&token=85e3cc0e-5b02-4c01-8917-5c9a14649a34)

In this case the Duplicator creates 10 indices and uses them simply to provide each duplicated Shape with a position based on the Distribution settings (in this case a **Grid** with a **Height** of **350** and a **Size mode** of **Fit**). **Index:0** (the first shape) gets assigned a **Position Y** of **0** and **Index:9** (the tenth/last shape) gets assigned a **Position Y** of **350** with the other Shapes distributed evenly between.

Ok, so what happens if we add this Duplicator to a second Duplicator? Here the second Duplicator has been set to a **Grid** of **Count X = 5** and **Count Y = 1**.

![](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-LgCVsa8CEHp6lauyE_9%2F-LgCcj1v6pjY9yau5mzu%2Findex2.png?alt=media\&token=d0429834-0a3a-4869-857a-442b38b283d4)

As you can see the indices flow through to the second Duplicator's shapes. As you keep duplicating Duplicator's this index count will keep flowing through the graph.

So how about a practical example.

1. Create a [Text Generator](/cavalry/nodes/utilities/string-generator.md).
2. Set the **Generator** to **Value**.
3. Add the **Text Generator** to a [Duplicator](/cavalry/nodes/shapes/duplicator.md).
4. On the **Grid Distribution** set the **Count** to **X = 1**, **Y = 10**.\
   **Result**: A column of zeros.

![](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg8DMUyOIX3S37Va39X%2F-Lg8FfQf5FZrqdN6PJwk%2FcontextNumbers0.png?alt=media\&token=9ad01564-8644-44fb-a8a3-c9b93d6838c0)

So, on the surface, there's nothing very interesting going on there :wink: but that's just because we've not asked the Duplicator to do anything with the indices. So let's ask it to create some random values to pass to the **Number** attribute.

1. Create a [Random](/cavalry/nodes/behaviours/random.md) Behaviour.
2. [Connect](/cavalry/getting-started/key-concepts/connections.md) ***random.id > textGenerator.number***.\
   **Result:** Each number is a random number between 0 and 10 (defaults).

![The Duplicator passes random numbers to each duplicate.](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg8DMUyOIX3S37Va39X%2F-Lg8HjcZE-8e7S9tlbI7%2FcontextNumbers0-5.png?alt=media\&token=5d6810b9-3859-4bdf-bb43-c5a179c92804)

The above is made possible by the fact that the Duplicator provides a **Index** to each number and the **Random** node utilises that context.&#x20;

* **Duplicator** asks **Text Generator** 10 times for its **Number**.
* In turn, **Text Generator** asks **Random** 10 times for the value of its **Number**.
* During those 10 times, **Random** receives **Index** values of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
* Based on each index, **Random** alters its **Seed** value to produce different results.

You can apply this idea to any attribute in Cavalry. Let's do the same thing to affect the number of sides of a Polygon.

1. Create a [Polygon](/cavalry/nodes/shapes/basic-shape.md) Shape.
2. Add it to a [Duplicator](/cavalry/nodes/shapes/duplicator.md).
3. Add a [Random](/cavalry/nodes/behaviours/random.md) Behaviour.
4. Set **Minimum** to **3** and **Maximum** to **5**.
5. Connect ***random.id > polygon.sides***.

![Each shape is given a random number of sides of between 3 and 5.](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-Lg9qj47vLtFlhUVO_gy%2F-Lg9rlW6-rQ6QcnhBTlE%2FrandomSides.png?alt=media\&token=7e1e478b-1a5e-4e8a-9bc6-332dcf8ef75f)

This concept can be used on Noise Deformers, Colors, Stroke Widths, Path Lengths, Blur Filters, Asset Arrays, Dynamic Rendering...anything. The possibilities are endless! :sunglasses:&#x20;

#### Switching to manual

Now there are occasions when you might want manual control of how these indices are assigned. There are two levels to this. The first is to prevent the Duplicator from using the 'incoming index'.

Taking our example of a grid of rectangles (the duplicated Duplicator):

1. In the [Attribute Editor](/cavalry/user-interface/menus/window-menu/attribute-editor.md), right-click on Duplicator1's header bar and uncheck **Advanced** -> **Use Incoming Index.**

![](https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-LgCg_WQtjMqxIdHIRTZ%2F-LgCgsoQjZ0v1LoWfIwG%2Findex3.png?alt=media\&token=4b9db39c-492a-4e31-97e0-f58eab75724c)

Now the indices from Duplicator1 are being cycled through to the second Duplicator.

To take this idea even further you will need the help of the [Context Index](/cavalry/nodes/utilities/context-index.md) Atom.
