simple interaction

simple interaction preview image

1 collaborator

Default-person Eleanor Anderson (Author)

Tags

(This model has yet to be categorized with any tags)
Part of project 'Organizational Change Set'
Model group MAM-2013 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 531 times • Downloaded 33 times • Run 0 times
Download the 'simple interaction' 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

turtles-own 
[ opinion
  current-group ]

patches-own
[ group-center ]

to setup
  clear-all
  create-turtles 100
  [ setxy random-xcor random-ycor 
  set opinion one-of ["reformer" "defender"]
  set current-group 0
  set-colors ]
  if movement = "groups"
  [ group-set ]
  reset-ticks
end 

to set-colors
  if opinion = "defender"
   [ set color blue ]
    if opinion = "reformer"
   [ set color red ] 
end 

;; create evenly sized groups of group-size size
;; do this by selecting a group of turtles of the right size as many times as is needed
;; create a temporary leader of each group
;; kill any turtles that don't fit evenly into groups of the chosen size
;; use leaders to stake out a patch for each group

to group-set
  let number-groups floor (count turtles / group-size )
  let leaders no-turtles
  repeat number-groups 
  [ ask n-of group-size turtles with [ current-group = 0 ]
    [ set current-group number-groups ]
    set leaders (turtle-set leaders (one-of turtles with [current-group = number-groups ]) )
    set number-groups number-groups - 1 ]
  ask turtles with [ current-group = 0 ]
  [ die ]
  layout-circle leaders 13

  ask leaders
  [ ask patch-here 
    [ set group-center [ current-group ] of myself ] ]
  ask turtles
  [ join ]
end 

to join
   move-to one-of patches with [group-center = [ current-group ] of myself ]
   bk 2
end 

to go
  if movement = "groups"
  [ choose-movers ]
  ask turtles
  [ meet-others
    learn
    set-colors ]
  tick
end 

;; identify a group of turtles that will move, one from each group
;; set their current-group to 0

to choose-movers
  let number-groups floor (count turtles / group-size )
  let movers one-of turtles
  let mover-groups (list [ current-group ] of movers )
  while [ length mover-groups < number-groups ]
  [ ask turtles
    [ if not member? current-group mover-groups
      [ set mover-groups ( sentence mover-groups current-group )
        set movers ( turtle-set movers self ) ] ] ]
  ask movers 
  [ set current-group 0 ]
end 

;; turtles interact in different ways, depending on what kind of movement is selected

to meet-others
  if movement = "all random"
  [ wiggle ]
  if movement = "a few at a time"
  [ some-move ]
  if movement = "groups"
  [ group-move ]
end 

to wiggle
  rt random 90
  lt random 90
  fd 1 
end 

to some-move
  let chance random-float 1
  if chance < moving-probability
  [ setxy random-xcor random-ycor ]
end 

to group-move
  ask turtles with [ current-group = 0 ]
  [ choose-again 
    join ]
end 


;; add turtles to groups, making sure they all remain the same size

to choose-again  
  let number-groups floor (count turtles / group-size )
  set current-group 1 + random number-groups
  if count other turtles with [ current-group = [ current-group ] of myself ] > group-size
  [ choose-again ]  
end 


;; turtles take on the opinion of the majority of turtles around them

to learn
  let defenders count turtles in-radius turtle-vision with [ color = blue ]
  let reformers count turtles in-radius turtle-vision with [ color = red ]
  if defenders > reformers 
  [ set opinion "defender" ]
  if reformers > defenders 
  [ set opinion "reformer" ]
end 

There are 2 versions of this model.

Uploaded by When Description Download
Eleanor Anderson over 11 years ago added 3 types of turtle movement Download this version
Eleanor Anderson over 11 years ago Initial upload Download this version

Attached files

File Type Description Last updated
EleanorAnderson_ 5 20 13.docx word project update 5 20 13 over 11 years ago, by Eleanor Anderson Download
simple interaction.png preview Preview for 'simple interaction' over 11 years ago, by Eleanor Anderson Download

This model does not have any ancestors.

This model does not have any descendants.