Child of TermitesLog

No preview image

This model is seeking new collaborators — would you please help?

2 collaborators

Patarakin_m Evgeny Patarakin (Author)
Alina (Advisor)

Tags

communities 

Tagged by Evgeny Patarakin over 7 years ago

networks 

Tagged by Evgeny Patarakin over 7 years ago

Child of model TermitesLog preview imageTermitesLog
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 461 times • Downloaded 21 times • Run 0 times
Download the 'Child of TermitesLog' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

extensions [nw csv]

patches-own [pagenum]

turtles-own [

  t-pagenum
   community ;;
  ]


directed-link-breed [friendbonds friendbond] ;

globals [
  wikilog ; log, куда записываются
  pages ;; перечень созданных страниц
  communities ;; перечень сообществ
  Mdl ; модулярность текущего сообщества
  ]

to setup
  clear-all
  set wikilog []
  set pages []
;;  set-default-shape turtles "bug"
    set-default-shape turtles "person"
  ;; randomly distribute wood chips
  ask patches

  [
     set pagenum 0  ;; это метка для пятна, что здесь нет палочки
     ;; А нужно ли иметь этот 0 в каждой точке
    if random-float 100 < density
    [ set pcolor yellow ] ]
  ;; randomly distribute termites
  create-turtles number [
    set color white
    setxy random-xcor random-ycor
    set size 3  ;; easier to see
  ]
end 

to go  ;; turtle procedure
  if length wikilog > number_of_turns [stop] ;; ограничитель числа ходов
  search-for-chip
  find-new-pile
  put-down-chip
end 

to search-for-chip  ;; turtle procedure -- "picks up chip" by turning orange
  ifelse pcolor = yellow [
    ;; Если это палочка, которую не брали, то надо записать в журнал, что я создал эту новую палочку
     ifelse 0 = [pagenum] of patch-here [
       let newpage 1 + length pages set pages lput newpage pages
       set t-pagenum newpage ;; это номер палочки, которую создал
            set wikilog lput (se [who] of self newpage "create" ) wikilog
       ]
     [set t-pagenum [pagenum] of patch-here ;; а если палочка, которую уже кто-то создал, то я записал себе номер этой палочки
       ]
    ;;
    set pcolor black  set color orange  fd 20 ] ;; взял палочку, и с этой палочкой пошел
  [ wiggle     search-for-chip ]  ;; а если ты не нашел, то продолжай поиск
end 

to find-new-pile  ;; turtle procedure -- look for yellow patches
  ;; это он ищет новую палочку, как только найдет - остановится и запустится put-down-chip
  if pcolor != yellow
  [ wiggle find-new-pile ]
end 

to put-down-chip  ;; turtle procedure -- finds empty spot & drops chip
  ;;; смотри - вот я нашел место, где могу положить палочку - я сюда положил палочку и ушел.
  ;; И записал в журнале, что я палочку положил
  ifelse pcolor = black   ;; в первой проверке это не так, потому что я только что нашел новую палочку, я теперь покручусь вокруг, найду новое пустое место и там палочку положу
  [
    ;; Передаю пятну номер статьи, которая тут теперь лежит

    ask patch-here [set pagenum [t-pagenum] of myself]
   set wikilog lput (se [who] of self [t-pagenum] of self "edit" ) wikilog
  ;;
    set pcolor yellow
    set color white
    set t-pagenum 0
    get-away ]
  [ rt random 360
    fd 1
    put-down-chip ]
end 

to get-away  ;; turtle procedure -- escape from yellow piles
  rt random 360
  fd 20
  if pcolor != black
    [ get-away ]
end 

to wiggle ; turtle procedure
  fd 1
  rt random 50
  lt random 50
end 

to save_log
    file-open user-new-file
      foreach wikilog [ [x] -> file-print csv:to-row  x ]
end 

to logs_to_sociogram
ask patches [set pcolor 0]
  ;; пока связи идут только от редакторов к автору статьи
  foreach edits [ [?1] ->
    let friend1 item 0 ?1
    let p1 item 1 ?1
    let friend2 first first filter [ [??1] -> (p1 = item 1 ??1) and ("create" = item 2 ??1) ] wikilog
    if friend1 != friend2 [
    ask turtle friend1 [ create-friendbond-to turtle friend2 ]
    ]

    ]

  repeat 8 [layout-spring  turtles links 1 5 7 ]
end 

to-report edits
report filter [ [?1] -> "edit" = item 2 ?1 ] wikilog
end 
;;

to ColorCommunity
  ask turtles [home st set size 5 set label "" set color 9.9]
  ask links [hide-link]
  set communities nw:louvain-communities
   set communities filter [x1 -> count x1 > 2] communities
  set communities sort-by [[ x1 x2] -> count x1 > count x2] communities
  if length communities > 14 [set communities sublist communities  0 13 ]
  let colors sublist  base-colors 0 (length communities)
  let radius max-pxcor * 3 / 4
  let dist  n-values length communities [ i -> i ]

  ask turtles [set heading 0]
  let angle 360 / length colors

  (foreach reverse communities reverse colors dist [ [community1 col dist1] ->
  ask community1 [      set color col set label ""

    rt angle * dist1
      fd (radius   )
   ;;   rt random 360
    ]
;; let Centr max-one-of community1 [nw:betweenness-centrality]

    ask links with [(member? end1 community1) and  (member? end2 community1) ] [show-link]
 repeat 7 [layout-spring community1 links with [(member? end1 community1) and  (member? end2 community1) ]  5 2 4 ]

])
end 

to CentralCommunity
    ask turtles [home st set color 9.9 set label ""]
  ask links [hide-link]
  set communities nw:louvain-communities
   set communities filter [x1 -> count x1 > 2] communities
  set communities sort-by [[ x1 x2] -> count x1 > count x2] communities
  if length communities > 14 [set communities sublist communities  0 14 ]
  let colors sublist  base-colors 0 (length communities)
  let radius max-pxcor - 15
  ask turtles [set heading 0]
 let angle 360 / length colors
  (foreach communities colors [ [community1 col] ->
    ask community1 [      set color col
    ]
 let Centr max-one-of community1 [nw:betweenness-centrality]
     layout-radial community1  links with [(member? end1 community1) and  (member? end2 community1) ] Centr
    ask links with [(member? end1 community1) and  (member? end2 community1) ] [show-link]
  ])
end 

to See_Community [group]
 ;; show CL
  ask turtles [ht set label "" set size 1]
  ask links [hide-link]
  let NewGroup group

  let GroupLinks links with [(member? end1 NewGroup) and  (member? end2 NewGroup) ]
        ask  NewGroup  [
    st set size 0.8
    set label who
  ]
       ask GroupLinks [show-link
  ]
;;  repeat 7 [ layout-spring  NewGroup GroupLinks  1 10 7 ]
end 

There is only one version of this model, created over 7 years ago by Evgeny Patarakin.

Attached files

No files

Parent: TermitesLog

This model does not have any descendants.

Graph of models related to 'Child of TermitesLog'