Helping_vs_Harming

Helping_vs_Harming preview image

1 collaborator

Default-person Joe Blass (Author)

Tags

(This model has yet to be categorized with any tags)
Parent of 1 model: Child of Helping_vs_Harming
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.2.0 • Viewed 383 times • Downloaded 58 times • Run 0 times
Download the 'Helping_vs_Harming' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model explores how the circumstances of a society can lead members of that society to attempt to exploit other members, protect themselves and other members from exploitation, or do nothing. The model is designed to show population change over time, as successful members of the society pass on the traits that made them successful to their children. Success is encoded with a parameter called social-currency, which is a stand-in for status, fitness, wealth, influence, and reputation in general. The idea is that only members above a certain social-currency status are able to find mates and reproduce.

A run of the model does not start at the creation of a society, but with a small society whose members encode particular sets of social values. At the beginning of each run, members of the society are overall likely to exploit, protect, or do nothing based on parameters set by the user. Over time the society's trends towards action will change based on what is rewarded and what is punished.

HOW IT WORKS

There are five global parameters set by the user, although I encourage you to only experiment with the three mentioned next. Theft-threshold and protection-threshold define the initial make-up of the society. Probability-of-getting-away indicates the global likelihood that a turtle who steals will not be caught.

Each turtle has their own theft threshold, protection threshold, and social currency (all turtles start with the same amount of social currency). Theft and protection thresholds are set for initial turtles by taking the global parameters and choosing a number within 5 of that parameter. Turtles born during the simulation have the average of their parents’ parameters, again with up to 5 degrees of randomness. The theft threshold and protection threshold are set such that 0 <= theft threshold < protection threshold <= 100.

At each tick, turtles select an action to perform as follows. First they pick a randeom number X between 0 and 100. If X < theft-threshold (for that particular turtle), they steal. If they steal, they also determine whether they are sneaky enough to get away with their theft. They do so by picking a number between 0 and 100; if the number is below the probability of getting away, they are sufficiently sneaky. If the action selection variable X < protect-threshold, turtles do nothing. Otherwise, protect-threshold <= X <= 100, and they protect. All turtles select an action before performing the action.

Actions are resolved as follows. Turtles who steal have a chance of getting away undetected; if they are not caught by a turtle who is protecting, they siphon social currency from their neighbors. If these thieving turtles are caught stealing, they give social currency to their neighbors who chose to protect, that is the turtles who caught them in the act. Turtles who protect against a thieving neighbor take social currency from that neighbor. If a turtle who protects fails to catch a turtle trying to steal, then it is punished for being a nosy busybody by giving up social currency to all of its neighbors. Turtles who do nothing can be stolen from, or can be rewarded if they have nearby protectors who do not catch any thieves. Otherwise, nothing happens to them.

There is a constant unit of social gain, set within the model to 7 (this can be changed from the code tab). Thieves who successfully steal get that amount, and all the turtles they steal from lose a fraction of that amount corresponding to the number of turtles stolen from. Turtles who successfully protect get that same amount from each stealing turtle they catch, divided amongst themselves and the other protectors who caught that same turtle. Turtles who protect and fail to catch a thief lose that same amount, divided amongst all their neighbors.

If turtles gain social currency above a particular threshold, set by the user, they can reproduce with another turtle above that threshold (at most once per tick for both turtles). They have one child, whose internal parameters have the average of their parents’ internal parameters, plus some randomness. Therefore if the parents were being rewarded for being likely to perform a particular behavior, then the children are more likely to display that behavior. Turtles also die after they reach their life expectancy, or if their social currency dips to zero.

HOW TO USE IT

SETUP button --- sets up the model by creating turtles and setting global parameters. There are initially 300 turtles.

GO buttons --- runs the model, either continuously or by a single tick.

THEFT-THRESHOLD slider --- sets the initial global threshold for stealing, which each setup turtle sets its internal parameters around as described in the How It Works section. The %likelihood of stealing = theft threshold

PROTECTION-THRESHOLD slider -- sets the initial global threshold for protecting, which each setup turtle sets its internal parameters around as described in the How It Works section. The %likelihood of protecting = (100- protection treshold)

Remember that, because of how actions are selected, a theft threshold set to 33 and a protection threshold set to 66 means that turtles are initially EQUALLY likely to steal, do nothing, or protect. The %likelihood of doing nothing is (protect threshold - theft threshold).

PROBABILITY-OF-GETTING-AWAY slider --- defines how likely a turtle who steals is to avoid being caught. This likelihood is independent of how many turtles are protecting near the thieving turtle. This is a global parameter that affects all turtles and does not change over time.

MATE-THRESHOLD slider --- defines how much social-currency a turtle needs to be able to reproduce. This parameter is global and does not change over time.

INITIAL-SOCIAL-CURRENCY slider --- defines how much social-currency turtles are born with (initially and for turtles born to parents). This parameter is global and does not change over time, although turtles' individual social currency potentially changes at each tick.

TIME-LIMIT? switch --- if true, stops the model automatically after 1000 ticks or when population reaches 5000.

VERBOSE? switch --- if true, has NetLogo display an error message if a user attempts to set theft-threshold > protect-threshold.

VISUALIZATION TOOLS There are six visualization tools: four monitors and two charts. * The monitors display the population of turtles and the proportion of total turtles who performed each of the four possible actions the previous turn. * The top chart, Proportion of Actions by Turn, displays the proportion of turtles taking each action over time. This provides a way of visualizing population change over time: if actions are selected for, then parents more likely to perform those actions are rewarded and pass their traits on to their children, who are more likely in turn to perform those actions. * The bottom chart, Proportion of Turtles by Type, displays the proportion of turtles who have performed a particular action more than ten times. Turtles can be of multiple types; the Mixed line indicates turtles who have protected and stolen more than ten times each. This chart provides an alternate visualization for the types of actions being selected for.

THINGS TO NOTICE

How sensitive is the model to varying probability of getting away? How does probability of getting away change which actions are selected for? Does it affect how many mixed turtles there are?

In general, models run best when initial-social-currency is approximately 20 and mate-threshold is approximately 60. That is, these parameters tend not to affect what traits are selected for, but more how fast or slowly populations change and grow. If you find that the population dies out quickly or explodes, try slightly adjusting the mate-threshold.

THINGS TO TRY

  1. Start by leaving theft-threshold at 33 and protection-threshold at 66, and varying probability-of-getting-away. Try probability-of-getting-away = 50, probability-of-getting-away = 55, probability-of-getting-away = 60, and probability-of-getting-away = 70. What changes? Note that, depending on the randomness inherent in setup, many of these runs may end quite early. If that happens, try again.

  2. Now change the theft and protection sliders. What happens if you make one extremely likely? What happens if you make doing-nothing extremely unlikely? What happens if you make both theft and protection unlikely?

  3. In general, models run best when initial-social-currency is approximately 20 and mate-threshold is approximately 60. Why? Try changing these parameters. What happens? How do changes in mate-threshold and initial-social-currency affect the model? What leads to changes in population size? What happens if mate-threshold <= initial-social-currency?

EXTENDING THE MODEL

  • One thing majorly missing is any sort of cognition. A first take would be to have turtles select actions based on some sort of reasoning, instead of random numbers.
  • There should be more of a reward for doing nothing, as currently nearly all parameter settings select against doing nothing.
  • social-gain could be changed to not be constant, such that turtles who successfully steal get more from each turtle they steal from, for example.
  • Turtles could be able to specialize in particular actions
  • Probability of getting away could be personalized to each turtle, such that some turtles are better at deception than others.
  • Similarly, protecting turtles could be made to be better or worse at detecting exploitations.
  • Turtles could get social-currency from their parents, rather than all be born with the same levels.

RELATED MODELS

This model is related to the altruism model. There is also a corresponding HubNet model on Modeling Commons.

CREDITS AND REFERENCES

This model was developed by Joseph Blass as a final project for Uri Wilensky's Multi-Agent Modeling course at Northwestern University, Spring 2015.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;;; originally all the globals were able to be set by the user; too many damn parameters! 
;;; Now they are set in setup; the indicated settings provide some nice behavior
globals [
  number-of-turtles
  social-radius
  social-gain  
  life-expectancy
]

turtles-own [
  ;;; internal setting variables
  social-currency
  p-theft
  p-protect
  age
  my-life-expectancy
  num-neighbors
  
  ;;; color variables
  r
  g
  b
  
  ;;; turn variables
  take-action
  my-neighbors
  got-away?
  
  ;; reproduction variables
  can-breed?
  my-mateworthy-neighbors
  my-mate
    
  ;;; helper variables
  random-choice-num ;;; every turn a turtle uses random to pick what to do; this is so we can pick one random number per turn in the ifelse block
  my-count ;; this is just a placeholder variable; not at all necessary for logic but is handy to avoid retyping code blocks
  ]

to setup
  ;;; initialize world block
  ca
  
  if (protect-threshold < theft-threshold) [ ;;; verbose is just there to be able to turn this message off for behavior-space experiments
    if verbose? [user-message "Oops: the protection threshold must be larger than the theft threshold"]
    stop
  ]
  
  ;;; set globals to some nice defaults
  set number-of-turtles 300 ;;; This mostly affects how fast things change; doesnt majorly affect the outcome of the model
  set social-radius 10 ;;; if this is smaller turtles tend to die out quickly
  set life-expectancy 40 ;;; much less than 50 and turtles die out before reproducing; much more and everything just slows down. Might as well specify instead of making it user-set.
  set social-gain 8 ;;; NOTE: in a different model, social-gain would be a crucial parameter to vary! 
  ;;; However, in this model it doesn't make things that interesting, just move faster.
  ;;; I think this is because this model is set up such that it's a constant increment, that is, turtles only ever gain or lose
  ;;; a maximum of social-gain divided amongst neighbors, rather than from each neighbor. Also, social-currency is not a zero sum game 
  ;;; (since turtles are born with social-currency). I thought it made sense to hide it from the user for simplicity
   
  ask patches [ set pcolor grey ] ;;; turtles are initialized black and can end up white, so grey background is best
  
  ;;; set up run block
  crt number-of-turtles [
    ;;; initialize color and location. we are going to do some color math so we have to do this a little hamfistedly
    set r 0
    set g 0
    set b 0
    set color rgb r g b ;; everyone starts off green, randomly placed in the world, with equal social currency
    set size 2
    setxy random-xcor random-ycor
    
    ;; internal variables
    set can-breed? (social-currency > mate-threshold)
    set social-currency initial-social-currency
    set p-theft (theft-threshold - 5 + random 11) ;; everyone has their own theft threshold within 5 of the set threshold
    set p-protect (protect-threshold - 5 + random 11) ;; ditto protection threshold
    if p-theft >= p-protect [set p-theft (p-protect - 1)] ;; make sure p-theft < p-protect; this gives preference to protection rather than theft. call me old-fashioned.
    set age 0
    set my-life-expectancy (life-expectancy - 5 + random 11)
    set got-away? false
  ]
  
  reset-ticks
end 

to go
  if (count turtles = 0) [stop]
  if time-limit? ;; do we want the model to eventually halt?
  [ if (count turtles > 5000 or ticks > 1000) [stop]] 
  ;;; these population/tick limits were decided upon by seeing where the model 
  ;;; starts to slow down enormously and by which point clear trends have emerged.  Note that
  ;;; these settings are much larger than is normally needed to see those trends.
  
  ;;; first code block resets internals, moves the turtles, and picks what to do
  ask turtles [
    
    turn-reset ;;; resets internal variables
    ;;; move
    rt random 360 ;; turtles wiggle and move randomly
    fd 5 ;; take a few steps
    
    ;;; pick an action. Actions will actually happen during the resolution phase
    ;;; this does NOT have to happen after ALL the turtles have moved because they are just picking what
    ;;; they WILL do, they are not actually doing it yet
    set random-choice-num random 100
    ifelse (random-choice-num < p-theft) 
    [ set take-action "steal" 
      ifelse (random 100 < probability-of-getting-away) ;; if you steal, figure out whether you get away with it (independent of who's watching)
      [ set got-away? true]
      [ set got-away? false]]
    [ ifelse (random-choice-num < p-protect) ;; if we got here that means p-theft < choice-num < p-protect
      [ set take-action "do-nothing" ] ;; and we do nothing
      [ set take-action "protect" ] ;; otherwise we protect
    ]
  ]  
  
  ;;; resolve performs the actions and resolves the consequences
  ;;; has to happen after all turtles have moved and chosen their actions
  ask turtles [resolve] ;; within resolve, functions to actually perform actions are called
  
  ;;; update social currency and age and check to see if turtles die
  ;;; death here may be redundant with the fact that they die at the beginning of the turn.
  ask turtles [
    if (social-currency > 100) [ set social-currency 100 ]
    if (social-currency <= 0) [ die ] ;; turtles at zero die
    if (age > my-life-expectancy) [ die ]
    set age (age + 1)
  ]
  
  ask turtles [ if can-breed? [ reproduce-if-possible ]] ;;; after all actions are resolved, turtles reproduce if they can
  
  tick
end 

to turn-reset
    ;;; reset some information at each tick
    set my-mate false ;; reset mate info
    set got-away? false 
    set color rgb r g b ;;; reset color
    set can-breed? (social-currency > mate-threshold) ;;; reset breeding status
    set my-neighbors other turtles in-radius social-radius ;; figure out who your neighbors are
    set num-neighbors count my-neighbors
    ;;; turtles have the opportunity to die at the beginning and end of turns
    ;;; at the beginning in case they are too old
    ;;; at the end so that turtles about to die do not have a chance to reproduce
    if (social-currency <= 0) [ die ] ;; turtles at zero die
    if (age > my-life-expectancy) [ die ]
end 

;;; calls the particular resolution functions

to resolve
  ifelse (take-action = "steal")
  [ steal ]
  [ ifelse (take-action = "protect") 
    [ protect ]
    [ do-nothing ]
  ]
end 

to steal
  ;;; note that steal actually handles MOST of what happens to turtles, i.e., both thieves and protectors  
  ;;; in this implementation, a successful thief takes TOTAL social-gain divided amongst the victims. 
  ;;; another possibility would be to have it take a social-gain from EACH victim
  ifelse (got-away? or not any? my-neighbors with [take-action = "protect"]) ;; if no one is watching out for thieves or you get away with it
  [ if (num-neighbors > 0) ;; provided you have neighbors
    [ set social-currency (social-currency + social-gain) ;; get social-gain from chumpy neighbors
      ask my-neighbors [set social-currency (social-currency - (social-gain / [num-neighbors] of myself))] 
    ] ;; each neighbor loses social-gain/count neighbors
  ]    ;;; if you have no neighbors, don't sweat it, you do nothing.
     
  ;;; otherwise, someone is watching out for thieves AND you got caught
  [ set my-count (count my-neighbors with [take-action = "protect"])
    set social-currency (social-currency - social-gain) ;; lose social-gain
    ask my-neighbors with [take-action = "protect"]
      [ set social-currency (social-currency + (social-gain / [my-count] of myself))]  ;;; protectors don't each get social-gain, since the more protectors you have, the less each protection matters
  ]
  
  ;;; thieves turn redder regardless of whether they were successful in stealing or not.  That's because 
  ;;; color is only used as a visualization tool and to help the system track how many times turtles
  ;;; have ATTEMPTED a particular action.
  ifelse (r < 230)
    [ set r (r + 25) ]
    [ set r 255 ]
end 

to protect
  ;;; catching thieves is handled by the steal function
  set my-count (count my-neighbors with [take-action = "steal" and not got-away?])
  if (my-count = 0) ;; if none of your neighbors tried to steal and did not get away with it, then you are being a busybody
    [ set social-currency (social-currency - social-gain) ;; lose social-gain 
      ask my-neighbors [set social-currency (social-currency + (social-gain / [num-neighbors] of myself))]
    ] ;;; all your neighbors are smugly satisfied with themselves and each other
  
  ;;; otherwise, someone has tried to steal
  ;;; but we don't have to do anything because it is handled by the steal function
  
  ;;; protectors turn bluer
  ifelse (b < 230) ;;; turtles who are protectors turn bluer
  [ set b (b + 25) ]
  [ set b 255 ]
end 

to do-nothing
  ;;; the only thing we need to do within this function is change the color a bit
  ;;; gaining or losing social value is handled by other functions.
  ifelse (g < 230) ;;; show the turtle's guilt by turning it redder
  [ set g (g + 25) ]
  [ set g 255 ]
end 

to reproduce-if-possible
  ;; only called by turtles who can reproduce, so we don't have to check within the function
  set my-mateworthy-neighbors my-neighbors with [can-breed? and (my-mate = false)] ;; my-mate is set to false at the beginning of each tick
  if any? my-mateworthy-neighbors
  [ set my-mate max-one-of my-mateworthy-neighbors [social-currency]
    ask my-mate [ set my-mate true ] 
    ;;; I know it's a bit odd to have the my-mate variable be a combination of booleans and agents, but this should still work
    ;;; the point is to have my-mate bound or not. We do it this way so that turtles don't mate twice per turn
    hatch 1 [
      set social-currency initial-social-currency
      set p-protect ((([p-protect] of myself + [p-protect] of [my-mate] of myself) / 2) - 5 + random 11) ;; average p-protect of parents, plus some randomness
      set p-theft ((([p-theft] of myself + [p-theft] of [my-mate] of myself) / 2) - 5 + random 11) ;; average p-theft of parents, plus some randomness
      if p-theft >= p-protect [set p-theft (p-protect - 1)] ;; make sure p-theft < p-protect; this gives preference to protection rather than theft. call me old-fashioned.
      set age 0
      set my-life-expectancy ((([my-life-expectancy] of myself + [my-life-expectancy] of [my-mate] of myself) / 2) - 5 + random 11)
      set got-away? false
      
      ;;; placement and color
      set r 0
      set g 0
      set b 0
      set color rgb r g b ;; no matter who your parents are, you start off innocent
      ;;; move a little
      rt random 360
      fd 3
    ]
  ]
end 

;;; reporters for charts

to-report proportion-of-thieving-turtles
  ifelse (count turtles = 0)
  [report 0]
  [ report count turtles with [r > 250] / count turtles]
end 

;;; next three reporters count the proportion of turtles of each "type"
;;; a turtle is of a type if they have performed a particular action ten times
;;; since each color starts at 0 and adds 25 each time an action is taken, we can 
;;; count types by seeing who has a color > 250.
;;; note that these will not sum to 1, since turtles are not necessarily of ANY type

to-report proportion-of-protector-turtles
  ifelse (count turtles = 0)
  [report 0]
  [ report count turtles with [b > 250] / count turtles]
end 

to-report proportion-of-placid-turtles
  ifelse (count turtles = 0)
  [report 0]
  [ report count turtles with [g > 250] / count turtles]
end 

to-report proportion-of-mixed-turtles
  ifelse (count turtles = 0)
  [report 0]
  [ report count turtles with [(r > 250) and (b > 250)] / count turtles]
end 

;;; next three reporters count the number of turtles who performed each of the three actions.

to-report turtles-who-just-stole
  report count turtles with [take-action = "steal"]
end 

to-report turtles-who-just-protected
  report count turtles with [take-action = "protect"]
end 

to-report turtles-who-just-did-nothing
  report count turtles with [take-action = "do-nothing"]
end 

;;; next three reporters count proportion of turtles who performed each of the three actions.
;;; they use the above three reporters.
;;; since all turtles do one of the three, these three values will always sum to 1.

to-report proportion-turtles-who-just-stole
  ifelse (count turtles = 0)
  [report 0]
  [ report turtles-who-just-stole / count turtles]
end 

to-report proportion-turtles-who-just-protected
  ifelse (count turtles = 0)
  [report 0]
  [ report turtles-who-just-protected / count turtles]
end 

to-report proportion-turtles-who-just-did-nothing
  ifelse (count turtles = 0)
  [report 0]
  [ report turtles-who-just-did-nothing / count turtles]
end 

;;; these next five reporters are for charts that are no longer included, but there was no reason to delete 
;;; the functions themselves.  If others want to visualize the breeding population, the functions are here.

;;; reports how many turtles can breed

to-report num-turtles-that-can-breed
  ifelse (count turtles = 0)
  [report 0]
  [ report count turtles with [can-breed?]]
end 

;;; uses previous reporter to report what proportion of all turtles can breed

to-report proportion-breeding-turtles
  ifelse (count turtles with [can-breed?] = 0)
  [report 0]
  [report ((count turtles with [can-breed?]) / count turtles)]
end 

;;; next three reporters report on the actions taken last turn by the turtles that can breed.
;;; ultimately these results are very similar to the overall actions taken so were not included.

to-report proportion-thieving-breeders
  ifelse (count turtles with [can-breed?] = 0)
    [report 0]
    [report ((count turtles with [can-breed? and (take-action = "steal")]) / num-turtles-that-can-breed)]
end 

to-report proportion-protecting-breeders
  ifelse (count turtles with [can-breed?] = 0)
    [report 0]
    [report ((count turtles with [can-breed? and (take-action = "protect")]) / num-turtles-that-can-breed)]
end 

to-report proportion-complacent-breeders
  ifelse (count turtles with [can-breed?] = 0)
    [report 0]
    [report ((count turtles with [can-breed? and (take-action = "do-nothing")]) / num-turtles-that-can-breed)]
end 

There are 8 versions of this model.

Uploaded by When Description Download
Joe Blass over 10 years ago Final version of model (info tab updated) Download this version
Joe Blass over 10 years ago Reverted to older version Download this version
Joe Blass over 10 years ago Reverted to older version Download this version
Joe Blass over 10 years ago Reverted to older version Download this version
Joe Blass over 10 years ago Final version of Helping vs. Harming model Download this version
Joe Blass over 10 years ago First version of Exploitation vs. Protection model Download this version
Joe Blass over 10 years ago Final version of Helping vs. Harming model Download this version
Joe Blass over 10 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Blass Poster Ad.pdf pdf Poster slam slides over 10 years ago, by Joe Blass Download
Blass_ABM_FinalProj_Poster.pdf pdf Final Project Poster: These sheets will be arranged in three columns of four sheets. first slide is a title. These slides are read by column, not by row over 10 years ago, by Joe Blass Download
Blass_Final_Proj_Proposal-v2.docx word updated design document over 10 years ago, by Joe Blass Download
Blass_Final_Proj_Proposal-v3.docx word Final Design Document over 10 years ago, by Joe Blass Download
Blass_Final_Proj_Proposal.docx word final project design document over 10 years ago, by Joe Blass Download
Blass_Final_Project_ABM_2015_v2.docx word Final Project Report over 10 years ago, by Joe Blass Download
Blass_Poster.pptx powerpoint poster over 10 years ago, by Joe Blass Download
Blass_status_update_5.18.docx word final project status update 1 over 10 years ago, by Joe Blass Download
Blass_status_update_5.25.docx word status update 2 over 10 years ago, by Joe Blass Download
Blass_status_update_6.1.docx word Final status update over 10 years ago, by Joe Blass Download
Helping_vs_Harming.png preview Preview for 'Helping_vs_Harming' over 10 years ago, by Joe Blass Download
Modeling Exploitative vs Protective Behavior_Blass_ABM2015 Final Project.pdf pdf Final Project Report over 10 years ago, by Joe Blass Download

This model does not have any ancestors.

Children:

Graph of models related to 'Helping_vs_Harming'