- Art
- Astronomy
- Biology
- Selection and Mutation Series
- Ant Patterns
- Bacterial Growth
- Bark Beetles
- Biological Buffer
- Birds Competing For Worms
- Color Bunnies
- Ecosystem - Predator, Prey, and Grass
- Ecosystem - Rabbits and Grass
- Ecosystem - Two Species
- Ecosystem With Predator, Prey, And Grass
- Forest Fire
- Honeycomb Formation
- Termites Perimeter
- Yeast Growth
- Chemistry
- Earth Science
- Mathematics
- Physics
- Social Science
Termites Perimeter
Submitted by librarian on Mon, 2006-08-07 14:58. :: Category
WHAT IS IT?
This model simulates one simplified aspect of termite behavior: mound building. The termites in this model follow a very simple general rule: when a termite finds a wood chip, it picks it up, and sets it down next to another chip.
This model does not capture (or even attempt to capture) all of the complexity of termite behavior. However, it demonstrates that, even with the simple rule described above, the aggregate result of individuals following the simple rule can be interesting, and even unexpected. Simply put, the whole is greater than the sum of its parts.
HOW IT WORKS
Each turtle (the termites in the model) wander randomly, until it finds a patch with a wood chip on it (based on the color of the patch), and without other turtles on the patch. When it does so, it changes the patch color and its own shape, to indicate that it has picked the chip up and is now carrying it. It then jumps randomly until it finds an empty patch, and then begins looking for another wood chip - which it does, again, by wandering randomly. When another chip is found, the turtle wanders randomly, looking for an empty patch adjacent to the chip (or to its neighboring chips); what that patch is found, the turtle changes the patch color and its own shape, to indicate that it has set the chip down.
As the process proceeds, a procedure is executed (every five seconds) to get a "snapshot" of the total perimeter of the wood chip piles (including piles made up of a single chip). This snapshot is plotted on a graph, so that the change in this value can be seen over time.
HOW TO USE IT
Specify the number of termite turtles to create with the "Number of Termites" slider.
Use the "Wood Chip Density" to control the percent of patches on which a wood chip will be placed. The process by which wood chips are placed involves randomness, so the actual percent will probably deviate from this value by a small amount.
Click the "Setup" button to create wood chips and termites. Any changes to the number of termites or the wood chip density will not take effect until this button is pressed.
Click the "Start" button to begin the process; this will start not only the gathering of chips by termites, but also the periodic polling & plotting of the total wood chip pile perimeter.
Click the "Stop" button to stop the wood gathering and perimeter plotting; the process can be restarted (with the "Start" button) after it is stopped in this fashion.
The plot shows the total wood chip pile perimeter, as the process proceeds. The plot is updated (as long as the "Plot" button is pressed) every five seconds, but the X axis of the plot is numbered according to the ordinal value of the updates: the first update (five seconds after the model is started) is plotted against an X value of 1; the second against an X value of 2; etc.
The "Plot" and "Gather" buttons are controlled by the "Start" and "Stop" buttons. In general, there is no need to press "Plot" or "Gather" directly; one exception would be if you wish to run the simulation of termites gathering wood, but are not interested in the perimeter plot - in which case, you could control execution simply with the "Gather" button.
THINGS TO NOTICE
At the start, many of the wood chips are isolated, individual chips. From the behavioral rules that the termites are following, it is clear that termites picking these chips up have no choice but to set them down next to other chips; thus, individual chips will usually be absorbed into larger piles fairly quickly.
EXPLORATIONS
Observe the process at least until there are only two piles of wood chips. If one pile is significantly larger than the other, do you think that will continue to be the case? Why is the number of piles decreasing?
What is happening in the plot of the total perimeter of the wood chip piles? Why is this happening? What is the sum of the perimeters of two isolated wood chips, vs. the perimeter of a pile made of two adjacent wood chips?
What two-dimensional geometric shape minimizes the perimeter for a given area?
The StarLogo canvas is actually not a rectangle, but a torus: the left and right edges wrap around to touch each other; the top and bottom edges do the same. Have you seen any wood chip piles that wrap around from one edge to the opposite edge?
Try running the model with a high wood chip density - 70%, for example. What shape of wood chip piles do you think will result? What about the shape of the open space(s)?
THINGS TO TRY
Set the number of termites to 100, the density to 15, click "Setup", and "Start". Watch how the distribution of wood chips changes as the process proceeds. What is happening to the chips?
Keep watching as the process proceeds. Do the wood chip piles tend to fall into a particular shape?
EXTENDING THE MODEL
The model could be extended to allow for mound building in the vertical direction, using patch color or other variables to represent the height of the mound. One important question to answer: What rules would be reasonable for determing whether a wood chip is placed adjacent to another, or on top of it?
STARLOGO FEATURES
The model uses the "nsum4" command to have each patch count how many wood chips are on the four surrounding sides. (Since the purpose of this computation is to compute perimeter, and since perimeter of a square is the sum of four sides, nsum4 is used instead of nsum.) "sum-of-patches-with" is then used to sum the difference between this number and four (the maximum number of wood chip neighbors a patch can have), for those patches which also have a chip; this sum is the total perimeter.
For the sake of simplicity and performance, the core simulation and the plotting of total perimeter are triggered by separate buttons, which are controlled in tandem with the "start{ButtonName}" and "stop{ButtonName}" commands. One implication of this approach is that the X-axis of the graphic plot is not necessarily proportional to "simulation time" - particularly when using the speed slider (at the top of the canvas) is used to slow down or speed up model execution.
CREDITS AND REFERENCES
This model is based on the Termites model included in the StarLogo Adventures Projects, and the book Adventures in Modeling, by Vanessa Colella, Eric Klopfer, and Mitchel Resnick (published by Teachers College Press, 2001); see
This version maintains the general behavior from the original model. However, some changes have been made to the implementation of the turtles behaviors, for the sake of code consistency and clarity. Additions to the observer procedures have also been made, to support computation of the total perimeter.
Turtle procedures
;; Procedure: setup-termite
;; Called by: setup procedure (observer)
;;
;; Set turtle shape & color for termite. Set random heading and position.
to setup-termite
setshape termite-shape
setcolor termite-color
setheading random 360
setxy (random screen-width) (random screen-height)
end
;; Procedure: gather-chips
;; Called by: Gather button
;;
;; High-level termite task: search for & pick up a chip; jump into the clear;
;; find another pile of chips to add to; find an empty spot for the chip, and
;; put it down; jump into the clear.
;;
to gather-chips
find-chip
pick-chip-up
get-away
find-new-pile
find-empty-spot
set-chip-down
get-away
end
;; Procedure: search-for-chip
;; Called by: gather-chips procedure (turtle)
;;
;; Check the current patch for the chip color, and no other turtles on the
;; patch. If found, stop; otherwise, wiggle and repeat.
;;
to find-chip
loop [
if ((patchcolor = chip-color) and (count-turtles-here = 1)) [
stop
]
wiggle
]
end
;; Procedure: pick-chip-up
;; Called by: gather-chips procedure (turtle)
;;
;; Change the patch color, chip variable, and turtle shape.
;;
to pick-chip-up
stamp background-color
setchip 0
setshape termite-wood-shape
end
;; Procedure: find-new-pile
;; Called by: gather-chips procedure (turtle)
;;
;; Check for the chip color on the current patch. If found, stop; otherwise,
;; wiggle and repeat.
;;
to find-new-pile
loop [
if (patchcolor = chip-color) [
stop
]
wiggle
]
end
;; Procedure: find-empty-spot
;; Called by: gather-chips procedure (turtle)
;;
;; Check for an unoccupied (by chips or other turtles) patch. If found, set the
;; chip down (by changing patch color and chip variable), change turtle shape,
;; and jump away; otherwise, wiggle and repeat.
to find-empty-spot
loop [
if ((patchcolor = background-color) and (count-turtles-here = 1)) [
stop
]
wiggle
]
end
;; Procedure: set-chip-down
;; Called by: gather-chips procedure (turtle)
;;
;; Change the patch color, chip variable, and turtle shape.
;;
to set-chip-down
stamp chip-color
setchip 1
setshape termite-shape
end
;; Procedure: get-away
;; Called by: gather-chips procedure (turtle)
;;
;; Jump repeatedly & randomly until a black patch is found.
;;
to get-away
loop [
setheading (random 360)
jump (random 20)
if (patchcolor = background-color) [
stop
]
]
end
;; Procedure: wiggle
;; Called by: find-chip, find-new-pile, find-empty-spot procedures (turtle)
;;
;; Move forward, and turn to a new heading by turning right and then left, by a
;; random amount each time.
;;
to wiggle
forward 1
right (random 50)
left (random 50)
end
Observer procedures
globals [
chip-color ; Color of wood chips
termite-color ; Color of termites
background-color ; Background color of canvas
total-perimeter ; Total perimeter of wood chips piles
]
patches-own [
neighboring-chips ; Variable for summing chips on neighboring patches
chip ; 1 if a chip is on the patch, 0 otherwise
]
;; Procedure: setup
;; Called by: Setup button
;;
;; Set constant values & background color. Create wood chips according to
;; specified density, and compute initial total perimeter. Create termite
;; turtles.
;;
to setup
clear-all
set chip-color (brown + 1)
set termite-color (green + 2)
set background-color black
setbg background-color
ask-patches [
if ((random 100) < density) [
setpatchcolor chip-color
setchip 1
]
]
update-perimeter
create-turtles-and-do number-termites [
setup-termite
]
end
;; Procedure: start-run
;; Called by: Start button
;;
;; Programmatically press Plot and Gather buttons.
;;
to start-run
startPlot
startGather
end
;; Procedure: stop-run
;; Called by: Stop button
;;
;; Programmatically stop Plot and Gather buttons.
;;
to stop-run
stopPlot
stopGather
end
;; Procedure: update-perimeter
;; Called by: Gather button, setup procedure (observer)
;;
;; Sum the chip flag from neighbors to all the patches. For those patches which
;; have a chip, and which have fewer than four neighbors with chips, sum all of
;; the neighbor chip counts; this gives a measure of the perimeter of all of the
;; wood chip piles (including those made up of only one chip).
;;
to update-perimeter
nsum4 chip neighboring-chips
set total-perimeter
(sum-of-patches-with [(chip = 1) and (neighboring-chips < 4)]
[4 - neighboring-chips])
end
4365 reads
