Agents on a Topographical Surface – Example 11.5
It’s been a while since I’ve posted any new content, but I decided to finally add a bit more about agents. This is actually something I started working on a while ago, and which I alluded to in Example 8.5, but it is a method to analyze a topographical surface to find potential corridors of movement, and also areas of inaccessibility.
The basic premise is fairly simple. Anyone who has spent any amount of time studying site design will know that you really shouldn’t have any paths steeper than 1:20. Sure, you can have paths 1:12 with landings every 10 meters, but that just looks ugly. The reason for this 1:20 rule is to make paths that are comfortable for people in wheel chairs and older people. But these paths are also more comfortable for everyone else as well!
Based on this regulation, I decided to create a script that would send a swarm of agents–old ladies and people in wheelchairs–across a landscape, and from this analysis, a designer could then perhaps better understand potential access and barrier points.
The script will follow two rules.
1 – Agents are limited in each “step” to movement uphill and/or downhill that does not exceed a specific gradient, in this case 1:20 (although this can be changed) This is very similar again to Example 8.5 and will use some of the same techniques.
2-Agents will tend to move in the same direction as their current direction. Nobody likes switchbacks. Unlike Example 8.5, there is no “destination” per se, the agents will just keep moving in one direction unless there are no good options in that direction, in which case they will turn to a new general direction.
In addition to analyzing sites for barrier free movement, this logic may be useful for modeling ecosystems as well. Most animals, like most people, also don’t like super steep slopes, and will follow lower gradients when possible. Sure, it IS possible to go straight up hill, but in the interest of conserving energy, in the long term lower gradients will be followed. With a bit more scientific rigor, this method of modeling may show potential migration corridors in larger landscapes, and also pinch points, where potential predators might like to hang out! And places that are inaccessible to most animals, might just be a good place for an animal without teeth to carve out a new ecological niche (mountain goats?) So enough of that, on the script.
First, you will need a surface. In this case, I used Elk to create an 8.6 x 8.6 km area of an interesting landscape southeast of Alfeld, Germany. Any landscape with some topographical variation will do. I then use the “Populate Geometry” component to put some starting agents on the surface. I will keep it low for now, just two, but can increase this later.
The second important thing here is to set up a “Step Size”, the distance the agents will cover in each round. Since I want the script to work for smaller and larger sites, I use a bit of math to make the step size proportional to the overall surface dimensions. Note that for clarity I use a rather large step size at first, but I will reduce this later to get more accurate results.
At each random point, I draw a circle with a radius equal to the “Step Size.” I then move this circle once up and once down based on the maximum amount an agent may move either up or down in each step. This is proportional to the gradient, in this case 1:20. My step in this case is 260 m (this will later be reduce for more accurate results) . That means with the 1:20 gradient I may not move up any more than 13m, or down more than 13m. A loft is drawn between the minimum and maximum circle, and this is then intersected (BREP | BREP Intersection component) with the surface to generate a curve or set of curves of possible vectors of movement. This is again exactly like Example 8.5 which you can refer to for additional explanation.
Note that the top right agent has only one curve of possible movement, while the bottom right agent has two. Once we start looping, a point along the curve in the current direction of movement will be privileged, but for now, the agent at rest could venture off in either direction.
Here I use the “List” component to give me only the first potential movement curve for each agent point. I then use “Curve Closest Point” to find the closest point on this curve–the agent’s destination–to the agent’s current position. I then add this new point into a list just after the current point.
Please pay attention to the data structuring, that is, the grafting and simplification. The goal is to get the initial point as point “0” on your list, while the second point becomes point “1”
For reference, to this point the overall script should look like the image below
Now we are going to go big and make the loop all at once! It looks like a lot but it is basically just repeating much of what we did before.
First, we use “List Component” along with the Round Counter to extract the last two points from our list. Right now the list only has two points for each agent, but this will quickly grow!
We then do exactly like step Two above, drawing circles at the current agent position (Point 1 in this case) with a radius based on the step size, and then finding curves of potential movement based on the maximum allowable gradient.
Instead of using list Item to select the first of these potential movement curves, we are now going to do it a little differently. We first find the current vector of movement based on the vector between the next to the last point (Point 0) and the last point (Point 1). We then draw a “Tentative” movement point, in this case at half the total movement, and then run a “Curve Closest Point” test between this “Tentative” point and the potential movement curves.
There could be one, two, three or even more potential movement curves…but there is always at least one. If all else fails the agent will go back to where he came from. 😉 Anyways, we then do one more “Closest Point” component to find which of these one, two, or 3+ Closest points on the Individual curves is the closest of the whole set. This is the next destination. If it doesn’t make sense, just copy EXACTLY what I did above and it should work.
I then merge this new agent current position into the ongoing list of agent positions.
Step Five – Running the Loop
Once this hard work is done, its smooth sailing–hopefully. In the image above I am labelling the points with their index number for clarity, but you can start to see how the agents are behaving. If it is working, slowly increase the number of iterations, and also now would be a good time to go back to the start and reduce the step size in the interest of more accurate results.
Step Six – Continue Looping and Play with Representation of Agents.
You may also want to increase the number of starting agents, by adding a few points to the initial “PopGeo” component. If all is well, it should be able to handle a few more. Lastly, you may want to make the agent trails look a little better. You can add a “Interpolate” curve or a “Nurbs Curve” between the points in the list to track the agents without the red “X’s”. You may also consider, AFTER the loop is finished, adding a “Dash” component. Be careful with this though, and make sure to disable/delete it if you decide you want to run a few more rounds!
There are may other Representation options. In the first image of this post, the agent paths are colored with a gradient based on how far ranging they are. Agents that are confined to topography to their local neighborhood are Orangeish, while agents that wander far from home get colored green. This wasn’t too hard to figure out, but I’ll leave that for you to figure out on your own, if you’d like.
By now, hopefully some patterns are starting to emerge. If this were a park landscape, you may start to see where pedestrian paths would be feasible, or where they could be difficult to construct. If a particular point needs to be accessed, you can also see potential ways to get there with accessible paths.
If this were an ecosystem simulation, you’ll start to see where would be a good place to hang out if you were a mountain lion looking for passing livestock, and might even see where the mountain goats would hang out. Also note that the edge boundaries have a huge effect on agent behavior towards the edges. This is a common problem with computer simulations, since the real world doesn’t have such hard boundaries, but you could image that if a fence were erected around this landscape to create a protection area or such, what the implications might be.
The script can now be fine-tuned / altered / improved in any number of ways. Here, as an example, a bit of randomness is added to the path of the agents by rotating the vector of “Tentative” movement. This frees up the agents to wander a bit more, but they still will be constrained by the gradient rules.
Comparison with the Actual Landscape Condition
Just out of curiosity, I decided to compare what I learned about the landscape from the agent modeling to the actual landscape condition.
The image to the left is taken from open street maps, the images to the right are the versions with agents strictly going to the closest point in the current direction (above) and the more wandering agents (below).
I’ll let you draw your own conclusions, but remember, topography isn’t the only thing shaping this landscape. Also, some of the information towards the edges is skewed because of the boundary problem discussed earlier.
Anyways, hope this helps as a good start to seeing how agent modeling can be useful in landscape surface analysis and design! As a last image, I just wanted to show a quick test I did of the same agents walking through the Iberian Peninsula. A more careful analysis could start to yield some insight into historical routes of movement through the Peninsula, which in turn informed Spain’s historical development.