⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ---l-change_5.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
;;All modelsglobals [ num-patches counter arena-mean]turtles-own [ acquirer-grammar-state perceived-grammar-state sample-set mylist mylist2 mylist-temp gamma ]patches-own [arena-grammar-state]to setup  ca  set num-patches screen-size-x * screen-size-y  initialize-arenaendto go-var ;for the variational model do-plotsask turtles   [    sample-arena-variational  ]update-colorsspeakendto go-hybrid  ;for the hybrid variational with functional bias do-plotsask turtles   [    sample-arena-hybrid  ]update-colorsspeakendto go-functional  do-plots  sample-arena-functional  update-colors  speak-prob  endto go-deterministic  do-plots  sample-arena-functional  update-colors  speak-det  endto initialize-arena ask patches[ifelse invasion? [set pcolor black    ask patch 0 0     [    set pcolor white    set arena-grammar-state 1    ask neighbors [set pcolor white set arena-grammar-state 1]    ]  ][ifelse (random-float 1 < initial-arena)  ;initialize arena to color and grammar-state   [      set pcolor white      set arena-grammar-state 1   ]   [      set pcolor black       set arena-grammar-state 0   ]]]ask patches    [ sprout 1 ;use "sprout" to ensure one turtle per patch; patches create turtles      [          set size .5       set acquirer-grammar-state 0       set color red      ]     ] end ;;;;;;;;;;;;;;;FUNCTIONAL BIAS PROCEDURE;;;;;;;;;;;;;;;;;;to sample-arena-functional ;observer procedure ask turtles  [ set sample-set random-n-of (round((proportion-to-sample) * num-patches)) patches set acquirer-grammar-state ((count sample-set with [arena-grammar-state = 1]) /  ((count sample-set with [arena-grammar-state = 1]) + ((1 - alpha) * (count sample-set with [arena-grammar-state = 0]))))  ] end  ;;;;;;;;;;;;;;;;VARIATIONAL SAMPLING PROCEDURE;;;;;;;;;;;;;to sample-arena-variational set gamma .02  ;this is the value from Yang 2002 used to smooth individual acquisition   ;a random set of speakers is sampled and retained as "sample-set". set sample-set random-n-of (round((proportion-to-sample) * num-patches)) patches   ;The values of "arena-grammar-state" from sample-set are put into "mylist" set mylist (values-from sample-set [arena-grammar-state])    ; make a copy of "mylist" so that it can be multiplied by the number of "utterances" from each speaker  set mylist-temp mylist   ;"mylist" is then expanded depending on how many "utterances" are sampled from each speaker    repeat (utterances - 1)    [     set mylist sentence mylist-temp mylist   ]    set counter (length mylist) ;for keeping track of total # utterances per acquisition cycle set mylist (shuffle mylist)      foreach  mylist        [         ifelse (random-float 1 <= ? )         [            set acquirer-grammar-state (acquirer-grammar-state + (gamma * ( 1 - acquirer-grammar-state)))         ]         [           set acquirer-grammar-state ((1 - gamma ) * acquirer-grammar-state )         ]       ]end;;;;;;;;;;;;;;;;;;HYBRID SAMPLING PROCEDURE;;;;;;;;;;;;;;;;;to sample-arena-hybrid ;observer procedureset gamma .01  ;this is the value from Yang 2002 used to smooth individual acquisitionset mylist2 [] ;a random set of speakers is sampled and retained as "sample-set". set sample-set random-n-of (round((proportion-to-sample) * num-patches)) patches ;The values of "arena-grammar-state" from sample-set are put into "mylist"  ;if invasion? = true, then neighbors are sampled ifelse (invasion? = true)     [     set mylist (values-from neighbors [arena-grammar-state])      ]     [     set mylist (values-from sample-set [arena-grammar-state])      ]   ;Using the grammar state values, set "mylist2" to comprise utterances of either 1 or 0  foreach mylist     [    ifelse (random-float 1 <= ? )       [set mylist2 lput 1 mylist2 ]      [set mylist2 lput 0 mylist2 ]    ]     ; make a copy of "mylist2" so that it can be multiplied by the number of "utterances" from each speaker  set mylist-temp mylist2       ;"mylist2" is then expanded depending on how many "utterances" are sampled from each speaker    repeat (utterances - 1)    [     set mylist2 sentence mylist-temp mylist2   ] set counter (length mylist2) ;for keeping track of total # utterances per acquisition cycle set mylist2 (shuffle mylist2)    ;introduce the bias here  set perceived-grammar-state ((length (filter [ ? = 1] mylist2) ) /                             ((length (filter [ ? = 1] mylist2) ) + ((1 - alpha) * (length (filter [ ? = 0] mylist2)))))      foreach  mylist2        [         ifelse (random-float 1 <= perceived-grammar-state )         [            set acquirer-grammar-state (acquirer-grammar-state + (gamma * ( 1 - acquirer-grammar-state)))         ]         [           set acquirer-grammar-state ((1 - gamma ) * acquirer-grammar-state )         ]       ]end  to speak ;  speak grammar to arena ask turtles      [      set arena-grammar-state-of patch-here ( acquirer-grammar-state )      ]endto speak-prob ;  speak grammar to arena  probabilistic set grammar state by the probability of "acquirer-grammar-state" ask turtles[    ifelse (random-float 1 < acquirer-grammar-state)       [set arena-grammar-state-of patch-here ( 1 )]      [set arena-grammar-state-of patch-here ( 0 )]]endto speak-det ;speak grammar to arena deterministic - winner take all!ask turtles[    ifelse (acquirer-grammar-state > .5 )       [set arena-grammar-state-of patch-here ( 1 )]      [set arena-grammar-state-of patch-here ( 0 )]]end  to update-colors ask turtles   [    set color scale-color red acquirer-grammar-state 0 1    ]  ask patches   [  set pcolor scale-color black arena-grammar-state 0 1   ]  ;diffuse pcolor .5  endto do-plots  set-current-plot "grammar states"  ;set-current-plot-pen "acquirers"  ;plot (mean values-from turtles [acquirer-grammar-state])  set-current-plot-pen "arena"  plot (mean values-from patches [arena-grammar-state])  set-current-plot-pen "individual"   plot (value-from (patch 0 0) [arena-grammar-state])  set arena-mean (mean values-from patches [arena-grammar-state])  end@#$#@#$#@GRAPHICS-WINDOW30210637366121213.00101110111CC-WINDOW5489646584Command Center0BUTTON1165419587go-variational go-varT1TOBSERVERNILNILBUTTON141010892setupsetupNIL1TOBSERVERTNILSLIDER349374596407initial-arenainitial-arena010.10.011NILSLIDER349413597446proportion-to-sampleproportion-to-sample0.0110.10.011NILSLIDER99372288405alphaalpha010.20.011NILPLOT16103288320grammar statesNILNIL0.010.00.01.0truetruePENS"arena" 1.0 0 -16777216 true"individual" 1.0 0 -2674135 trueSLIDER99330288363utterancesutterances11001011NILMONITOR2238792436utt/acqucounter01MONITOR2132992378arena-meanarena-mean31BUTTON1995328688go-hybridgo-hybridT1TOBSERVERTNILBUTTON

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -