The final central concept of Spry Logic is grouping, where steps in your Rule are grouped together. Before addressing why grouping is important, it’s important to have a look at how Spry processes logic.
How Spry processes logic
To start with, a simple explanation is that Spry (conceptually) runs through each set of logic steps twice. The first time is to calculate all of the points in space. The second time is to run the haulage equipment over those points. The most important thing to note is that the first run through that Spry completes does NOT use grouping, but runs through in the order in which the points and vectors are presented to it.
Once Spry has calculated where all of these points are, then it runs the haulage equipment over the points (that are added to the profile) which DOES use grouping. Groups are prioritised in the order they appear, but the truck moves along the points from top to bottom in Forward groups and from bottom to top in Reverse groups.
Why use Groups? And when?
Groups can have multiple uses. In a simple sense, groups are great for organising your steps. You can also copy and paste groups across different rules without copy and pasting the whole rule all at once. The power of groups however comes from something a little more complex.
Logic rules usually work best when you calculate (part one as discussed above) steps in each group FROM the better known or more static points TO the lesser known or more dynamic points. What does this mean in practice? Imagine a simple scenario where the top of your ramp is static/permanent, but as you dig the bottom of the ramp continues down deeper and deeper. The following comparison is this scenario with and without reverse groups.
In this example there is only one extra step needed, but let’s look at one where the top of that ramp then leads to another semi-permanent ramp.
In the example above there are other methods to use less steps but using reverse groups is the leanest and usually more readable.
To summarise, Spry first calculates each step in order from top to bottom regardless of grouping. After this, Spry will constitute the final haul string by going over each step group by group, but in reverse groups moves travels from bottom to top. Each group should usually start with a more known point and move to a less known point.