Fads And Fashions Two Choices
WHAT IS IT?
A two-choice polling game where turtles choose a color based upon the color of turtles they have encountered. Turtles change color (if change is necessary) after decision-time meetings, to the color of the turtles met most often if majority rule is in effect (or least often if minority rule is in effect.).
HOW TO USE IT
"total-turtles" controls the number of turtles created. "percent-red" controls the percentage of red turtles. "decision-time" controls the number of meetings after which a turtle will decide to change color or not. "wiggle-angle" sets the maximum random angle of side-to-side "wiggling" turtles will do as they walk. "rt-bias" and "lt-bias" bias the direction walked by each turtle by a number of degrees right or left. Click the setup button to setup agents using the user-defined values. Click the majority button to run the simulation using the majority rule or click the minority button to run the simulation using the minority rule Click the Graph-it button to activate the graphing. Click stopall to stop the program.
THINGS TO NOTICE
Watch the plot to see how populations of red and green turtles change over time. You can also watch the reds and greens monitors to see how the values change over time. Be sure to look at both the Plot Window and the 2D representation of the color distribution. What are the effects of clustering on the system over time? Why does clustering occur?
EXPLORATIONS
Try setting right-bias to 30 degrees, wiggle-angle to 10 degrees, the population to around 500, and try each of the majority and minority buttons for ten or fifteen minutes. Try this again without a bias. What is the influence of a high right or left bias?
Turtle procedures
turtles-own [
numred ; number of red turtles encountered
numgreen ; number of green turtles encountered
]
globals [
MajorityRule ; is Majority rule the one to follow?
MinorityRule ; is Minority rule the one to folllow?
]
;; majority procedure
;; called by the majority button
;; Sets Majority rule in effect and calls go repeatedly.
;;
to majority
set MajorityRule true
set MinorityRule false
go
end
;; minority procedure
;; called by the minority button
;; Sets Minority rule in effect and calls go repeatedly.
;;
to minority
set MajorityRule false
set MinorityRule true
go
end
;; go procdure
;; called by the majority and minority procedures
;; Turtles wiggle, grab a partner and add the partner to their current count
;; of red or green turtles encountered. If the total number of turtles
;; encountered equals the decisiontime set by the user using the decisiontime
;; slider, then check to see whether there are more reds or greens and decide
;; which color to turn to based on whether majority or minority rule is in
;; effect. Once a decision has been made, reset the turtle's count of reds
;; and greens encountered back to 0.
;; If all the turtles are now one color then stop the program.
;;
to go
wiggle
grab one-of-turtles-here [
if (color-of partner) = red
[setnumred numred + 1]
if (color-of partner) = green
[setnumgreen numgreen + 1]
if numred + numgreen = decisiontime
[
if numred > numgreen and MajorityRule = true
[setc red]
if numgreen > numred and MajorityRule = true
[setc green]
if numred > numgreen and MinorityRule = true
[setc green]
if numgreen > numred and MinorityRule = true
[setc red]
setnumred 0
setnumgreen 0
]
]
if (count-color red) = 0 or (count-color green) = 0 [stopall]
end
;; wiggle procedure
;; called by the go procedure
;; A fixed amount set by the user (rt-bias or lt-bias) is added to a random
;; quantity between 0 and the user-defined wiggle-angle. The turtle turns
;; right then left and goes forward 1 step.
;;
to wiggle
rt ((random wiggle-angle) + rt-bias)
lt ((random wiggle-angle) + lt-bias)
fd 1
end
Observer procedures
;; setup procedure
;; called by the setup button
;; Clears all, creates user-specified number of turtles (totalturtles slider.)
;; Sets the turtle's position and color then sets up the graph.
;; (n.b. the graphs are set up the old way, now we can use the plot wizard)
;;
to setup
ca
crt totalturtles
ask-turtles [
setxy random screen-width random screen-height
ifelse (random 101) > percentred
[setc green]
[setc red]]
setup-graph
end
;; setup-graph
;; called by the setup procedure
;; Creates the graph: title, axes and colors for the curves
;;
to setup-graph
pp 1 ppreset setppc green
pp 2 ppreset setppc red
setplot-title "Red or Green Chile?"
setplot-yrange 0 100
setplot-xrange 0 100
viewplot
end
;; graph-it procedure
;; called by the graph-it button
;; Graphs the number of individuals who chose each kind of chile.
;;
to graph-it
pp 1 ppd plot count-color green
pp 2 ppd plot count-color red
end
