Prejudice Reduction
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is an agent-based model of neighbor interactions which uses evolutionary game-theory. It has implications for biology, sociology, social psychology, and social and political philosophy.
HOW IT WORKS
Agents (the little squares that don't go anywhere) are born with one of eight possible reactive strategies. Which strategy they get is determined purely by chance. interact with their neighbors one at a time, sum up the points they get from these interactions, and then see if any of their neighbors did better than they did.
HOW TO USE IT
This section could explain how to use the model, including a description of each of the items in the interface tab.
THINGS TO NOTICE
Notice that with default payoff values (Axelrod's prisoner's dilemma payoffs of 0,1,3,5), tit-for-tat (TFT) wins out.
THINGS TO TRY
This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
EXTENDING THE MODEL
This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
NETLOGO FEATURES
This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
RELATED MODELS
This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
CREDITS AND REFERENCES
Patrick Grim, "The Greater Generosity of the Spatialized Prisoner's Dilemma," Journal of Theoretical Biology 173 (1995), 353-359
Patrick Grim, "Spatialization and Greater Generosity in the Stochastic Prisoner's Dilemma," BioSystems 37 (1996), 3-17.
Patrick Grim, Gary Mar, and Paul St. Denis, The Philosophical Computer. MIT Press, 1998.
http://www.sunysb.edu/philosophy/faculty/pgrim/index.html
http://www.computationalphilosophy.org/
This NetLogo code was written by Will Braynen (July 2007) Ported to NetLogo 7.0.3 (January 2026)
Comments and Questions
;; Written by Will Braynen (June 2013). ;; ;; Software for an agent-based game-theoretic model of the contact hypothesis ;; of prejudice reduction, to accompany "Modeling Prejudice Reduction," ;; in the Handbook of Computational Social Psychology, adapted from ;; Public Affairs Quarterly 19 (2) 2005. ;; ;; REFERENCES ;; Grim, Patrick, Evan Selinger, William Braynen, Robert Rosenberger, ;; Randy Au, Nancy Louie, and John Connolly. 2005. ;; "Modeling Prejudice Reduction: Spatialized Game Theory and the Contact Hypothesis." ;; Public Affairs Quarterly 19 (2): 95–125. ;; ;; Based on work done by Patrick Grim. (See "The Philosophy Computer", ;; Grim, Mar, and St. Denis, MIT Press, 1998.) ;; ;; This is NetLogo code, so to run it, you need to install NetLogo: ;; http://ccl.northwestern.edu/netlogo/ ;; It's free. I recommend installing it and playing around with it and ;; this source code. NetLogo is the easiest programming environment ;; for agent-based modeling out there. ;; ;; PORTED TO NETLOGO 7.0.3 - January 2026 patches-own [ ethnicity strategy new_strategy behavior cooperated defected score ] globals [ total_cooperated total_defected is_show_ethnicities is_segregated ] ;; This procedure sets up the patches and patches to setup clear-all reset-ticks init-global-counters ;; ethnicities and (de)segregation set is_show_ethnicities false set is_segregated true ;; Initialize all patches ask patches [ init-patch ] display-agents end to init-patch ;; patch procedure init-patch-counters set strategy (random 9) ;; segregate by default. ;; if you change your mind though, ;; then use this code instead: ;; "set ethnicity (random 2)" ifelse (pxcor < 0) [ set ethnicity 0 ] [ set ethnicity 1 ] end ;; reset counters to init-patch-counters ;; patch procedure set score 0 set cooperated 0 set defected 0 end ;; maps ethnicity e1 to color to-report etchnicity-to-color [ e1 ] if (0 = e1) [ report red ] if (1 = e1) [ report green ] end ;; maps strategy s1 to color to-report strategy-to-color [ s1 ] if (0 = s1) [ report green ] if (1 = s1) [ report cyan ] if (2 = s1) [ report red ] if (3 = s1) [ report magenta ] if (4 = s1) [ report yellow ] if (5 = s1) [ report 7 ] ;; dark gray if (6 = s1) [ report 3 ] ;; light gray if (7 = s1) [ report blue ] if (8 = s1) [ report 27 ] ;; light orange end to display-agents ifelse is_show_ethnicities [ ask patches [ set pcolor (etchnicity-to-color ethnicity) ]] [ ask patches [ set pcolor (strategy-to-color strategy) ]] end ;; This procedure makes the patches do stuff: ;; (1) patches will interact with their eight neighbors ;; (2) patches will imitate their most successful neighbor (taking on their strategy or behavior, ;; depending on the model). Neighborhood in which to look at the best score should be variable ;; (i.e. nearest 4 neighbors, nearest 8 neighbors, nearest 16 neighbors, and so on till we ;; get to global knowledge; could also do this with a royal family). to go ;; patches interact ask patches [ play_with_neighbors ] ;; patches evolve ask patches [ evolve ] ;; Update patches' strategies ask patches [ set strategy new_strategy ] ;; Display the new strategies display-agents ;if (ticks > 30) [ stop ] init-global-counters ask patches [ count-total-cooperated ] my-update-plots tick end ; go to init-global-counters set total_cooperated 0 set total_defected 0 end ;;;;;;;;;;;;;; ;; ;; Start the main chunk of code specific to ethnicities ;; to show_ethnicities set is_show_ethnicities (not is_show_ethnicities) ; toggle ifelse is_show_ethnicities [ ask patches [ set pcolor (etchnicity-to-color ethnicity) ]] [ ask patches [ set pcolor (strategy-to-color strategy) ]] end to desegregate set is_segregated (not is_segregated) ; toggle ask patches [ init_ethnicity ] display-agents end ; a patch changes its ethnicity ; (or moves, depending on your point of view) to init_ethnicity ifelse is_segregated [ ifelse (pxcor < 0) [ set ethnicity 0 ] [ set ethnicity 1 ]] [ set ethnicity (random 2) ] end ;; ;; End the main chunk of code specific to ethnicities ;; ;;;;;;;;;;;;;; to my-update-plots ;; Strategies plot set-current-plot "Strategies" set-current-plot-pen "000 AllD" plot count patches with [strategy = 0] set-current-plot-pen "001" plot count patches with [strategy = 1] set-current-plot-pen "010 STFT" plot count patches with [strategy = 2] set-current-plot-pen "011" plot count patches with [strategy = 3] set-current-plot-pen "100" ;; C-then-AllD plot count patches with [strategy = 4] set-current-plot-pen "101" plot count patches with [strategy = 5] set-current-plot-pen "110 TFT" plot count patches with [strategy = 6] set-current-plot-pen "111 AllC" plot count patches with [strategy = 7] set-current-plot-pen "PTFT" plot count patches with [strategy = 8] ;; Behavior plot set-current-plot "Behavior" set-current-plot-pen "C" plot total_cooperated set-current-plot-pen "D" plot total_defected end ; update-plot to count-total-cooperated ;; patch procedure ;; increment total_cooperated by the number of times the current patch cooperated set total_cooperated (total_cooperated + cooperated) set total_defected (total_defected + defected) end to play_with_neighbors ;; patch procedure init-patch-counters ;; ;; eight neighbors to play with ;; set score (play-with 0 1 ; north + play-with 1 1 ; east-north (northeast) + play-with 1 0 ; east + play-with 1 -1 ; east-south (southeast) + play-with 0 -1 ; south + play-with -1 -1 ; west-south (southwest) + play-with -1 0 ; west + play-with -1 1 ; west-north (northwest) ) end to-report play-with [ x y ] ;; patch procedure ;; what is my strategy? let s1 (my-strategy x y) let s2 (neighbor-strategy x y) report payoff s1 s2 end ;; ;; x and y are coordinates of the neighbor I want to play with ;; to-report neighbor-strategy [ x y ] if (([strategy] of patch-at x y) != 8) ; I am not PTFT -- life is simple [ report ([strategy] of patch-at x y) ] if (([strategy] of patch-at x y) = 8) ; I am PTFT -- life is complicated [ ifelse (([ethnicity] of patch-at x y) = ethnicity) [ report 6 ] ; I am the same ethnicity as my neighbor, so I am TFT (110 = 6) [ report 0 ] ; I am not the same ethnicity as my neighbor, so I am AllD (000 = 0) ] end ;; ;; x and y are coordinates of the neighbor I want to play with ;; to-report my-strategy [ x y ] if (strategy != 8) ; I am not PTFT -- life is simple [ report strategy ] if (strategy = 8) ; I am PTFT -- life is complicated [ ifelse (ethnicity = ([ethnicity] of patch-at x y)) [ report 6 ] ; I am the same ethnicity as my neighbor, so I am TFT (110 = 6) [ report 0 ] ; I am not the same ethnicity as my neighbor, so I am AllD (000 = 0) ] end to evolve ;; patch procedure ;; Find fittest neighbor let fittest-neighbor max-one-of (patches in-radius imitation_radius) [score] ;; switch to the strategy/behavior of patch with highest score ;; if it's higher than yours. otherwise, keep your own! ifelse (score < [score] of fittest-neighbor) [ ;; imitate-behavior-of-successful-neighbor set new_strategy ([strategy] of fittest-neighbor) ] [ ;; keep your own! set new_strategy strategy ] end to increment_cooperated [ inc ] set cooperated (cooperated + inc) set defected (defected + (rounds_to_play - inc)) end ;; s1 is strategy1 ;; s2 is strategy2 to-report payoff [ s1 s2 ] ;; reporter ;; 000 if (s1 = 0) [ increment_cooperated (0) ] if (s1 = 0 and s2 = 0) [ report rounds_to_play * payoffs_dd ] if (s1 = 0 and s2 = 1) [ report payoffs_dd + (rounds_to_play - 1) * payoffs_dc ] if (s1 = 0 and s2 = 2) [ report rounds_to_play * payoffs_dd ] if (s1 = 0 and s2 = 3) [ report payoffs_dd + (rounds_to_play - 1) * payoffs_dc ] if (s1 = 0 and s2 = 4) [ report payoffs_dc + (rounds_to_play - 1) * payoffs_dd ] if (s1 = 0 and s2 = 5) [ report rounds_to_play * payoffs_dc ] if (s1 = 0 and s2 = 6) [ report payoffs_dc + (rounds_to_play - 1) * payoffs_dd ] if (s1 = 0 and s2 = 7) [ report rounds_to_play * payoffs_dc ] ;; 001 if (s1 = 1 and s2 = 0) [ increment_cooperated (rounds_to_play - 2) report payoffs_dd + (rounds_to_play - 1) * payoffs_cd ] if (s1 = 1 and s2 = 1) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 2) * payoffs_dd + (rounds_to_play / 2) * payoffs_cc ] if (s1 = 1 and s2 = 2) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 4) * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 1 and s2 = 3) [ increment_cooperated (1) report payoffs_dd + payoffs_cc + (rounds_to_play - 2) * payoffs_dc ] if (s1 = 1 and s2 = 4) [ increment_cooperated (rounds_to_play - 2) report payoffs_dc + payoffs_dd + (rounds_to_play - 2) * payoffs_cd ] if (s1 = 1 and s2 = 5) [ increment_cooperated (0) report rounds_to_play * payoffs_dc ] if (s1 = 1 and s2 = 6) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 4) * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 1 and s2 = 7) [ increment_cooperated (0) report rounds_to_play * payoffs_dc ] ;; 010 if (s1 = 2 and s2 = 0) [ increment_cooperated (0) report rounds_to_play * payoffs_dd ] if (s1 = 2 and s2 = 1) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 4) * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 2 and s2 = 2) [ increment_cooperated (0) report rounds_to_play * payoffs_dd ] if (s1 = 2 and s2 = 3) [ increment_cooperated (rounds_to_play - 2) report payoffs_dd + payoffs_dc + (rounds_to_play - 2) * payoffs_cc ] if (s1 = 2 and s2 = 4) [ increment_cooperated (1) report payoffs_dc + payoffs_cd + (rounds_to_play - 2) * payoffs_dd ] if (s1 = 2 and s2 = 5) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 4) * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 2 and s2 = 6) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 2) * payoffs_dc + (rounds_to_play / 2) * payoffs_cd ] if (s1 = 2 and s2 = 7) [ increment_cooperated (rounds_to_play - 2) report payoffs_dc + (rounds_to_play - 1) * payoffs_cc ] ;; 011 if (s1 = 3) [ increment_cooperated (rounds_to_play - 1) ] if (s1 = 3 and s2 = 0) [ report payoffs_dd + (rounds_to_play - 1) * payoffs_cd ] if (s1 = 3 and s2 = 1) [ report payoffs_dd + payoffs_cc + (rounds_to_play - 2) * payoffs_cd ] if (s1 = 3 and s2 = 2) [ report payoffs_dd + payoffs_cd + (rounds_to_play - 2) * payoffs_cc ] if (s1 = 3 and s2 = 3) [ report payoffs_dd + (rounds_to_play - 1) * payoffs_cc ] if (s1 = 3 and s2 = 4) [ report payoffs_dc + (rounds_to_play - 1) * payoffs_cd ] if (s1 = 3 and s2 = 5) [ report payoffs_dc + payoffs_cc + (rounds_to_play - 2) * payoffs_cd ] if (s1 = 3 and s2 = 6) [ report payoffs_dc + payoffs_cd + (rounds_to_play - 2) * payoffs_cc ] if (s1 = 3 and s2 = 7) [ report payoffs_dc + (rounds_to_play - 1) * payoffs_cc ] ;; 100 if (s1 = 4) [ increment_cooperated (1) ] if (s1 = 4 and s2 = 0) [ report payoffs_cd + (rounds_to_play - 1) * payoffs_dd ] if (s1 = 4 and s2 = 1) [ report payoffs_cd + payoffs_dd + (rounds_to_play - 2) * payoffs_dc ] if (s1 = 4 and s2 = 2) [ report payoffs_cd + payoffs_dc + (rounds_to_play - 2) * payoffs_dd ] if (s1 = 4 and s2 = 3) [ report payoffs_cd + (rounds_to_play - 1) * payoffs_dc ] if (s1 = 4 and s2 = 4) [ report payoffs_cc + (rounds_to_play - 1) * payoffs_dd ] if (s1 = 4 and s2 = 5) [ report payoffs_cc + payoffs_dd + (rounds_to_play - 2) * payoffs_dc ] if (s1 = 4 and s2 = 6) [ report payoffs_cc + payoffs_dc + (rounds_to_play - 2) * payoffs_dd ] if (s1 = 4 and s2 = 7) [ report payoffs_cc + (rounds_to_play - 1) * payoffs_dc ] ;; 101 if (s1 = 5 and s2 = 0) [ increment_cooperated (rounds_to_play) report rounds_to_play * payoffs_cd ] if (s1 = 5 and s2 = 1) [ increment_cooperated (rounds_to_play) report rounds_to_play * payoffs_cd ] if (s1 = 5 and s2 = 2) [ increment_cooperated (rounds_to_play / 2) report 50 * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 5 and s2 = 3) [ increment_cooperated (2) report payoffs_cd + payoffs_cc + (rounds_to_play - 2) * payoffs_dc ] if (s1 = 5 and s2 = 4) [ increment_cooperated (rounds_to_play - 2) report payoffs_cc + payoffs_dd + (rounds_to_play - 2) * payoffs_cd ] if (s1 = 5 and s2 = 5) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 2) * payoffs_cc + (rounds_to_play / 2) * payoffs_dd ] if (s1 = 5 and s2 = 6) [ increment_cooperated (rounds_to_play / 2) report 50 * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 5 and s2 = 7) [ increment_cooperated (1) report payoffs_cc + (rounds_to_play - 1) * payoffs_dc ] ;; 110 if (s1 = 6 and s2 = 0) [ increment_cooperated (1) report payoffs_cd + (rounds_to_play - 1) * payoffs_dd ] if (s1 = 6 and s2 = 1) [ increment_cooperated (rounds_to_play / 2) report 50 * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 6 and s2 = 2) [ increment_cooperated (rounds_to_play / 2) report (rounds_to_play / 2) * payoffs_cd + (rounds_to_play / 2) * payoffs_dc ] if (s1 = 6 and s2 = 3) [ increment_cooperated (rounds_to_play - 1) report payoffs_cd + payoffs_dc + (rounds_to_play - 2) * payoffs_cc ] if (s1 = 6 and s2 = 4) [ increment_cooperated (2) report payoffs_cc + payoffs_cd + (rounds_to_play - 2) * payoffs_dd ] if (s1 = 6 and s2 = 5) [ increment_cooperated (rounds_to_play / 2) report 50 * (payoffs_cc + payoffs_cd + payoffs_dc + payoffs_dd) ] if (s1 = 6 and s2 = 6) [ increment_cooperated (rounds_to_play) report rounds_to_play * payoffs_cc ] if (s1 = 6 and s2 = 7) [ increment_cooperated (rounds_to_play) report rounds_to_play * payoffs_cc ] ;; 111 if (s1 = 7) [ increment_cooperated (rounds_to_play) ] if (s1 = 7 and s2 = 0) [ report rounds_to_play * payoffs_cd ] if (s1 = 7 and s2 = 1) [ report rounds_to_play * payoffs_cd ] if (s1 = 7 and s2 = 2) [ report payoffs_cd + (rounds_to_play - 1) * payoffs_cc ] if (s1 = 7 and s2 = 3) [ report payoffs_cd + (rounds_to_play - 1) * payoffs_cc ] if (s1 = 7 and s2 = 4) [ report payoffs_cc + (rounds_to_play - 1) * payoffs_cd ] if (s1 = 7 and s2 = 5) [ report payoffs_cc + (rounds_to_play - 1) * payoffs_cd ] if (s1 = 7 and s2 = 6) [ report rounds_to_play * payoffs_cc ] if (s1 = 7 and s2 = 7) [ report rounds_to_play * payoffs_cc ] end
There is only one version of this model, created about 3 hours ago by William Braynen.
Attached files
| File | Type | Description | Last updated | |
|---|---|---|---|---|
| Prejudice Reduction.png | preview | Preview for 'Prejudice Reduction' | about 3 hours ago, by William Braynen | Download |
This model does not have any ancestors.
This model does not have any descendants.
Download this model