Try to get the caterpillars to form a rolling swarm.
The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. You can get Java from here.
powered by NetLogo
view/download model file: caterpillar.nlogo
Some social caterpillars can move in a strange formation called a rolling swarm. Basically, they assemble into a kind of moving conveyor belt, made out of caterpillars. By riding on this conveyor belt, the caterpillars can give themselves a speed boost. You can see this happening in this video by Destin at Smarter Every Day and read about it on my blog.
But why do they work together? I implemented a simple model, suggested by my friend Deepak Iyer, to show how seemingly co-operative behavior can emerge out of simple, selfish rules. Here’s how it works.
That’s the one key rule. The remaining rules just model the physics of this world:
In this model, there’s no organizing force that makes these caterpillars organize. Surprisingly, through blind comeptition, they end up co-operating and helping each other out. This is an example of an emergent phenomenon, where “more is different”.
Choose how many caterpillars you want.
Choose how far you want them to be able to see.
Click on the Start button to place the caterpillars.
Click on Go! to start them moving.
Drag the speed slider to make it faster or slower.
You’ll see that as caterpillars try to overtake each other, they form moving trains of caterpillars (a rolling swarm).
In the plot of caterpillar speed, watch the green line (the average speed of caterpillars). The blue line is the speed that a caterpillar has moving by itself. Notice that when they swarm, they all speed up, on average.
Watch how a single caterpillar (shown in spotlight, in red) moves through the swarm. It should spend some of its time moving slowly on the ground, and some of its time moving fast in the higher layers.
Can a caterpillar cheat by staying on the top layer? (No, because it’ll be thrown off by its higher speed.)
Can you make a rolling swarm out of a handful of caterpillars (fewer than 5)? Try playing with the range to get it to work.
Now add more caterpillars. What do you need to do to get them to swarm?
It’s possible to get two separate moving swarms, but a little tricky. Can you get it to happen? Why doesn't it last?
What do you need to do to get four layers in your swarm? Can you go further?
As you increase the number of layers in the swarm, what happens to the speed? Can you devise a relation between the number of layers and the speed?
Here’s my blog post on the science of these swarming caterpillars
And here’s an incredible article by Ed Yong on the science of swarming
What other features could you easily include to make this model more realistic?
For different numbers of caterpillars, is there a minimum or maximum range that you need to form swarms? Advanced: could you make a plot of range versus number of caterpillars, that shows when the caterpillars swarm and when they don’t. Is there a phase transition - a sudden change from non-swarming to swarming behavior?
I created this model in NetLogo by modifying the code for the following model of traffic:
* Wilensky, U. (1997). NetLogo Traffic Basic model. http://ccl.northwestern.edu/netlogo/models/TrafficBasic. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
Copyright 2013 Aatish Bhatia. Based on the NetLogo Traffic Basic model (1997) by Uri Wilensky.
This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
globals [ sample-car ] turtles-own [ speed speed-limit speed-min ] to setup clear-all ask patches [ setup-road ] setup-cars reset-ticks ;watch sample-car end to setup-road ;; patch procedure if (pycor < 5) and (pycor > -5) [ set pcolor white ] end to setup-cars set-default-shape turtles "caterpillar" crt number-of-caterpillars [ set color green set size 3 set xcor random-xcor set ycor -4 set heading 90 ;;; set initial speed to be 1 and speed limit to be 5 set speed 1 set speed-limit 5 set speed-min 1 separate-cars ] set sample-car one-of turtles ask sample-car [ set color red ] end ;collision detection and climb function ;so we don't end up with any two cars on the same patch to separate-cars ;; turtle procedure let other-cars-here one-of other turtles-here let car-above one-of turtles-on patch-at 0 1 if any? other turtles-here and (car-above = nobody) [ ;match speed ;set speed [speed] of other-cars-here ;move one step up left 90 forward 1 right 90 ;increment speed by one set speed speed + 1 ;repeat if needed separate-cars ] ;prevents pileups when there isn't space to move up if any? other turtles-here and (car-above != nobody) [ ;match speed set speed [speed] of other-cars-here back 1 separate-cars ] end to fall ;; turtle procedure ;check to see if there is anyone below let car-below one-of turtles-on patch-at 0 -1 ;if not, and you're above the ground level if (car-below = nobody) and (ycor > -4) [ ;fall one step down rt 90 fd 1 lt 90 ;reduce speed by one step set speed speed - 1 ;repeat if needed fall ] end to go ask turtles [ ; if there is a car ahead of you, exceed its speed let car-ahead one-of turtles-on patch-ahead range if (car-ahead != nobody) [ set speed [speed + 1] of car-ahead ] ; if not, slow down to minimum speed let car-below one-of turtles-on patch-at 0 -1 if (car-ahead = nobody) and (ycor = -4) ;(car-below = nobody) [ set speed speed-min ] if (car-ahead = nobody) and (car-below != nobody) [ set speed [speed + 1] of car-below ] ; don't slow down below speed minimum or speed up beyond speed limit ;if speed < speed-min [ set speed speed-min ] if speed > speed-limit [ set speed speed-limit ] ;increment position fd speed ] ask turtles [ ;collision detection separate-cars ] ask turtles [ ;fall function fall ] tick end