Leadership II

No preview image

1 collaborator

Headshot Mert Iseri (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model Leadership Parent of 1 model: Leadership Final
Model group EECS 372-Spring 2011 | Visible to everyone | Changeable by the author
Model was written in NetLogo 4.1.2 • Viewed 222 times • Downloaded 20 times • Run 5 times
Download the 'Leadership II' 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 section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

Each node has a binary value of leadaership? and follower?. If both these values are false, the node is neutral. The program returns an error message if both are true. If one is true the node changes color to indicate it is either a leader (purple) or a follower (white).

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

This section could give some ideas of things for the user to notice while running the model.

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

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

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

Click to Run Model

breed [ nodes node ]

nodes-own [ leadership-value key-supporter? leader? neutral? num-votes-received voted-before?]
links-own [ number-votes-given ]

globals [ total-num-votes total-num-leaders ]

to setup
  clear-all
  set-default-shape nodes "person"
  repeat num-nodes [
    ask patch random-xcor random-ycor [
      sprout-nodes 1 [
        set leadership-value random 100
        set key-supporter? false
        set leader? false
        set neutral? true
        set voted-before? false
        set num-votes-received 0
      ]
    ]
  ]
  recolor
end 

to go
  ask nodes [ 
    vote-for-leader
    move
  ]
  ask nodes [
    update-visuals
  ]
  ask nodes [
    transform
  ]
  if not any? nodes with [ neutral? = true ] [
    stop 
  ]
  recolor
  update-globals
  tick
end 

; recolors nodes according to their characteristics: leader, key-supporter or neutral

to recolor  
  ask nodes [
    ifelse leader? [
      set color violet
      ]
    [ ifelse key-supporter? [
        set color white
        ]
      [ ifelse neutral? [
          set color gray - 1 
          ]
        [ set color pink ]         ;this is the error flag, if there are any nodes that are pink - there is an error in code
      ]
    ]
  ]
end 

to move
  ask nodes [
    ifelse neutral? [
      rt random 30
      lt random 30
      fd .01
      ]
    [ rt random 30
      lt random 30
      fd .0001
      ]
  ]
end 

to vote-for-leader
  let my-candidate max-one-of (other nodes in-radius vision) [ leadership-value ]
  if my-candidate != NOBODY [
    if [ leadership-value ] of my-candidate > leadership-value [
      ask my-candidate [
        set num-votes-received num-votes-received + 1
      ]
      ifelse out-link-neighbor? my-candidate [
        ask out-link-to my-candidate [
          set number-votes-given number-votes-given + 1
        ]
      ]
      [ ask my-out-links [
        die
      ]
      create-link-to my-candidate [ set number-votes-given 1 ]
      ]
    ]
  ]
end 

to update-globals
  set total-num-votes sum [num-votes-received] of nodes
  set total-num-leaders count nodes with [ leader? = true ] 
end 

to update-visuals
  ifelse show-num-votes? [ 
    set label word (num-votes-received) "     " 
    ]
  [ set label "" ]
end 

to transform
  if num-votes-received > 1000 [
    set leadership-value leadership-value * 2
    set neutral? false
    set leader? true
    ask my-out-links [
      die
    ]
    
  ;; this is sort of a confusing bit so I'll do some explaining
  ;; basically, the way the model chooses followers is through the properties
  ;; of the links (specifically links-own [ number-votes-given ]  
  ;; the following code examines the out-links from the leaders and finds the top followers
  
    let num-supporters count in-link-neighbors
    let num-key-supporters min (list num-supporters 5)
    ask max-n-of num-key-supporters in-link-neighbors [ [ number-votes-given ] of out-link-to myself ] [
      set neutral? false
      set key-supporter? true
    ]
  ]
  ;; add the counting  link weights here 
end 


There is only one version of this model, created almost 13 years ago by Mert Iseri.

Attached files

No files

Parent: Leadership

Children:

Graph of models related to 'Leadership II'