patches-own [ vote ;; my vote (0 or 1) total ;; sum of votes around me ] to setup ca ask patches [ set vote random 2 recolor-patch ] end to go ask patches [ set total (sum values-from neighbors [vote]) ] ;; use two ask patches blocks so all patches compute "total" ;; before any patches change their votes ask patches [ if total > 5 [ set vote 1 ] if total < 3 [ set vote 0 ] if total = 4 [ if change-vote-if-tied? [ set vote (1 - vote) ] ] if total = 5 [ ifelse award-close-calls-to-loser? [ set vote 0 ] [ set vote 1 ] ] if total = 3 [ ifelse award-close-calls-to-loser? [ set vote 1 ] [ set vote 0 ] ] recolor-patch ] end to recolor-patch ;; patch procedure ifelse vote = 0 [ set pcolor red ] [ set pcolor blue ] end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1998 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1998). NetLogo Voting model. ; http://ccl.northwestern.edu/netlogo/models/Voting. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Voting ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 276 10 741 496 45 45 5.0 0 10 1 1 1 CC-WINDOW 1 295 273 450 Command Center BUTTON 74 66 129 99 setup setup NIL 1 T OBSERVER T BUTTON 136 66 191 99 NIL go T 1 T OBSERVER T MONITOR 44 207 132 256 blue patches count patches with\n [ pcolor = blue ] 0 1 MONITOR 136 207 224 256 red patches count patches with\n [ pcolor = red ] 0 1 SWITCH 27 118 241 151 change-vote-if-tied? change-vote-if-tied? 1 1 -1000 SWITCH 27 152 241 185 award-close-calls-to-loser? award-close-calls-to-loser? 1 1 -1000 @#$#@#$#@ WHAT IS IT? ----------- This model is a simple cellular automaton that simulates voting distribution by having each patch take a "vote" of its eight surrounding neighbors, then perhaps change its own vote according to the outcome. HOW TO USE IT ------------- Click the SETUP button to create an approximately equal but random distribution of blue and red patches. Click GO to run the simulation. When both switches are off, the central patch changes its color to match the majority vote, but if there is a 4-4 tie, then it does not change. If the CHANGE-VOTE-IF-TIED? switch is on, then in the case of a tie, the central patch will always change its vote. If the AWARD-CLOSE-CALLS-TO-CLOSER? switch is on, then if the result is 5-3, the central patch votes with the losing side instead of the winning side. THINGS TO NOTICE ---------------- Watch how any setup quickly settles to a static state when both switches are off. Watch what happens when only the CHANGE-VOTE-IF-TIED? switch is on. How is the result different? Watch what happens when only the AWARD-CLOSE-CALLS-TO-LOSER? switch is on. How is the result different? What happens when both switches are on? EXTENDING THE MODEL ------------------- Try other voting rules. Start with a nonrandom red-and-blue pattern. For example, one could make half of the screen blue and half red. Can you enhance the model to incorporate multiple colors and multiple votes? One might interpret shades of color to represent the degree of a patch's opinion about an issue: strongly against, against, neutral, etc. Each patch could have more than two choices and weighted votes: blue patches' vote could count twice, etc. RELATED MODELS -------------- Ising (a physics model, but the rules are very similar) CREDITS AND REFERENCES ---------------------- This model is described in Rudy Rucker's "Artificial Life Lab", published in 1993 by Waite Group Press. To refer to this model in academic publications, please use: Wilensky, U. (1998). NetLogo Voting model. http://ccl.northwestern.edu/netlogo/models/Voting. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1998 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Voting for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 2.0beta5 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@