Surface Area
WHAT IS IT?
This project explores the impact of surface area on speed of consumption. In this model, each of the three buttons (make 1 square, make 4 squares, and make 16 squares) draw the same number of red patches. (32 X 32 = 1024 patches of red.) The difference is that "make 1 square" draws a single 32 X 32 square "make 4 squares" draws four 16 X 16 squares "make 16 squares" draws sixteen 8 X 8 squares The agents move around the environment and "eat" red patches they encounter. Will the agents eat the piles of single large pile of food slower, faster or at the same speed as the smaller piles of food?
HOW TO USE IT
Click the SETUP button to setup the agents. Click one of the make_square buttons to draw the piles of food. Notice that if agents are on the same patch as the food, they are moved off the food. Click the GO button to start the simulation. The number of turtles slider controls the initial number of agents.
THINGS TO NOTICE
Watch the plot window to see how the number of red patches changes over time.
EXPLORATIONS
What accounts for the difference in speed of eating the piles? What happens when you press more than one of the make__square buttons then run the simulation?
Turtle procedures
;; go procedure
;; called by the observer go procedure
;; Turtles check to see if they are on a red patch, and if they are, they stamp
;; it black, turn around and go two steps before going on. After a short wait,
;; all turtles go forward 1 step.
;;
to go
if pc = red [
stamp black
rt 180
fd 2
]
wait (0.005 / number * 0.4)
fd 1
end
;; relocate procedure
;; called by the make__square observer procedures and recursively by itself.
;; Wiggles and jumps a random distance between 0 - 49. If that patch is red,
;; the procedure calls itself (and will eventually find an empty patch.)
;;
to relocate
rt random 20
lt random 20
jump random 50
if pc = red [relocate]
end
Observer procedures
patches-own [
square1
square4
square16
]
;; setup procedure
;; called by the setup button
;; Clears the plots, graphics and turtles, BUT not the patches.
;; Creates the number of turtles indicated on the slider, turns them yellow, and
;; moves them to random positions on the screen.
;;
to setup
clearplots
cg
ct
crt number
ask-turtles [setc yellow]
ask-turtles [
repeat 50 [
fd 5
seth random 360
]
]
end
;; go procedure
;; called by the go button
;; Asks all turtles to execute the turtle go procedure
;; and if there are no more red patches, the program stops.
;;
to go
ask-turtles [go]
if (count-pc red) = 0 [stopall]
end
;; make1square procedure
;; called by the "make 1 square" button
;; All patches store 3 different settings:
;; one for the single 32 X 32 square
;; one for the four 16 X 16 squares
;; one for the sixteen 8 X 8 squares
;; This procedure sets up the canvas to show the one 32 X 32 square in red
;; If any turtles live on this square, they get relocated to a black patch.
;;
to make1square
ask-patches [
if square1 = 1
[setpc red]
]
ask-turtles [
if pc = red [relocate]
]
end
;; make4square procedure
;; called by the "make 4 squares" button
;; All patches store 3 different settings:
;; one for the single 32 X 32 square
;; one for the four 16 X 16 squares
;; one for the sixteen 8 X 8 squares
;; This procedure sets up the canvas to show the four 16 X 16 squares in red
;; If any turtles live on this square, they get relocated to a black patch.
;;
to make4square
ask-patches [
if square4 = 1
[setpc red]
]
ask-turtles [
if pc = red [relocate]
]
end
;; make16 square procedure
;; called by the "make 16 squares" button
;; All patches store 3 different settings:
;; one for the single 32 X 32 square
;; one for the four 16 X 16 squares
;; one for the sixteen 8 X 8 squares
;; This procedure sets up the canvas to show the sixteen 8 X 8 squares in red
;; If any turtles live on this square, they get relocated to a black patch.
;;
to make16square
ask-patches [
if square16 = 1
[setpc red]
]
ask-turtles [
if pc = red [relocate]
]
end
