Institutional Formation

Institutional Formation preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.5 • Viewed 262 times • Downloaded 39 times • Run 0 times
Download the 'Institutional Formation' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

globals
[
  supergame
  danger
  turtle1
  turtle2
  tieturtles
  closerturtlelink
  closerturtle
  turtletrust
  globalcit
  gameturtle
  gameturtlelink
  worstturtlelink
  worstturtle
  globaltrust
  group-size        ;; current running size of group being explored
  biggestgroup
  groups            ;; list of connected components
  truststore
]

breed[boths both]
breed[As A]
breed[Bs B]
breed[nones none]

undirected-link-breed[connectors connector]

turtles-own
[
  group
  explored?    ;; used to compute connected components in the graph
]

links-own
[
  linkgroup
  instcit
  mutualtrust  ;; true if the link represents a loner joining a group
]


;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  set-default-shape turtles "circle"

  ;; Set up the turtles and their characteristics
  setup-turtles
  color-turtles
  setup-links
  color-links
  
  set globaltrust 0
  set danger 0
  ;find-all-components

  reset-ticks
end 

to setup-turtles
  create-turtles 100
  ask turtles [ 
    setxy random-xcor random-ycor
    ]
           
  ask turtles [
    if random 4 < buttonCCC [ set breed boths ]
    if breed != boths and random 3 < buttonA [ set breed As ]
    if breed != boths and breed != As and random 3 < buttonB [ set breed Bs ]
    if breed != boths and breed != As and breed != Bs [ set breed nones ]
  ]
end 

to setup-links
  ask turtles [ create-links-with other turtles ]
  ask links [
   set instcit 0
   set mutualtrust trustcontrol ;; Starting trust
    if (is-both? end1 = true) and (is-both? end2 = true) [set mutualtrust (mutualtrust + 30)]
    if (is-A? end1 = true) and (is-A? end2 = true) [set mutualtrust (mutualtrust + 20)]
    if (is-B? end1 = true) and (is-B? end2 = true) [set mutualtrust (mutualtrust + 20)]
    if (is-B? end1 = true) and (is-both? end2 = true) [set mutualtrust (mutualtrust + 20)]
    if (is-both? end1 = true) and (is-B? end2 = true) [set mutualtrust (mutualtrust + 20)]
    if (is-A? end1 = true) and (is-both? end2 = true) [set mutualtrust (mutualtrust + 20)]
    if (is-both? end1 = true) and (is-A? end2 = true) [set mutualtrust (mutualtrust + 20)]
    hide-link
]
end 

;;;;;;;;;;;;;;;;;;;;;;;
;;; Main Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;

to go
  
  ifelse supergameswitch = TRUE [
  set-supergame ]
  [set supergame 0]
  
  interact
  institutions
  if conflictswitch = TRUE [
  conflict ]
  groupsize
  tick
end 

to set-supergame
  let numberturtles count turtles
  set supergame (gamesleft * 1 * (1 / numberturtles))
end 

to interact
  
  carefully [
  
  ask turtles [
    
    fd 1
    
    let closelinks my-links with [link-length < 10]
    let dangerouslinks closelinks with [mutualtrust < 25]
    let coollinks closelinks with [mutualtrust >= 25]
    set closerturtlelink max-one-of coollinks [mutualtrust] ; the guy who he is most close to
    set gameturtlelink one-of coollinks
    set worstturtlelink min-one-of dangerouslinks [mutualtrust]
    
    if worstturtlelink != nobody [
    ifelse [who] of self != [who] of [end2] of worstturtlelink
    [set worstturtle [end2] of worstturtlelink]
    [set worstturtle [end1] of worstturtlelink]
    ]
    
    ifelse [who] of self != [who] of [end2] of closerturtlelink
    [set closerturtle [end2] of closerturtlelink]
    [set closerturtle [end1] of closerturtlelink]
    
    let x [xcor] of closerturtle
    let y [ycor] of closerturtle
    facexy x y
    fd 2
    
    if worstturtlelink != nobody [
    let xw [xcor] of worstturtle
    let yw [ycor] of worstturtle
    facexy xw yw
    bk 4
    ]
    
    if dangerswitch = TRUE [
    ifelse group != biggestgroup 
    [set danger -0.5 * (biggestgroup - group) ]
    [set danger 0]
    ]
  
    ask gameturtlelink [
      
     if mutualtrust > 100 [
    set mutualtrust 100 ]
    if mutualtrust < 0 [
     set mutualtrust 0 ]
    
    let trust1 (random-normal mutualtrust 10) / 100
    let trust2 (random-normal mutualtrust 10) / 100
      
    ifelse (1 - trust1) * danger + trust1 * 2 > (1 - trust1) * -2 + trust1 * (supergame + instcit) ; Payoffs from cooperating, FALSE is cooperate
    [ifelse (1 - trust2) * danger + trust2 * 2 < (1 - trust2) * -2 + trust2 * (supergame + instcit) ; both parties
      [set mutualtrust (mutualtrust - 0)
       set globaltrust (globaltrust - 0)] ; other party cooperates
      [set mutualtrust (mutualtrust - 10)
       set globaltrust (globaltrust - 10)]
      ] ; other party does not cooperate/robs
    [ifelse (1 - trust2) * danger + trust2 * 2 < (1 - trust2) * -2 + trust2 * (supergame + instcit) ; turtle cooperates
      [set mutualtrust (mutualtrust + 10)
        set globaltrust (globaltrust + 10)] ; other party cooperates
      [set mutualtrust (mutualtrust - 20)
       set globaltrust (globaltrust - 20) ] ; other party does not cooperate/robs
    ]
   
    
  ]
    
  ]
  ]
  [print "Error, I am alone!"]
end 

to institutions
  ask links with [mutualtrust > 80] [
    show-link
    set instcit 0.5
    set linkgroup TRUE
    set turtle1 [end2] of self
    set turtle2 [end1] of self
    set tieturtles (turtle-set turtle1 turtle2)
    set color white
    set thickness 0.3
    
    ask turtle1 [
    let x [xcor] of turtle2
    let y [ycor] of turtle2
    facexy x y
    fd 2
    ]
    
    ask turtle2 [
    let x [xcor] of turtle1
    let y [ycor] of turtle1
    facexy x y
    ]

    ]
  
    ask links with [mutualtrust <= 80] [
    set instcit 0
    set color black
    set thickness 0.3
    set linkgroup FALSE
    hide-link
    ]
    
    ask links with [mutualtrust < 25] [
    set color red - 3
    set thickness 0.1
    hide-link
    ]
end 

to groupsize
  ask turtles [
    set group count my-links with [linkgroup = TRUE] + 1
  ]
  set biggestgroup max [group] of turtles
end 

to conflict
  ask turtles [
    let closeturtles turtles in-radius 4
    let dangerousturtle max-one-of closeturtles [group]
    if [group] of dangerousturtle > [group] of self [
      if [mutualtrust] of (link [who] of self [who] of dangerousturtle) < 25 [
      die
    ]
  ]
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Visualization Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; color links according to past experience

to color-turtles
  ask turtles[
    if (is-both? self = true) [set color brown]
    if (is-A? self = true) [set color blue]
    if (is-B? self = true) [set color red]
    if (is-none? self = true) [set color yellow]
  ]
end 

to color-links  
    ask links[
      set thickness 0
      set color black]
end 
  




; Copyright 2007 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created over 11 years ago by Menno Schellekens.

Attached files

File Type Description Last updated
Institutional Formation.png preview Preview for 'Institutional Formation' over 11 years ago, by Menno Schellekens Download

This model does not have any ancestors.

This model does not have any descendants.